86 Cerr(
"***** sScannerManager::CheckParameters() -> Scanner object not initialized !" << endl);
91 Cerr(
"***** sScannerManager::CheckParameters() -> Scanner file type (generic or user provided) not initialized !" << endl);
96 Cerr(
"***** sScannerManager::CheckParameters() -> Scanner name not initialized" << endl);
101 Cerr(
"***** sScannerManager::CheckParameters() -> Path to scanner file not initialized !" << endl);
106 Cerr(
"***** sScannerManager::CheckParameters() -> Verbosity level not initialized !" << endl);
112 Cerr(
"***** sScannerManager::CheckParameters() -> A problem occurred while checking Scanner Object parameters !" << endl);
137 Cerr(
"***** WARNING: sScannerManager::Describe() -> Trying to describe the scanner object while it is not initialized !" << endl);
141 Cout(endl <<
"---------------------------------------------------------------------------" << endl);
142 Cout(
"sScannerManager::Describe() -> Here is some generic content of the scanner:" << endl);
169 Cerr(
"***** sScannerManager::Initialize() -> Parameters have not been checked !" << endl);
177 Cerr(
"***** sScannerManager::Initialize() -> A problem occurred while initializing Scanner Object !" << endl);
202 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
203 if (mpi_rank!=0)
return 0;
210 vector<string> list_scanner_names;
213 Cerr(
"***** sScannerManager::ShowScannersDescription() -> A problem occurred while recovering scanner names from the scanner repository !" << endl);
218 cout << endl <<
"Here is the list of all available scanners in the repository along with their options:" << endl << endl;
219 for (
unsigned int iter = 0; iter!=list_scanner_names.size(); iter++)
224 cout <<
"------------------------------------------------------------------" << endl;
225 cout <<
"----- \"" << list_scanner_names[iter] <<
"\"" << endl;
226 cout <<
"------------------------------------------------------------------" << endl;
228 scanner_file.append(list_scanner_names[iter]);
233 cout << description << endl << endl;
253 if (a_scannerName.empty())
255 Cerr(
"***** sScannerManager::FindScannerSystem() -> scanner name is empty !" << endl);
260 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
"sScannerManager::FindScannerSystem() -> Search for scanner " << a_scannerName <<
" in the configuration directory" << endl);
263 vector<string> repository_scanner_names;
266 Cerr(
"***** sScannerManager::FindScannerSystem() -> A problem occurred while recovering scanner names from the scanner repository !" << endl);
275 string generic_scanner_file, user_scanner_file;
278 for (
unsigned int index_name=0 ; index_name<repository_scanner_names.size() ; index_name++)
280 string gfile = a_scannerName;
281 string ufile = a_scannerName;
283 if (gfile.append(
".geom") == repository_scanner_names[index_name])
285 generic_scanner_file = a_scannerName;
286 generic_scanner_file.append(
".geom");
288 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
" --> Matched generic file for the scanner system: " << repository_scanner_names[index_name] << endl);
291 if (ufile.append(
".hscan") == repository_scanner_names[index_name])
293 user_scanner_file = a_scannerName;
294 user_scanner_file.append(
".hscan");
296 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
" --> matched custom LUT for the scanner system: " << repository_scanner_names[index_name] << endl);
305 Cerr(
"***** WARNING sScannerManager::FindScannerSystem() -> Both a generic file and user-provided LUT have been detected for the " << a_scannerName <<
" system." << endl);
306 Cerr(
" The generic file (*.geom) will be selected by default." << endl);
317 Cerr(
"***** sScannerManager::FindScannerSystem() -> Scanner '"<< a_scannerName <<
318 "' is not known in the scanner repository. Please provide a LUT/generic file for this scanner in the scanner repository in: " <<
352 if( a_fileTypeFlag == 0 )
354 else if ( a_fileTypeFlag == 1 )
358 Cerr(
"***** sScannerManager::InitScannerWithFile() -> Error : File type provided in argument must be == 0 (lut) or == 1 (geom). Current value is '" << a_fileTypeFlag <<
" !" << endl);
385 typedef vScanner *(*maker_scanner) ();
390 Cerr(
"***** sScannerManager::BuildScannerObject() -> 'Modality' field not found in the header of the scanner configuration file at :"<< endl);
399 if (list[scanner_type])
mp_Scanner = list[scanner_type]();
402 Cerr(
"***** sScannerManager::BuildScannerObject() -> Modality '" << scanner_type <<
"' is unknown !" << endl);
433 if (
m_verbose>=
VERBOSE_NORMAL)
Cout(
"sScannerManager::GetGeometricInfoFromDataFile() -> Look for acquisition specific settings into datafile header"<< endl);
438 Cerr(
"***** sScannerManager::GetGeometricInfoFromDataFile() -> An error occurred while getting information from the datafile." << endl);
466 Cerr(
"***** sScannerManager::BuildScannerObject() -> Unknow scanner type !" << endl);
473 Cerr(
"***** sScannerManager::InstantiateScanner() -> An error occurred while instanciating the Scanner object !" << endl);
500 Cerr(
"***** sScannerManager::BuildLUT() -> A problem occurred while generating/reading the LUT !" << endl);
527 DIR *respository_dir;
529 string str_geom(
".geom"), str_hscan(
".hscan");
533 if ((respository_dir =
opendir(scanner_repository.c_str())) != NULL)
536 while ((ent =
readdir (respository_dir)) != NULL)
538 string scanner_name = ent->
d_name;
540 if(scanner_name.at(scanner_name.size()-1) !=
'~')
542 if(scanner_name.find(str_geom)!=string::npos || scanner_name.find(str_hscan)!=string::npos )
544 ap_scannerNames->push_back(scanner_name);
552 Cerr(
"***** sScannerManager::GetAvailableScanners() -> Could not open the repository directory at: " << scanner_repository << endl);
576 if( a_systemStr ==
"PET" )
578 else if( a_systemStr ==
"SPECT_PINHOLE" )
580 else if( a_systemStr ==
"SPECT_CONVERGENT" )
582 else if( a_systemStr ==
"CT" )
584 else if( a_systemStr ==
"SINOGRAM" )
640 uint16_t* ap_nbHeads,
641 FLTNB* ap_acquisitionZoom,
642 uint16_t* ap_nbOfBins,
645 FLTNB*& ap_CORtoDetectorDistance,
646 int* ap_headRotDirection)
651 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
"sScannerManager::GetSPECTSpecificParameters() -> Get acquisition dependent parameters"<< endl);
656 Cerr(
"***** sScannerManager::GetSPECTSpecificParameters()-> The scanner object is not of SPECT type !" << endl);
663 if (
mp_Scanner->
GetSPECTSpecificParameters(ap_nbOfProjections, ap_nbHeads, ap_acquisitionZoom, ap_nbOfBins, ap_pixSizeXY, ap_angles, ap_CORtoDetectorDistance, ap_headRotDirection) )
665 Cerr(
"***** sScannerManager::GetSPECTSpecificParameters()-> A problem occurred while retrieving SPECT parameters from the scanner object !" << endl);
686 int* ap_headRotDirection)
696 Cerr(
"***** sScannerManager::GetCTSpecificParameters()-> The scanner object is not of CT type !" << endl);
705 Cerr(
"***** sScannerManager::GetCTSpecificParameters()-> A problem occurred while retrieving CT parameters from the scanner object !" << endl);
736 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Not implemented for CT yet!" << endl);
742 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Not implemented for Sinogram scanner yet!" << endl);
747 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Unknown scanner type!" << endl);
783 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Not implemented for CT yet!" << endl);
789 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Not implemented for Sinogram scanner yet!" << endl);
794 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Unknown scanner type!" << endl);
822 int a_nbRGates,
int a_nbCGates,
823 int a_fr,
int a_rg,
int a_cg)
832 return ap_nbEltsArray[a_elt1]+a_elt2+1 +
833 (int64_t)(a_fr*a_nbRGates*a_nbCGates + a_rg*a_nbCGates + a_cg)* nb_total_elts*nb_total_elts/2;
847 Cerr(
"sScannerManager::PROJ_GetCurrentProgression()-> Not implemented for CT yet!" << endl);
853 Cerr(
"sScannerManager::PROJ_GetCurrentProgression()-> Not implemented for Sinogram scanner yet!" << endl);
858 Cerr(
"sScannerManager::PROJ_GetCurrentProgression()-> Unknown scanner type!" << endl);
881 return nb_total_elts*nb_total_elts/2;
891 Cerr(
"sScannerManager::PROJ_GetProgressionFinalValue()-> Not implemented for CT yet!" << endl);
897 Cerr(
"sScannerManager::PROJ_GetProgressionFinalValue()-> Not implemented for Sinogram scanner yet!" << endl);
902 Cerr(
"sScannerManager::PROJ_GetProgressionFinalValue()-> Unknown scanner type!" << endl);
926 Cerr(
"***** sScannerManager::SetPETSpecificParameters() -> The scanner object is not of PET type !" << endl);
956 Cerr(
"***** sScannerManager::PROJ_GetPETSpecificParameters()-> The scanner object is not of PET type !" << endl);
962 FLTNB max_ring_diff = -1.;
966 Cerr(
"***** sScannerManager::PROJ_GetPETSpecificParameters()-> A problem occurred while retrieving PET parameters from the scanner object !" << endl);
970 *ap_maxRingDiff = max_ring_diff;
993 uint32_t a_nbOfProjections,
996 FLTNB* ap_projectionAngles,
997 FLTNB a_CORtoDetectorDistance,
998 string a_rotDirection)
1007 Cerr(
"***** sScannerManager::SetPETSpecificParameters()-> The scanner object is not of PET type !" << endl);
1016 if(a_nbOfProjections == 0)
1018 Cerr(
"***** sScannerManager::SetSPECTSpecificParameters()-> Error, SPECT analytic projection requires an user-specified number of projections !" << endl);
1028 if(ap_projectionAngles == NULL)
1031 if(a_firstAngle<0 || a_stepAngle<0)
1033 Cerr(
"***** sScannerManager::SetSPECTSpecificParameters()-> Error, SPECT projection requires to set the projection angles using either the '-SPECT_ang' or '-SPECT_c_ang' options !" << endl);
1039 ap_projectionAngles =
new FLTNB[a_nbOfProjections];
1040 ap_projectionAngles[0] = a_firstAngle;
1042 for(uint32_t a=1 ; a<a_nbOfProjections ; a++)
1043 ap_projectionAngles[a] = ap_projectionAngles[a-1] + a_stepAngle;
1049 Cerr(
"***** sScannerManager::SetSPECTAngles() -> An error occurred while trying to initialize SPECT projection angles !" << endl);
1056 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)
Set SPECT number of Bins.
int GetAvailableScanners(vector< string > *ap_scannerNames)
Gather all the names of the header files (.geom & .hscan) in the repository folder in the vector<stri...
virtual int PROJ_SetSPECTNbProjections(uint32_t a_nbOfProjections)
Set SPECT number of views.
int64_t PROJ_GetModalityStartValueInnerLoop(int64_t a_elt1)
Get the start value for the inner loop of analytic projection depending on the modality.
virtual int PROJ_GetPETSpecificParameters(FLTNB *ap_maxRingDiff)
Get geometric PET specific parameters to initialize the datafile.
virtual int SetPETMaxAxialDiffmm(FLTNB a_maxAxialDiffmm)
Set the maximal axial difference in mm between 2 crystals forming a lor.
int FindScannerSystem(string a_scannerName)
Look for a file matching with the scanner name in parameter inside the scanner repository.
virtual int PROJ_SetSPECTAngles(FLTNB *ap_projectionAngles)
Set SPECT projection angles.
int BuildScannerObject()
Instantiate the specific scanner object related to the modality, and set verbosity of scanner object...
int64_t PROJ_GetProgressionFinalValue()
Get numerator value according to the modality to compute percent progression during the projection pr...
virtual int GetGeometricInfoFromDataFile(string a_path)=0
This function is implemented in child classes Recover geometric informations specific to the scanne...
int GetModalityFromString(string a_systemStr)
A simple utility function which returns the integer corresponding to the system string passed in pa...
static sScannerManager * mp_Instance
bool m_hasUserScannerFile
virtual uint16_t PROJ_GetSPECTNbProjections()
return the total number of projections for a SPECT acquisition
virtual int CheckParameters()=0
This function is implemented in child classes. Check that all parameters have been correctly initia...
std::map< string, maker_scanner > mp_listOfScannerTypes
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)
Transfer geometric information recovered from the datafile to the scanner object. ...
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...
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)
Set the pointer to the image dimensions and quantification object.
#define SCANNER_SPECT_CONVERGENT
string m_pathToScannerFile
virtual int Instantiate(bool a_scannerFileIsLUT)=0
This function is implemented in child classes. Read the mandatory fields from the scanner file and al...
bool m_hasGenericScannerFile
#define VERBOSE_DEBUG_LIGHT
virtual int SetRotDirection(string a_rotDirection)
Set rotation direction of the system.
int BuildLUT()
Call the eponym function of the scanner class.
const string & GetPathToConfigDir()
Return the path to the CASTOR config directory.
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...
Singleton class that Instantiate and initialize the scanner object.
void Describe()
A function used to describe the generic parts of the datafile.
Declaration of class sScannerManager.
int PROJ_SetPETSpecificParameters(FLTNB a_maxAxialDiffmm)
Deliver to the PET scanner object all informations provided from the datafile header.
static int closedir(DIR *dirp)
static DIR * opendir(const char *dirname)
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)
Deliver to the SPECT scanner object all informations provided from the acquisition parameters...
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)
Recover geometric SPECT specific parameters from the scanner to initialize the datafile.
void SetVerbose(int a_verboseLevel)
Set verbosity.
int Initialize()
Initialization : .
#define SCANNER_SPECT_PINHOLE
virtual int PROJ_SetSPECTCORtoDetectorDistance(FLTNB a_CORtoDetectorDistance)
Set distance between center of rotation and SPECT detectors.
virtual int GetSystemNbElts()=0
This is a pure virtual method that must be implemented by children.
oImageDimensionsAndQuantification * mp_ID
void ShowHelpScanner()
Show help about all implemented scanners.
int64_t PROJ_GetCurrentProgression(int64_t a_elt1, int64_t a_elt2, int64_t *ap_nbEltsArray, int a_nbRGates, int a_nbCGates, int a_fr, int a_rg, int a_cg)
Get numerator value according to the modality to compute percent progression during the analytical pr...
void Describe()
Call the eponym function from the Scanner object (if initialized)
#define DEBUG_VERBOSE(IGNORED1, IGNORED2)
int64_t PROJ_GetModalityStopValueMainLoop()
Get the stop value for the main loop of analytic projection depending on the modality.
static struct dirent * readdir(DIR *dirp)
int GetCTSpecificParameters(uint16_t *ap_nbOfProjections, FLTNB *&ap_angles, int *ap_headRotDirection)
Transfer geometric information recovered from the datafile to the scanner object. ...
int GetGeometricInfoFromDataFile(string a_pathToDataFilename)
Call the specialized function of the scanner object in order to get geometric informations from the d...
int PROJ_GetPETSpecificParameters(FLTNB *ap_maxAxialDiffmm)
Transfer addresses to each geometric parameter of the PET scanner objets to the corresponding pointer...
virtual int GetCTSpecificParameters(uint16_t *ap_nbOfProjections, FLTNB *&ap_angles, int *ap_detectorRotDirection)
Recover geometric CT specific parameters from the scanner to initialize the datafile.
Declaration of class sAddonManager.
Generic class for scanner objects.
#define VERBOSE_DEBUG_NORMAL
int InitScannerWithFile(string a_pathScanFile, string a_scannerName, int a_fileTypeFlag)
Initialize member variables (file path, file type, and scanner name) with the provided arguments...
virtual int BuildLUT(bool a_scannerFileIsLUT)=0
This function is implemented in child classes. Instantiate the scanner look-up-table (LUT) ...