60 cout <<
"Usage: castor-datafileExplorer -df datafile.cdh [settings]" << endl;
62 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;
63 cout <<
"from the reader. If the '-e' option is supply, an event-by-event exploration will be performed: information about each event will be" << endl;
64 cout <<
"displayed." << endl;
66 cout <<
"[Mandatory parameters]:" << endl;
67 cout <<
" -df datafile.cdh : Give the path to a single datafile." << endl;
69 cout <<
"[Options]:" << endl;
70 cout <<
" -e : Flag for event by event exploration (will list the content of each event)." << endl;
71 cout <<
" -i : Flag for interactive one by one event exploration when -e option is supplied." << endl;
72 cout <<
" -g : Flag for global exploration (will not list the content of each event but will supply a summary)." << endl;
73 cout <<
" -vb value : Give the verbosity level, from 0 (no verbose) to 2 (default: 1)" << endl;
74 cout <<
" --help,-h,-help : Print out this help page." << endl;
77 cout <<
" Build date: " << BUILD_DATE << endl;
81 cout <<
" This program is part of the CASToR release version " <<
CASTOR_VERSION <<
"." << endl;
94 int main(
int argc,
char** argv)
102 MPI_Init(&argc, &argv);
103 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
104 MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
105 if (mpi_rank!=0)
return 0;
120 string path_to_data_filename;
124 bool event_by_event_flag =
false;
126 bool interactive_flag =
false;
128 bool global_flag =
false;
135 for (
int i=1; i<argc; i++)
138 string option = (string)argv[i];
140 if (option==
"-h" || option==
"--help" || option==
"-help")
146 else if (option==
"-vb")
150 Cerr(
"***** castor-datafileExplorer() -> Argument missing for option: " << option << endl);
155 Cerr(
"***** castor-datafileExplorer() -> Exception when trying to read provided verbosity level '" << verbose <<
" for option: " << option << endl);
161 else if (option==
"-df")
165 Cerr(
"***** castor-datafileExplorer() -> Argument missing for option: " << option << endl);
168 path_to_data_filename = (string)argv[i+1];
172 else if (option==
"-e")
174 event_by_event_flag =
true;
177 else if (option==
"-i")
179 interactive_flag =
true;
182 else if (option==
"-g")
189 Cerr(
"***** castor-datafileExplorer() -> Unknown option '" << option <<
"' !" << endl);
199 if (path_to_data_filename==
"")
201 Cerr(
"***** castor-datafileExplorer() -> Please provide a datafile name !" << endl);
207 Cerr(
"***** castor-datafileExplorer() -> Verbose less than 1 has no sense for a program used to solely print out information on screen !" << endl);
211 if (verbose>2) verbose = 2;
213 if (global_flag && event_by_event_flag)
215 Cerr(
"***** castor-datafileExplorer() -> Cannot use global and event-by-event mode at the same time !" << endl);
224 Cout(
"==============================================================" << endl);
225 Cout(
"castor-datafileExplorer() -> Initialization starts" << endl);
239 string scanner_name =
"";
242 Cerr(
"***** castor-datafileExplorer() -> A problem occured while trying to find the system name in the datafile header !" << endl);
247 Cerr(
"***** castor-datafileExplorer() -> A problem occurred while searching for scanner system !" << endl);
252 Cerr(
"***** castor-datafileExplorer() -> A problem occurred during scanner object construction ! !" << endl);
257 Cerr(
"***** castor-datafileExplorer() -> A problem occurred while creating Scanner object !" << endl);
262 Cerr(
"***** castor-datafileExplorer() -> A problem occurred while retrieving scanner fields from the datafile header !" << endl);
267 Cerr(
"***** castor-datafileExplorer() -> A problem occurred while generating/reading the LUT !" << endl);
272 Cerr(
"***** castor-datafileExplorer() -> A problem occured while checking scanner manager parameters !" << endl);
277 Cerr(
"***** castor-datafileExplorer() -> A problem occured while initializing scanner !" << endl);
298 Cerr(
"***** castor-datafileExplorer() -> Unknown scanner type (" << p_ScannerManager->
GetScannerType() <<
") for datafile construction ! Abort." << endl);
308 bool do_not_affect_quantification =
false;
311 Cerr(
"***** castor-datafileExplorer() -> A problem occurred during datafile header reading ! Abort." << endl);
316 Cerr(
"***** castor-datafileExplorer() -> A problem occurred while checking datafile parameters ! Abort." << endl);
321 Cerr(
"***** castor-datafileExplorer() -> A problem occurred in datafile initialization ! Abort." << endl);
326 Cerr(
"***** castor-datafileExplorer() -> A problem occurred in datafile initialization ! Abort." << endl);
331 Cerr(
"***** castor-datafileExplorer() -> A problem occured in datafile preparation ! Abort." << endl);
336 Cout(
"castor-datafileExplorer() -> End of initialization" << endl);
337 Cout(
"==============================================================" << endl);
347 Cout(
"==============================================================" << endl);
353 if (event_by_event_flag)
355 Cout(
"castor-datafileExplorer() -> Start exploration of all events" << endl);
357 int64_t index_start = 0; int64_t index_stop = 0;
360 int64_t index = index_start;
361 while (index>=index_start && index<index_stop)
364 Cout(
"------------------------- Event index " << index <<
" -------------------------" << endl);
369 Cerr(
"***** castor-datafileExplorer() -> An error occured while getting the event from index " << index <<
" !" << endl);
375 if (interactive_flag)
378 cout <<
"--------> Give an event index or simply press enter for next event: " << flush;
380 string answer =
""; getline(cin,answer);
383 if (answer==
"") index++;
388 int64_t next_index = stoll(answer);
389 if (next_index<index_start || next_index>=index_stop)
391 Cerr(
"***** castor-datafileExplorer() -> The provided event index (" << next_index <<
") is out of datafile range"
392 <<
" [" << index_start <<
":" << index_stop <<
"[ !" << endl);
395 else index = next_index;
400 Cout(
"==============================================================" << endl);
407 else if (global_flag)
410 Cout(
"castor-datafileExplorer() -> Start global exploration of all events" << endl);
412 cout <<
"0 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%" << endl;
413 cout <<
"|----|----|----|----|----|----|----|----|----|----|" << endl;
414 cout <<
"|" << flush;
415 int progression_percentage_old = 0;
416 int progression_nb_bars = 0;
417 uint64_t progression_printing_index = 0;
419 int64_t index_start = 0; int64_t index_stop = 0;
424 for (int64_t index=index_start ; index<index_stop ; index++)
427 if (progression_printing_index%1000==0)
429 int progression_percentage_new = ((int)( (((
float)(index-index_start+1))/((
float)(index_stop-index_start)) ) * 100.));
430 if (progression_percentage_new>=progression_percentage_old+2)
432 int nb_steps = (progression_percentage_new-progression_percentage_old)/2;
433 for (
int i=0; i<nb_steps; i++)
435 cout <<
"-" << flush;
436 progression_nb_bars++;
438 progression_percentage_old += nb_steps*2;
441 progression_printing_index++;
446 Cerr(
"***** castor-datafileExplorer() -> An error occured while getting the event from index " << index <<
" !" << endl);
453 int progression_total_bars = 49;
454 for (
int i=0; i<progression_total_bars-progression_nb_bars; i++) cout <<
"-";
456 Cout(
" --> Total number of data: " << total_nb_data << endl);
457 Cout(
"==============================================================" << endl);
This class is designed to be a mother virtual class for DataFile.
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.
void GetEventIndexStartAndStop(int64_t *ap_indexStart, int64_t *ap_indexStop, int a_subsetNum=0, int a_NbSubsets=1)
Compute the index start and stop of the events loop with respect to the current subset and MPI size a...
Declaration of class oImageDimensionsAndQuantification.
int CheckParameters()
Check the initialization of member variables Call the CheckSpecificParameters() function implemente...
int FindScannerSystem(string a_scannerName)
Look for a file matching with the scanner name in parameter inside the scanner repository.
int BuildScannerObject()
Instantiate the specific scanner object related to the modality, and set verbosity of scanner object...
int ReadInfoInHeader(bool a_affectQuantificationFlag=true)
Read and check general information from the header datafile Call the ReadSpecificInformationInHeade...
void SetVerbose(int a_verboseLevel)
set verbosity
virtual int ComputeSizeEvent()=0
This function is implemented in child classes Computation of the size of each event according to th...
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.
int InitializeMappedFile()
Check the datafile existency, map it to memory and get the raw char* pointer. .
Declaration of class iScannerPET.
int InstantiateScanner()
Instantiate scanner using the related function in the scanner classes.
int ConvertFromString(const string &a_str, string *a_result)
Copy the 'a_str' string in the position pointed by 'a_result'.
vEvent * GetEvent(int64_t a_eventIndex, int a_th=0)
#define SCANNER_SPECT_CONVERGENT
int BuildLUT()
Call the eponym function of the scanner class.
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.
virtual FLTNB GetEventValue(int a_bin)=0
Pure virtual function implemented in the child classes.
Declaration of class sScannerManager.
virtual int PrepareDataFile()=0
This function is implemented in child classes Store different kind of information inside arrays (da...
Inherit from vDataFile. Class that manages the reading of a SPECT input file (header + data)...
void SetHeaderDataFileName(const string &a_headerFileName)
set the data header file name
int main(int argc, char **argv)
#define KEYWORD_MANDATORY
int Initialize()
Initialization : .
Declaration of class sRandomNumberGenerator.
void SetVerbose(int a_verbose)
Set the member m_verboseLevel to the provided value.
void SetBedIndex(int a_bedIndex)
set the bed index corresponding to this data file
virtual void Describe()=0
This function can be used to get a description of the event printed out.
Declaration of class sOutputManager.
Mother class for the Event objects.
Inherit from vDataFile. Class that manages the reading of a CT input file (header + data)...
void Describe()
A function used to describe the generic parts of the datafile.
This class is designed to manage all dimensions and quantification related stuff. ...
This file is used for all kind of different functions designed for options parsing and ASCII file rea...
virtual INTNB GetNbValueBins()=0
Get the number of event value bins.
void SetVerbose(int a_verboseLevel)
set verbosity
void SetDefault()
A function used to set number of threads and MPI instances to 1 and bypass the CheckParameters() func...
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
set the pointer to the oImageDimensionsAndQuantification object
Inherit from vDataFile. Class that manages the reading of a PET input file (header + data)...
int GetGeometricInfoFromDataFile(string a_pathToDataFilename)
Call the specialized function of the scanner object in order to get geometric informations from the d...
Declaration of class sAddonManager.
void GetUserEndianness()
Check user/host computer endianness and write it to the global variable User_Endianness.