87 Cerr(
"***** sScannerManager::CheckParameters() -> Scanner object not initialized !" << endl);
92 Cerr(
"***** sScannerManager::CheckParameters() -> Scanner file type (generic or user provided) not initialized !" << endl);
97 Cerr(
"***** sScannerManager::CheckParameters() -> Scanner name not initialized" << endl);
102 Cerr(
"***** sScannerManager::CheckParameters() -> Path to scanner file not initialized !" << endl);
107 Cerr(
"***** sScannerManager::CheckParameters() -> Verbosity level not initialized !" << endl);
113 Cerr(
"***** sScannerManager::CheckParameters() -> A problem occurred while checking Scanner Object parameters !" << endl);
138 Cerr(
"***** WARNING: sScannerManager::Describe() -> Trying to describe the scanner object while it is not initialized !" << endl);
142 Cout(endl <<
"---------------------------------------------------------------------------" << endl);
143 Cout(
"sScannerManager::Describe() -> Here is some generic content of the scanner:" << endl);
170 Cerr(
"***** sScannerManager::Initialize() -> Parameters have not been checked !" << endl);
178 Cerr(
"***** sScannerManager::Initialize() -> A problem occurred while initializing Scanner Object !" << endl);
203 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
204 if (mpi_rank!=0)
return 0;
211 vector<string> list_scanner_names;
214 Cerr(
"***** sScannerManager::ShowScannersDescription() -> A problem occurred while recovering scanner names from the scanner repository !" << endl);
219 cout << endl <<
"Here is the list of all available scanners in the repository along with their options:" << endl << endl;
220 for (
unsigned int iter = 0; iter!=list_scanner_names.size(); iter++)
225 cout <<
"------------------------------------------------------------------" << endl;
226 cout <<
"----- \"" << list_scanner_names[iter] <<
"\"" << endl;
227 cout <<
"------------------------------------------------------------------" << endl;
229 scanner_file.append(list_scanner_names[iter]);
234 cout << description << endl << endl;
254 if (a_scannerName.empty())
256 Cerr(
"***** sScannerManager::FindScannerSystem() -> scanner name is empty !" << endl);
261 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
"sScannerManager::FindScannerSystem() -> Search for scanner " << a_scannerName <<
" in the configuration directory" << endl);
264 vector<string> repository_scanner_names;
267 Cerr(
"***** sScannerManager::FindScannerSystem() -> A problem occurred while recovering scanner names from the scanner repository !" << endl);
276 string generic_scanner_file, user_scanner_file;
279 for (
unsigned int index_name=0 ; index_name<repository_scanner_names.size() ; index_name++)
281 string gfile = a_scannerName;
282 string ufile = a_scannerName;
284 if (gfile.append(
".geom") == repository_scanner_names[index_name])
286 generic_scanner_file = a_scannerName;
287 generic_scanner_file.append(
".geom");
289 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
" --> Matched generic file for the scanner system: " << repository_scanner_names[index_name] << endl);
292 if (ufile.append(
".hscan") == repository_scanner_names[index_name])
294 user_scanner_file = a_scannerName;
295 user_scanner_file.append(
".hscan");
297 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
" --> matched custom LUT for the scanner system: " << repository_scanner_names[index_name] << endl);
306 Cerr(
"***** WARNING sScannerManager::FindScannerSystem() -> Both a generic file and user-provided LUT have been detected for the " << a_scannerName <<
" system." << endl);
307 Cerr(
" The generic file (*.geom) will be selected by default." << endl);
318 Cerr(
"***** sScannerManager::FindScannerSystem() -> Scanner '"<< a_scannerName <<
319 "' is not known in the scanner repository. Please provide a LUT/generic file for this scanner in the scanner repository in: " <<
353 if( a_fileTypeFlag == 0 )
355 else if ( a_fileTypeFlag == 1 )
359 Cerr(
"***** sScannerManager::InitScannerWithFile() -> Error : File type provided in argument must be == 0 (lut) or == 1 (geom). Current value is '" << a_fileTypeFlag <<
" !" << endl);
386 typedef vScanner *(*maker_scanner) ();
391 Cerr(
"***** sScannerManager::BuildScannerObject() -> 'Modality' field not found in the header of the scanner configuration file at :"<< endl);
400 if (list[scanner_type])
mp_Scanner = list[scanner_type]();
403 Cerr(
"***** sScannerManager::BuildScannerObject() -> Modality '" << scanner_type <<
"' is unknown !" << endl);
434 if (
m_verbose>=
VERBOSE_NORMAL)
Cout(
"sScannerManager::GetGeometricInfoFromDataFile() -> Look for acquisition specific settings into datafile header"<< endl);
439 Cerr(
"***** sScannerManager::GetGeometricInfoFromDataFile() -> An error occurred while getting information from the datafile." << endl);
467 Cerr(
"***** sScannerManager::BuildScannerObject() -> Unknow scanner type !" << endl);
474 Cerr(
"***** sScannerManager::InstantiateScanner() -> An error occurred while instanciating the Scanner object !" << endl);
501 Cerr(
"***** sScannerManager::BuildLUT() -> A problem occurred while generating/reading the LUT !" << endl);
528 DIR *respository_dir;
530 string str_geom(".geom"), str_hscan(".hscan");
534 if ((respository_dir =
opendir(scanner_repository.c_str())) != NULL)
537 while ((ent =
readdir (respository_dir)) != NULL)
539 string scanner_name = ent->
d_name;
541 if(scanner_name.at(scanner_name.size()-1) !=
'~')
543 if(scanner_name.find(str_geom)!=string::npos || scanner_name.find(str_hscan)!=string::npos )
545 ap_scannerNames->push_back(scanner_name);
553 Cerr(
"***** sScannerManager::GetAvailableScanners() -> Could not open the repository directory at: " << scanner_repository << endl);
577 if( a_systemStr ==
"PET" )
579 else if( a_systemStr ==
"SPECT_PINHOLE" )
581 else if( a_systemStr ==
"SPECT_CONVERGENT" )
583 else if( a_systemStr ==
"CT" )
585 else if( a_systemStr ==
"SINOGRAM" )
641 uint16_t* ap_nbHeads,
642 FLTNB* ap_acquisitionZoom,
643 uint16_t* ap_nbOfBins,
646 FLTNB*& ap_CORtoDetectorDistance,
647 int* ap_headRotDirection)
652 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
"sScannerManager::GetSPECTSpecificParameters() -> Get acquisition dependent parameters"<< endl);
657 Cerr(
"***** sScannerManager::GetSPECTSpecificParameters()-> The scanner object is not of SPECT type !" << endl);
664 if (
mp_Scanner->
GetSPECTSpecificParameters(ap_nbOfProjections, ap_nbHeads, ap_acquisitionZoom, ap_nbOfBins, ap_pixSizeXY, ap_angles, ap_CORtoDetectorDistance, ap_headRotDirection) )
666 Cerr(
"***** sScannerManager::GetSPECTSpecificParameters()-> A problem occurred while retrieving SPECT parameters from the scanner object !" << endl);
687 int* ap_headRotDirection)
697 Cerr(
"***** sScannerManager::GetCTSpecificParameters()-> The scanner object is not of CT type !" << endl);
706 Cerr(
"***** sScannerManager::GetCTSpecificParameters()-> A problem occurred while retrieving CT parameters from the scanner object !" << endl);
741 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Not implemented for CT yet!" << endl);
747 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Not implemented for Sinogram scanner yet!" << endl);
752 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Unknown scanner type!" << endl);
788 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Not implemented for CT yet!" << endl);
794 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Not implemented for Sinogram scanner yet!" << endl);
799 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Unknown scanner type!" << endl);
827 int a_nbRGates,
int a_nbCGates,
828 int a_fr,
int a_rg,
int a_cg)
837 return ap_nbEltsArray[a_elt1]+a_elt2+1 +
838 (int64_t)(a_fr*a_nbRGates*a_nbCGates + a_rg*a_nbCGates + a_cg)* nb_total_elts*nb_total_elts/2;
851 Cerr(
"sScannerManager::PROJ_GetCurrentProgression()-> Not implemented for CT yet!" << endl);
857 Cerr(
"sScannerManager::PROJ_GetCurrentProgression()-> Not implemented for Sinogram scanner yet!" << endl);
862 Cerr(
"sScannerManager::PROJ_GetCurrentProgression()-> Unknown scanner type!" << endl);
885 return nb_total_elts*nb_total_elts/2;
895 Cerr(
"sScannerManager::PROJ_GetProgressionFinalValue()-> Not implemented for CT yet!" << endl);
901 Cerr(
"sScannerManager::PROJ_GetProgressionFinalValue()-> Not implemented for Sinogram scanner yet!" << endl);
906 Cerr(
"sScannerManager::PROJ_GetProgressionFinalValue()-> Unknown scanner type!" << endl);
930 Cerr(
"***** sScannerManager::SetPETSpecificParameters() -> The scanner object is not of PET type !" << endl);
960 Cerr(
"***** sScannerManager::PROJ_GetPETSpecificParameters()-> The scanner object is not of PET type !" << endl);
966 FLTNB max_ring_diff = -1.;
970 Cerr(
"***** sScannerManager::PROJ_GetPETSpecificParameters()-> A problem occurred while retrieving PET parameters from the scanner object !" << endl);
974 *ap_maxRingDiff = max_ring_diff;
997 uint32_t a_nbOfProjections,
1000 FLTNB* ap_projectionAngles,
1001 FLTNB a_CORtoDetectorDistance,
1002 string a_rotDirection)
1011 Cerr(
"***** sScannerManager::SetPETSpecificParameters()-> The scanner object is not of PET type !" << endl);
1020 if(a_nbOfProjections == 0)
1022 Cerr(
"***** sScannerManager::SetSPECTSpecificParameters()-> Error, SPECT analytic projection requires an user-specified number of projections !" << endl);
1032 if(ap_projectionAngles == NULL)
1035 if(a_firstAngle<0 || a_stepAngle<0)
1037 Cerr(
"***** sScannerManager::SetSPECTSpecificParameters()-> Error, SPECT projection requires to set the projection angles using either the '-SPECT_ang' or '-SPECT_c_ang' options !" << endl);
1043 ap_projectionAngles =
new FLTNB[a_nbOfProjections];
1044 ap_projectionAngles[0] = a_firstAngle;
1046 for(uint32_t a=1 ; a<a_nbOfProjections ; a++)
1047 ap_projectionAngles[a] = ap_projectionAngles[a-1] + a_stepAngle;
1053 Cerr(
"***** sScannerManager::SetSPECTAngles() -> An error occured while trying to initialize SPECT projection angles !" << endl);
1060 Cerr(
"***** sScannerManager::SetPETSpecificParameters() -> An error occured 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.
static sScannerManager * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
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.
Singleton class that manages output writing on disk (images, sinograms, etc). It also manages loggi...
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.
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) ...