42 #include "TApplication.h"
64 cout <<
"Usage: castor-GATERootToCastor -i path_to_ifile.root -OR- -il path_to_ifile.txt "<< endl;
65 cout <<
" -s scanner_alias "<< endl;
66 cout <<
" -o path_to_out_file "<< endl;
67 cout <<
" -m path_to_macro.mac " << endl;
68 cout <<
" [-t only convert true prompts]" << endl;
69 cout <<
" [-oh histogram datafile output]" << endl;
70 cout <<
" [-atn path_to_atn_image(cm-1)]" << endl;
71 cout <<
" [-k recover coincidence kind]" << endl;
72 cout <<
" [-ist isotope_alias" << endl;
73 cout <<
" [-ot time offsets in s]" << endl;
74 cout <<
" [-vb verbosity]" << endl;
77 cout <<
"[Main settings]:" << endl;
78 cout <<
" -i path_to_file.root : give an input root datafile to convert" << endl;
79 cout <<
" -il path_to_file.txt : give an input text file containing a list of root files to convert" << endl;
80 cout <<
" : they will be concatenated into 1 CASToR datafile" << endl;
81 cout <<
" : the path to each datafile to convert must be entered on a newline" << endl;
82 cout <<
" -m path_to_macro.mac : gives the input GATE macro file used for the GATE simulation" << endl;
83 cout <<
" -o path_to_out_file : give the path to the output file which will be created inside this folder (no default)" << endl;
84 cout <<
" -s scanner_alias : provide the name of the scanner used for to acquire the original data" << endl;
85 cout <<
" : Must correspond to a .geom or .hscan file in the config/scanner repository." << endl;
86 cout <<
" : A geom file can be created from the macro files using the facultative option -geo (see below)" << endl;
88 cout <<
"[Optional settings]:" << endl;
89 cout <<
" -t : only the true prompts will be converted" << endl;
90 cout <<
" -oh : Indicate if the output datafile should be written in histogram format (default : List-mode)" << endl;
91 cout <<
" -atn path_image:proj : For PET histogram output, provide an attenuation image (cm-1) related to the acquisition." << endl;
92 cout <<
" Analytic projection will be performed during the data conversion in order to estimate PET attenuation correction factors (acf) for each histogram event" << endl;
93 cout <<
" path_image : path to the attenuation image" << endl;
94 cout <<
" proj : (optional) projector to use for analytic projection. Defaut projector = Incremental siddon" << endl;
95 cout <<
" -k : For List-mode output, write kind of coincidence (true/scatter/rdm/...) in the output datafile (disabled by default)" << endl;
96 cout <<
" -ist isotope_alias : provide alias of the isotope used during the simulation"<< endl;
97 cout <<
" Aliases for supported PET isotopes and their parameters are listed in config/misc/isotopes_pet"<< endl;
98 cout <<
" Other isotopes can be added in the same file"<< endl;
99 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;
100 cout <<
" The option must start with the path to the output image which will be generated." << endl;
101 cout <<
" Dimensions and voxel sizes of the image must be provided using commas as separators, as in the following template:" << endl;
102 cout <<
" path/to/image:dimX,dimY,dimZ,voxSizeX,voxSizeY,voxSizeZ"<< endl;
103 cout <<
" -geo : Generate a CASToR geom file from the provided GATE macro file(s)"<< endl;
104 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;
105 cout <<
" -sp_bins nbinsT,nbinsA : Option specific to simulation using SPECThead systems, with root output."<< endl;
106 cout <<
" Give transaxial and axial number of bins for projections, separated by a comma."<< endl;
107 cout <<
" Pixel sizes will be computed from the crystal surface and the transaxial/axial number of bins" << endl;
108 cout <<
" -ot list : Provide a serie of time offset in seconds to apply before each input file"<< endl;
109 cout <<
" (In the case of converting several datafiles of a dynamic acquisition, timestamps of events may be resetted for each file" << endl;
110 cout <<
" This variable allows to manually increment the time between each datafile(s) if required" << endl;
111 cout <<
" The number of time offsets must be equal to the number of input files, provided by -i or -if options." << endl;
112 cout <<
" 'list' is a list of time offsets, separated by ','" << endl;
114 cout <<
"[Miscellaneous settings]:" << endl;
115 cout <<
" -vb : give the verbosity level, from 0 (no verbose) to above 5 (at the event level) (default: 1)." << endl;
117 #ifdef CASTOR_VERSION
118 cout <<
" This program is part of the CASToR release version " <<
CASTOR_VERSION <<
"." << endl;
129 int main(
int argc,
char** argv)
140 string input_file =
"";
141 vector<string> path_to_input_file;
144 string path_to_out_file =
"";
145 string path_to_data_filename =
"";
146 string path_to_header_filename =
"";
147 string path_to_mac_file =
"";
148 string path_to_atn_image =
"";
149 string path_to_src_image =
"";
152 string scanner_name =
"";
158 bool true_only_flag =
false;
164 bool histo_out_flag =
false;
167 bool estimate_acf_flag =
false;
169 string options_projector =
"incrementalSiddon";
172 bool kind_flag =
false;
175 string istp_alias =
"";
178 bool src_img_flag =
false;
179 INTNB dim_src_img[3];
180 FLTNB vox_src_img[3];
181 FLTNB* p_src_img = NULL;
184 bool geom_flag =
false;
187 bool input_is_intf =
false;
190 uint16_t spect_bin_axl = 0,
194 string offset_time_str =
"";
195 uint32_t* offset_time_list = NULL;
200 for (
int i=1; i<argc; i++)
202 string option = (string)argv[i];
204 if (option==
"-h" || option==
"--help" || option==
"-help")
ShowHelp(0);
209 if (path_to_input_file.size() > 0)
211 Cerr(
"***** castor-GATERootToCastor :: the following file names have already been provided (-i/-il options must be used ONCE): " << endl);
212 for (
size_t i=0 ; i<path_to_input_file.size() ; i++)
213 Cout(path_to_input_file[i] << endl);
218 if (argv[i+1] == NULL)
220 Cerr(
"***** castor-GATERootToCastor :: argument missing for option: " << option << endl);
225 input_file = argv[i+1];
226 path_to_input_file.push_back(input_file);
233 else if (option==
"-il")
235 if (path_to_input_file.size() > 0)
237 Cerr(
"***** castor-GATERootToCastor :: the following file names have already been provided (-i/-il options must be used ONCE) " << endl);
238 for (
size_t i=0 ; i<path_to_input_file.size() ; i++)
239 Cout(path_to_input_file[i] << endl);
244 if (argv[i+1] == NULL)
246 Cerr(
"***** castor-GATERootToCastor :: argument missing for option: " << option << endl);
251 ifstream ifile(argv[i+1], ios::in);
258 input_file = argv[i+1];
261 while (getline(ifile, line))
264 path_to_input_file.push_back(path_to_datafile);
269 Cerr(
"***** castor-GATERootToCastor :: Error, can't read txt file: " << argv[i+1] << endl);
279 else if (option==
"-m")
281 path_to_mac_file = (string)argv[i+1];
285 else if (option==
"-s")
287 if (argv[i+1] == NULL)
289 Cerr(
"***** castor-GATERootToCastor :: argument missing for option: " << option << endl);
293 scanner_name = argv[i+1];
297 else if (option==
"-o")
299 if (argv[i+1] == NULL)
301 Cerr(
"***** castor-GATERootToCastor :: argument missing for option: " << option << endl);
305 path_to_out_file = argv[i+1];
309 else if (option==
"-t")
312 true_only_flag =
true;
314 Cerr(
"***** castor-GATERootToCastor :: Option: " << option <<
" is only available for dataset generated with Gate in a Root format." << endl);
315 Cerr(
"***** castor-GATERootToCastor :: Root support is currently not enabled (CASTOR_ROOT environnement variable should be set before compilation)" << endl);
321 else if (option==
"-ot")
325 Cerr(
"***** castor-GATERootToCastor :: Argument missing for option: " << option << endl);
328 offset_time_str = (string)argv[i+1];
333 else if (option==
"-oh")
335 histo_out_flag =
true;
338 else if (option==
"-atn")
342 Cerr(
"***** castor-GATERootToCastor :: Argument missing for option: " << option << endl);
346 path_to_atn_image = argv[i+1];
349 size_t pos = path_to_atn_image.find_first_of(
":");
351 if (pos != string::npos)
353 options_projector = path_to_atn_image.substr(pos+1);
354 path_to_atn_image = path_to_atn_image.substr(0,pos);
357 estimate_acf_flag =
true;
362 else if (option==
"-k")
368 else if (option==
"-ist")
370 if (argv[i+1] == NULL)
372 Cerr(
"***** castor-GATERootToCastor :: argument missing for option: " << option << endl);
376 istp_alias = argv[i+1];
382 else if (option==
"-isrc")
384 if (argv[i+1] == NULL)
386 Cerr(
"***** castor-GATERootToCastor :: argument missing for option: " << option << endl);
392 string input = argv[i+1];
393 int pos_colon = input.find_first_of(
":");
394 path_to_src_image = input.substr(0,pos_colon);
395 input = input.substr(pos_colon + 1);
398 string p_dims_str[6];
401 Cerr(
"***** castor-GATERootToCastor :: Invalid argument " << argv[i+1] <<
" for option " << option <<
" !" << endl);
406 for(
int i=0 ; i<3 ; i++)
409 Cerr(
"***** castor-GATERootToCastor :: Conversion error for elt " << p_dims_str[i] <<
" for option " << option <<
" !" << endl);
414 for(
int i=0 ; i<3 ; i++)
417 Cerr(
"***** castor-GATERootToCastor :: Conversion error for elt " << p_dims_str[i+3] <<
" for option " << option <<
" !" << endl);
422 p_src_img =
new FLTNB[dim_src_img[0]*dim_src_img[1]*dim_src_img[2]];
424 for(
int v=0 ; v<dim_src_img[0]*dim_src_img[1]*dim_src_img[2] ; v++)
433 else if (option==
"-geo")
439 else if (option==
"-sp_bins")
441 string input = argv[i+1];
445 Cerr(
"***** castor-GATERootToCastor :: Invalid argument " << argv[i+1] <<
" for option " << option <<
" !" << endl);
449 spect_bin_trs = s_bins[0];
450 spect_bin_axl = s_bins[1];
457 else if (option==
"-vb")
461 Cerr(
"***** castor-GATERootToCastor :: Argument missing for option: " << option << endl);
464 vb = atoi(argv[i+1]);
470 Cerr(
"***** castor-GATERootToCastor :: Unknown option '" << option <<
"' !" << endl);
483 if (path_to_input_file.empty() )
485 Cerr(
"***** castor-GATERootToCastor :: Please provide at least one data filename (-i or -if)" << endl);
512 Cout(
" Selected root data-file(s) to convert: " << endl);
513 for (
size_t i=0 ; i<path_to_input_file.size() ; i++)
514 Cout(path_to_input_file[i] << endl);
524 Cerr(
"***** castor-GATERootToCastor :: CASToR must be compiled with ROOT to read input root files (check installation instructions)" << endl);
528 else if(src_img_flag)
530 Cerr(
"***** castor-GATERootToCastor :: Can't use -isrc with interfile dataset ");
531 Cerr(
" (image of the source can only be generated from root file) !" << endl);
536 for (
size_t i=0 ; i<path_to_input_file.size() ; i++)
538 ifstream input_file(path_to_input_file[i].c_str(), ios::in);
541 Cerr(
"***** gOptions::ReadDataASCIIFile() -> Couldn't find or read data-file '"<< path_to_input_file[i] <<
"' !" << endl);
547 if (path_to_out_file.empty() )
549 Cerr(
"***** castor-GATERootToCastor :: Please provide the output file name (-o)" << endl);
554 if(vb >= 2)
Cout(
" selected output file:" << path_to_out_file << endl);
557 if (path_to_mac_file.empty())
559 Cerr(
"***** castor-GATERootToCastor :: Please provide the macro file associated to the GATE root datafile (-m) :" << endl);
564 if(vb >= 2)
Cout(
" selected macro file: " << path_to_mac_file << endl);
567 if (scanner_name.empty())
569 Cerr(
"***** castor-GATERootToCastor :: Please provide a scanner alias (-s) :" << endl);
574 if(vb >= 2)
Cout(
" selected scanner alias: " << scanner_name << endl);
594 Cerr(
"***** castor-GATERootToCastor :: A problem occured while checking for the config directory path !" << endl);
600 Cerr(
"*****castor-GATERootToCastor :: A problem occured while initializing output directory !" << endl);
606 Cerr(
"***** castor-GATERootToCastor :: A problem occured while logging command line arguments !" << endl);
612 cout << std::setprecision(2);
620 if(GATE_system_type<0)
623 Cerr(
"***** castor-GATERootToCastor :: GATE system type not found : " << endl);
624 Cerr(
" This script only supports conversion for cylindricalPET, ecat and SPECThead systems" << endl);
625 Cerr(
" The system type is recovered from the lines '/gate/systems/...'" << endl);
636 string path_to_geom = scanner_repository + scanner_name +
".geom";
639 switch ( GATE_system_type )
642 if( vb>=2 )
Cout(endl <<
" --- CylindricalPET system detected. Proceeding to conversion... --- " << endl << endl);
646 Cerr(
"***** castor-GATERootToCastor :: An error occured while trying to process mac file for cylindrical system: " << path_to_mac_file << endl);
652 if( vb>=2 )
Cout(endl <<
" --- ECAT system detected. Proceeding to conversion... --- " << endl << endl);
656 Cerr(
"***** castor-GATEMacToGeom :: An error occured while trying to process mac file for ecat system: " << path_to_mac_file << endl);
662 if( vb>=2 )
Cout(endl <<
" --- SPECThead system detected. Proceeding to conversion... --- " << endl << endl);
666 Cerr(
"***** castor-GATEMacToGeom :: An error occured while trying to process mac file for SPECT system: " << path_to_mac_file << endl);
672 Cerr(
"***** castor-GATERootToCastor :: System type not found : " << endl);
673 Cerr(
" This script only supports conversion for cylindricalPET ecat and SPECThead systems" << endl);
674 Cerr(
" The system type is recovered from the lines '/gate/systems/...'" << endl);
679 if( vb>=2 )
Cout(endl <<
" --- Conversion completed --- " << endl << endl);
691 scanner_name = (scanner_name.find(
OS_SEP)) ?
692 scanner_name.substr(scanner_name.find_last_of(
OS_SEP)+1) :
697 Cerr(
"**** castor-GATERootToCastor :: A problem occurred while searching for scanner system !" << endl);
702 path_to_data_filename = path_to_out_file +
".Cdf";
703 path_to_header_filename = path_to_out_file +
".Cdh";
714 if(!istp_alias.empty())
718 Cerr(
"**** castor-GATERootToCastor :: A problem occurred while checking isotope name !" << endl);
727 uint16_t max_nb_lines_per_event = 1;
735 histo_out_flag =
true;
745 if(estimate_acf_flag)
809 if(estimate_acf_flag)
814 Cerr(
"***** castor-GATERootToCastor :: Estimation of acf from an attenuation image (-atn option) is only available for histogram datafile output !" << endl
815 <<
" Add the (-oh) option to the command line to enable this option." << endl);
822 Cerr(
"***** castor-GATERootToCastor :: Estimation of acf from an attenuation image (-atn option) only available for PET systems ! (detected system is SPECT)" << endl);
830 Cerr(
"***** castor-GATERootToCastor :: An error occurred while trying to read the interfile header of attenuation file " << path_to_atn_image <<
" !" << endl);
857 Cerr(
"***** castor-GATERootToCastor :: A problem occured while checking image dimensions parameters !" << endl);
862 Cerr(
"***** castor-GATERootToCastor :: A problem occured while initializing image dimensions !" << endl);
869 Cerr(
"***** castor-GATERootToCastor :: A problem occured while initializing Dynamic data manager's class !" << endl);
884 Cerr(
"***** castor-GATERootToCastor :: Error during image initialization !" << endl);
892 Cerr(
"**** castor-GATERootToCastor :: A problem occurred during scanner object construction !" << endl);
898 Cerr(
"**** castor-GATERootToCastor :: A problem occurred while creating Scanner object !" << endl);
904 Cerr(
"***** castor-GATERootToCastor :: A problem occurred while generating/reading the LUT !" << endl);
911 Cerr(
"***** castor-GATERootToCastor :: A problem occured while checking scanner manager parameters !" << endl);
917 Cerr(
"***** castor-GATERootToCastor :: A problem occured while initializing scanner !" << endl);
935 Cerr(
"***** castor-GATERootToCastor :: A problem occured while checking projector manager's parameters !" << endl);
942 Cerr(
"***** castor-GATERootToCastor :: A problem occured while initializing projector manager !" << endl);
951 offset_time_list =
new uint32_t[path_to_input_file.size()];
952 for(
size_t f=0 ; f<path_to_input_file.size() ; f++)
953 offset_time_list[f] = 0;
956 if(offset_time_str !=
"")
958 vector<string> offsets;
959 size_t comma_pos = 0;
960 while ((comma_pos=offset_time_str.find_first_of(
",")) != string::npos)
962 string offset = offset_time_str.substr(0,comma_pos);
963 offsets.push_back(offset);
964 offset_time_str = offset_time_str.substr(comma_pos+1);
968 if(offsets.size() != path_to_input_file.size())
970 Cerr(
"**** castor-GATERootToCastor :: Unmatching number of offsets with -ot option ! "
971 << offsets.size() <<
" have been found, while "<< path_to_input_file.size() <<
"input file have been provided !" << endl);
975 for(
size_t o=0 ; o<offsets.size() ; o++)
980 Cerr(
"**** castor-GATERootToCastor :: Error while trying to convert offset : "<< offsets[o] <<
" in ms ! " << endl);
985 offset_time_list[o] = (uint32_t)offset*1000;
993 Cout(
" --- Start conversion of datafile(s) : " << input_file << endl
994 <<
" using mac file: " << path_to_mac_file << endl
995 <<
" CASToR output header datafile: " << path_to_header_filename << endl
996 <<
" CASToR output binary datafile: " << path_to_data_filename << endl << endl);
1003 uint64_t nLORs_tot = 0,
1011 uint32_t nCrystalsTot = 0;
1012 uint32_t nRsectorsAngPos = 1, nRsectorsAxial = 1;
1014 int rsector_id_order = 0;
1015 uint32_t nModulesTransaxial = 1, nModulesAxial = 1;
1016 uint32_t nSubmodulesTransaxial = 1, nSubmodulesAxial = 1;
1017 uint32_t nCrystalsTransaxial = 1, nCrystalsAxial = 1;
1018 uint32_t nBlocksLine = 1, nBlocksPerRing = 1;
1019 uint8_t nLayers = 1;
1020 uint32_t nb_crystal_per_layer[4] = {0,0,0,0};
1023 uint32_t nProjectionsByHead =1;
1024 uint32_t nProjectionsTot = 1;
1026 uint32_t nPixelsAxial = 1;
1027 uint32_t nPixelsTransaxial = 1;
1028 uint32_t nbSimulatedPixels = 1;
1029 float_t distToDetector = 0.;
1031 float_t head1stAngleDeg = 0;
1032 float_t headAngPitchDeg = -1;
1033 float_t headAngStepDeg = -1;
1034 float_t crystalSizeAxl=-1.,
1036 FLTNB* p_proj_spect_image=NULL;
1039 vector<uint32_t> nLayersRptTransaxial, nLayersRptAxial;
1042 uint8_t** p_bins = NULL;
1043 uint32_t bins_elts = 0;
1044 uint32_t start_time_ms = 0;
1045 uint32_t duration_ms = 1000;
1049 uint32_t castorID1=0;
1050 uint32_t castorID2=0;
1054 int32_t crystalID1=0, crystalID2=0;
1057 int32_t rsectorID1=0 , rsectorID2=0;
1058 int32_t moduleID1=0 , moduleID2=0;
1059 int32_t submoduleID1=0, submoduleID2=0;
1060 int32_t layerID1=0 , layerID2=0;
1063 int32_t blockID1=0, blockID2=0;
1067 float_t gPosX, gPosY, gPosZ;
1073 int32_t eventID1= 0, eventID2= 0;
1074 int32_t comptonPhantomID1 = 0, comptonPhantomID2= 0;
1075 int32_t rayleighPhantomID1 = 0,rayleighPhantomID2 = 0;
1076 double_t time1= 0, time2= 0;
1077 int32_t sourceID1=0, sourceID2=0;
1078 float_t sourcePosX1=0., sourcePosY1=0., sourcePosZ1=0.;
1085 TApplication *Tapp =
new TApplication(
"tapp",0,0);
1086 TTree** GEvents =
new TTree *[path_to_input_file.size()];
1087 TFile** Tfile_root =
new TFile*[path_to_input_file.size()];
1092 for (
size_t iFic=0 ; iFic<path_to_input_file.size() ; iFic++)
1094 Tfile_root[iFic] =
new TFile(path_to_input_file[iFic].c_str(),
"READ",
"ROOT file with histograms");
1096 GEvents[iFic] = (TTree*)Tfile_root[iFic]->Get(
"Singles");
1098 GEvents[iFic] = (TTree*)Tfile_root[iFic]->Get(
"Coincidences");
1100 nLORs_tot += GEvents[iFic]->GetEntries();
1107 uint64_t printing_index = 0;
1108 uint64_t printing_ratio = (nLORs_tot>10000) ? 10000 : nLORs_tot/10;
1139 Cerr(
"**** castor-GATERootToCastor :: Error when reading mac file : "<< path_to_mac_file <<
" !" << endl);
1143 nCrystalsTot = nPixelsAxial * nPixelsTransaxial;
1147 p_proj_spect_image =
new FLTNB[nHeads*nProjectionsByHead*nCrystalsTot];
1151 Cerr(
"**** castor-GATERootToCastor :: Error when trying to read image : "<< path_to_input_file[0] <<
" !" << endl);
1176 Cerr(
"**** castor-GATERootToCastor :: Error when reading mac file : "<< path_to_mac_file <<
" !" << endl);
1180 nbSimulatedPixels = nPixelsAxial*nPixelsTransaxial;
1182 if((spect_bin_trs>0 || spect_bin_axl>0) && nbSimulatedPixels > 1 )
1184 Cerr(
"**** castor-GATERootToCastor :: WARNING : Spect bins have been initialized, but the simulation already provide a specific number of pixels (="<< nPixelsAxial*nPixelsTransaxial <<
") !"<< endl <<
1185 " Pixel matrix used by default !" << endl);
1190 if(spect_bin_trs == 0 && spect_bin_axl == 0 && nbSimulatedPixels==1)
1192 Cerr(
"**** castor-GATERootToCastor :: Error : Axial and transaxial bins values expected (use option -spect_b) !"<< endl);
1197 if(crystalSizeAxl<0 || crystalSizeTrs<0)
1199 Cerr(
"**** castor-GATERootToCastor :: Crystal dimensions not correctly read in the mac files !" << endl);
1203 nPixelsTransaxial = spect_bin_trs;
1204 nPixelsAxial = spect_bin_axl;
1206 if(vb>=2)
Cout(
"Transaxial/Axial nb pixels : " << nPixelsTransaxial <<
" , " << nPixelsAxial << endl <<
1207 "Transaxial/Axial pixel sizes : " << crystalSizeTrs/nPixelsTransaxial <<
" , " << crystalSizeAxl/nPixelsAxial << endl);
1211 nCrystalsTot = nPixelsAxial * nPixelsTransaxial;
1213 if(vb>=2)
Cout(
"Number of Projections: " << nProjectionsByHead << endl <<
1214 "Detected number of crystals in the system : " << nCrystalsTot << endl);
1220 bins_elts = nHeads*nProjectionsByHead;
1222 p_bins =
new uint8_t*[bins_elts];
1223 for (
size_t p=0; p<bins_elts ; p++)
1225 p_bins[p] =
new uint8_t[nCrystalsTot];
1227 for (
size_t c=0; c<nCrystalsTot ; c++)
1229 p_bins[p][c] = input_is_intf ? (uint8_t)p_proj_spect_image[p*nCrystalsTot+c] : 0 ;
1234 nLORs_tot += p_proj_spect_image[p*nCrystalsTot+c];
1235 nLORs_unknown += p_proj_spect_image[p*nCrystalsTot+c];
1241 delete[] p_proj_spect_image;
1251 nb_crystal_per_layer,
1254 nCrystalsTransaxial,
1256 nLayersRptTransaxial,
1258 nSubmodulesTransaxial,
1268 Cerr(
"**** castor-GATERootToCastor :: Error when reading mac file : "<< path_to_mac_file <<
" !" << endl);
1279 nCrystalsTransaxial,
1286 Cerr(
"**** castor-GATERootToCastor :: Error when reading mac file : "<< path_to_mac_file <<
" !" << endl);
1292 if(vb>=2)
Cout(
"Detected number of crystals in the system : " << nCrystalsTot << endl);
1297 Cout(
" Allocating memory for bins... " << endl <<
1298 " Warning : this step can require huge amount of memory if the system contains a high number of crystals !" << endl);
1300 bins_elts = nCrystalsTot;
1302 p_bins =
new uint8_t*[bins_elts];
1303 for (
size_t c=0; c<bins_elts ; c++)
1305 p_bins[c] =
new uint8_t[nCrystalsTot-c];
1307 for (
size_t c2=0; c2<nCrystalsTot-c ; c2++)
1311 Cout(
" Memory allocation for bins completed " << endl << endl);
1323 for (
size_t iFic=0 ; iFic<path_to_input_file.size() ; iFic++)
1325 if(vb>=2)
Cout(endl <<
"Processing datafile " << iFic <<
" : " << path_to_input_file[iFic] <<
"..." << endl);
1332 GEvents[iFic]->SetBranchAddress(
"time1",&time1);
1333 GEvents[iFic]->SetBranchAddress(
"rsectorID1",&rsectorID1);
1334 GEvents[iFic]->SetBranchAddress(
"moduleID1",&moduleID1);
1335 GEvents[iFic]->SetBranchAddress(
"submoduleID1",&submoduleID1);
1336 GEvents[iFic]->SetBranchAddress(
"crystalID1",&crystalID1);
1337 GEvents[iFic]->SetBranchAddress(
"layerID1", &layerID1);
1338 GEvents[iFic]->SetBranchAddress(
"comptonPhantom1",&comptonPhantomID1);
1339 GEvents[iFic]->SetBranchAddress(
"RayleighPhantom1",&rayleighPhantomID1);
1340 GEvents[iFic]->SetBranchAddress(
"eventID1",&eventID1);
1341 GEvents[iFic]->SetBranchAddress(
"sourceID1",&sourceID1);
1343 GEvents[iFic]->SetBranchAddress(
"time2",&time2);
1344 GEvents[iFic]->SetBranchAddress(
"rsectorID2",&rsectorID2);
1345 GEvents[iFic]->SetBranchAddress(
"moduleID2",&moduleID2);
1346 GEvents[iFic]->SetBranchAddress(
"submoduleID2",&submoduleID2);
1347 GEvents[iFic]->SetBranchAddress(
"crystalID2",&crystalID2);
1348 GEvents[iFic]->SetBranchAddress(
"layerID2", &layerID2);
1349 GEvents[iFic]->SetBranchAddress(
"comptonPhantom2",&comptonPhantomID2);
1350 GEvents[iFic]->SetBranchAddress(
"RayleighPhantom2",&rayleighPhantomID2);
1351 GEvents[iFic]->SetBranchAddress(
"eventID2",&eventID2);
1352 GEvents[iFic]->SetBranchAddress(
"sourceID2",&sourceID2);
1354 GEvents[iFic]->SetBranchAddress(
"sourcePosX1",&sourcePosX1);
1355 GEvents[iFic]->SetBranchAddress(
"sourcePosY1",&sourcePosY1);
1356 GEvents[iFic]->SetBranchAddress(
"sourcePosZ1",&sourcePosZ1);
1360 GEvents[iFic]->SetBranchAddress(
"time",&time1);
1361 GEvents[iFic]->SetBranchAddress(
"headID", &headID);
1362 GEvents[iFic]->SetBranchAddress(
"crystalID",&crystalID1);
1363 GEvents[iFic]->SetBranchAddress(
"pixelID", &pixelID);
1364 GEvents[iFic]->SetBranchAddress(
"rotationAngle", &rotAngle);
1365 GEvents[iFic]->SetBranchAddress(
"globalPosX",&gPosX);
1366 GEvents[iFic]->SetBranchAddress(
"globalPosY",&gPosY);
1367 GEvents[iFic]->SetBranchAddress(
"globalPosZ",&gPosZ);
1368 GEvents[iFic]->SetBranchAddress(
"comptonPhantom",&comptonPhantomID1);
1369 GEvents[iFic]->SetBranchAddress(
"RayleighPhantom",&rayleighPhantomID1);
1370 GEvents[iFic]->SetBranchAddress(
"sourcePosX",&sourcePosX1);
1371 GEvents[iFic]->SetBranchAddress(
"sourcePosY",&sourcePosY1);
1372 GEvents[iFic]->SetBranchAddress(
"sourcePosZ",&sourcePosZ1);
1376 GEvents[iFic]->SetBranchAddress(
"time1",&time1);
1377 GEvents[iFic]->SetBranchAddress(
"blockID1",&blockID1);
1378 GEvents[iFic]->SetBranchAddress(
"crystalID1",&crystalID1);
1379 GEvents[iFic]->SetBranchAddress(
"comptonPhantom1",&comptonPhantomID1);
1380 GEvents[iFic]->SetBranchAddress(
"RayleighPhantom1",&rayleighPhantomID1);
1381 GEvents[iFic]->SetBranchAddress(
"eventID1",&eventID1);
1382 GEvents[iFic]->SetBranchAddress(
"sourceID1",&sourceID1);
1384 GEvents[iFic]->SetBranchAddress(
"time2",&time2);
1385 GEvents[iFic]->SetBranchAddress(
"blockID2",&blockID2);
1386 GEvents[iFic]->SetBranchAddress(
"crystalID2",&crystalID2);
1387 GEvents[iFic]->SetBranchAddress(
"comptonPhantom2",&comptonPhantomID2);
1388 GEvents[iFic]->SetBranchAddress(
"RayleighPhantom2",&rayleighPhantomID2);
1389 GEvents[iFic]->SetBranchAddress(
"eventID2",&eventID2);
1390 GEvents[iFic]->SetBranchAddress(
"sourceID2",&sourceID2);
1391 GEvents[iFic]->SetBranchAddress(
"sourcePosX1",&sourcePosX1);
1392 GEvents[iFic]->SetBranchAddress(
"sourcePosY1",&sourcePosY1);
1393 GEvents[iFic]->SetBranchAddress(
"sourcePosZ1",&sourcePosZ1);
1402 for (
int i=0; i<GEvents[iFic]->GetEntries() ; i++)
1404 GEvents[iFic]->GetEntry(i);
1408 Cout(
"File#" << iFic <<
", event#" << i << endl;);
1415 Cout(
"Crystal 1 : RsectorID: " << rsectorID1 <<
", moduleID: " << moduleID1 <<
", submoduleID: " << submoduleID1 <<
", crystalID: " << crystalID1
1416 <<
", layerID: " << layerID1 << endl;);
1417 Cout(
"Crystal 2 :RsectorID: " << rsectorID2 <<
", moduleID2: " << moduleID2 <<
", submoduleID: " << submoduleID2 <<
", crystalID: " << crystalID2
1418 <<
", layerID: " << layerID2 << endl;);
1422 nModulesTransaxial, nModulesAxial,
1423 nSubmodulesTransaxial, nSubmodulesAxial,
1424 nCrystalsTransaxial, nCrystalsAxial,
1425 nLayers, nb_crystal_per_layer,
1426 nLayersRptTransaxial, nLayersRptAxial,
1427 layerID1, crystalID1, submoduleID1, moduleID1, rsectorID1);
1430 nModulesTransaxial, nModulesAxial,
1431 nSubmodulesTransaxial, nSubmodulesAxial,
1432 nCrystalsTransaxial, nCrystalsAxial,
1433 nLayers, nb_crystal_per_layer,
1434 nLayersRptTransaxial, nLayersRptAxial,
1435 layerID2, crystalID2, submoduleID2, moduleID2, rsectorID2);
1439 Cout(
"--> castorID1: " << castorID1 << endl;);
1440 Cout(
"--> castorID2: " << castorID2 << endl;);
1448 Cout(
"Projection ID : headID: " << headID <<
", rotation angle (deg): " << rotAngle << endl;);
1449 Cout(
"Crystal ID : crystalID: " << crystalID1 <<
", pixelID: " << pixelID <<
", globalPosX " << gPosX <<
", globalPosY " << gPosY <<
", globalPosZ " << gPosZ << endl;);
1456 nProjectionsByHead);
1475 Cout(
"--> castorID1: " << castorID1 << endl;);
1476 Cout(
"--> castorID2: " << castorID2 << endl;);
1485 Cout(
"Crystal 1 : BlockID: " << blockID1 <<
", crystalID: " << crystalID1 << endl;);
1486 Cout(
"Crystal 2 : BlockID: " << blockID2 <<
", crystalID: " << crystalID2 << endl;);
1489 castorID1 =
ConvertIDecat(nBlocksPerRing, nBlocksLine, nCrystalsTransaxial, nCrystalsAxial, crystalID1, blockID1);
1490 castorID2 =
ConvertIDecat(nBlocksPerRing, nBlocksLine, nCrystalsTransaxial, nCrystalsAxial, crystalID2, blockID2);
1494 Cout(
"--> castorID1: " << castorID1 << endl;);
1495 Cout(
"--> castorID2: " << castorID2 << endl;);
1501 kind =
ComputeKindGATEEvent(eventID1, eventID2, comptonPhantomID1, comptonPhantomID2, rayleighPhantomID1, rayleighPhantomID2);
1527 if (true_only_flag==
true && kind !=
KIND_TRUE)
1538 p_bins[castorID1][castorID2]++;
1543 uint32_t time_in_ms = time1*1000;
1545 Event->
SetID1(0, castorID1);
1546 Event->
SetID2(0, castorID2);
1559 if (castorID1 < castorID2)
1560 p_bins[castorID1][castorID2-castorID1-1]++;
1562 p_bins[castorID2][castorID1-castorID2-1]++;
1568 uint32_t time_in_ms = time1*1000;
1569 int nb_lines_in_event = 1;
1572 Event->
SetID1(0, castorID1);
1573 Event->
SetID2(0, castorID2);
1585 eventID1 == eventID2)
1588 x = (int)(( sourcePosX1 + dim_src_img[0]/2*vox_src_img[0]) / vox_src_img[0]);
1590 y = (int)(( sourcePosY1 + dim_src_img[1]/2*vox_src_img[1]) / vox_src_img[1]);
1591 z = (int)(( sourcePosZ1 + dim_src_img[2]/2*vox_src_img[2]) / vox_src_img[2]);
1593 if(x >= 0 && x < dim_src_img[0] &&
1594 y >= 0 && y < dim_src_img[1] &&
1595 z >= 0 && z < dim_src_img[2] )
1596 p_src_img[z*dim_src_img[1]*dim_src_img[0] + y*dim_src_img[0] + x]++;
1601 if (printing_index%(nLORs_tot/printing_ratio) == 0)
1604 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 "
1605 << percent <<
" % ";
1612 if(vb>=2)
Cout(endl <<
"DataFile " << iFic <<
" : " << path_to_input_file[iFic] <<
" process OK" << endl);
1618 delete[] Tfile_root;
1635 Cout(endl <<
"Generate the histogram datafile" << endl);
1637 uint32_t nb_bins = bins_elts*nCrystalsTot;
1638 printing_ratio = (nb_bins>1000) ? 1000 : nb_bins/10;
1641 for (
size_t id1=0 ; id1<bins_elts ; id1++)
1642 for (
size_t id2=0; id2<nCrystalsTot ; id2++)
1644 uint32_t nb_events_in_bin = p_bins[id1][id2];
1658 if (printing_index%((nb_bins)/printing_ratio) == 0)
1661 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 "
1662 << percent <<
" % ";
1672 Cout(endl <<
"The output histogram contains " << nBINs <<
" events." << endl);
1686 FLTNB* p_angles =
new FLTNB[nProjectionsTot];
1687 FLTNB* p_distToDetector =
new FLTNB[nProjectionsTot];
1689 for(
size_t h=0 ; h<nHeads ; h++)
1690 for(
size_t p=0 ; p<nProjectionsByHead ; p++)
1692 int idx_proj = h*nProjectionsByHead+p;
1693 p_angles[idx_proj] = head1stAngleDeg
1695 + h*headAngPitchDeg;
1698 p_distToDetector[idx_proj] = distToDetector;
1701 ((
iDataFileSPECT*)Out_data_file)->SetNbBins(nPixelsTransaxial, nPixelsAxial);
1702 ((
iDataFileSPECT*)Out_data_file)->SetNbProjections(nProjectionsTot);
1706 Cerr(
"**** castor-GATERootToCastor :: Error when trying to set projection angles values !" << endl);
1710 if( ((
iDataFileSPECT*)Out_data_file)->InitCorToDetectorDistance(p_distToDetector) )
1712 Cerr(
"**** castor-GATERootToCastor :: Error when trying to set distance between center of rotation and detectors !" << endl);
1716 ((
iDataFileSPECT*)Out_data_file)->SetHeadRotDirection(headRotDirection);
1719 delete[] p_distToDetector;
1731 Cout(endl <<
"Generate the histogram datafile" << endl);
1732 uint32_t nb_bins = (nCrystalsTot*nCrystalsTot - nCrystalsTot)/2;
1733 printing_ratio = (nb_bins>1000) ? 1000 : nb_bins/10;
1736 for (
size_t id1=0 ; id1 <bins_elts ; id1++)
1737 for (
size_t id2 = id1+1; id2 < nCrystalsTot;id2++)
1739 uint32_t nb_events_in_bin = p_bins[id1][id2-id1-1];
1748 if(estimate_acf_flag)
1759 ((
iEventPET*)Event)->SetAttenuationCorrectionFactor(1/std::exp(-fp));
1767 if (printing_index%((nb_bins)/printing_ratio) == 0)
1770 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 "
1771 << percent <<
" % ";
1781 Cout(endl <<
"The output histogram contains " << nBINs <<
" events." << endl);
1800 if (vb>=2)
Cout(
"Writing source image ..." << endl);
1814 if (
IntfWriteImgFile(path_to_src_image.append(
"_src"), p_src_img, IF, vb) )
1816 Cerr(
"***** castor-GATERootToCastor :: Error writing Interfile of output image !" << endl);
1821 Cout(endl <<
"The simulated dataset contained " << nLORs_tot <<
" coincidences/singles, with: " << endl
1822 <<
" " << nLORs_trues <<
" trues (" << 100*nLORs_trues/nLORs_tot <<
" %), " << endl
1823 <<
" " << nLORs_scatters <<
" scatters (" << 100*nLORs_scatters/nLORs_tot <<
" %)," << endl
1824 <<
" " << nLORs_rdms <<
" randoms (" << 100*nLORs_rdms/nLORs_tot <<
" %)," << endl
1825 <<
" " << nLORs_unknown <<
" unknown (" << 100*nLORs_unknown/nLORs_tot <<
" %)." << endl);
1827 if (vb>=2)
Cout(
"Writing raw datafile ..." << endl);
1833 Cout(endl <<
" --- Conversion completed --- " << endl);
1839 if (vb>=2)
Cout(
" Deallocating objects ..." << endl);
1844 for(
size_t b=0; b<bins_elts ; b++)
1866 delete[]offset_time_list;
1867 delete Out_data_file;
1869 if(src_img_flag && p_src_img)
1873 if(estimate_acf_flag)
1875 if(p_ImageSpace)
delete p_ImageSpace;
1876 if(p_ProjectorManager)
delete p_ProjectorManager;
1877 if(p_ID)
delete p_ID;
1879 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...
virtual int WriteHeader()=0
This function is implemented in child classes. Generate a header file according to the data output ...
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.
virtual int WriteEvent(vEvent *ap_Event, int a_th=0)=0
This function is implemented in child classes Write event according to the chosen type of data...
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...
Inherit from iEventSPECT. Class for SPECT histogram mode events.
void SetVerbose(int a_verboseLevel)
set verbosity
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.
uint32_t ConvertIDcylindrical(uint32_t nRsectorsAngPos, uint32_t nRsectorsAxial, int a_rsectorIdOrder, 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...
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.
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 &nRsectorsAxial, uint32_t &nRsectorsAngPos, int &rsector_id_order, uint32_t &start_time_ms, uint32_t &duration_ms, int vb)
Recover informations about the scanner element of a cylindricalPET system and acquisition duration...
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...
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.
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)
This class is designed to manage all dimensions and quantification related stuff. ...
void SetNbBeds(int a_nbBeds)
Set the number of bed positions and allocate the bed positions if not already done.
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 ...
int PROJ_DeleteTmpDataFile()
Delete temporary datafile used for multithreaded output writing if needed.
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)...
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.