73 Cerr(
"***** sScannerManager::CheckParameters() -> Scanner object not initialized !" << endl);
78 Cerr(
"***** sScannerManager::CheckParameters() -> Scanner file type (generic or user provided) not initialized !" << endl);
83 Cerr(
"***** sScannerManager::CheckParameters() -> Scanner name not initialized" << endl);
88 Cerr(
"***** sScannerManager::CheckParameters() -> Path to scanner file not initialized !" << endl);
93 Cerr(
"***** sScannerManager::CheckParameters() -> Verbosity level not initialized !" << endl);
99 Cerr(
"***** sScannerManager::CheckParameters() -> A problem occurred while checking Scanner Object parameters !" << endl);
125 Cerr(
"***** sScannerManager::Initialize() -> Parameters have not been checked !" << endl);
133 Cerr(
"***** sScannerManager::Initialize() -> A problem occurred while initializing Scanner Object !" << endl);
158 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
159 if (mpi_rank!=0)
return 0;
166 vector<string> list_scanner_names;
169 Cerr(
"***** sScannerManager::ShowScannersDescription() -> A problem occurred while recovering scanner names from the scanner repository !" << endl);
174 cout << endl <<
"Here is the list of all available scanners in the repository along with their options:" << endl << endl;
175 for (
unsigned int iter = 0; iter!=list_scanner_names.size(); iter++)
180 cout <<
"------------------------------------------------------------------" << endl;
181 cout <<
"----- \"" << list_scanner_names[iter] <<
"\"" << endl;
182 cout <<
"------------------------------------------------------------------" << endl;
184 scanner_file.append(list_scanner_names[iter]);
189 cout << description << endl << endl;
209 if (a_scannerName.empty())
211 Cerr(
"***** sScannerManager::FindScannerSystem() -> scanner name is empty !" << endl);
216 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
"sScannerManager::FindScannerSystem() -> Search for scanner " << a_scannerName <<
" in the configuration directory" << endl);
219 vector<string> repository_scanner_names;
222 Cerr(
"***** sScannerManager::FindScannerSystem() -> A problem occurred while recovering scanner names from the scanner repository !" << endl);
231 string generic_scanner_file, user_scanner_file;
234 for (
unsigned int index_name=0 ; index_name<repository_scanner_names.size() ; index_name++)
236 string gfile = a_scannerName;
237 string ufile = a_scannerName;
239 if (gfile.append(
".geom") == repository_scanner_names[index_name])
241 generic_scanner_file = a_scannerName;
242 generic_scanner_file.append(
".geom");
244 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
" --> Matched generic file for the scanner system: " << repository_scanner_names[index_name] << endl);
247 if (ufile.append(
".hscan") == repository_scanner_names[index_name])
249 user_scanner_file = a_scannerName;
250 user_scanner_file.append(
".hscan");
252 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
" --> matched custom LUT for the scanner system: " << repository_scanner_names[index_name] << endl);
261 Cerr(
"***** WARNING sScannerManager::FindScannerSystem() -> Both a generic file and user-provided LUT have been detected for the " << a_scannerName <<
" system." << endl);
262 Cerr(
" The generic file (*.geom) will be selected by default." << endl);
273 Cerr(
"***** sScannerManager::FindScannerSystem() -> Scanner '"<< a_scannerName <<
274 "' is not known in the scanner repository. Please provide a LUT/generic file for this scanner in the scanner repository in: " <<
302 typedef vScanner *(*maker_scanner) ();
307 Cerr(
"***** sScannerManager::BuildScannerObject() -> 'Modality' field not found in the header of the scanner configuration file at :"<< endl);
316 if (list[scanner_type])
mp_Scanner = list[scanner_type]();
319 Cerr(
"***** sScannerManager::BuildScannerObject() -> Modality '" << scanner_type <<
"' is unknown !" << endl);
347 if (
m_verbose>=
VERBOSE_NORMAL)
Cout(
"sScannerManager::GetGeometricInfoFromDatafile() -> Look for acquisition specific settings into datafile header"<< endl);
352 Cerr(
"***** sScannerManager::GetGeometricInfoFromDatafile() -> An error occurred while getting information from the datafile." << endl);
380 Cerr(
"***** sScannerManager::BuildScannerObject() -> Unknow scanner type !" << endl);
387 Cerr(
"***** sScannerManager::InstantiateScanner() -> An error occurred while instanciating the Scanner object !" << endl);
414 Cerr(
"***** sScannerManager::BuildLUT() -> A problem occurred while generating/reading the LUT !" << endl);
441 DIR *respository_dir;
443 string str_geom(".geom"), str_hscan(".hscan");
447 if ((respository_dir =
opendir(scanner_repository.c_str())) != NULL)
450 while ((ent =
readdir (respository_dir)) != NULL)
452 string scanner_name = ent->
d_name;
454 if(scanner_name.at(scanner_name.size()-1) !=
'~')
456 if(scanner_name.find(str_geom)!=string::npos || scanner_name.find(str_hscan)!=string::npos )
458 ap_scannerNames->push_back(scanner_name);
466 Cerr(
"***** sScannerManager::GetAvailableScanners() -> Could not open the repository directory at: " << scanner_repository << endl);
500 Cerr(
"***** sScannerManager::GetScannerLayerNbRings() -> Error when trying to get the number of rings in the system for the crystal layer " << a_layer+1 <<
" !" << endl);
503 else return nb_rings;
507 Cerr(
"***** sScannerManager::GetScannerLayerNbRings() -> This function is only available for PET scanners !" << endl);
529 uint16_t* ap_nbHeads,
530 uint16_t* ap_nbOfBins,
533 FLTNB*& ap_CORtoDetectorDistance,
534 int* ap_headRotDirection)
539 if (
m_verbose>=
VERBOSE_DETAIL)
Cout(
"sScannerManager::GetSPECTSpecificParameters() -> Get acquisition dependent parameters"<< endl);
544 Cerr(
"***** sScannerManager::PROJ_GetSPECTSpecificParameters()-> The scanner object is not of PET type !" << endl);
551 Cerr(
"***** sScannerManager::PROJ_GetSPECTSpecificParameters()-> A problem occurred while retrieving SPECT parameters from the scanner object !" << endl);
587 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Not implemented for CT yet!" << endl);
593 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Not implemented for Sinogram scanner yet!" << endl);
598 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Unknown scanner type!" << endl);
634 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Not implemented for CT yet!" << endl);
640 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Not implemented for Sinogram scanner yet!" << endl);
645 Cerr(
"sScannerManager::PROJ_GetModalityStopValueMainLoop()-> Unknown scanner type!" << endl);
673 int a_nbRGates,
int a_nbCGates,
674 int a_fr,
int a_rg,
int a_cg)
683 return ap_nbEltsArray[a_elt1]+a_elt2+1 +
684 (int64_t)(a_fr*a_nbRGates*a_nbCGates + a_rg*a_nbCGates + a_cg)* nb_total_elts*nb_total_elts/2;
697 Cerr(
"sScannerManager::PROJ_GetCurrentProgression()-> Not implemented for CT yet!" << endl);
703 Cerr(
"sScannerManager::PROJ_GetCurrentProgression()-> Not implemented for Sinogram scanner yet!" << endl);
708 Cerr(
"sScannerManager::PROJ_GetCurrentProgression()-> Unknown scanner type!" << endl);
731 return nb_total_elts*nb_total_elts/2;
741 Cerr(
"sScannerManager::PROJ_GetProgressionFinalValue()-> Not implemented for CT yet!" << endl);
747 Cerr(
"sScannerManager::PROJ_GetProgressionFinalValue()-> Not implemented for Sinogram scanner yet!" << endl);
752 Cerr(
"sScannerManager::PROJ_GetProgressionFinalValue()-> Unknown scanner type!" << endl);
776 Cerr(
"***** sScannerManager::SetPETSpecificParameters() -> The scanner object is not of PET type !" << endl);
806 Cerr(
"***** sScannerManager::PROJ_GetPETSpecificParameters()-> The scanner object is not of PET type !" << endl);
811 int max_ring_diff = -1;
815 Cerr(
"***** sScannerManager::PROJ_GetPETSpecificParameters()-> A problem occurred while retrieving PET parameters from the scanner object !" << endl);
819 if (max_ring_diff < 0)
821 Cerr(
"***** sScannerManager::PROJ_GetPETSpecificParameters()-> max ring difference should be > 0 !" << endl);
825 *ap_maxRingDiff = max_ring_diff;
848 uint32_t a_nbOfProjections,
851 FLTNB* ap_projectionAngles,
852 FLTNB a_CORtoDetectorDistance,
853 string a_rotDirection)
862 Cerr(
"***** sScannerManager::SetPETSpecificParameters()-> The scanner object is not of PET type !" << endl);
871 if(a_nbOfProjections == 0)
873 Cerr(
"***** sScannerManager::SetSPECTSpecificParameters()-> Error, SPECT analytic projection requires an user-specified number of projections !" << endl);
883 if(ap_projectionAngles == NULL)
886 if(a_firstAngle<0 || a_stepAngle<0)
888 Cerr(
"***** sScannerManager::SetSPECTSpecificParameters()-> Error, SPECT projection requires to set the projection angles using either the '-SPECT_ang' or '-SPECT_c_ang' options !" << endl);
894 ap_projectionAngles =
new FLTNB[a_nbOfProjections];
895 ap_projectionAngles[0] = a_firstAngle;
897 for(uint32_t a=1 ; a<a_nbOfProjections ; a++)
898 ap_projectionAngles[a] = ap_projectionAngles[a-1] + a_stepAngle;
904 Cerr(
"***** sScannerManager::SetSPECTAngles() -> An error occured while trying to initialize SPECT projection angles !" << endl);
911 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.
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 PROJ_GetPETSpecificParameters(int *ap_maxRingDiff)
Get geometric PET specific parameters to initialize the datafile.
int PROJ_GetPETSpecificParameters(int *a_maxRingDiff)
Transfer addresses to each geometric parameter of the PET scanner objets to the corresponding pointer...
static sScannerManager * mp_Instance
bool m_hasUserScannerFile
virtual uint16_t PROJ_GetSPECTNbProjections()
return the total number of projections for a SPECT acquisition
virtual int GetScannerLayerNbRings(int a_layer)
Return an error by default.
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
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 GetSPECTSpecificParameters(uint16_t *ap_nbOfProjections, uint16_t *ap_nbHeads, 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. ...
int InstantiateScanner()
Instantiate scanner using the related function in the scanner classes.
sScannerManager()
sScannerManager constructor.
static sAddonManager * GetInstance()
#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.
Declaration of class sScannerManager.
static int closedir(DIR *dirp)
int PROJ_SetPETSpecificParameters(int a_maxRingDiff)
Deliver to the PET scanner object all informations provided from the datafile header.
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...
void SetVerbose(int a_verboseLevel)
Set verbosity.
int Initialize()
Initialization : .
#define SCANNER_SPECT_PINHOLE
virtual int GetSPECTSpecificParameters(uint16_t *ap_nbOfProjections, uint16_t *ap_nbHeads, 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.
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.
virtual int GetGeometricInfoFromDatafile(string a_path)=0
This function is implemented in child classes Recover geometric informations specific to the scanne...
virtual int SetPETMaxRingDiff(int a_maxRingDiff)
Set the maximal ring difference.
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...
int GetScannerLayerNbRings(int a_layer)
Ask the number of rings to the scanner object for a specific layer. Returns an error if this inform...
int GetGeometricInfoFromDatafile(string a_pathToDataFilename)
Call the specialized function of the scanner object in order to get geometric informations from the d...
#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)
Declaration of class sAddonManager.
Generic class for scanner objects.
virtual int BuildLUT(bool a_scannerFileIsLUT)=0
This function is implemented in child classes. Instantiate the scanner look-up-table (LUT) ...