54 #define IF_TYPE_UNKNOWN -1
58 #define IF_TYPE_GEOM 1
79 cout <<
"Usage: castor-scannerLUTExplorer -df datafile.cdh [settings]" << endl;
81 cout <<
"This program can be used to explore a datafile and get some info about it. By default, it simply prints general information recovered" << endl;
82 cout <<
"from the reader. If the '-e' option is supply, an element-by-element exploration will be performed: information about each element will be" << endl;
83 cout <<
"displayed." << endl;
84 cout <<
"For CT scanners or SPECT cameras described by a .geom file, a datafile must also be provided in order to get information regarding the projection angles." << endl;
86 cout <<
"[Mandatory parameters]:" << endl;
87 cout <<
" -sf scan_file : Give the path to the header of a single lut file, or to a geom file." << endl;
89 cout <<
"[Options]:" << endl;
90 cout <<
" -e : Flag for scanner element by element exploration (will list the content of each element)." << endl;
91 cout <<
" -i : Flag for interactive one by one scanner element exploration when -e option is supplied." << endl;
92 cout <<
" -g : Flag for global exploration (geometric characteristics of all elements will be displayed)." << endl;
93 cout <<
" -o path_out_file : Path to an output file in which the data will be printed." << endl;
94 cout <<
" -df data_file : For CT or SPECT system, using a .geom file as input. Give the path to the header of a datafile in order to get projection informations." << endl;
95 cout <<
" -vb value : Give the verbosity level, from 0 (no verbose) to 2 (default: 1)" << endl;
96 cout <<
" --help,-h,-help : Print out this help page." << endl;
99 cout <<
" Build date: " << BUILD_DATE << endl;
102 #ifdef CASTOR_VERSION
103 cout <<
" This program is part of the CASToR release version " <<
CASTOR_VERSION <<
"." << endl;
119 void GetInputFileType(
string& ap_pathToScanFilename,
string& ap_pathToBinary,
int a_modality,
int& ap_inputFileType)
124 if(ap_pathToBinary.find(
".hscan") != string::npos
125 || ap_pathToBinary.find(
".lut") != string::npos)
128 if( ap_pathToBinary.find_last_of(
".hscan") != string::npos )
129 ap_pathToBinary = ap_pathToBinary.substr(ap_pathToBinary.find_last_of(
".hscan")) +
".lut";
131 ap_pathToScanFilename = ap_pathToBinary.substr(ap_pathToBinary.find_last_of(
".lut")) +
".hscan";
133 Cout(
" A scanner LUT binary file has been provided " << endl);
144 key_str =
"number of rsectors";
146 key_str =
"number of detector heads";
148 key_str =
"detector radius";
151 Cerr(
"***** castor-scannerLUTExplorer() -> Error, this modality is not implemented yet !" << endl);
159 Cerr(
"***** castor-scannerLUTExplorer() -> An error occurred while trying to read a mandatory parameter for a .geom file in the scanner header file !" << endl);
162 else if (rvalue == 1)
164 Cerr(
"***** castor-scannerLUTExplorer() -> The provided file has not been identified as a scanner binary file (no .hscan or .lut extension), nor a .geom file (a mandatory key is missing) !" << endl);
170 Cout(
" A generic geometry file has been provided " << endl);
186 int main(
int argc,
char** argv)
194 MPI_Init(&argc, &argv);
195 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
196 MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
197 if (mpi_rank!=0)
return 0;
212 string path_to_scan_filename =
"";
215 string path_to_data_filename =
"";
223 bool elt_by_elt_flag =
false;
225 bool global_flag =
false;
229 string path_fout =
"";
237 for (
int i=1; i<argc; i++)
240 string option = (string)argv[i];
242 if (option==
"-h" || option==
"--help" || option==
"-help")
248 else if (option==
"-vb")
252 Cerr(
"***** castor-scannerLUTExplorer() -> Argument missing for option: " << option << endl);
257 Cerr(
"***** castor-scannerLUTExplorer() -> Exception when trying to read provided verbosity level '" << verbose <<
" for option: " << option << endl);
263 else if (option==
"-sf")
267 Cerr(
"***** castor-scannerLUTExplorer() -> Argument missing for option: " << option << endl);
270 path_to_scan_filename = (string)argv[i+1];
274 else if (option==
"-df")
278 Cerr(
"***** castor-scannerLUTExplorer() -> Argument missing for option: " << option << endl);
281 path_to_data_filename = (string)argv[i+1];
285 else if (option==
"-e")
287 elt_by_elt_flag =
true;
290 else if (option==
"-g")
294 else if (option==
"-o")
298 Cerr(
"***** castor-scannerLUTExplorer()) -> Argument missing for option: " << option << endl);
301 path_fout = argv[i+1];
308 Cerr(
"***** castor-scannerLUTExplorer() -> Unknown option '" << option <<
"' !" << endl);
318 if (path_to_scan_filename==
"")
320 Cerr(
"***** castor-scannerLUTExplorer() -> Please provide a datafile name !" << endl);
326 Cerr(
"***** castor-scannerLUTExplorer() -> Verbose less than 1 has no sense for a program used to solely print out information on screen !" << endl);
330 if (verbose>2) verbose = 2;
332 if (global_flag && elt_by_elt_flag)
334 Cerr(
"***** castor-scannerLUTExplorer() -> Cannot use global and element-by-element mode at the same time !" << endl);
345 string path_to_binary = path_to_scan_filename;
353 Cout(
"==============================================================" << endl);
354 Cout(
"castor-scannerLUTExplorer() -> Initialization starts" << endl);
368 string modality_str =
"";
372 Cerr(
"***** castor-scannerLUTExplorer() -> Error when trying to read the 'modality' key in the scanner file !" << endl);
379 GetInputFileType(path_to_scan_filename, path_to_binary, modality, input_file_type);
394 Cerr(
"***** castor-proj() -> A problem occured while checking for the config directory path !" << endl);
401 Cerr(
"***** castor-proj() -> A problem occured while initializing output directory !" << endl);
407 Cerr(
"***** castor-proj() -> A problem occured while logging command line arguments !" << endl);
416 string scanner_name =
"";
419 Cerr(
"***** castor-scannerLUTExplorer() -> A problem occured while trying to find the system name in the datafile header !" << endl);
424 if (p_ScannerManager->
InitScannerWithFile(path_to_scan_filename, scanner_name, input_file_type) )
426 Cerr(
"***** castor-scannerLUTExplorer() -> A problem occurred during scanner object initialization ! !" << endl);
432 Cerr(
"***** castor-scannerLUTExplorer() -> A problem occurred during scanner object construction ! !" << endl);
437 Cerr(
"***** castor-scannerLUTExplorer() -> A problem occurred while creating Scanner object !" << endl);
444 if(path_to_data_filename ==
"")
446 Cerr(
"***** castor-scannerLUTExplorer() -> Error : For SPECT / CT systems, a datafile is required to compute the look-up-table from a geom file (i.e projection angles) !" << endl);
451 Cerr(
"***** castor-scannerLUTExplorer() -> A problem occurred while retrieving scanner fields from the datafile header !" << endl);
457 Cerr(
"***** castor-scannerLUTExplorer() -> A problem occurred while generating/reading the LUT !" << endl);
462 Cerr(
"***** castor-scannerLUTExplorer() -> A problem occured while checking scanner manager parameters !" << endl);
467 Cerr(
"***** castor-scannerLUTExplorer() -> A problem occured while initializing scanner !" << endl);
472 Cout(
"castor-scannerLUTExplorer() -> End of initialization" << endl);
473 Cout(
"==============================================================" << endl);
483 Cout(
"==============================================================" << endl);
491 Cout(
"castor-scannerLUTExplorer() -> Start exploration of all scanner elements" << endl);
493 int64_t index_start = 0; int64_t index_stop = p_ScannerManager->
GetSystemNbElts();
496 int64_t index = index_start;
497 while (index>=index_start && index<index_stop)
500 Cout(
"------------------------- Element index " << index <<
" -------------------------" << endl);
503 FLTNB position1[3], position2[3];
504 FLTNB orientation1[3], orientation2[3];
509 Cout(
"Scanner element center location (x,y,z): "<< position2[0] <<
" ; " << position2[1] <<
" ; " << position2[2] <<
" ." ;);
510 Cout(
"Orientation (x,y,z): "<< orientation2[0] <<
" ; " << orientation2[1] <<
" ; " << orientation2[2] << endl;);
513 cout <<
"--------> Give an element index or simply press enter for next element: " << flush;
515 string answer =
""; getline(cin,answer);
518 if (answer==
"") index++;
523 int64_t next_index = stoll(answer);
524 if (next_index<index_start || next_index>=index_stop)
526 Cerr(
"***** castor-scannerLUTExplorer() -> The provided element index (" << next_index <<
") is out of datafile range"
527 <<
" [" << index_start <<
":" << index_stop <<
"[ !" << endl);
530 else index = next_index;
534 Cout(
"==============================================================" << endl);
541 else if (global_flag)
544 Cout(
"castor-scannerLUTExplorer() -> Start global exploration of all elements" << endl);
547 int64_t index_start = 0; int64_t index_stop = p_ScannerManager->
GetSystemNbElts();
550 for (int64_t index=index_start ; index<index_stop ; index++)
553 FLTNB position1[3], position2[3];
554 FLTNB orientation1[3], orientation2[3];
558 Cout(
"Scanner element center location (x,y,z): "<< position2[0] <<
" ; " << position2[1] <<
" ; " << position2[2] <<
" ." ;);
559 Cout(
"Orientation (x,y,z): "<< orientation2[0] <<
" ; " << orientation2[1] <<
" ; " << orientation2[2] << endl;);
562 Cout(
"==============================================================" << endl);
568 Cout(
"==============================================================" << endl);
This header file is mainly used to declare some macro definitions and all includes needed from the st...
static sScannerManager * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
Declaration of class oImageDimensionsAndQuantification.
void SetVerbose(int a_verbose)
set verbosity
void GetInputFileType(string &ap_pathToScanFilename, string &ap_pathToBinary, int a_modality, int &ap_inputFileType)
int BuildScannerObject()
Instantiate the specific scanner object related to the modality, and set verbosity of scanner object...
int GetModalityFromString(string a_systemStr)
A simple utility function which returns the integer corresponding to the system string passed in pa...
static sOutputManager * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
Declaration of class iDataFileCT.
Declaration of class iDataFilePET.
int CheckParameters()
Check if all parameters have been correctly initialized, and call the CheckParameters function of the...
Declaration of class iDataFileSPECT.
Declaration of class iScannerPET.
int InstantiateScanner()
Instantiate scanner using the related function in the scanner classes.
int LogCommandLine(int argc, char **argv)
Write log file header with the provided command line options and different informations.
int ConvertFromString(const string &a_str, string *a_result)
Copy the 'a_str' string in the position pointed by 'a_result'.
int CheckConfigDir(const string &a_path)
Set the path to the CASTOR config directory from the given path if not empty or through the existence...
#define SCANNER_SPECT_CONVERGENT
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...
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.
vScanner * GetScannerObject()
#define KEYWORD_MANDATORY
int Initialize()
Initialization : .
Declaration of class sRandomNumberGenerator.
int main(int argc, char **argv)
Declaration of class sOutputManager.
int InitOutputDirectory(const string &a_pathFout, const string &a_pathDout)
Create the output directory if any, extract the base name and create the log file.
This file is used for all kind of different functions designed for options parsing and ASCII file rea...
void Describe()
Call the eponym function from the Scanner object (if initialized)
void SetVerbose(int a_verboseLevel)
set verbosity
int GetGeometricInfoFromDataFile(string a_pathToDataFilename)
Call the specialized function of the scanner object in order to get geometric informations from the d...
virtual int GetPositionsAndOrientations(int a_index1, int a_index2, FLTNB ap_Position1[3], FLTNB ap_Position2[3], FLTNB ap_Orientation1[3], FLTNB ap_Orientation2[3], FLTNB *ap_POI1=NULL, FLTNB *ap_POI2=NULL)=0
This is a pure virtual method that must be implemented by children. Get the central positions and o...
Declaration of class sAddonManager.
void GetUserEndianness()
Check user/host computer endianness and write it to the global variable User_Endianness.
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...