8 #include "sScannerManager.hh" 9 #include "sAddonManager.hh" 64 Cerr(
"***** sScannerManager::CheckParameters() -> Scanner object not initialized !" << endl);
69 Cerr(
"***** sScannerManager::CheckParameters() -> Scanner file type (generic or user provided) not initialized !" << endl);
74 Cerr(
"***** sScannerManager::CheckParameters() -> Scanner name not initialized" << endl);
79 Cerr(
"***** sScannerManager::CheckParameters() -> Path to scanner file not initialized !" << endl);
84 Cerr(
"***** sScannerManager::CheckParameters() -> Verbosity level not initialized !" << endl);
90 Cerr(
"***** sScannerManager::CheckParameters() -> A problem occurred while checking Scanner Object parameters !" << endl);
115 Cerr(
"***** WARNING: sScannerManager::Describe() -> Trying to describe the scanner object while it is not initialized !" << endl);
119 Cout(endl <<
"---------------------------------------------------------------------------" << endl);
120 Cout(
"sScannerManager::Describe() -> Here is some generic content of the scanner:" << endl);
147 Cerr(
"***** sScannerManager::Initialize() -> Parameters have not been checked !" << endl);
155 Cerr(
"***** sScannerManager::Initialize() -> A problem occurred while initializing Scanner Object !" << endl);
180 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
181 if (mpi_rank!=0)
return 0;
188 vector<string> list_scanner_names;
191 Cerr(
"***** sScannerManager::ShowScannersDescription() -> A problem occurred while recovering scanner names from the scanner repository !" << endl);
196 cout << endl <<
"Here is the list of all available scanners in the repository along with their options:" << endl << endl;
197 for (
unsigned int iter = 0; iter!=list_scanner_names.size(); iter++)
202 cout <<
"------------------------------------------------------------------" << endl;
203 cout <<
"----- \"" << list_scanner_names[iter] <<
"\"" << endl;
204 cout <<
"------------------------------------------------------------------" << endl;
206 scanner_file.append(list_scanner_names[iter]);
211 cout << description << endl << endl;
231 if (a_scannerName.empty())
233 Cerr(
"***** sScannerManager::FindScannerSystem() -> scanner name is empty !" << endl);
238 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
"sScannerManager::FindScannerSystem() -> Search for scanner " << a_scannerName <<
" in the configuration directory" << endl);
241 vector<string> repository_scanner_names;
244 Cerr(
"***** sScannerManager::FindScannerSystem() -> A problem occurred while recovering scanner names from the scanner repository !" << endl);
253 string generic_scanner_file, user_scanner_file;
256 for (
unsigned int index_name=0 ; index_name<repository_scanner_names.size() ; index_name++)
258 string gfile = a_scannerName;
259 string ufile = a_scannerName;
261 if (gfile.append(
".geom") == repository_scanner_names[index_name])
263 generic_scanner_file = a_scannerName;
264 generic_scanner_file.append(
".geom");
266 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
" --> Matched generic file for the scanner system: " << repository_scanner_names[index_name] << endl);
269 if (ufile.append(
".hscan") == repository_scanner_names[index_name])
271 user_scanner_file = a_scannerName;
272 user_scanner_file.append(
".hscan");
274 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
" --> matched custom LUT for the scanner system: " << repository_scanner_names[index_name] << endl);
283 Cerr(
"***** WARNING sScannerManager::FindScannerSystem() -> Both a generic file and user-provided LUT have been detected for the " << a_scannerName <<
" system." << endl);
284 Cerr(
" The generic file (*.geom) will be selected by default." << endl);
295 Cerr(
"***** sScannerManager::FindScannerSystem() -> Scanner '"<< a_scannerName <<
296 "' is not known in the scanner repository. Please provide a LUT/generic file for this scanner in the scanner repository in: " <<
330 if( a_fileTypeFlag == 0 )
332 else if ( a_fileTypeFlag == 1 )
336 Cerr(
"***** sScannerManager::InitScannerWithFile() -> Error : File type provided in argument must be == 0 (lut) or == 1 (geom). Current value is '" << a_fileTypeFlag <<
" !" << endl);
363 typedef vScanner *(*maker_scanner) ();
368 Cerr(
"***** sScannerManager::BuildScannerObject() -> 'Modality' field not found in the header of the scanner configuration file at :"<< endl);
377 if (list[scanner_type])
mp_Scanner = list[scanner_type]();
380 Cerr(
"***** sScannerManager::BuildScannerObject() -> Modality '" << scanner_type <<
"' is unknown !" << endl);
411 if (
m_verbose>=
VERBOSE_NORMAL)
Cout(
"sScannerManager::GetGeometricInfoFromDataFile() -> Look for acquisition specific settings into datafile header"<< endl);
416 Cerr(
"***** sScannerManager::GetGeometricInfoFromDataFile() -> An error occurred while getting information from the datafile." << endl);
444 Cerr(
"***** sScannerManager::BuildScannerObject() -> Unknow scanner type !" << endl);
451 Cerr(
"***** sScannerManager::InstantiateScanner() -> An error occurred while instanciating the Scanner object !" << endl);
478 Cerr(
"***** sScannerManager::BuildLUT() -> A problem occurred while generating/reading the LUT !" << endl);
505 DIR *respository_dir;
507 string str_geom(
".geom"), str_hscan(
".hscan");
511 if ((respository_dir =
opendir(scanner_repository.c_str())) != NULL)
514 while ((ent =
readdir (respository_dir)) != NULL)
516 string scanner_name = ent->
d_name;
518 if(scanner_name.at(scanner_name.size()-1) !=
'~')
520 if(scanner_name.find(str_geom)!=string::npos || scanner_name.find(str_hscan)!=string::npos )
522 ap_scannerNames->push_back(scanner_name);
530 Cerr(
"***** sScannerManager::GetAvailableScanners() -> Could not open the repository directory at: " << scanner_repository << endl);
554 if( a_systemStr ==
"PET" )
556 else if( a_systemStr ==
"SPECT_PINHOLE" )
558 else if( a_systemStr ==
"SPECT_CONVERGENT" )
560 else if( a_systemStr ==
"CT" )
562 else if( a_systemStr ==
"SINOGRAM" )
618 uint16_t* ap_nbHeads,
619 FLTNB* ap_acquisitionZoom,
620 uint16_t* ap_nbOfBins,
623 FLTNB*& ap_CORtoDetectorDistance,
624 int* ap_headRotDirection)
629 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
"sScannerManager::GetSPECTSpecificParameters() -> Get acquisition dependent parameters"<< endl);
634 Cerr(
"***** sScannerManager::GetSPECTSpecificParameters()-> The scanner object is not of SPECT type !" << endl);
641 if (
mp_Scanner->
GetSPECTSpecificParameters(ap_nbOfProjections, ap_nbHeads, ap_acquisitionZoom, ap_nbOfBins, ap_pixSizeXY, ap_angles, ap_CORtoDetectorDistance, ap_headRotDirection) )
643 Cerr(
"***** sScannerManager::GetSPECTSpecificParameters()-> A problem occurred while retrieving SPECT parameters from the scanner object !" << endl);
664 int* ap_headRotDirection)
674 Cerr(
"***** sScannerManager::GetCTSpecificParameters()-> The scanner object is not of CT type !" << endl);
683 Cerr(
"***** sScannerManager::GetCTSpecificParameters()-> A problem occurred while retrieving CT parameters from the scanner object !" << endl);
714 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Not implemented for CT yet!" << endl);
720 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Not implemented for Sinogram scanner yet!" << endl);
725 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Unknown scanner type!" << endl);
761 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Not implemented for CT yet!" << endl);
767 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Not implemented for Sinogram scanner yet!" << endl);
772 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Unknown scanner type!" << endl);
804 return ap_nbEltsArray[a_elt1]+a_elt2+1 +
805 (int64_t)(a_nbDynImgProcessed)* nb_total_elts*nb_total_elts/2;
818 Cerr(
"sScannerManager::PROJ_GetCurrentProgression()-> Not implemented for CT yet!" << endl);
824 Cerr(
"sScannerManager::PROJ_GetCurrentProgression()-> Not implemented for Sinogram scanner yet!" << endl);
829 Cerr(
"sScannerManager::PROJ_GetCurrentProgression()-> Unknown scanner type!" << endl);
852 return nb_total_elts*nb_total_elts/2;
862 Cerr(
"sScannerManager::PROJ_GetProgressionFinalValue()-> Not implemented for CT yet!" << endl);
868 Cerr(
"sScannerManager::PROJ_GetProgressionFinalValue()-> Not implemented for Sinogram scanner yet!" << endl);
873 Cerr(
"sScannerManager::PROJ_GetProgressionFinalValue()-> Unknown scanner type!" << endl);
897 Cerr(
"***** sScannerManager::SetPETSpecificParameters() -> The scanner object is not of PET type !" << endl);
927 Cerr(
"***** sScannerManager::PROJ_GetPETSpecificParameters()-> The scanner object is not of PET type !" << endl);
933 FLTNB max_ring_diff = -1.;
937 Cerr(
"***** sScannerManager::PROJ_GetPETSpecificParameters()-> A problem occurred while retrieving PET parameters from the scanner object !" << endl);
941 *ap_maxRingDiff = max_ring_diff;
964 uint32_t a_nbOfProjections,
967 FLTNB* ap_projectionAngles,
968 FLTNB a_CORtoDetectorDistance,
969 string a_rotDirection)
978 Cerr(
"***** sScannerManager::SetPETSpecificParameters()-> The scanner object is not of PET type !" << endl);
987 if(a_nbOfProjections == 0)
989 Cerr(
"***** sScannerManager::SetSPECTSpecificParameters()-> Error, SPECT analytic projection requires an user-specified number of projections !" << endl);
999 if(ap_projectionAngles == NULL)
1002 if(a_firstAngle<0 || a_stepAngle<0)
1004 Cerr(
"***** sScannerManager::SetSPECTSpecificParameters()-> Error, SPECT projection requires to set the projection angles using either the '-SPECT_ang' or '-SPECT_c_ang' options !" << endl);
1010 ap_projectionAngles =
new FLTNB[a_nbOfProjections];
1011 ap_projectionAngles[0] = a_firstAngle;
1013 for(uint32_t a=1 ; a<a_nbOfProjections ; a++)
1014 ap_projectionAngles[a] = ap_projectionAngles[a-1] + a_stepAngle;
1020 Cerr(
"***** sScannerManager::SetSPECTAngles() -> An error occurred while trying to initialize SPECT projection angles !" << endl);
1027 Cerr(
"***** sScannerManager::SetPETSpecificParameters() -> An error occurred while trying to initialize SPECT distance between center of rotation to detectors !" << endl);
virtual int PROJ_SetSPECTNbBins(uint16_t *ap_nbOfBins)
int GetAvailableScanners(vector< string > *ap_scannerNames)
virtual int PROJ_SetSPECTNbProjections(uint32_t a_nbOfProjections)
int64_t PROJ_GetModalityStartValueInnerLoop(int64_t a_elt1)
virtual int PROJ_GetPETSpecificParameters(FLTNB *ap_maxRingDiff)
virtual int SetPETMaxAxialDiffmm(FLTNB a_maxAxialDiffmm)
int FindScannerSystem(string a_scannerName)
virtual int PROJ_SetSPECTAngles(FLTNB *ap_projectionAngles)
int BuildScannerObject()
Instantiate the specific scanner object related to the modality, and set verbosity of scanner object...
static struct dirent * readdir(DIR *dirp)
std::map< string, maker_scanner > mp_listOfScannerTypes
int64_t PROJ_GetProgressionFinalValue()
Get numerator value according to the modality to compute percent progression during the projection pr...
int GetModalityFromString(string a_systemStr)
static sScannerManager * mp_Instance
bool m_hasUserScannerFile
virtual uint16_t PROJ_GetSPECTNbProjections()
return the total number of projections for a SPECT acquisition
virtual int GetGeometricInfoFromDataFile(string a_path)=0
virtual int CheckParameters()=0
This function is implemented in child classes. Check that all parameters have been correctly initia...
virtual int BuildLUT(bool a_scannerFileIsLUT)=0
int GetSPECTSpecificParameters(uint16_t *ap_nbOfProjections, uint16_t *ap_nbHeads, FLTNB *ap_acquisitionZoom, uint16_t *ap_nbOfBins, FLTNB *ap_pixSizeXY, FLTNB *&ap_angles, FLTNB *&ap_CORtoDetectorDistance, int *ap_headRotDirection)
static sOutputManager * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
bool m_allParametersChecked
virtual int Initialize()=0
This function is implemented in child classes. Check initialization and set several parameters to t...
static DIR * opendir(const char *dirname)
int CheckParameters()
Check if all parameters have been correctly initialized, and call the CheckParameters function of the...
int InstantiateScanner()
Instantiate scanner using the related function in the scanner classes.
sScannerManager()
sScannerManager constructor.
static sAddonManager * GetInstance()
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ID)
#define SCANNER_SPECT_CONVERGENT
string m_pathToScannerFile
bool m_hasGenericScannerFile
virtual int SetRotDirection(string a_rotDirection)
int BuildLUT()
Call the eponym function of the scanner class.
#define DEBUG_VERBOSE(IGNORED1, IGNORED2)
const string & GetPathToConfigDir()
Return the path to the CASTOR config directory.
Singleton class that Instantiate and initialize the scanner object.
void Describe()
A function used to describe the generic parts of the datafile.
int PROJ_SetPETSpecificParameters(FLTNB a_maxAxialDiffmm)
int64_t PROJ_GetCurrentProgression(int64_t a_elt1, int64_t a_elt2, int64_t *ap_nbEltsArray, uint16_t a_nbDynImgProcessed)
int ShowScannersDescription()
Get the description associated to the different scanners and print all on screen. Walk through the ...
~sScannerManager()
sScannerManager destructor.
#define KEYWORD_MANDATORY
int PROJ_SetSPECTSpecificParameters(uint16_t *ap_nbOfBins, uint32_t a_nbOfProjections, FLTNB a_firstAngle, FLTNB a_stepAngle, FLTNB *ap_projectionAngles, FLTNB a_CORtoDetectorDistance, string a_rotDirection)
virtual int GetSPECTSpecificParameters(uint16_t *ap_nbOfProjections, uint16_t *ap_nbHeads, FLTNB *ap_acquisitionZoom, uint16_t *ap_nbOfBins, FLTNB *ap_pixSizeXY, FLTNB *&ap_angles, FLTNB *&ap_CORtoDetectorDistance, int *ap_headRotDirection)
#define VERBOSE_DEBUG_NORMAL
void SetVerbose(int a_verboseLevel)
oImageDimensionsAndQuantification * mp_ID
int Initialize()
Initialization : .
#define SCANNER_SPECT_PINHOLE
virtual int PROJ_SetSPECTCORtoDetectorDistance(FLTNB a_CORtoDetectorDistance)
virtual int GetSystemNbElts()=0
This is a pure virtual method that must be implemented by children.
void ShowHelpScanner()
Show help about all implemented scanners.
static int closedir(DIR *dirp)
void Describe()
Call the eponym function from the Scanner object (if initialized)
int64_t PROJ_GetModalityStopValueMainLoop()
Get the stop value for the main loop of analytic projection depending on the modality.
virtual int Instantiate(bool a_scannerFileIsLUT)=0
#define VERBOSE_DEBUG_LIGHT
int GetCTSpecificParameters(uint16_t *ap_nbOfProjections, FLTNB *&ap_angles, int *ap_headRotDirection)
int ReadDataASCIIFile(const string &a_file, const string &a_keyword, T *ap_return, int a_nbElts, bool a_mandatoryFlag)
Look for "a_nbElts" elts in the "a_file" file matching the "a_keyword" string passed as parameter a...
int GetGeometricInfoFromDataFile(string a_pathToDataFilename)
int PROJ_GetPETSpecificParameters(FLTNB *ap_maxAxialDiffmm)
virtual int GetCTSpecificParameters(uint16_t *ap_nbOfProjections, FLTNB *&ap_angles, int *ap_detectorRotDirection)
Generic class for scanner objects.
int InitScannerWithFile(string a_pathScanFile, string a_scannerName, int a_fileTypeFlag)