19 #include "TApplication.h"
41 cout <<
"Usage: castor-GATERootToCastor -i path_to_ifile.root -OR- -il path_to_ifile.txt "<< endl;
42 cout <<
" -s scanner_alias "<< endl;
43 cout <<
" -o path_to_out_file "<< endl;
44 cout <<
" -m path_to_macro.mac " << endl;
45 cout <<
" [-t only convert true prompts]" << endl;
46 cout <<
" [-oh histogram datafile output]" << endl;
47 cout <<
" [-atn path_to_atn_image(cm-1)]" << endl;
48 cout <<
" [-k recover coincidence kind]" << endl;
49 cout <<
" [-ist isotope_alias" << endl;
50 cout <<
" [-ot time offsets in s]" << endl;
51 cout <<
" [-vb verbosity]" << endl;
54 cout <<
"[Main settings]:" << endl;
55 cout <<
" -i path_to_file.root : give an input root datafile to convert" << endl;
56 cout <<
" -il path_to_file.txt : give an input text file containing a list of root files to convert" << endl;
57 cout <<
" : they will be concatenated into 1 CASToR datafile" << endl;
58 cout <<
" : the path to each datafile to convert must be entered on a newline" << endl;
59 cout <<
" -m path_to_macro.mac : gives the input GATE macro file used for the GATE simulation" << endl;
60 cout <<
" -o path_to_out_file : give the path to the output file which will be created inside this folder (no default)" << endl;
61 cout <<
" -s scanner_alias : provide the name of the scanner used for to acquire the original data" << endl;
62 cout <<
" : Must correspond to a .geom or .hscan file in the config/scanner repository." << endl;
63 cout <<
" : A geom file can be created from the macro files using the facultative option -geo (see below)" << endl;
65 cout <<
"[Optional settings]:" << endl;
66 cout <<
" -t : only the true prompts will be converted" << endl;
67 cout <<
" -oh : Indicate if the output datafile should be written in histogram format (default : List-mode)" << endl;
68 cout <<
" -atn path_image:proj : For PET histogram output, provide an attenuation image (cm-1) related to the acquisition." << endl;
69 cout <<
" Analytic projection will be performed during the data conversion in order to estimate PET attenuation correction factors (acf) for each histogram event" << endl;
70 cout <<
" path_image : path to the attenuation image" << endl;
71 cout <<
" proj : (optional) projector to use for analytic projection. Defaut projector = Incremental siddon" << endl;
72 cout <<
" -k : For List-mode output, write kind of coincidence (true/scatter/rdm/...) in the output datafile (disabled by default)" << endl;
73 cout <<
" -ist isotope_alias : provide alias of the isotope used during the simulation"<< endl;
74 cout <<
" Aliases for supported PET isotopes and their parameters are listed in config/misc/isotopes_pet"<< endl;
75 cout <<
" Other isotopes can be added in the same file"<< endl;
76 cout <<
" -isrc path_to_img:dims : Provide name and dimensions (separated by a colon) of an image generated with the source (annihilation) XYZ position"<< endl;
77 cout <<
" The option must start with the path to the output image which will be generated." << endl;
78 cout <<
" Dimensions and voxel sizes of the image must be provided using commas as separators, as in the following template:" << endl;
79 cout <<
" path/to/image:dimX,dimY,dimZ,voxSizeX,voxSizeY,voxSizeZ"<< endl;
80 cout <<
" -geo : Generate a CASToR geom file from the provided GATE macro file(s)"<< endl;
81 cout <<
" A geom file with the 'scanner_alias' (from the -s option) basename will be generated in the scanner repository (default location : /config/scanner)" << endl;
82 cout <<
" -sp_bins nbinsT,nbinsA : Option specific to simulation using SPECThead systems, with root output."<< endl;
83 cout <<
" Give transaxial and axial number of bins for projections, separated by a comma."<< endl;
84 cout <<
" Pixel sizes will be computed from the crystal surface and the transaxial/axial number of bins" << endl;
85 cout <<
" -ot list : Provide a serie of time offset in seconds to apply before each input file"<< endl;
86 cout <<
" (In the case of converting several datafiles of a dynamic acquisition, timestamps of events may be resetted for each file" << endl;
87 cout <<
" This variable allows to manually increment the time between each datafile(s) if required" << endl;
88 cout <<
" The number of time offsets must be equal to the number of input files, provided by -i or -if options." << endl;
89 cout <<
" 'list' is a list of time offsets, separated by ','" << endl;
91 cout <<
"[Miscellaneous settings]:" << endl;
92 cout <<
" -vb : give the verbosity level, from 0 (no verbose) to above 5 (at the event level) (default: 1)." << endl;
95 cout <<
" This program is part of the CASToR release version " <<
CASTOR_VERSION <<
"." << endl;
106 int main(
int argc,
char** argv)
117 string input_file =
"";
118 vector<string> path_to_input_file;
121 string path_to_out_file =
"";
122 string path_to_data_filename =
"";
123 string path_to_header_filename =
"";
124 string path_to_mac_file =
"";
125 string path_to_atn_image =
"";
126 string path_to_src_image =
"";
129 string scanner_name =
"";
135 bool true_only_flag =
false;
141 bool histo_out_flag =
false;
144 bool estimate_acf_flag =
false;
146 string options_projector =
"incrementalSiddon";
149 bool kind_flag =
false;
152 string istp_alias =
"";
155 bool src_img_flag =
false;
156 INTNB dim_src_img[3];
157 FLTNB vox_src_img[3];
158 FLTNB* p_src_img = NULL;
161 bool geom_flag =
false;
164 bool input_is_intf =
false;
167 uint16_t spect_bin_axl = 0,
171 string offset_time_str =
"";
172 uint32_t* offset_time_list = NULL;
177 for (
int i=1; i<argc; i++)
179 string option = (string)argv[i];
181 if (option==
"-h" || option==
"--help" || option==
"-help")
ShowHelp(0);
186 if (path_to_input_file.size() > 0)
188 Cerr(
"***** castor-GATERootToCastor :: the following file names have already been provided (-i/-il options must be used ONCE): " << endl);
189 for (
size_t i=0 ; i<path_to_input_file.size() ; i++)
190 Cout(path_to_input_file[i] << endl);
195 if (argv[i+1] == NULL)
197 Cerr(
"***** castor-GATERootToCastor :: argument missing for option: " << option << endl);
202 input_file = argv[i+1];
203 path_to_input_file.push_back(input_file);
210 else if (option==
"-il")
212 if (path_to_input_file.size() > 0)
214 Cerr(
"***** castor-GATERootToCastor :: the following file names have already been provided (-i/-il options must be used ONCE) " << endl);
215 for (
size_t i=0 ; i<path_to_input_file.size() ; i++)
216 Cout(path_to_input_file[i] << endl);
221 if (argv[i+1] == NULL)
223 Cerr(
"***** castor-GATERootToCastor :: argument missing for option: " << option << endl);
228 ifstream ifile(argv[i+1], ios::in);
235 input_file = argv[i+1];
238 while (getline(ifile, line))
241 path_to_input_file.push_back(path_to_datafile);
246 Cerr(
"***** castor-GATERootToCastor :: Error, can't read txt file: " << argv[i+1] << endl);
256 else if (option==
"-m")
258 path_to_mac_file = (string)argv[i+1];
262 else if (option==
"-s")
264 if (argv[i+1] == NULL)
266 Cerr(
"***** castor-GATERootToCastor :: argument missing for option: " << option << endl);
270 scanner_name = argv[i+1];
274 else if (option==
"-o")
276 if (argv[i+1] == NULL)
278 Cerr(
"***** castor-GATERootToCastor :: argument missing for option: " << option << endl);
282 path_to_out_file = argv[i+1];
286 else if (option==
"-t")
289 true_only_flag =
true;
291 Cerr(
"***** castor-GATERootToCastor :: Option: " << option <<
" is only available for dataset generated with Gate in a Root format." << endl);
292 Cerr(
"***** castor-GATERootToCastor :: Root support is currently not enabled (CASTOR_ROOT environnement variable should be set before compilation)" << endl);
298 else if (option==
"-ot")
302 Cerr(
"***** castor-GATERootToCastor :: Argument missing for option: " << option << endl);
305 offset_time_str = (string)argv[i+1];
310 else if (option==
"-oh")
312 histo_out_flag =
true;
315 else if (option==
"-atn")
319 Cerr(
"***** castor-GATERootToCastor :: Argument missing for option: " << option << endl);
323 path_to_atn_image = argv[i+1];
326 size_t pos = path_to_atn_image.find_first_of(
":");
328 if (pos != string::npos)
330 options_projector = path_to_atn_image.substr(pos+1);
331 path_to_atn_image = path_to_atn_image.substr(0,pos);
334 estimate_acf_flag =
true;
339 else if (option==
"-k")
345 else if (option==
"-ist")
347 if (argv[i+1] == NULL)
349 Cerr(
"***** castor-GATERootToCastor :: argument missing for option: " << option << endl);
353 istp_alias = argv[i+1];
359 else if (option==
"-isrc")
361 if (argv[i+1] == NULL)
363 Cerr(
"***** castor-GATERootToCastor :: argument missing for option: " << option << endl);
369 string input = argv[i+1];
370 int pos_colon = input.find_first_of(
":");
371 path_to_src_image = input.substr(0,pos_colon);
372 input = input.substr(pos_colon + 1);
375 string p_dims_str[6];
378 Cerr(
"***** castor-GATERootToCastor :: Invalid argument " << argv[i+1] <<
" for option " << option <<
" !" << endl);
383 for(
int i=0 ; i<3 ; i++)
386 Cerr(
"***** castor-GATERootToCastor :: Conversion error for elt " << p_dims_str[i] <<
" for option " << option <<
" !" << endl);
391 for(
int i=0 ; i<3 ; i++)
394 Cerr(
"***** castor-GATERootToCastor :: Conversion error for elt " << p_dims_str[i+3] <<
" for option " << option <<
" !" << endl);
399 p_src_img =
new FLTNB[dim_src_img[0]*dim_src_img[1]*dim_src_img[2]];
401 for(
int v=0 ; v<dim_src_img[0]*dim_src_img[1]*dim_src_img[2] ; v++)
410 else if (option==
"-geo")
416 else if (option==
"-sp_bins")
418 string input = argv[i+1];
422 Cerr(
"***** castor-GATERootToCastor :: Invalid argument " << argv[i+1] <<
" for option " << option <<
" !" << endl);
426 spect_bin_trs = s_bins[0];
427 spect_bin_axl = s_bins[1];
434 else if (option==
"-vb")
438 Cerr(
"***** castor-GATERootToCastor :: Argument missing for option: " << option << endl);
441 vb = atoi(argv[i+1]);
447 Cerr(
"***** castor-GATERootToCastor :: Unknown option '" << option <<
"' !" << endl);
460 if (path_to_input_file.empty() )
462 Cerr(
"***** castor-GATERootToCastor :: Please provide at least one data filename (-i or -if)" << endl);
489 Cout(
" Selected root data-file(s) to convert: " << endl);
490 for (
size_t i=0 ; i<path_to_input_file.size() ; i++)
491 Cout(path_to_input_file[i] << endl);
501 Cerr(
"***** castor-GATERootToCastor :: CASToR must be compiled with ROOT to read input root files (check installation instructions)" << endl);
505 else if(src_img_flag)
507 Cerr(
"***** castor-GATERootToCastor :: Can't use -isrc with interfile dataset ");
508 Cerr(
" (image of the source can only be generated from root file) !" << endl);
515 if (path_to_out_file.empty() )
517 Cerr(
"***** castor-GATERootToCastor :: Please provide the output file name (-o)" << endl);
522 if(vb >= 2)
Cout(
" selected output file:" << path_to_out_file << endl);
525 if (path_to_mac_file.empty())
527 Cerr(
"***** castor-GATERootToCastor :: Please provide the macro file associated to the GATE root datafile (-m) :" << endl);
532 if(vb >= 2)
Cout(
" selected macro file: " << path_to_mac_file << endl);
535 if (scanner_name.empty())
537 Cerr(
"***** castor-GATERootToCastor :: Please provide a scanner alias (-s) :" << endl);
542 if(vb >= 2)
Cout(
" selected scanner alias: " << scanner_name << endl);
562 Cerr(
"***** castor-GATERootToCastor :: A problem occured while checking for the config directory path !" << endl);
568 Cerr(
"*****castor-GATERootToCastor :: A problem occured while initializing output directory !" << endl);
574 Cerr(
"***** castor-GATERootToCastor :: A problem occured while logging command line arguments !" << endl);
580 cout << std::setprecision(2);
588 if(GATE_system_type<0)
591 Cerr(
"***** castor-GATERootToCastor :: GATE system type not found : " << endl);
592 Cerr(
" This script only supports conversion for cylindricalPET, ecat and SPECThead systems" << endl);
593 Cerr(
" The system type is recovered from the lines '/gate/systems/...'" << endl);
604 string path_to_geom = scanner_repository + scanner_name +
".geom";
607 switch ( GATE_system_type )
610 if( vb>=2 )
Cout(endl <<
" --- CylindricalPET system detected. Proceeding to conversion... --- " << endl << endl);
614 Cerr(
"***** castor-GATERootToCastor :: An error occured while trying to process mac file for cylindrical system: " << path_to_mac_file << endl);
620 if( vb>=2 )
Cout(endl <<
" --- ECAT system detected. Proceeding to conversion... --- " << endl << endl);
624 Cerr(
"***** castor-GATEMacToGeom :: An error occured while trying to process mac file for ecat system: " << path_to_mac_file << endl);
630 if( vb>=2 )
Cout(endl <<
" --- SPECThead system detected. Proceeding to conversion... --- " << endl << endl);
634 Cerr(
"***** castor-GATEMacToGeom :: An error occured while trying to process mac file for SPECT system: " << path_to_mac_file << endl);
640 Cerr(
"***** castor-GATERootToCastor :: System type not found : " << endl);
641 Cerr(
" This script only supports conversion for cylindricalPET ecat and SPECThead systems" << endl);
642 Cerr(
" The system type is recovered from the lines '/gate/systems/...'" << endl);
647 if( vb>=2 )
Cout(endl <<
" --- Conversion completed --- " << endl << endl);
659 scanner_name = (scanner_name.find(
OS_SEP)) ?
660 scanner_name.substr(scanner_name.find_last_of(
OS_SEP)+1) :
665 Cerr(
"**** castor-GATERootToCastor :: A problem occurred while searching for scanner system !" << endl);
670 path_to_data_filename = path_to_out_file +
".Cdf";
671 path_to_header_filename = path_to_out_file +
".Cdh";
682 if(!istp_alias.empty())
686 Cerr(
"**** castor-GATERootToCastor :: A problem occurred while checking isotope name !" << endl);
695 uint16_t max_nb_lines_per_event = 1;
703 histo_out_flag =
true;
713 if(estimate_acf_flag)
778 if(estimate_acf_flag)
783 Cerr(
"***** castor-GATERootToCastor :: Estimation of acf from an attenuation image (-atn option) is only available for histogram datafile output !" << endl
784 <<
" Add the (-oh) option to the command line to enable this option." << endl);
791 Cerr(
"***** castor-GATERootToCastor :: Estimation of acf from an attenuation image (-atn option) only available for PET systems ! (detected system is SPECT)" << endl);
799 Cerr(
"***** castor-GATERootToCastor :: An error occurred while trying to read the interfile header of attenuation file " << path_to_atn_image <<
" !" << endl);
826 Cerr(
"***** castor-GATERootToCastor :: A problem occured while checking image dimensions parameters !" << endl);
831 Cerr(
"***** castor-GATERootToCastor :: A problem occured while initializing image dimensions !" << endl);
838 Cerr(
"***** castor-GATERootToCastor :: A problem occured while initializing Dynamic data manager's class !" << endl);
853 Cerr(
"***** castor-GATERootToCastor :: Error during image initialization !" << endl);
861 Cerr(
"**** castor-GATERootToCastor :: A problem occurred during scanner object construction !" << endl);
867 Cerr(
"**** castor-GATERootToCastor :: A problem occurred while creating Scanner object !" << endl);
873 Cerr(
"***** castor-GATERootToCastor :: A problem occurred while generating/reading the LUT !" << endl);
880 Cerr(
"***** castor-GATERootToCastor :: A problem occured while checking scanner manager parameters !" << endl);
886 Cerr(
"***** castor-GATERootToCastor :: A problem occured while initializing scanner !" << endl);
904 Cerr(
"***** castor-GATERootToCastor :: A problem occured while checking projector manager's parameters !" << endl);
911 Cerr(
"***** castor-GATERootToCastor :: A problem occured while initializing projector manager !" << endl);
920 offset_time_list =
new uint32_t[path_to_input_file.size()];
921 for(
size_t f=0 ; f<path_to_input_file.size() ; f++)
922 offset_time_list[f] = 0;
925 if(offset_time_str !=
"")
927 vector<string> offsets;
928 size_t comma_pos = 0;
929 while ((comma_pos=offset_time_str.find_first_of(
",")) != string::npos)
931 string offset = offset_time_str.substr(0,comma_pos);
932 offsets.push_back(offset);
933 offset_time_str = offset_time_str.substr(comma_pos+1);
937 if(offsets.size() != path_to_input_file.size())
939 Cerr(
"**** castor-GATERootToCastor :: Unmatching number of offsets with -ot option ! "
940 << offsets.size() <<
" have been found, while "<< path_to_input_file.size() <<
"input file have been provided !" << endl);
944 for(
size_t o=0 ; o<offsets.size() ; o++)
949 Cerr(
"**** castor-GATERootToCastor :: Error while trying to convert offset : "<< offsets[o] <<
" in ms ! " << endl);
954 offset_time_list[o] = (uint32_t)offset*1000;
962 Cout(
" --- Start conversion of datafile(s) : " << input_file << endl
963 <<
" using mac file: " << path_to_mac_file << endl
964 <<
" CASToR output header datafile: " << path_to_header_filename << endl
965 <<
" CASToR output binary datafile: " << path_to_data_filename << endl << endl);
972 uint64_t nLORs_tot = 0,
980 uint32_t nCrystalsTot = 0;
981 uint32_t nRsectorsPerRing = 1;
982 uint32_t nModulesTransaxial = 1, nModulesAxial = 1;
983 uint32_t nSubmodulesTransaxial = 1, nSubmodulesAxial = 1;
984 uint32_t nCrystalsTransaxial = 1, nCrystalsAxial = 1;
985 uint32_t nBlocksLine = 1, nBlocksPerRing = 1;
987 uint32_t nb_crystal_per_layer[4] = {0,0,0,0};
990 uint32_t nProjectionsByHead =1;
991 uint32_t nProjectionsTot = 1;
993 uint32_t nPixelsAxial = 1;
994 uint32_t nPixelsTransaxial = 1;
995 uint32_t nbSimulatedPixels = 1;
996 float_t distToDetector = 0.;
998 float_t head1stAngleDeg = 0;
999 float_t headAngPitchDeg = -1;
1000 float_t headAngStepDeg = -1;
1001 float_t crystalSizeAxl=-1.,
1003 FLTNB* p_proj_spect_image=NULL;
1006 vector<uint32_t> nLayersRptTransaxial, nLayersRptAxial;
1009 uint8_t** p_bins = NULL;
1010 uint32_t bins_elts = 0;
1011 uint32_t start_time_ms = 0;
1012 uint32_t duration_ms = 1000;
1016 uint32_t castorID1=0;
1017 uint32_t castorID2=0;
1021 int32_t crystalID1=0, crystalID2=0;
1024 int32_t rsectorID1=0 , rsectorID2=0;
1025 int32_t moduleID1=0 , moduleID2=0;
1026 int32_t submoduleID1=0, submoduleID2=0;
1027 int32_t layerID1=0 , layerID2=0;
1030 int32_t blockID1=0, blockID2=0;
1034 float_t gPosX, gPosY, gPosZ;
1040 int32_t eventID1= 0, eventID2= 0;
1041 int32_t comptonPhantomID1 = 0, comptonPhantomID2= 0;
1042 int32_t rayleighPhantomID1 = 0,rayleighPhantomID2 = 0;
1043 double_t time1= 0, time2= 0;
1044 int32_t sourceID1=0, sourceID2=0;
1045 float_t sourcePosX1=0., sourcePosY1=0., sourcePosZ1=0.;
1052 TApplication *Tapp =
new TApplication(
"tapp",0,0);
1053 TTree** GEvents =
new TTree *[path_to_input_file.size()];
1054 TFile** Tfile_root =
new TFile*[path_to_input_file.size()];
1059 for (
size_t iFic=0 ; iFic<path_to_input_file.size() ; iFic++)
1061 Tfile_root[iFic] =
new TFile(path_to_input_file[iFic].c_str(),
"READ",
"ROOT file with histograms");
1063 GEvents[iFic] = (TTree*)Tfile_root[iFic]->Get(
"Singles");
1065 GEvents[iFic] = (TTree*)Tfile_root[iFic]->Get(
"Coincidences");
1067 nLORs_tot += GEvents[iFic]->GetEntries();
1074 uint64_t printing_index = 0;
1075 uint64_t printing_ratio = (nLORs_tot>10000) ? 10000 : nLORs_tot/10;
1106 Cerr(
"**** castor-GATERootToCastor :: Error when reading mac file : "<< path_to_mac_file <<
" !" << endl);
1110 nCrystalsTot = nPixelsAxial * nPixelsTransaxial;
1114 p_proj_spect_image =
new FLTNB[nHeads*nProjectionsByHead*nCrystalsTot];
1118 Cerr(
"**** castor-GATERootToCastor :: Error when trying to read image : "<< path_to_input_file[0] <<
" !" << endl);
1143 Cerr(
"**** castor-GATERootToCastor :: Error when reading mac file : "<< path_to_mac_file <<
" !" << endl);
1147 nbSimulatedPixels = nPixelsAxial*nPixelsTransaxial;
1149 if((spect_bin_trs>0 || spect_bin_axl>0) && nbSimulatedPixels > 1 )
1151 Cerr(
"**** castor-GATERootToCastor :: WARNING : Spect bins have been initialized, but the simulation already provide a specific number of pixels (="<< nPixelsAxial*nPixelsTransaxial <<
") !"<< endl <<
1152 " Pixel matrix used by default !" << endl);
1157 if(spect_bin_trs == 0 && spect_bin_axl == 0 && nbSimulatedPixels==1)
1159 Cerr(
"**** castor-GATERootToCastor :: Error : Axial and transaxial bins values expected (use option -spect_b) !"<< endl);
1164 if(crystalSizeAxl<0 || crystalSizeTrs<0)
1166 Cerr(
"**** castor-GATERootToCastor :: Crystal dimensions not correctly read in the mac files !" << endl);
1170 nPixelsTransaxial = spect_bin_trs;
1171 nPixelsAxial = spect_bin_axl;
1173 if(vb>=2)
Cout(
"Transaxial/Axial nb pixels : " << nPixelsTransaxial <<
" , " << nPixelsAxial << endl <<
1174 "Transaxial/Axial pixel sizes : " << crystalSizeTrs/nPixelsTransaxial <<
" , " << crystalSizeAxl/nPixelsAxial << endl);
1178 nCrystalsTot = nPixelsAxial * nPixelsTransaxial;
1180 if(vb>=2)
Cout(
"Number of Projections: " << nProjectionsByHead << endl <<
1181 "Detected number of crystals in the system : " << nCrystalsTot << endl);
1187 bins_elts = nHeads*nProjectionsByHead;
1189 p_bins =
new uint8_t*[bins_elts];
1190 for (
size_t p=0; p<bins_elts ; p++)
1192 p_bins[p] =
new uint8_t[nCrystalsTot];
1194 for (
size_t c=0; c<nCrystalsTot ; c++)
1196 p_bins[p][c] = input_is_intf ? (uint8_t)p_proj_spect_image[p*nCrystalsTot+c] : 0 ;
1201 nLORs_tot += p_proj_spect_image[p*nCrystalsTot+c];
1202 nLORs_unknown += p_proj_spect_image[p*nCrystalsTot+c];
1208 delete[] p_proj_spect_image;
1218 nb_crystal_per_layer,
1221 nCrystalsTransaxial,
1223 nLayersRptTransaxial,
1225 nSubmodulesTransaxial,
1233 Cerr(
"**** castor-GATERootToCastor :: Error when reading mac file : "<< path_to_mac_file <<
" !" << endl);
1244 nCrystalsTransaxial,
1251 Cerr(
"**** castor-GATERootToCastor :: Error when reading mac file : "<< path_to_mac_file <<
" !" << endl);
1257 if(vb>=2)
Cout(
"Detected number of crystals in the system : " << nCrystalsTot << endl);
1262 Cout(
" Allocating memory for bins... " << endl <<
1263 " Warning : this step can require huge amount of memory if the system contains a high number of crystals !" << endl);
1265 bins_elts = nCrystalsTot;
1267 p_bins =
new uint8_t*[bins_elts];
1268 for (
size_t c=0; c<bins_elts ; c++)
1270 p_bins[c] =
new uint8_t[nCrystalsTot-c];
1272 for (
size_t c2=0; c2<nCrystalsTot-c ; c2++)
1276 Cout(
" Memory allocation for bins completed " << endl << endl);
1288 for (
size_t iFic=0 ; iFic<path_to_input_file.size() ; iFic++)
1290 if(vb>=2)
Cout(endl <<
"Processing datafile " << iFic <<
" : " << path_to_input_file[iFic] <<
"..." << endl);
1297 GEvents[iFic]->SetBranchAddress(
"time1",&time1);
1298 GEvents[iFic]->SetBranchAddress(
"rsectorID1",&rsectorID1);
1299 GEvents[iFic]->SetBranchAddress(
"moduleID1",&moduleID1);
1300 GEvents[iFic]->SetBranchAddress(
"submoduleID1",&submoduleID1);
1301 GEvents[iFic]->SetBranchAddress(
"crystalID1",&crystalID1);
1302 GEvents[iFic]->SetBranchAddress(
"layerID1", &layerID1);
1303 GEvents[iFic]->SetBranchAddress(
"comptonPhantom1",&comptonPhantomID1);
1304 GEvents[iFic]->SetBranchAddress(
"RayleighPhantom1",&rayleighPhantomID1);
1305 GEvents[iFic]->SetBranchAddress(
"eventID1",&eventID1);
1306 GEvents[iFic]->SetBranchAddress(
"sourceID1",&sourceID1);
1308 GEvents[iFic]->SetBranchAddress(
"time2",&time2);
1309 GEvents[iFic]->SetBranchAddress(
"rsectorID2",&rsectorID2);
1310 GEvents[iFic]->SetBranchAddress(
"moduleID2",&moduleID2);
1311 GEvents[iFic]->SetBranchAddress(
"submoduleID2",&submoduleID2);
1312 GEvents[iFic]->SetBranchAddress(
"crystalID2",&crystalID2);
1313 GEvents[iFic]->SetBranchAddress(
"layerID2", &layerID2);
1314 GEvents[iFic]->SetBranchAddress(
"comptonPhantom2",&comptonPhantomID2);
1315 GEvents[iFic]->SetBranchAddress(
"RayleighPhantom2",&rayleighPhantomID2);
1316 GEvents[iFic]->SetBranchAddress(
"eventID2",&eventID2);
1317 GEvents[iFic]->SetBranchAddress(
"sourceID2",&sourceID2);
1319 GEvents[iFic]->SetBranchAddress(
"sourcePosX1",&sourcePosX1);
1320 GEvents[iFic]->SetBranchAddress(
"sourcePosY1",&sourcePosY1);
1321 GEvents[iFic]->SetBranchAddress(
"sourcePosZ1",&sourcePosZ1);
1325 GEvents[iFic]->SetBranchAddress(
"time",&time1);
1326 GEvents[iFic]->SetBranchAddress(
"headID", &headID);
1327 GEvents[iFic]->SetBranchAddress(
"crystalID",&crystalID1);
1328 GEvents[iFic]->SetBranchAddress(
"pixelID", &pixelID);
1329 GEvents[iFic]->SetBranchAddress(
"rotationAngle", &rotAngle);
1330 GEvents[iFic]->SetBranchAddress(
"globalPosX",&gPosX);
1331 GEvents[iFic]->SetBranchAddress(
"globalPosY",&gPosY);
1332 GEvents[iFic]->SetBranchAddress(
"globalPosZ",&gPosZ);
1333 GEvents[iFic]->SetBranchAddress(
"comptonPhantom",&comptonPhantomID1);
1334 GEvents[iFic]->SetBranchAddress(
"RayleighPhantom",&rayleighPhantomID1);
1335 GEvents[iFic]->SetBranchAddress(
"sourcePosX",&sourcePosX1);
1336 GEvents[iFic]->SetBranchAddress(
"sourcePosY",&sourcePosY1);
1337 GEvents[iFic]->SetBranchAddress(
"sourcePosZ",&sourcePosZ1);
1341 GEvents[iFic]->SetBranchAddress(
"time1",&time1);
1342 GEvents[iFic]->SetBranchAddress(
"blockID1",&blockID1);
1343 GEvents[iFic]->SetBranchAddress(
"crystalID1",&crystalID1);
1344 GEvents[iFic]->SetBranchAddress(
"comptonPhantom1",&comptonPhantomID1);
1345 GEvents[iFic]->SetBranchAddress(
"RayleighPhantom1",&rayleighPhantomID1);
1346 GEvents[iFic]->SetBranchAddress(
"eventID1",&eventID1);
1347 GEvents[iFic]->SetBranchAddress(
"sourceID1",&sourceID1);
1349 GEvents[iFic]->SetBranchAddress(
"time2",&time2);
1350 GEvents[iFic]->SetBranchAddress(
"blockID2",&blockID2);
1351 GEvents[iFic]->SetBranchAddress(
"crystalID2",&crystalID2);
1352 GEvents[iFic]->SetBranchAddress(
"comptonPhantom2",&comptonPhantomID2);
1353 GEvents[iFic]->SetBranchAddress(
"RayleighPhantom2",&rayleighPhantomID2);
1354 GEvents[iFic]->SetBranchAddress(
"eventID2",&eventID2);
1355 GEvents[iFic]->SetBranchAddress(
"sourceID2",&sourceID2);
1356 GEvents[iFic]->SetBranchAddress(
"sourcePosX1",&sourcePosX1);
1357 GEvents[iFic]->SetBranchAddress(
"sourcePosY1",&sourcePosY1);
1358 GEvents[iFic]->SetBranchAddress(
"sourcePosZ1",&sourcePosZ1);
1367 for (
int i=0; i<GEvents[iFic]->GetEntries() ; i++)
1369 GEvents[iFic]->GetEntry(i);
1373 Cout(
"File#" << iFic <<
", event#" << i << endl;);
1380 Cout(
"Crystal 1 : RsectorID: " << rsectorID1 <<
", moduleID: " << moduleID1 <<
", submoduleID: " << submoduleID1 <<
", crystalID: " << crystalID1
1381 <<
", layerID: " << layerID1 << endl;);
1382 Cout(
"Crystal 2 :RsectorID: " << rsectorID2 <<
", moduleID2: " << moduleID2 <<
", submoduleID: " << submoduleID2 <<
", crystalID: " << crystalID2
1383 <<
", layerID: " << layerID2 << endl;);
1387 nModulesTransaxial, nModulesAxial,
1388 nSubmodulesTransaxial, nSubmodulesAxial,
1389 nCrystalsTransaxial, nCrystalsAxial,
1390 nLayers, nb_crystal_per_layer,
1391 nLayersRptTransaxial, nLayersRptAxial,
1392 layerID1, crystalID1, submoduleID1, moduleID1, rsectorID1);
1395 nModulesTransaxial, nModulesAxial,
1396 nSubmodulesTransaxial, nSubmodulesAxial,
1397 nCrystalsTransaxial, nCrystalsAxial,
1398 nLayers, nb_crystal_per_layer,
1399 nLayersRptTransaxial, nLayersRptAxial,
1400 layerID2, crystalID2, submoduleID2, moduleID2, rsectorID2);
1404 Cout(
"--> castorID1: " << castorID1 << endl;);
1405 Cout(
"--> castorID2: " << castorID2 << endl;);
1413 Cout(
"Projection ID : headID: " << headID <<
", rotation angle (deg): " << rotAngle << endl;);
1414 Cout(
"Crystal ID : crystalID: " << crystalID1 <<
", pixelID: " << pixelID <<
", globalPosX " << gPosX <<
", globalPosY " << gPosY <<
", globalPosZ " << gPosZ << endl;);
1421 nProjectionsByHead);
1440 Cout(
"--> castorID1: " << castorID1 << endl;);
1441 Cout(
"--> castorID2: " << castorID2 << endl;);
1450 Cout(
"Crystal 1 : BlockID: " << blockID1 <<
", crystalID: " << crystalID1 << endl;);
1451 Cout(
"Crystal 2 : BlockID: " << blockID2 <<
", crystalID: " << crystalID2 << endl;);
1454 castorID1 =
ConvertIDecat(nBlocksPerRing, nBlocksLine, nCrystalsTransaxial, nCrystalsAxial, crystalID1, blockID1);
1455 castorID2 =
ConvertIDecat(nBlocksPerRing, nBlocksLine, nCrystalsTransaxial, nCrystalsAxial, crystalID2, blockID2);
1459 Cout(
"--> castorID1: " << castorID1 << endl;);
1460 Cout(
"--> castorID2: " << castorID2 << endl;);
1466 kind =
ComputeKindGATEEvent(eventID1, eventID2, comptonPhantomID1, comptonPhantomID2, rayleighPhantomID1, rayleighPhantomID2);
1492 if (true_only_flag==
true && kind !=
KIND_TRUE)
1503 p_bins[castorID1][castorID2]++;
1508 uint32_t time_in_ms = time1*1000;
1510 Event->
SetID1(0, castorID1);
1511 Event->
SetID2(0, castorID2);
1524 if (castorID1 < castorID2)
1525 p_bins[castorID1][castorID2-castorID1-1]++;
1527 p_bins[castorID2][castorID1-castorID2-1]++;
1533 uint32_t time_in_ms = time1*1000;
1534 int nb_lines_in_event = 1;
1537 Event->
SetID1(0, castorID1);
1538 Event->
SetID2(0, castorID2);
1550 eventID1 == eventID2)
1553 x = (int)(( sourcePosX1 + dim_src_img[0]/2*vox_src_img[0]) / vox_src_img[0]);
1555 y = (int)(( sourcePosY1 + dim_src_img[1]/2*vox_src_img[1]) / vox_src_img[1]);
1556 z = (int)(( sourcePosZ1 + dim_src_img[2]/2*vox_src_img[2]) / vox_src_img[2]);
1558 if(x >= 0 && x < dim_src_img[0] &&
1559 y >= 0 && y < dim_src_img[1] &&
1560 z >= 0 && z < dim_src_img[2] )
1561 p_src_img[z*dim_src_img[1]*dim_src_img[0] + y*dim_src_img[0] + x]++;
1566 if (printing_index%(nLORs_tot/printing_ratio) == 0)
1569 cout <<
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b "
1570 << percent <<
" \% ";
1577 if(vb>=2)
Cout(endl <<
"Datafile " << iFic <<
" : " << path_to_input_file[iFic] <<
" process OK" << endl);
1583 delete[] Tfile_root;
1600 Cout(endl <<
"Generate the histogram datafile" << endl);
1602 uint32_t nb_bins = bins_elts*nCrystalsTot;
1603 printing_ratio = (nb_bins>1000) ? 1000 : nb_bins/10;
1606 for (
size_t id1=0 ; id1<bins_elts ; id1++)
1607 for (
size_t id2=0; id2<nCrystalsTot ; id2++)
1609 uint32_t nb_events_in_bin = p_bins[id1][id2];
1623 if (printing_index%((nb_bins)/printing_ratio) == 0)
1626 cout <<
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b "
1627 << percent <<
" \% ";
1637 Cout(endl <<
"The output histogram contains " << nBINs <<
" events." << endl);
1651 FLTNB* p_angles =
new FLTNB[nProjectionsTot];
1652 FLTNB* p_distToDetector =
new FLTNB[nProjectionsTot];
1654 for(
size_t h=0 ; h<nHeads ; h++)
1655 for(
size_t p=0 ; p<nProjectionsByHead ; p++)
1657 int idx_proj = h*nProjectionsByHead+p;
1658 p_angles[idx_proj] = head1stAngleDeg
1660 + h*headAngPitchDeg;
1663 p_distToDetector[idx_proj] = distToDetector;
1666 ((
iDataFileSPECT*)Out_data_file)->SetNbBins(nPixelsTransaxial, nPixelsAxial);
1667 ((
iDataFileSPECT*)Out_data_file)->SetNbProjections(nProjectionsTot);
1671 Cerr(
"**** castor-GATERootToCastor :: Error when trying to set projection angles values !" << endl);
1675 if( ((
iDataFileSPECT*)Out_data_file)->InitCorToDetectorDistance(p_distToDetector) )
1677 Cerr(
"**** castor-GATERootToCastor :: Error when trying to set distance between center of rotation and detectors !" << endl);
1681 ((
iDataFileSPECT*)Out_data_file)->SetHeadRotDirection(headRotDirection);
1684 delete[] p_distToDetector;
1696 Cout(endl <<
"Generate the histogram datafile" << endl);
1697 uint32_t nb_bins = (nCrystalsTot*nCrystalsTot - nCrystalsTot)/2;
1698 printing_ratio = (nb_bins>1000) ? 1000 : nb_bins/10;
1701 for (
size_t id1=0 ; id1 <bins_elts ; id1++)
1702 for (
size_t id2 = id1+1; id2 < nCrystalsTot;id2++)
1704 uint32_t nb_events_in_bin = p_bins[id1][id2-id1-1];
1713 if(estimate_acf_flag)
1724 ((
iEventPET*)Event)->SetAttenuationCorrectionFactor(1/std::exp(-fp));
1732 if (printing_index%((nb_bins)/printing_ratio) == 0)
1735 cout <<
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b "
1736 << percent <<
" \% ";
1746 Cout(endl <<
"The output histogram contains " << nBINs <<
" events." << endl);
1765 if (vb>=2)
Cout(
"Writing source image ..." << endl);
1779 if (
IntfWriteImgFile(path_to_src_image.append(
"_src"), p_src_img, IF, vb) )
1781 Cerr(
"***** castor-GATERootToCastor :: Error writing Interfile of output image !" << endl);
1786 Cout(endl <<
"The simulated dataset contained " << nLORs_tot <<
" coincidences/singles, with: " << endl
1787 <<
" " << nLORs_trues <<
" trues (" << 100*nLORs_trues/nLORs_tot <<
" %), " << endl
1788 <<
" " << nLORs_scatters <<
" scatters (" << 100*nLORs_scatters/nLORs_tot <<
" %)," << endl
1789 <<
" " << nLORs_rdms <<
" randoms (" << 100*nLORs_rdms/nLORs_tot <<
" %)," << endl
1790 <<
" " << nLORs_unknown <<
" unknown (" << 100*nLORs_unknown/nLORs_tot <<
" %)." << endl);
1792 if (vb>=2)
Cout(
"Writing raw datafile ..." << endl);
1798 Cout(endl <<
" --- Conversion completed --- " << endl);
1804 if (vb>=2)
Cout(
" Deallocating objects ..." << endl);
1809 for(
size_t b=0; b<bins_elts ; b++)
1831 delete[]offset_time_list;
1832 delete Out_data_file;
1834 if(src_img_flag && p_src_img)
1838 if(estimate_acf_flag)
1840 if(p_ImageSpace)
delete p_ImageSpace;
1841 if(p_ProjectorManager)
delete p_ProjectorManager;
1842 if(p_ID)
delete p_ID;
1844 Cout(
" --- END --- " << endl << endl);
void SetDataMode(int a_dataMode)
set the data mode
uint32_t ConvertIDSPECTRoot1(int32_t a_headID, float_t a_rotAngle, float_t a_angStep, uint32_t a_nProjectionsByHead)
Compute a CASToR projection index of a GATE SPECThead system.
This class is designed to be a mother virtual class for Datafile.
void LMS_InstantiateImage()
Allocate memory for the main image matrices (for list-mode sensitivity generation) ...
This header file is mainly used to declare some macro definitions and all includes needed from the st...
int SetPETIsotope(int a_bed, const string &a_isotope)
Set the PET isotope for the provided bed.
static sScannerManager * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
int InitDynamicData(string a_pathTo4DDataSplittingFile, int a_respMotionCorrectionFlag, int a_cardMotionCorrectionFlag, int a_doubleMotionCorrectionFlag, int a_invMotionCorrectionFlag, int a_nbRespGates, int a_nbCardGates)
Call the eponym function from the oDynamicDataManager object in order to initialize its data...
void SetNbLines(uint16_t a_value)
Set the number of lines of the Event.
void SetVerbose(int a_verbose)
set verbosity
void SetAtnCorrectionFlagOn()
set to true the flag indicating the presence of attenuation correction factors in the datafile ...
void SetFOVSizeZ(FLTNB a_fovSizeZ)
Set the FOV's size along the Z axis, in mm.
This file gathers various function dedicated to data conversion in order to convert various type of G...
void SetComputationStrategy(int a_computationStrategy)
Set the computation strategy for the system matrix elements storage.
int Initialize()
A function used to initialize the manager and the projectors or system matrices it manages...
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the image dimensions in use.
int FindScannerSystem(string a_scannerName)
Look for a file matching with the scanner name in parameter inside the scanner repository.
void SetFOVSizeY(FLTNB a_fovSizeY)
Set the FOV's size along the Y axis, in mm.
void SetNbVoxZ(INTNB a_nbVoxZ)
Set the number of voxels along the Z axis.
int ReadMacSPECT(string a_pathMac, float_t &distToDetector, uint32_t &nHeads, uint32_t &nPixAxl, uint32_t &nPixTrs, float_t &crystalSizeAxl, float_t &crystalSizeTrs, uint32_t &nProjectionsTot, uint32_t &nProjectionsByHead, float_t &head1stAngle, float_t &headAngPitch, float_t &headAngStepDeg, int &headRotDirection, uint32_t &start_time_ms, uint32_t &duration_ms, int vb)
Recover informations about the scanner element of an ECAT system, and acquisition duration...
int BuildScannerObject()
Instantiate the specific scanner object related to the modality, and set verbosity of scanner object...
void SetNbRespGates(int a_nbRespGates)
Set the number of respiratory gates.
void SetOffsetY(FLTNB a_offsetY)
Set the image offset along the Y axis, in mm.
void ShowHelp(int a_returnCode)
void SetFOVOutMasking(FLTNB a_fovOutPercent, INTNB a_nbSliceOutMask)
Set the output FOV masking settings: transaxial unmasked FOV percent and number of extrem slices to r...
virtual int PROJ_WriteHeader()=0
This function is implemented in child classes. Generate a header file according to the projection a...
Inherit from iEventSPECT. Class for SPECT histogram mode events.
void SetVerbose(int a_verboseLevel)
set verbosity
int ReadMacCylindrical(string a_pathMac, uint8_t &nLayers, uint32_t *nb_crystal_per_layer, uint32_t &nCrystalsTot, uint32_t &nCrystalsAxial, uint32_t &nCrystalsTransaxial, vector< uint32_t > &nLayersRptAxial, vector< uint32_t > &nLayersRptTransaxial, uint32_t &nSubmodulesAxial, uint32_t &nSubmodulesTransaxial, uint32_t &nModulesAxial, uint32_t &nModulesTransaxial, uint32_t &nRsectorsPerRing, uint32_t &start_time_ms, uint32_t &duration_ms, int vb)
Recover informations about the scanner element of a cylindricalPET system and acquisition duration...
void SetOptionsForward(const string &a_optionsForward)
Set the forward projection options contained in the provided string.
void SetDuration(FLTNB a_value)
virtual int ComputeSizeEvent()=0
This function is implemented in child classes Computation of the size of each event according to th...
virtual void SetEventValue(int a_bin, FLTNBDATA a_value)=0
This function is implemented by child classes.
static sOutputManager * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
void SetOffsetZ(FLTNB a_offsetZ)
Set the image offset along the Z axis, in mm.
Declaration of class iDataFilePET.
void SetOptionsCommon(const string &a_optionsCommon)
Set the common projection options contained in the provided string.
int CheckParameters()
Check if all parameters have been correctly initialized, and call the CheckParameters function of the...
void SetNbVoxX(INTNB a_nbVoxX)
Set the number of voxels along the X axis.
int SetNbThreads(const string &a_nbThreads)
Set the number of threads.
Declaration of class iDataFileSPECT.
void SetOptionsBackward(const string &a_optionsBackward)
Set the backward projection options contained in the provided string.
int IntfReadHeader(const string &a_pathToHeaderFile, Intf_fields *ap_IntfFields, int vb)
Read an Interfile header.
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 PROJ_LoadInitialImage(const string &a_pathToImage)
Load the initial image for the analytical projection.
void SetIsotope(string a_value)
initialize the isotope string value
int PROJ_WriteData()
Write/Merge chunk of data in a general data file.
int ConvertFromString(const string &a_str, string *a_result)
Copy the 'a_str' string in the position pointed by 'a_result'.
void SetIsotope(string a_value)
initialize the isotope string value
#define FIXED_LIST_COMPUTATION_STRATEGY
void SetNbVoxY(INTNB a_nbVoxY)
Set the number of voxels along the Y axis.
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...
Inherit from iEventPET. Class for PET list-mode events.
int CheckParameters()
A function used to check the parameters settings.
void SetNbCardGates(int a_nbCardGates)
Set the number of cardiac gates.
Inherit from iEventPET. Class for PET histogram mode events.
int BuildLUT()
Call the eponym function of the scanner class.
int ComputeKindGATEEvent(uint32_t eventID1, uint32_t eventID2, int comptonPhantom1, int comptonPhantom2, int rayleighPhantom1, int rayleighPhantom2)
Determine kind of a given coincidence event, from its attributes.
void SetStartTime(FLTNB a_value)
int Initialize()
A function used to initialize all that is needed.
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.
void SetFrames(const string &a_frameList)
Set the frame list (a string that will be parsed by the InitializeFramingAndQuantification function) ...
void SetFOVSizeX(FLTNB a_fovSizeX)
Set the FOV's size along the X axis, in mm.
void SetDataType(int a_dataType)
set the data type
Singleton class that Instantiate and initialize the scanner object.
int IntfReadProjectionImage(const string &a_pathToHeaderFile, FLTNB *ap_ImgMatrix, Intf_fields *ap_IF, int vb, bool a_lerpFlag)
Main function which reads a projection Interfile 3D projection image and store its content in the pro...
void LMS_DeallocateImage()
Free memory for the main image matrices (for list-mode sensitivity generation)
int ReadMacECAT(string a_pathMac, uint32_t &nCrystalsTot, uint32_t &nCrystalsAxial, uint32_t &nCrystalsTransaxial, uint32_t &nBlocksLine, uint32_t &nBlocksPerRing, uint32_t &start_time_ms, uint32_t &duration_ms, int vb)
Recover informations about the scanner element of an ECAT system and acquisition duration, from a GATE macro file.
Declaration of class sScannerManager.
void SetVoxSizeY(FLTNB a_voxSizeY)
Set the voxel's size along the Y axis, in mm.
int CreateGeomWithECAT(string a_pathMac, string a_pathGeom)
Read a GATE macro file containing the description of an ecat system, and convert it to a geom file...
virtual int PrepareDataFile()=0
This function is implemented in child classes Store different kind of information inside arrays (da...
oProjectionLine * ComputeProjectionLine(vEvent *ap_Event, int a_th)
This function is used to compute system matrix elements from the associated projector or pre-computed...
Inherit from vDataFile. Class that manages the reading of a SPECT input file (header + data)...
void SetOffsetX(FLTNB a_offsetX)
Set the image offset along the X axis, in mm.
void SetHeaderDataFileName(const string &a_headerFileName)
set the data header file name
vScanner * GetScannerObject()
void SetVoxSizeX(FLTNB a_voxSizeX)
Set the voxel's size along the X axis, in mm.
void IntfKeyInitFields(Intf_fields *ap_IF)
Init the file of an Interfile fields structure passed in parameter to their default values...
virtual int PROJ_WriteEvent(vEvent *ap_Event, int a_th)=0
This function is implemented in child classes Write event according to the chosen type of data...
int CheckParameters()
A function used to check the parameters settings.
void SetMPIRank(int a_mpiRank)
Initialize the machine index for MPI.
void SetVerbose(int a_verboseLevel)
Set the verbose level.
int AllocateID()
Instantiate the mp_ID1 and mp_ID2 indices arrays.
int PROJ_DeleteTmpDatafile()
Delete temporary datafile used for multithreaded output writing if needed.
bool NotEmptyLine()
This function is used to know if the line contains any voxel contribution.
void SetDataFile(vDataFile *ap_DataFile)
Set a data file in use to later recover some information from it.
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
set the pointer to the oImageDimensionsAndQuantification object
#define GATE_SYS_CYLINDRICAL
Inherit from vEvent. Main PET class for the Event objects.
void SetNbEvents(int64_t a_value)
initialize the number of events with a int64_t value
int Initialize()
Initialization : .
void SetVerbose(int a_verbose)
Set the member m_verboseLevel to the provided value.
void SetID2(int a_line, uint32_t a_value)
Set the indice associated with the line index for the 2nd ID of the Event.
This class is designed to manage and store system matrix elements associated to a vEvent...
string GetPathOfFile(const string &a_pathToFile)
Simply return the path to the directory of a file path string passed in parameter.
void SetVoxSizeZ(FLTNB a_voxSizeZ)
Set the voxel's size along the Z axis, in mm.
Declaration of class oImageSpace.
void SetVerbose(int a_verboseLevel)
set verbosity
This class is designed to manage the projection part of the reconstruction.
Interfile fields. This structure contains all the Interfile keys currently managed by CASToR Decl...
void SetTimeInMs(uint32_t a_value)
Set the timestamp of the Event.
Declaration of class sOutputManager.
This class holds all the matrices in the image domain that can be used in the algorithm: image...
Mother class for the Event objects.
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.
FLTNB ForwardProject(FLTNB *ap_image=NULL)
Simply forward projects the provided image if not null, or else 1, for the current TOF bin...
int main(int argc, char **argv)
uint32_t ConvertIDcylindrical(uint32_t nRsectorsPerRing, uint32_t nModulesTransaxial, uint32_t nModulesAxial, uint32_t nSubmodulesTransaxial, uint32_t nSubmodulesAxial, uint32_t nCrystalsTransaxial, uint32_t nCrystalsAxial, uint8_t nLayers, uint32_t *nCrystalPerLayer, vector< uint32_t > nLayersRptTransaxial, vector< uint32_t > nLayersRptAxial, int32_t layerID, int32_t crystalID, int32_t submoduleID, int32_t moduleID, int32_t rsectorID)
Compute a CASToR crystal index of a GATE cylindricalPET system from its indexes (rsector/module/submo...
This class is designed to manage all dimensions and quantification related stuff. ...
void SetNbBeds(int a_nbBeds)
Set the number of bed positions.
This file is used for all kind of different functions designed for options parsing and ASCII file rea...
void SetVerbose(int a_verboseLevel)
set verbosity
uint32_t ConvertIDecat(int32_t nBlocksPerRing, int32_t nBlocksLine, int32_t nCrystalsTransaxial, int32_t nCrystalsAxial, int32_t crystalID, int32_t blockID)
Compute a CASToR crystal index of a GATE ecat system from its indexes (block/crystal) and the system ...
void SetScanner(vScanner *ap_Scanner)
Set the scanner in use.
int ReadIntfSPECT(string a_pathIntf, float_t &ap_distToDetector, uint32_t &ap_nHeads, uint32_t &ap_nPixAxl, uint32_t &ap_nPixTrs, float_t &ap_crystalSizeAxl, float_t &ap_crystalSizeTrs, uint32_t &ap_nProjectionsTot, uint32_t &ap_nProjectionsByHead, float_t &ap_head1stAngle, float_t &ap_headAngPitch, float_t &headAngStepDeg, int &ap_headRotDirection, uint32_t &ap_start_time_ms, uint32_t &ap_duration_ms, int vb)
Recover informations about the scanner element of an ECAT system, and acquisition duration...
Declaration of class oProjectorManager.
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)...
void SetPercentageLoad(int a_percentageLoad)
Set the percentage of the data file that will be loaded in memory.
int ReadStringOption(const string &a_input, T *ap_return, int a_nbElts, const string &sep, const string &a_option)
Parse the 'a_input' string corresponding to the 'a_option' into 'a_nbElts' elements, using the 'sep' separator. The results are returned in the templated 'ap_return' dynamic templated array. Call "ConvertFromString()" to perform the correct conversion depending on the type of the data to convert.
int GetGATESystemType(const string &a_pathMac)
Read a GATE macro file and identify the system type from the 'gate/systems/' command lines...
void SetMaxNumberOfLinesPerEvent(uint16_t a_value)
set the max number of line per event in the datafile
int CreateGeomWithCylindrical(string a_pathMac, string a_pathGeom)
Read a GATE macro file containing the description of a cylindricalPET system, and convert it to a geo...
virtual int PROJ_InitFile()=0
This function is implemented in child classes Initialize the fstream objets for output writing as w...
int IntfWriteImgFile(const string &a_pathToImg, FLTNB *ap_ImgMatrix, const Intf_fields &ap_IntfF, int vb)
Main function dedicated to Interfile 3D image writing. Recover image information from a provided In...
int CreateGeomWithSPECT(string a_pathMac, string a_pathGeom)
Read a GATE macro file containing the description of a SPECThead system, and convert it to a geom fil...
void GetUserEndianness()
Check user/host computer endianness and write it to the global variable User_Endianness.
uint32_t ConvertIDSPECTRoot2(uint32_t a_nbSimulatedPixels, uint32_t a_nPixTrs, uint32_t a_nPixAxl, int32_t a_headID, int32_t a_crystalID, int32_t a_pixelID, float_t a_rotAngle, float_t a_headAngPitch, float_t a_crystalSizeAxl, float_t a_crystalSizeTrs, float_t a_gPosX, float_t a_gPosY, float_t a_gPosZ)
Compute a CASToR crystal index of a GATE SPECThead system.
Inherit from iEventSPECT. Class for SPECT list-mode events.
void SetID1(int a_line, uint32_t a_value)
Set the indice associated with the line index for the 1st ID of the Event.