43 vector<string> values;
48 line = (line.find(
"#") != string::npos) ?
49 line.substr(0, line.find_first_of(
"#")) :
52 size_t foundAdress = line.find(a_key);
54 if (foundAdress != string::npos)
56 values =
Split(a_line);
57 values.erase (values.begin());
76 vector<string>
Split(
string a_line)
79 stringstream ss(a_line);
81 vector<string> tokens;
84 tokens.push_back(buf);
104 for(uint16_t i=0; i < ap_v.size(); i++)
108 for (
int j=0; j<i; j++)
130 int WriteVector(ofstream& file,
const string& a_key, vector <T> a_vals)
132 int n = a_vals.size();
137 for (
int i=0; i < n; i++)
142 file << ss.str() << endl;
144 file << ss.str() <<
",";
148 file << a_key <<
"0" <<endl;
153 template int WriteVector(ofstream& file,
const string& a_key, vector <double> a_vals);
169 int WriteVector(ofstream& file,
const string& a_key, vector <string> a_vals)
171 int n = a_vals.size();
176 for (
int i=0; i < n; i++)
179 file << a_vals[i] << endl;
181 file << a_vals[i] <<
",";
185 file << a_key <<
"0" <<endl;
204 int WriteVector(ofstream& file,
const string& a_key, vector <vector<string> > a_vals)
206 int n = a_vals.size();
208 for (
int i=0; i < n; i++)
209 for (
int j=0; j < 3; j++)
210 if (i == n-1 && j == 2)
211 file << a_vals[i][j] << endl;
213 file << a_vals[i][j] <<
",";
234 ifstream mac_file(a_pathMac, ios::in);
240 while(getline(mac_file, quickLine))
242 vector <string> values;
247 ap_pathToMacFiles.push_back(
GetPathOfFile(a_pathMac)+values[0]);
252 Cerr(
"***** GetGATEMacFiles() -> Couldn't open mac file "<< a_pathMac <<
" !" << endl);
278 vector<string> path_mac_files;
279 path_mac_files.push_back(a_pathMac);
283 Cerr(
"***** GetGATESystemType() -> Error occured when trying to recover paths to GATE macro files !" << endl);
287 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
288 cout << f <<
" : " << path_mac_files[f] << endl;
291 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
293 ifstream mac_file(path_mac_files[f], ios::in);
298 while(getline(mac_file, line))
301 if(line.find(
"/gate/systems/") != string::npos )
303 if(line.find(
"/gate/systems/ecat") != string::npos )
306 if(line.find(
"/gate/systems/cylindricalPET") != string::npos )
309 if(line.find(
"/gate/systems/SPECThead") != string::npos )
312 if(line.find(
"/gate/systems/OPET") != string::npos ||
313 line.find(
"/gate/systems/CTSCANNER") != string::npos ||
314 line.find(
"/gate/systems/CPET") != string::npos ||
315 line.find(
"/gate/systems/ecatAccel") != string::npos ||
316 line.find(
"/gate/systems/OpticalSystem") != string::npos )
318 Cerr(
"unsupported system detected (line = " << line <<
") ! "<< endl);
319 Cerr(
"supported systems for this script are cylindricalPET, SPECThead, and ecat" << endl);
326 Cerr(
"***** GetGATESystemType() -> Error : Couldn't open mac file "<< path_mac_files[f] <<
" !" << endl);
363 string& rsector_name,
365 string& submodule_name,
366 string& crystal_name,
367 vector<string>& layers_name,
372 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
374 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
379 while(getline(mac_file, quickLine))
381 vector <string> values;
383 values =
CheckGATECommand(
"/gate/systems/cylindricalPET/rsector/attach", quickLine);
387 rsector_name = values[0];
391 values =
CheckGATECommand(
"/gate/systems/cylindricalPET/module/attach", quickLine);
394 module_name = values[0];
398 values =
CheckGATECommand(
"/gate/systems/cylindricalPET/submodule/attach", quickLine);
401 submodule_name = values[0];
405 values =
CheckGATECommand(
"/gate/systems/cylindricalPET/crystal/attach", quickLine);
408 crystal_name = values[0];
417 values =
CheckGATECommand(
"/gate/systems/cylindricalPET/layer"+ss.str()+
"/attach", quickLine);
420 layers_name.push_back(values[0]);
429 Cerr(
"***** GetGATEAliasesCylindrical()->Couldn't open mac file "<< path_mac_files[f] <<
" !" << endl);
440 Cout(
"***** GetGATEAliasesCylindrical() :: Error : Missing elements in the system architecture" << endl <<
441 " At least two of the following lines are required :" << endl <<
442 " - /gate/systems/cylindricalPET/rsector/attach" << endl <<
443 " - /gate/systems/cylindricalPET/module/attach" << endl <<
444 " - /gate/systems/cylindricalPET/submodule/attach" << endl <<
445 " - /gate/systems/cylindricalPET/crystal/attach" << endl <<
446 " - /gate/systems/cylindricalPET/layeri[i=0..3]/attach" << endl);
452 if(rsector_name.empty())
454 if(module_name.empty())
457 rsector_name = submodule_name;
463 rsector_name = module_name;
470 if(!rsector_name.empty())
Cout(
"Detected rsector container's name : " << rsector_name << endl);
471 if(!module_name.empty())
Cout(
"Detected module container's name : " << module_name << endl);
472 if(!submodule_name.empty())
Cout(
"Detected submodule container's name : " << submodule_name << endl);
473 if(!crystal_name.empty())
Cout(
"Detected crystal container's name : " << crystal_name << endl);
474 for(
size_t l=0 ; l<layers_name.size() ; l++)
475 if(!layers_name[l].empty())
Cout(
"Detected layer #"<< l <<
" container's name : " << layers_name[l] << endl);
504 string& crystal_name,
509 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
511 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
517 while(getline(mac_file, quickLine))
519 vector <string> values;
524 block_name = values[0];
531 crystal_name = values[0];
538 Cerr(
"***** GetGATEAliasesEcat()-> Couldn't open mac file "<< path_mac_files[f].c_str()<<
" !" << endl);
547 Cerr(
"***** GetGATEAliasesEcat() :: Error : Missing elements in the system architecture" << endl
548 <<
" The following lines are required :" << endl
549 <<
" - /gate/systems/ecat/block/attach" << endl
550 <<
" - /gate/systems/ecat/crystal/attach" << endl);
556 Cout(
"First container's name (usually block) is : " << block_name << endl
557 <<
"Second container's name (usually crystal) is : " << crystal_name << endl);
588 string& crystal_name,
594 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
596 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
603 while(getline(mac_file, quickLine))
605 vector <string> values;
607 values =
CheckGATECommand(
"/gate/systems/SPECThead/base/attach", quickLine);
610 base_name = values[0];
614 values =
CheckGATECommand(
"/gate/systems/SPECThead/crystal/attach", quickLine);
617 crystal_name = values[0];
621 values =
CheckGATECommand(
"/gate/systems/SPECThead/pixel/attach", quickLine);
624 pixel_name = values[0];
632 Cerr(
"***** GetGATEAliasesSPECT()-> Couldn't open mac file "<< path_mac_files[f].c_str()<<
" !" << endl);
640 Cerr(
"***** GetGATEAliasesSPECT() :: Error : Missing elements in the system architecture" << endl
641 <<
" The following line is required :" << endl
642 <<
" - /gate/systems/SPECThead/crystal/attach" << endl);
648 Cout(
"Crystal container's name is : " << crystal_name << endl);
674 int32_t nCrystalsTransaxial,
675 int32_t nCrystalsAxial,
679 int32_t nCrystalsPerRing = nBlocksPerRing * nCrystalsTransaxial;
681 int32_t ringID = (int32_t)( blockID/nBlocksPerRing ) * nCrystalsAxial
682 + (int32_t)( crystalID/nCrystalsTransaxial );
684 int32_t castorID = nCrystalsPerRing * ringID
685 + nCrystalsTransaxial*( blockID % nBlocksPerRing )
686 + crystalID % nCrystalsTransaxial;
709 uint32_t a_nProjectionsByHead)
712 int32_t angID = round(a_rotAngle/a_angStep);
715 int32_t castorID = a_headID*a_nProjectionsByHead + angID;
752 float_t a_headAngPitch,
753 float_t a_crystalSizeAxl,
754 float_t a_crystalSizeTrs,
759 int32_t castorID = 0;
762 if (a_nbSimulatedPixels > 1)
764 castorID = a_pixelID;
771 FLTNB sizePixTrs = a_crystalSizeTrs/a_nPixTrs;
772 FLTNB sizePixAxl = a_crystalSizeAxl/a_nPixAxl;
775 uint32_t axialID = (int32_t)(( a_gPosZ + a_nPixAxl/2*sizePixAxl) / sizePixAxl);
779 float_t ang = a_headID*a_headAngPitch + a_rotAngle;
782 float_t sin_a = sin(-ang*M_PI/180);
783 float_t cos_a = cos(-ang*M_PI/180);
784 float_t trs_pos = a_gPosX*sin_a + a_gPosY*cos_a ;
787 uint32_t transID = (int32_t)(( trs_pos + a_nPixTrs/2*sizePixTrs) / sizePixTrs);
789 if(axialID >= 0 && axialID < a_nPixAxl &&
790 transID >= 0 && transID < a_nPixTrs )
792 castorID = axialID*a_nPixTrs + transID;
796 castorID = a_nPixAxl*a_nPixTrs;
833 uint32_t nModulesTransaxial,
834 uint32_t nModulesAxial,
835 uint32_t nSubmodulesTransaxial,
836 uint32_t nSubmodulesAxial,
837 uint32_t nCrystalsTransaxial,
838 uint32_t nCrystalsAxial,
840 uint32_t* nCrystalPerLayer,
841 vector<uint32_t> nLayersRptTransaxial,
842 vector<uint32_t> nLayersRptAxial,
850 uint32_t castorID = 0;
853 if(nLayersRptTransaxial.size()==0 && nLayersRptAxial.size()==0)
861 for(
int l=0 ; l<layer; l++)
862 castorID += nCrystalPerLayer[l];
864 int32_t nTrsCrystalsPerSubmodule = nCrystalsTransaxial;
865 int32_t nTrsCrystalsPerModule = nTrsCrystalsPerSubmodule * nSubmodulesTransaxial;
866 int32_t nTrsCrystalsPerRsector = nTrsCrystalsPerModule * nModulesTransaxial;
867 int32_t nCrystalsPerRing = nTrsCrystalsPerRsector * nRsectorsPerRing;
869 int32_t ringID = (int32_t)(moduleID/nModulesTransaxial) * nSubmodulesAxial * nCrystalsAxial
870 + (int32_t)(submoduleID/nSubmodulesTransaxial) * nCrystalsAxial
871 + (int32_t)(crystalID/nCrystalsTransaxial);
873 castorID += nCrystalsPerRing * ringID
874 + nTrsCrystalsPerRsector * rsectorID
875 + nTrsCrystalsPerModule * ( moduleID % nModulesTransaxial )
876 + nTrsCrystalsPerSubmodule * ( submoduleID % nSubmodulesTransaxial )
877 + crystalID % nCrystalsTransaxial;
885 uint32_t sum_crystals = nLayersRptTransaxial[layer]
886 * nLayersRptAxial[layer];
889 while (layerID >= (int32_t)sum_crystals)
892 sum_crystals += nLayersRptTransaxial[layer]
893 * nLayersRptAxial[layer];
898 for(
int l=0 ; l<layer ; l++)
899 castorID += nCrystalPerLayer[l];
901 int32_t nTrsCrystalsPerSubmodule = nCrystalsTransaxial * nLayersRptTransaxial[layer];
902 int32_t nTrsCrystalsPerModule = nTrsCrystalsPerSubmodule * nSubmodulesTransaxial;
903 int32_t nTrsCrystalsPerRsector = nTrsCrystalsPerModule * nModulesTransaxial;
904 int32_t nCrystalsPerRing = nTrsCrystalsPerRsector * nRsectorsPerRing;
906 int32_t ringID = (int32_t)(moduleID/nModulesTransaxial) * nSubmodulesAxial * nCrystalsAxial * nLayersRptAxial[layer]
907 + (int32_t)(submoduleID/nSubmodulesTransaxial) * nCrystalsAxial * nLayersRptAxial[layer]
908 + (int32_t)(crystalID/nCrystalsTransaxial) * nLayersRptAxial[layer];
910 if(nLayersRptTransaxial.empty() || nLayersRptAxial.empty() )
911 ringID += (int32_t)(layerID/nLayersRptTransaxial[layer]);
913 castorID += nCrystalsPerRing * ringID
914 + nTrsCrystalsPerRsector * rsectorID
915 + nTrsCrystalsPerModule * ( moduleID % nModulesTransaxial )
916 + nTrsCrystalsPerSubmodule * ( submoduleID % nSubmodulesTransaxial )
917 + crystalID % nCrystalsTransaxial
918 + layerID % nLayersRptTransaxial[layer];
944 int comptonPhantom1,
int comptonPhantom2,
945 int rayleighPhantom1,
int rayleighPhantom2)
947 if (eventID1 != eventID2)
952 if (comptonPhantom1 == 0 && comptonPhantom2 == 0 &&
953 rayleighPhantom1 == 0 && rayleighPhantom2 == 0)
958 if (comptonPhantom1 == 1 || comptonPhantom2 == 1 ||
959 rayleighPhantom1 == 1 || rayleighPhantom2 == 1)
962 if (comptonPhantom1 > 1 || comptonPhantom2 > 1 ||
963 rayleighPhantom1 > 1 || rayleighPhantom2 > 1)
999 uint32_t *nb_crystal_per_layer,
1000 uint32_t &nCrystalsTot,
1001 uint32_t &nCrystalsAxial,
1002 uint32_t &nCrystalsTransaxial,
1003 vector<uint32_t> &nLayersRptAxial,
1004 vector<uint32_t> &nLayersRptTransaxial,
1005 uint32_t &nSubmodulesAxial,
1006 uint32_t &nSubmodulesTransaxial,
1007 uint32_t &nModulesAxial,
1008 uint32_t &nModulesTransaxial,
1009 uint32_t &nRsectorsPerRing,
1010 uint32_t &start_time_ms,
1011 uint32_t &duration_ms,
1014 vector<string> path_mac_files;
1015 path_mac_files.push_back(a_pathMac);
1020 Cerr(
"***** GetGATESystemType() -> Error occured when trying to recover paths to GATE macro files !" << endl);
1024 string rsector_name =
"";
1025 string module_name =
"";
1026 string submodule_name =
"";
1027 string crystal_name =
"";
1028 string mod_rptr_type =
"cubicArray";
1029 string smod_rptr_type =
"cubicArray";
1030 string cry_rptr_type =
"cubicArray";
1031 string lay_rptr_type =
"cubicArray";
1033 vector <string> layers_name;
1034 bool is_rsector_Y_axis =
false;
1037 if(
GetGATEAliasesCylindrical(path_mac_files, rsector_name, module_name, submodule_name, crystal_name, layers_name, vb) )
1039 Cerr(
"***** GetGATESystemType() -> Error occured when trying to recover aliases for the elements of the cylindricalPET !" << endl);
1044 nLayers = layers_name.size();
1047 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
1049 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
1052 double time_start =-1.,
1056 while(getline(mac_file, line))
1058 vector <string> values;
1064 kword =
"/gate/"+rsector_name+
"/placement/setTranslation";
1068 if (values.size()>0)
1070 FLTNB rsector_pos_X =0.,
1076 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
1081 if(rsector_pos_Y!=0) is_rsector_Y_axis =
true;
1085 kword =
"/gate/"+rsector_name+
"/ring/setRepeatNumber";
1087 if (values.size()>0)
1091 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1100 kword = is_rsector_Y_axis ?
1101 "/gate/"+module_name+
"/cubicArray/setRepeatNumberX":
1102 "/gate/"+module_name+
"/cubicArray/setRepeatNumberY";
1105 if (values.size()>0)
1109 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1114 kword =
"/gate/"+module_name+
"/cubicArray/setRepeatNumberZ";
1116 if (values.size()>0)
1120 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1126 kword =
"/gate/"+module_name+
"/linear/setRepeatNumber";
1128 if (values.size()>0)
1132 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1140 kword = is_rsector_Y_axis ?
1141 "/gate/"+submodule_name+
"/cubicArray/setRepeatNumberX":
1142 "/gate/"+submodule_name+
"/cubicArray/setRepeatNumberY";
1145 if (values.size()>0)
1149 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1154 kword =
"/gate/"+submodule_name+
"/cubicArray/setRepeatNumberZ";
1156 if (values.size()>0)
1160 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1166 kword =
"/gate/"+submodule_name+
"/linear/setRepeatNumber";
1168 if (values.size()>0)
1172 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1181 kword = is_rsector_Y_axis ?
1182 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberX":
1183 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
1185 kword =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
1187 if (values.size()>0)
1191 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1196 kword =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberZ";
1198 if (values.size()>0)
1202 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1209 kword =
"/gate/"+crystal_name+
"/linear/setRepeatNumber";
1211 if (values.size()>0)
1215 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1224 for(
int l=0 ; l<nLayers ; l++)
1226 kword = is_rsector_Y_axis ?
1227 "/gate/"+layers_name[l]+
"/cubicArray/setRepeatNumberX":
1228 "/gate/"+layers_name[l]+
"/cubicArray/setRepeatNumberY";
1231 if (values.size()>0)
1236 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1239 nLayersRptTransaxial.push_back(val);
1242 kword =
"/gate/"+layers_name[l]+
"/cubicArray/setRepeatNumberZ";
1244 if (values.size()>0)
1249 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1252 nLayersRptAxial.push_back(val);
1256 kword =
"/gate/"+layers_name[l]+
"/linear/setRepeatNumber";
1258 if (values.size()>0)
1263 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1266 nLayersRptAxial.push_back(val);
1273 kword =
"/gate/application/setTimeStart";
1275 if (values.size()>0)
1279 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1284 if (values.size()>1)
1286 if(values[1] ==
"s") time_start *= 1000;
1289 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1291 start_time_ms = time_start;
1294 kword =
"/gate/application/setTimeStop";
1296 if (values.size()>0)
1300 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1305 if (values.size()>1)
1307 if(values[1] ==
"s") time_stop *= 1000;
1310 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1313 kword =
"/gate/application/addSlice";
1315 if (values.size()>0)
1317 double time_slice_tmp=0;
1321 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1326 if (values.size()>1)
1328 if(values[1] ==
"s") time_slice_tmp *= 1000;
1331 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1333 time_slices += time_slice_tmp;
1338 duration_ms = (time_slices>0) ?
1339 (uint32_t)(time_slices-time_start) :
1342 duration_ms = (time_start>=0 && time_stop>=0) ?
1343 (uint32_t)(time_stop-time_start) :
1352 nCrystalsTot = nRsectorsPerRing
1353 * nModulesTransaxial * nModulesAxial
1354 * nSubmodulesTransaxial * nSubmodulesAxial
1355 * nCrystalsTransaxial * nCrystalsAxial;
1358 for(
int l=0 ; l<nLayers ; l++)
1360 uint32_t nb_crystals_layer = nRsectorsPerRing
1361 * nModulesTransaxial * nModulesAxial
1362 * nSubmodulesTransaxial * nSubmodulesAxial
1363 * nCrystalsTransaxial * nCrystalsAxial;
1366 if(nLayersRptTransaxial.size()>0 || nLayersRptAxial.size()>0 )
1367 nb_crystals_layer *= nLayersRptTransaxial[l] * nLayersRptAxial[l];
1369 nb_crystal_per_layer[l] = nb_crystals_layer;
1371 nCrystalsTot += nb_crystals_layer;
1378 Cout(
"-----------------------------------------------------------" << endl);
1379 Cout(
"ReadMacCylindrical()-> Information recovered from mac file:" << endl);
1380 Cout(
"-----------------------------------------------------------" << endl);
1381 Cout(
"Number of rsectors: " << nRsectorsPerRing << endl);
1382 Cout(
"Number of axial modules: " << nModulesAxial << endl);
1383 Cout(
"Number of transaxial modules: " << nModulesTransaxial << endl);
1384 Cout(
"Number of axial submodules: " << nSubmodulesAxial << endl);
1385 Cout(
"Number of transaxial submodules: " << nSubmodulesTransaxial << endl);
1386 Cout(
"Number of axial crystals: " << nCrystalsAxial << endl);
1387 Cout(
"Number of transaxial crystals: " << nCrystalsTransaxial << endl);
1388 Cout(
"Number of layers: " << nLayers << endl);
1389 for(
int l=0 ; l<nLayers ; l++)
1390 Cout(
"Layer "<< l <<
" : Number of crystals: " << nb_crystal_per_layer << endl);
1391 Cout(
"Total number of crystals (including layers): " << nCrystalsTot << endl);
1392 Cout(
"Acquisition start time (ms): " << start_time_ms << endl);
1393 Cout(
"Acquisition duration (ms): " << duration_ms << endl);
1394 Cout(
"-----------------------------------------------------------" << endl << endl);
1420 uint32_t &nCrystalsTot,
1421 uint32_t &nCrystalsAxial,
1422 uint32_t &nCrystalsTransaxial,
1423 uint32_t &nBlocksLine,
1424 uint32_t &nBlocksPerRing,
1425 uint32_t &start_time_ms,
1426 uint32_t &duration_ms,
1430 vector<string> path_mac_files;
1431 path_mac_files.push_back(a_pathMac);
1434 Cerr(
"***** GetGATESystemType() -> Error occured when trying to recover paths to GATE macro files !" << endl);
1438 string block_name =
"block";
1439 string crystal_name =
"crystal";
1440 bool is_block_Y_axis =
false;
1445 Cerr(
"***** GetGATESystemType() -> Error occured when trying to recover aliases for the elements of the ecat !" << endl);
1451 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
1453 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
1456 double time_start=-1.,
1460 while(getline(mac_file, line))
1462 vector <string> values;
1465 kword =
"/gate/"+block_name+
"/placement/setTranslation";
1467 if (values.size()>0)
1469 FLTNB block_pos_X=0.,
1475 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
1480 if(block_pos_Y!=0) is_block_Y_axis =
true;
1483 kword =
"/gate/"+block_name+
"/ring/setRepeatNumber";
1485 if (values.size()>0)
1489 Cerr(
"***** dataConversionUtilities::readMacECAT()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1494 kword =
"/gate/"+block_name+
"/linear/setRepeatNumber";
1496 if (values.size()>0)
1500 Cerr(
"***** dataConversionUtilities::readMacECAT()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1505 kword = is_block_Y_axis ?
1506 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberX":
1507 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
1510 if (values.size()>0)
1514 Cerr(
"***** dataConversionUtilities::readMacECAT()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1519 kword =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberZ";
1521 if (values.size()>0)
1525 Cerr(
"***** dataConversionUtilities::readMacECAT()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1531 kword =
"/gate/application/setTimeStart";
1533 if (values.size()>0)
1537 Cerr(
"***** dataConversionUtilities::readMacECAT()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1542 if (values.size()>1)
1544 if(values[1] ==
"s") time_start *= 1000;
1547 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1549 start_time_ms = time_start;
1552 kword =
"/gate/application/setTimeStop";
1554 if (values.size()>0)
1558 Cerr(
"***** dataConversionUtilities::readMacECAT()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1563 if (values.size()>1)
1565 if(values[1] ==
"s") time_stop *= 1000;
1568 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1571 kword =
"/gate/application/addSlice";
1573 if (values.size()>0)
1575 double time_slice_tmp=0;
1579 Cerr(
"***** dataConversionUtilities::readMacECAT()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1584 if (values.size()>1)
1586 if(values[1] ==
"s") time_slice_tmp *= 1000;
1589 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1591 time_slices = time_slice_tmp;
1596 duration_ms = (time_slices>0) ?
1597 (uint32_t)(time_slices-time_start) :
1600 duration_ms = (time_start>=0 && time_stop>=0) ?
1601 (uint32_t)(time_stop-time_start) :
1608 nCrystalsTot = nCrystalsTransaxial * nCrystalsAxial
1609 * nBlocksLine * nBlocksPerRing;
1615 Cout(
"-----------------------------------------------------" << endl);
1616 Cout(
"ReadMacECAT()-> Information recovered from mac file:" << endl);
1617 Cout(
"-----------------------------------------------------" << endl);
1618 Cout(
"Number of blocks per ring: " << nBlocksPerRing << endl);
1619 Cout(
"Number of axial blocks: " << nBlocksLine << endl);
1620 Cout(
"Number of axial crystals: " << nCrystalsAxial << endl);
1621 Cout(
"Number of transaxial crystals: " << nCrystalsTransaxial << endl);
1622 Cout(
"Total number of crystals: " << nCrystalsTot << endl);
1623 Cout(
"Acquisition start time (ms): " << start_time_ms << endl);
1624 Cout(
"Acquisition duration (ms): " << duration_ms << endl);
1625 Cout(
"-----------------------------------------------------" << endl << endl);
1657 float_t &a_distToDetector,
1659 uint32_t &a_nPixAxl,
1660 uint32_t &a_nPixTrs,
1661 float_t &a_crystalSizeAxl,
1662 float_t &a_crystalSizeTrs,
1663 uint32_t &a_nProjectionsTot,
1664 uint32_t &a_nProjectionsByHead,
1665 float_t &a_head1stAngle,
1666 float_t &a_headAngPitch,
1667 float_t &a_headAngStepDeg,
1668 int &a_headRotDirection,
1669 uint32_t &a_start_time_ms,
1670 uint32_t &a_duration_ms,
1674 vector<string> path_mac_files;
1675 path_mac_files.push_back(a_pathMac);
1679 Cerr(
"***** GetGATESystemType() -> Error occured when trying to recover paths to GATE macro files !" << endl);
1683 string head_name =
"SPECThead";
1684 string crystal_name =
"crystal";
1685 string pixel_name =
"pixel";
1686 string head_orbit_name =
"";
1687 bool is_head_Y_axis =
false;
1692 Cerr(
"***** GetGATESystemType() -> Error occured when trying to recover aliases for the elements of the ecat !" << endl);
1697 double time_start=-1.,
1702 head_rot_speed =-1.;
1705 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
1707 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
1711 while(getline(mac_file, line))
1713 vector <string> values;
1715 kword =
"/gate/"+head_name+
"/placement/setTranslation";
1717 if (values.size()>0)
1719 FLTNB head_pos_X=0.,
1725 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occured while trying to parse line: " << line<< endl);
1730 if(head_pos_Y!=0) is_head_Y_axis =
true;
1732 a_distToDetector = is_head_Y_axis ? abs(head_pos_Y) : abs(head_pos_X) ;
1737 kword =
"/gate/"+head_name+
"/ring/setRepeatNumber";
1739 if (values.size()>0)
1743 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occured while trying to parse line: " << line<< endl);
1748 kword =
"/gate/"+head_name+
"/ring/setFirstAngle";
1750 if (values.size()>0)
1754 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occured while trying to parse line: " << line<< endl);
1759 kword =
"/gate/"+head_name+
"/ring/setAngularPitch";
1761 if (values.size()>0)
1765 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occured while trying to parse line: " << line<< endl);
1770 kword =
"/gate/"+head_name+
"/moves/insert";
1772 if (values.size()>0)
1776 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occured while trying to parse line: " << line<< endl);
1781 kword =
"/gate/"+head_name+
"/"+head_orbit_name+
"/setSpeed";
1783 if (values.size()>0)
1787 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occured while trying to parse line: " << line<< endl);
1792 kword =
"/gate/"+head_name+
"/"+head_orbit_name+
"/setPoint2";
1794 if (values.size()>0)
1799 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occured while trying to parse line: " << line<< endl);
1807 kword = is_head_Y_axis ?
1808 "/gate/"+crystal_name+
"/geometry/setXLength":
1809 "/gate/"+crystal_name+
"/geometry/setYLength";
1812 if (values.size()>0)
1816 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
1822 kword =
"/gate/"+crystal_name+
"/geometry/setZLength";
1824 if (values.size()>0)
1828 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
1835 kword = is_head_Y_axis ?
1836 "/gate/"+pixel_name+
"/cubicArray/setRepeatNumberX":
1837 "/gate/"+pixel_name+
"/cubicArray/setRepeatNumberY";
1841 if (values.size()>0)
1845 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
1850 kword =
"/gate/"+pixel_name+
"/cubicArray/setRepeatNumberZ";
1852 if (values.size()>0)
1856 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
1861 kword =
"/gate/application/setTimeStart";
1863 if (values.size()>0)
1867 Cerr(
"***** dataConversionUtilities::readMacECAT()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1872 if (values.size()>1)
1874 if(values[1] ==
"s") time_start *= 1000;
1877 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1879 a_start_time_ms = time_start;
1882 kword =
"/gate/application/setTimeSlice";
1884 if (values.size()>0)
1888 Cerr(
"***** dataConversionUtilities::readMacECAT()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1893 if (values.size()>1)
1895 if(values[1] ==
"s") time_slice *= 1000;
1898 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1900 time_slice_ms = time_slice;
1903 kword =
"/gate/application/setTimeStop";
1905 if (values.size()>0)
1909 Cerr(
"***** dataConversionUtilities::readMacECAT()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1914 if (values.size()>1)
1916 if(values[1] ==
"s") time_stop *= 1000;
1919 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1922 kword =
"/gate/application/addSlice";
1924 if (values.size()>0)
1926 double time_slice_tmp=0;
1930 Cerr(
"***** dataConversionUtilities::readMacECAT()-> Error occured while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1935 if (values.size()>1)
1937 if(values[1] ==
"s") time_slice_tmp *= 1000;
1940 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1942 time_slices = time_slice_tmp;
1949 a_duration_ms = (time_slices>0) ?
1950 (uint32_t)(time_slices-time_start) :
1954 a_duration_ms = (time_start>=0 && time_stop>=0) ?
1955 (uint32_t)(time_stop-time_start) :
1960 a_nProjectionsByHead = a_duration_ms / time_slice_ms;
1961 a_nProjectionsTot = a_nHeads*a_nProjectionsByHead;
1964 a_headAngPitch = (a_headAngPitch<0) ?
1968 a_headAngStepDeg = head_rot_speed*time_slice_ms/1000.;
1970 if(head_rot_speed<0)
1972 Cerr(
"***** GetGATESystemType() -> Error couldn't find line '/gate/"+head_name+
"/"+head_orbit_name+
"/setSpeed' !" << endl);
1973 Cerr(
" This information is mandatory to compute the projection angle step." << endl);
1979 Cerr(
"***** GetGATESystemType() -> Error couldn't find line '/gate/application/setTimeSlice' !" << endl);
1980 Cerr(
" This information is mandatory to compute the projection angle step." << endl);
1984 if(a_duration_ms == 0)
1988 Cerr(
"***** GetGATESystemType() -> Error couldn't compute acquisition find line '/gate/application/setTimeStop' !" << endl);
1989 Cerr(
" This information is mandatory to compute the acquisition duration." << endl);
1994 Cerr(
"***** GetGATESystemType() -> Error couldn't compute acquisition find line '/gate/application/setTimeStart' !" << endl);
1995 Cerr(
" This information is mandatory to compute the acquisition duration." << endl);
2006 Cout(
"-----------------------------------------------------" << endl);
2007 Cout(
"ReadMacSPECT()-> Information recovered from mac file:" << endl);
2008 Cout(
"-----------------------------------------------------" << endl);
2009 Cout(
"Distance to detector: " << a_distToDetector << endl);
2010 Cout(
"Number of heads: " << a_nHeads << endl);
2011 Cout(
"Number of axial pixels: " << a_nPixAxl << endl);
2012 Cout(
"Number of transaxial pixels: " << a_nPixTrs << endl);
2013 Cout(
"Crystal axial size: " << a_crystalSizeAxl << endl);
2014 Cout(
"Crystal transaxial size: " << a_crystalSizeTrs << endl);
2015 Cout(
"Number of projections per head: " << a_nProjectionsByHead << endl);
2016 Cout(
"Total number of projections: " << a_nProjectionsTot << endl);
2017 Cout(
"Head(s) first transaxial angle: " << a_head1stAngle << endl);
2018 Cout(
"Head(s) angular pitch: " << a_headAngPitch << endl);
2019 Cout(
"Angular step between projections (deg): " << a_headAngStepDeg << endl);
2020 Cout(
"Rotation direction (0=CW, 1=CCW): " << a_headRotDirection << endl);
2021 Cout(
"Acquisition start time (ms): " << a_start_time_ms << endl);
2022 Cout(
"Acquisition duration (ms): " << a_duration_ms << endl);
2023 Cout(
"-----------------------------------------------------" << endl << endl);
2056 float_t &a_distToDetector,
2058 uint32_t &a_nPixAxl,
2059 uint32_t &a_nPixTrs,
2060 float_t &a_crystalSizeAxl,
2061 float_t &a_crystalSizeTrs,
2062 uint32_t &a_nProjectionsTot,
2063 uint32_t &a_nProjectionsByHead,
2064 float_t &a_head1stAngle,
2065 float_t &a_headAngPitchDeg,
2066 float_t &a_headAngStepDeg,
2067 int &a_headRotDirection,
2068 uint32_t &a_start_time_ms,
2069 uint32_t &a_duration_ms,
2076 key =
"matrix size [1]";
2079 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2080 Cerr(
" Either key not found or conversion error" << endl);
2084 key =
"matrix size [2]";
2087 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2088 Cerr(
" Either key not found or conversion error" << endl);
2092 FLTNB size_pix_trs = 1.,
2095 key =
"scaling factor (mm/pixel) [1]";
2098 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2099 Cerr(
" Either key not found or conversion error" << endl);
2103 key =
"scaling factor (mm/pixel) [2]";
2106 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2107 Cerr(
" Either key not found or conversion error" << endl);
2111 key =
"total number of images";
2114 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2115 Cerr(
" Either key not found or conversion error" << endl);
2119 key =
"number of projections";
2122 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2123 Cerr(
" Either key not found or conversion error" << endl);
2127 key =
"number of detector heads";
2130 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2131 Cerr(
" Either key not found or conversion error" << endl);
2135 key =
"study duration (sec)";
2138 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2139 Cerr(
" Either key not found or conversion error" << endl);
2143 a_duration_ms *= 1000;
2146 FLTNB size_crystal_X =0.,
2149 key =
"crystal x dimension (cm)";
2152 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2153 Cerr(
" Either key not found or conversion error" << endl);
2157 key =
"crystal y dimension (cm)";
2160 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2161 Cerr(
" Either key not found or conversion error" << endl);
2165 key =
"crystal z dimension (cm)";
2168 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2169 Cerr(
" Either key not found or conversion error" << endl);
2175 if(size_crystal_X>0 && size_crystal_Y>0)
2176 a_crystalSizeTrs = (size_crystal_X>size_crystal_Y) ? size_crystal_X*10. : size_crystal_Y*10.;
2177 a_crystalSizeAxl = (a_crystalSizeAxl>0) ? a_crystalSizeAxl*10. : a_crystalSizeAxl ;
2180 FLTNB head_pos_X =-1.,
2184 key =
"head x translation (cm)";
2187 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2188 Cerr(
" Either key not found or conversion error" << endl);
2192 key =
"head y translation (cm)";
2195 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2196 Cerr(
" Either key not found or conversion error" << endl);
2200 key =
"head z translation (cm)";
2203 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2204 Cerr(
" Either key not found or conversion error" << endl);
2209 if(head_pos_X > head_pos_Y)
2210 a_distToDetector = head_pos_X > head_pos_Z ? head_pos_X*10 : head_pos_Z*10;
2212 a_distToDetector = head_pos_Y > head_pos_Z ? head_pos_Y*10 : head_pos_Z*10;
2215 key =
"direction of rotation";
2219 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2220 Cerr(
" Either key not found or conversion error" << endl);
2228 key =
"start angle";
2231 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2232 Cerr(
" Either key not found or conversion error" << endl);
2236 key =
"extent of rotation";
2237 uint32_t extent_rotation =360;
2240 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2241 Cerr(
" Either key not found or conversion error" << endl);
2245 a_headAngStepDeg = (
FLTNB)extent_rotation / a_nProjectionsByHead;
2247 float_t first_angle = 0;
2248 float_t second_angle = extent_rotation;
2250 key =
"start angle";
2253 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2254 Cerr(
" Either key not found or conversion error" << endl);
2258 key =
"start angle";
2261 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2262 Cerr(
" Either key not found or conversion error" << endl);
2266 a_headAngPitchDeg = second_angle - first_angle;
2291 string scanner_name =
GetFileFromPath(a_pathGeom.substr(0,a_pathGeom.find(
".geom")));
2292 double scanner_radius = 0.;
2293 uint32_t number_of_elements = 0;
2294 string description =
"PET system extracted from GATE macro: " + a_pathMac;
2297 string rsector_name =
"";
2298 uint32_t number_of_rsectors = 1;
2299 double rsector_first_angle = 0.;
2300 double rsector_angular_span = 360.;
2301 double rsector_pos_X = 0.;
2302 double rsector_pos_Y = 0.;
2303 uint32_t rsector_nb_zshifts = 0;
2304 vector <double> vec_rsector_Z_Shift;
2305 bool is_rsector_Y_axis =
false;
2308 string module_name =
"";
2309 uint32_t number_of_modules_trans = 1;
2310 uint32_t number_of_modules_axial = 1;
2311 double module_step_trans = 0.;
2312 double module_step_axial = 0.;
2313 double module_size_Y;
2314 double module_size_Z;
2317 string submodule_name =
"";
2318 uint32_t number_of_submodules_trans = 1;
2319 uint32_t number_of_submodules_axial = 1;
2320 double submodule_step_trans = 0.;
2321 double submodule_step_axial = 0.;
2322 double submodule_size_Y;
2323 double submodule_size_Z;
2326 string crystal_name =
"";
2327 uint32_t number_of_crystals_trans = 1;
2328 uint32_t number_of_crystals_axial = 1;
2329 double crystal_step_trans = 0.;
2330 double crystal_step_axial = 0.;
2331 double crystal_size_depth = 0.;
2332 double crystal_size_trans = 0.;
2333 double crystal_size_axial = 0.;
2337 int number_of_layers = 0;
2338 string n_layers =
"1";
2339 vector <uint32_t> number_of_lyr_elts_trans;
2340 vector <uint32_t> number_of_lyr_elts_axial;
2342 vector <string> layers_names;
2343 vector <vector <double> > layers_positions;
2344 vector <double> layers_size_depth;
2345 vector <double> layers_size_trans;
2346 vector <double> layers_size_axial;
2348 vector <double> layers_step_trans;
2349 vector <double> layers_step_axial;
2352 uint32_t voxels_number_trans;
2353 uint32_t voxels_number_axial;
2356 double mean_depth_of_interaction = -1.;
2357 double min_angle_diff = 0.;
2364 vector <string> vec_scanner_radius;
2367 vector <string> vec_number_of_rsectors;
2368 vector <string> vec_rsector_first_angle;
2372 vector <string> vec_number_of_modules_trans;
2373 vector <string> vec_number_of_modules_axial;
2374 vector <string> vec_module_gap_trans;
2375 vector <string> vec_module_gap_axial;
2378 vector <string> vec_number_of_submodules_trans;
2379 vector <string> vec_number_of_submodules_axial;
2380 vector <string> vec_submodule_gap_trans;
2381 vector <string> vec_submodule_gap_axial;
2384 vector <string> vec_number_of_crystals_trans;
2385 vector <string> vec_number_of_crystals_axial;
2386 vector <string> vec_crystal_gap_trans;
2387 vector <string> vec_crystal_gap_axial;
2390 vector <string> vec_mean_depth_of_interaction;
2391 vector <string> vec_min_angle_diff;
2393 vector<string> path_mac_files;
2394 path_mac_files.push_back(a_pathMac);
2399 Cerr(
"***** GetGATESystemType() -> Error occured when trying to recover paths to GATE macro files !" << endl);
2404 if(
GetGATEAliasesCylindrical(path_mac_files, rsector_name, module_name, submodule_name, crystal_name, layers_names, 2) )
2406 Cerr(
"***** GetGATESystemType() -> Error occured when trying to recover aliases for the elements of the cylindricalPET !" << endl);
2411 n_layers = layers_names.size();
2415 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
2417 ifstream systemMac(path_mac_files[f].c_str(), ios::in);
2421 while(getline(systemMac, line))
2423 vector <string> values;
2430 entry =
"/gate/"+rsector_name+
"/placement/setTranslation";
2434 if (values.size()>0)
2439 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2445 if(rsector_pos_X!=0 && rsector_pos_Y !=0)
2447 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2448 Cerr(
" Rsector cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
2453 if(rsector_pos_Y!=0) is_rsector_Y_axis =
true;
2455 scanner_radius += is_rsector_Y_axis ? abs(rsector_pos_Y) : abs(rsector_pos_X) ;
2459 entry = is_rsector_Y_axis ?
2460 "/gate/"+rsector_name+
"/geometry/setYLength" :
2461 "/gate/"+rsector_name+
"/geometry/setXLength";
2464 if (values.size()>0)
2466 double rsector_size = 0.;
2469 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2473 scanner_radius -= rsector_size/2;
2477 entry =
"/gate/"+rsector_name+
"/geometry/setZLength";
2479 if (values.size()>0)
2483 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2488 voxels_number_axial = fov_axial/4 + 1;
2493 entry =
"/gate/"+rsector_name+
"/ring/setModuloNumber";
2495 if (values.size()>0)
2499 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2504 entry =
"/gate/"+rsector_name+
"/ring/setRepeatNumber";
2506 if (values.size()>0)
2510 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2515 entry =
"/gate/"+rsector_name+
"/ring/setFirstAngle";
2517 if (values.size()>0)
2521 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2526 entry =
"/gate/"+rsector_name+
"/ring/setAngularSpan";
2528 if (values.size()>0)
2532 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2538 for (
int i=1; i <8; i++)
2540 entry =
"/gate/"+rsector_name+
"/ring/setZShift"+
toString(i);
2542 if (values.size()>0)
2547 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2551 vec_rsector_Z_Shift.push_back(zshift);
2559 entry = is_rsector_Y_axis ?
2560 "/gate/"+module_name+
"/cubicArray/setRepeatNumberX":
2561 "/gate/"+module_name+
"/cubicArray/setRepeatNumberY";
2564 if (values.size()>0)
2568 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2576 entry =
"/gate/"+module_name+
"/cubicArray/setRepeatNumberZ";
2579 if (values.size()>0)
2583 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2589 entry = is_rsector_Y_axis ?
2590 "/gate/"+module_name+
"/geometry/setXLength":
2591 "/gate/"+module_name+
"/geometry/setYLength";
2594 if (values.size()>0)
2598 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2604 entry =
"/gate/"+module_name+
"/geometry/setZLength";
2606 if (values.size()>0)
2610 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2615 entry =
"/gate/"+module_name+
"/cubicArray/setRepeatVector";
2617 if (values.size()>0)
2619 string trs_step = is_rsector_Y_axis ?
2626 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2635 entry =
"/gate/"+module_name+
"/linear/setRepeatNumber";
2638 if (values.size()>0)
2642 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2647 entry =
"/gate/"+module_name+
"/linear/setRepeatVector";
2649 if (values.size()>0)
2653 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2660 entry = is_rsector_Y_axis ?
2661 "/gate/"+submodule_name+
"/cubicArray/setRepeatNumberX":
2662 "/gate/"+submodule_name+
"/cubicArray/setRepeatNumberY";
2666 if (values.size()>0)
2670 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2675 entry =
"/gate/"+submodule_name+
"/cubicArray/setRepeatNumberZ";
2677 if (values.size()>0)
2681 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2689 entry = is_rsector_Y_axis ?
2690 "/gate/"+submodule_name+
"/geometry/setXLength":
2691 "/gate/"+submodule_name+
"/geometry/setYLength";
2694 if (values.size()>0)
2698 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2703 entry =
"/gate/"+submodule_name+
"/geometry/setZLength";
2705 if (values.size()>0)
2709 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2714 entry =
"/gate/"+submodule_name+
"/cubicArray/setRepeatVector";
2716 if (values.size()>0)
2718 string trs_step = is_rsector_Y_axis ?
2725 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2733 entry =
"/gate/"+submodule_name+
"/linear/setRepeatNumber";
2736 if (values.size()>0)
2740 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2746 entry =
"/gate/"+submodule_name+
"/linear/setRepeatVector";
2748 if (values.size()>0)
2752 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2762 entry = is_rsector_Y_axis ?
2763 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberX":
2764 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
2768 if (values.size()>0)
2772 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2777 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberZ";
2779 if (values.size()>0)
2783 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2789 entry =
"/gate/"+crystal_name+
"/geometry/setXLength";
2791 if (values.size()>0)
2796 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2800 if (is_rsector_Y_axis)
2801 crystal_size_trans = x_length;
2803 crystal_size_depth = x_length;
2806 entry =
"/gate/"+crystal_name+
"/geometry/setYLength";
2808 if (values.size()>0)
2813 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2817 if (is_rsector_Y_axis)
2818 crystal_size_depth = y_length;
2820 crystal_size_trans = y_length;
2824 entry =
"/gate/"+crystal_name+
"/geometry/setZLength";
2826 if (values.size()>0)
2830 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2835 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatVector";
2837 if (values.size()>0)
2839 string trs_step = is_rsector_Y_axis ?
2846 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2852 entry =
"/gate/"+crystal_name+
"/linear/setRepeatNumber";
2855 if (values.size()>0)
2859 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2864 entry =
"/gate/"+crystal_name+
"/linear/setRepeatVector";
2866 if (values.size()>0)
2870 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2879 entry =
"/gate/"+crystal_name+
"/daughters/name";
2881 if (values.size()>0)
2883 layers_names.push_back(values[0]);
2888 for (
int i=0; i < number_of_layers; i++)
2891 entry =
"/gate/"+layers_names[i]+
"/placement/setTranslation";
2894 if (values.size()>0)
2896 vector<double> layer_pos;
2897 for(
int d=0 ; d<3 ; d++)
2902 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2905 layer_pos.push_back(pos);
2908 if(is_rsector_Y_axis)
2910 double pos = layer_pos[1];
2911 layer_pos[1] = layer_pos[0];
2915 layers_positions.push_back(layer_pos);
2920 entry =
"/gate/"+layers_names[i]+
"/geometry/setXLength";
2923 if (values.size()>0)
2928 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2932 if (is_rsector_Y_axis)
2933 layers_size_trans.push_back(xlength);
2935 layers_size_depth.push_back(xlength);
2939 entry =
"/gate/"+layers_names[i]+
"/geometry/setYLength";
2941 if (values.size()>0)
2946 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2949 if (is_rsector_Y_axis)
2950 layers_size_depth.push_back(ylength);
2952 layers_size_trans.push_back(ylength);
2955 entry =
"/gate/"+layers_names[i]+
"/geometry/setZLength";
2957 if (values.size()>0)
2962 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2965 layers_size_axial.push_back(zlength);
2971 entry = is_rsector_Y_axis ?
2972 "/gate/"+layers_names[i]+
"/cubicArray/setRepeatNumberX":
2973 "/gate/"+layers_names[i]+
"/cubicArray/setRepeatNumberY";
2976 if (values.size()>0)
2981 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2984 number_of_lyr_elts_trans.push_back(step_trs);
2987 entry =
"/gate/"+layers_names[i]+
"/cubicArray/setRepeatNumberZ";
2989 if (values.size()>0)
2994 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
2997 number_of_lyr_elts_axial.push_back(step_axl);
3000 entry =
"/gate/"+layers_names[i]+
"/cubicArray/setRepeatVector";
3002 if (values.size()>0)
3004 string trs_step = is_rsector_Y_axis ?
3008 double step_trs, step_axl;
3012 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
3017 layers_step_trans.push_back(step_trs);
3018 layers_step_axial.push_back(step_axl);
3023 entry =
"/gate/"+layers_names[i]+
"/linear/setRepeatNumber";
3026 if (values.size()>0)
3031 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
3034 number_of_lyr_elts_axial.push_back(step_axl);
3038 entry =
"/gate/"+layers_names[i]+
"/linear/setRepeatVector";
3040 if (values.size()>0)
3045 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
3049 layers_step_axial.push_back(step_axl);
3055 entry =
"/gate/digitizer/Coincidences/minSectorDifference";
3057 if (values.size()>0)
3059 FLTNB min_sector_diff= 0.;
3063 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
3067 min_angle_diff = 360./number_of_rsectors*min_sector_diff;
3076 if(number_of_layers == 0)
3078 number_of_elements = number_of_rsectors
3079 * number_of_modules_trans
3080 * number_of_modules_axial
3081 * number_of_submodules_trans
3082 * number_of_submodules_axial
3083 * number_of_crystals_trans
3084 * number_of_crystals_axial;
3087 for(
int l=0 ; l<number_of_layers ; l++)
3089 int32_t nb_crystals_layer = number_of_rsectors
3090 * number_of_modules_trans
3091 * number_of_modules_axial
3092 * number_of_submodules_trans
3093 * number_of_submodules_axial
3094 * number_of_crystals_trans
3095 * number_of_crystals_axial;
3098 if(number_of_lyr_elts_trans.size()>0 || number_of_lyr_elts_axial.size()>0 )
3099 nb_crystals_layer *= number_of_lyr_elts_trans[l] * number_of_lyr_elts_axial[l];
3101 number_of_elements += nb_crystals_layer;
3106 fov_trans = scanner_radius/2;
3108 voxels_number_trans = fov_trans/2 + 1;
3112 if (module_step_axial - module_size_Z >= 0)
3113 module_step_axial = module_step_axial - module_size_Z;
3115 if (module_step_trans - module_size_Y >= 0)
3116 module_step_trans =module_step_trans - module_size_Y;
3118 if (submodule_step_axial - submodule_size_Z >= 0)
3119 submodule_step_axial = submodule_step_axial - submodule_size_Z;
3121 if (submodule_step_trans - submodule_size_Y >= 0)
3122 submodule_step_trans = submodule_step_trans - submodule_size_Y;
3124 if (crystal_step_axial - crystal_size_axial >= 0)
3125 crystal_step_axial = crystal_step_axial - crystal_size_axial;
3127 if (crystal_step_trans - crystal_size_trans >= 0)
3128 crystal_step_trans = crystal_step_trans - crystal_size_trans;
3133 rsector_first_angle -= round(atan2f(rsector_pos_X , rsector_pos_Y) * 180. / M_PI);
3136 if (number_of_layers > 0)
3138 for (
int l=0; l < number_of_layers ; l++)
3141 vec_scanner_radius.push_back(
toString(scanner_radius+layers_positions[l][0]) );
3144 vec_number_of_rsectors.push_back(
toString(number_of_rsectors) );
3145 vec_rsector_first_angle.push_back(
toString(rsector_first_angle) );
3148 vec_number_of_modules_trans.push_back(
toString(number_of_modules_trans) );
3149 vec_number_of_modules_axial.push_back(
toString(number_of_modules_axial) );
3150 vec_module_gap_trans.push_back(
toString(module_step_trans) );
3151 vec_module_gap_axial.push_back(
toString(module_step_axial) );
3154 vec_number_of_submodules_trans.push_back(
toString(number_of_submodules_trans) );
3155 vec_number_of_submodules_axial.push_back(
toString(number_of_submodules_axial) );
3156 vec_submodule_gap_trans.push_back(
toString(submodule_step_trans) );
3157 vec_submodule_gap_axial.push_back(
toString(submodule_step_axial) );
3160 uint32_t nb_tot_trs_cry = (number_of_lyr_elts_trans.size()>0) ?
3161 number_of_lyr_elts_trans[l]*number_of_crystals_trans :
3162 number_of_crystals_trans ;
3164 uint32_t nb_tot_axl_cry = (number_of_lyr_elts_axial.size()>0) ?
3165 number_of_lyr_elts_axial[l]*number_of_crystals_axial :
3166 number_of_crystals_axial ;
3168 vec_number_of_crystals_trans.push_back(
toString(nb_tot_trs_cry) );
3169 vec_number_of_crystals_axial.push_back(
toString(nb_tot_axl_cry) );
3173 if(layers_step_trans.size()>0 &&
3174 layers_step_trans.size()>0)
3176 if (layers_step_trans[l] - layers_size_trans[l] >= 0)
3177 crystal_step_trans = layers_step_trans[l] - layers_size_trans[l];
3179 if (layers_step_axial[l] - layers_size_axial[l] >= 0)
3180 crystal_step_axial = layers_step_axial[l] - layers_size_axial[l];
3184 crystal_step_trans = crystal_step_trans ;
3185 crystal_step_axial = crystal_step_axial ;
3188 vec_crystal_gap_trans.push_back(
toString(crystal_step_trans) );
3189 vec_crystal_gap_axial.push_back(
toString(crystal_step_axial) );
3192 vec_mean_depth_of_interaction.push_back(
toString(mean_depth_of_interaction) );
3193 vec_min_angle_diff.push_back(
toString(min_angle_diff) );
3199 layers_size_depth.push_back( crystal_size_depth );
3200 layers_size_trans.push_back( crystal_size_trans );
3201 layers_size_axial.push_back( crystal_size_axial );
3205 vec_scanner_radius.push_back(
toString(scanner_radius) );
3208 vec_number_of_rsectors.push_back(
toString(number_of_rsectors) );
3209 vec_rsector_first_angle.push_back(
toString(rsector_first_angle) );
3212 vec_number_of_modules_trans.push_back(
toString(number_of_modules_trans) );
3213 vec_number_of_modules_axial.push_back(
toString(number_of_modules_axial) );
3214 vec_module_gap_trans.push_back(
toString(module_step_trans) );
3215 vec_module_gap_axial.push_back(
toString(module_step_axial) );
3218 vec_number_of_submodules_trans.push_back(
toString(number_of_submodules_trans) );
3219 vec_number_of_submodules_axial.push_back(
toString(number_of_submodules_axial) );
3220 vec_submodule_gap_trans.push_back(
toString(submodule_step_trans) );
3221 vec_submodule_gap_axial.push_back(
toString(submodule_step_axial) );
3224 vec_number_of_crystals_trans.push_back(
toString(number_of_crystals_trans) );
3225 vec_number_of_crystals_axial.push_back(
toString(number_of_crystals_axial) );
3226 vec_crystal_gap_trans.push_back(
toString(crystal_step_trans) );
3227 vec_crystal_gap_axial.push_back(
toString(crystal_step_axial) );
3230 vec_mean_depth_of_interaction.push_back(
toString(mean_depth_of_interaction) );
3231 vec_min_angle_diff.push_back(
toString(min_angle_diff) );
3234 number_of_layers = 1;
3239 ofstream fileGeom(a_pathGeom.c_str(), ios::out | ios::trunc);
3242 fileGeom <<
"# comments" << endl;
3243 fileGeom <<
"# Y _________ "<< endl;
3244 fileGeom <<
"# | / _ \\ \\ "<< endl;
3245 fileGeom <<
"# | | / \\ | |"<< endl;
3246 fileGeom <<
"# |_____ Z | | | | |"<< endl;
3247 fileGeom <<
"# \\ | | | | |" << endl;
3248 fileGeom <<
"# \\ | \\_/ | |" << endl;
3249 fileGeom <<
"# X \\___/_____/" << endl;
3250 fileGeom <<
"# Left-handed axis orientation"<< endl;
3251 fileGeom <<
"# scanner axis is z" << endl;
3252 fileGeom <<
"# positions in millimeters"<< endl;
3253 fileGeom <<
"# Use comma without space as separator in the tables." << endl;
3255 fileGeom <<
""<< endl;
3258 fileGeom <<
"# MANDATORY FIELDS"<< endl;
3259 fileGeom <<
"modality : " << modality << endl;
3260 fileGeom <<
"scanner name : " << scanner_name << endl;
3261 fileGeom <<
"number of elements : " << number_of_elements << endl;
3262 fileGeom <<
"number of layers : " << number_of_layers << endl;
3263 fileGeom <<
"" << endl;
3264 fileGeom <<
"voxels number transaxial : " << voxels_number_trans << endl;
3265 fileGeom <<
"voxels number axial : " << voxels_number_axial << endl;
3267 fileGeom <<
"field of view transaxial : " << fov_trans << endl;
3268 fileGeom <<
"field of view axial : " << fov_axial << endl << endl;
3269 fileGeom <<
"description : " << description << endl;
3270 fileGeom <<
"" << endl;
3271 WriteVector(fileGeom,
"scanner radius : ",vec_scanner_radius);
3272 WriteVector(fileGeom,
"number of rsectors : ",vec_number_of_rsectors);
3273 WriteVector(fileGeom,
"number of crystals transaxial : ",vec_number_of_crystals_trans);
3274 WriteVector(fileGeom,
"number of crystals axial : ",vec_number_of_crystals_axial);
3275 fileGeom <<
""<< endl;
3276 WriteVector(fileGeom,
"crystals size depth : ", layers_size_depth);
3277 WriteVector(fileGeom,
"crystals size transaxial : ", layers_size_trans);
3278 WriteVector(fileGeom,
"crystals size axial : ", layers_size_axial);
3279 fileGeom <<
""<< endl;
3280 fileGeom <<
""<< endl;
3283 fileGeom <<
"# OPTIONAL FIELDS"<< endl;
3284 WriteVector(fileGeom,
"rsectors first angle : ",vec_rsector_first_angle);
3285 WriteVector(fileGeom,
"number of modules transaxial : ",vec_number_of_modules_trans);
3286 WriteVector(fileGeom,
"number of modules axial : ",vec_number_of_modules_axial);
3287 WriteVector(fileGeom,
"module gap transaxial : ",vec_module_gap_trans);
3288 WriteVector(fileGeom,
"module gap axial : ",vec_module_gap_axial);
3289 WriteVector(fileGeom,
"number of submodules transaxial : ",vec_number_of_submodules_trans);
3290 WriteVector(fileGeom,
"number of submodules axial : ",vec_number_of_submodules_axial);
3291 WriteVector(fileGeom,
"submodule gap transaxial : ",vec_submodule_gap_trans);
3292 WriteVector(fileGeom,
"submodule gap axial : ",vec_submodule_gap_axial);
3293 WriteVector(fileGeom,
"crystal gap transaxial : ",vec_crystal_gap_trans);
3294 WriteVector(fileGeom,
"crystal gap axial : ",vec_crystal_gap_axial);
3295 WriteVector(fileGeom,
"mean depth of interaction : ", vec_mean_depth_of_interaction);
3296 fileGeom <<
"rotation direction : CCW " << endl;
3297 fileGeom <<
""<< endl;
3300 if(min_angle_diff > 0.) fileGeom <<
"min angle difference : " << min_angle_diff << endl;
3303 if(rsector_angular_span >= 360.0005 ||
3304 rsector_angular_span <= 359.9995 )
3306 rsector_angular_span *= (number_of_rsectors+1)/number_of_rsectors;
3307 fileGeom <<
"rsectors angular span : " << rsector_angular_span << endl;
3310 if(rsector_nb_zshifts > 0) fileGeom <<
"rsectors nbZShift :" << rsector_nb_zshifts << endl;
3311 if(!vec_rsector_Z_Shift.empty())
WriteVector(fileGeom,
"rsectors ZShift : ", vec_rsector_Z_Shift);
3315 cout <<
"Output geom file written at :" << a_pathGeom << endl;
3319 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Couldn't open geom file for writing "<< a_pathGeom <<
" !" << endl);
3347 string scanner_name =
GetFileFromPath(a_pathGeom.substr(0,a_pathGeom.find_first_of(
".geom")));
3348 double scanner_radius = 0.;
3349 uint32_t number_of_elements = 0;
3350 string description =
"ECAT system extracted from GATE macro: " + a_pathMac;
3353 string block_name =
"block";
3354 uint32_t number_of_blocks = 1;
3355 uint32_t number_of_blocks_trans = 1;
3356 uint32_t number_of_blocks_axial = 1;
3357 double block_step_trans = 0.;
3358 double block_step_axial = 0.;
3359 double block_size_Y;
3360 double block_size_Z;
3361 double block_pos_X = 0.;
3362 double block_pos_Y = 0.;
3363 double block_first_angle = 0.;
3364 double block_angular_span = 360.;
3365 uint32_t block_nb_zshifts = 0;
3366 vector <double> vec_block_Z_Shift;
3367 bool is_block_Y_axis =
false;
3372 string crystal_name =
"crystal";
3373 uint32_t number_of_crystals_trans = 1;
3374 uint32_t number_of_crystals_axial = 1;
3375 double crystal_step_trans = 0.;
3376 double crystal_step_axial = 0.;
3377 double crystal_size_depth = 0.;
3378 double crystal_size_trans = 0.;
3379 double crystal_size_axial = 0.;
3382 uint32_t voxels_number_trans;
3383 uint32_t voxels_number_axial;
3386 double min_angle_diff = 0.;
3388 vector<string> path_mac_files;
3389 path_mac_files.push_back(a_pathMac);
3394 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Error occured when trying to recover paths to GATE macro files !" << endl);
3402 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Error occured when trying to recover aliases for the elements of the ecat !" << endl);
3408 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
3410 ifstream systemMac(path_mac_files[f].c_str(), ios::in);
3413 while(getline(systemMac, line))
3417 vector <string> values;
3421 entry =
"/gate/"+block_name+
"/placement/setTranslation";
3423 if (values.size()>0)
3428 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3434 if(block_pos_X!=0 && block_pos_Y !=0)
3436 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3437 Cerr(
" Block cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
3442 if(block_pos_Y!=0) is_block_Y_axis =
true;
3444 scanner_radius += is_block_Y_axis ? abs(block_pos_Y) : abs(block_pos_X) ;
3449 entry = is_block_Y_axis ?
3450 "/gate/"+block_name+
"/geometry/setYLength" :
3451 "/gate/"+block_name+
"/geometry/setXLength";
3454 if (values.size()>0)
3456 double block_size = 0.;
3459 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
3463 scanner_radius -= block_size/2;
3468 entry =
"/gate/"+block_name+
"/geometry/setZLength";
3470 if (values.size()>0)
3474 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3478 voxels_number_axial = fov_axial/4 + 1;
3483 entry =
"/gate/"+block_name+
"/ring/setRepeatNumber";
3485 if (values.size()>0)
3489 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3495 entry =
"/gate/"+block_name+
"/ring/setFirstAngle";
3497 if (values.size()>0)
3501 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3507 entry =
"/gate/"+block_name+
"/ring/setAngularSpan";
3509 if (values.size()>0)
3513 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3518 entry =
"/gate/"+block_name+
"/ring/setModuloNumber";
3520 if (values.size()>0)
3524 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
3529 for (
int i=1; i<8; i++)
3531 entry =
"/gate/"+block_name+
"/ring/setZShift"+
toString(i);
3533 if (values.size()>0)
3538 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3541 vec_block_Z_Shift.push_back(zshift);
3549 entry =
"/gate/"+block_name+
"/linear/setRepeatNumber";
3551 if (values.size()>0)
3555 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3560 entry = is_block_Y_axis ?
3561 "/gate/"+block_name+
"/geometry/setXLength":
3562 "/gate/"+block_name+
"/geometry/setYLength";
3565 if (values.size()>0)
3569 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3574 entry =
"/gate/"+block_name+
"/geometry/setZLength";
3576 if (values.size()>0)
3580 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3585 entry =
"/gate/"+block_name+
"/linear/setRepeatVector";
3587 if (values.size()>0)
3591 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3601 entry = is_block_Y_axis ?
3602 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberX":
3603 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
3606 if (values.size()>0)
3610 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3615 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberZ";
3617 if (values.size()>0)
3621 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3627 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatVector";
3629 if (values.size()>0)
3631 string trs_step = is_block_Y_axis ?
3638 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3645 entry =
"/gate/"+crystal_name+
"/geometry/setXLength";
3647 if (values.size()>0)
3652 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3656 if (is_block_Y_axis)
3657 crystal_size_trans = x_length;
3659 crystal_size_depth = x_length;
3664 entry =
"/gate/"+crystal_name+
"/geometry/setYLength";
3666 if (values.size()>0)
3671 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3675 if (is_block_Y_axis)
3676 crystal_size_depth = y_length;
3678 crystal_size_trans = y_length;
3681 entry =
"/gate/"+crystal_name+
"/geometry/setZLength";
3683 if (values.size()>0)
3687 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3695 entry =
"/gate/digitizer/Coincidences/minSectorDifference";
3697 if (values.size()>0)
3699 double min_sector_diff;
3702 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occured while trying to parse line: " << line<< endl);
3705 min_angle_diff = 360/number_of_blocks*min_sector_diff;
3712 number_of_elements = number_of_blocks *
3713 number_of_blocks_axial *
3714 number_of_crystals_trans *
3715 number_of_crystals_axial;
3718 fov_trans = scanner_radius/2;
3720 voxels_number_trans = fov_trans/2 + 1;
3722 if (crystal_step_axial - crystal_size_axial >= 0)
3723 crystal_step_axial = crystal_step_axial - crystal_size_axial;
3725 if (crystal_step_trans - crystal_size_trans >= 0)
3726 crystal_step_trans = crystal_step_trans - crystal_size_trans;
3728 if (block_step_axial - block_size_Z >= 0)
3729 block_step_axial = block_step_axial - block_size_Z;
3731 if (block_step_trans - block_size_Y >= 0)
3732 block_step_trans = block_step_trans - block_size_Y;
3735 block_first_angle -= round(atan2f(block_pos_X , block_pos_Y) * 180. / M_PI);
3739 ofstream fileGeom(a_pathGeom.c_str(), ios::out | ios::trunc);
3743 fileGeom <<
"# comments" << endl;
3744 fileGeom <<
"# Y _________ "<< endl;
3745 fileGeom <<
"# | / _ \\ \\ "<< endl;
3746 fileGeom <<
"# | | / \\ | |"<< endl;
3747 fileGeom <<
"# |_____ Z | | | | |"<< endl;
3748 fileGeom <<
"# \\ | | | | |" << endl;
3749 fileGeom <<
"# \\ | \\_/ | |" << endl;
3750 fileGeom <<
"# X \\___/_____/" << endl;
3751 fileGeom <<
"# Left-handed axis orientation"<< endl;
3752 fileGeom <<
"# scanner axis is z" << endl;
3753 fileGeom <<
"# positions in millimeters"<< endl;
3754 fileGeom <<
"# Use comma without space as separator in the tables." << endl;
3757 fileGeom <<
"modality : " << modality << endl;
3758 fileGeom <<
"scanner name : " << scanner_name << endl;
3759 fileGeom <<
"number of elements : " << number_of_elements << endl;
3760 fileGeom <<
"number of layers : " <<
"1" << endl;
3761 fileGeom <<
"" << endl;
3762 fileGeom <<
"# default reconstruction parameters" << endl;
3763 fileGeom <<
"voxels number transaxial : " << voxels_number_trans << endl;
3764 fileGeom <<
"voxels number axial : " << voxels_number_axial << endl;
3766 fileGeom <<
"field of view transaxial : " << fov_trans << endl;
3767 fileGeom <<
"field of view axial : " << fov_axial << endl;
3768 fileGeom <<
"" << endl;
3769 fileGeom <<
"description : " << description << endl;
3770 fileGeom <<
"" << endl;
3771 fileGeom <<
"scanner radius : " << scanner_radius << endl;
3772 fileGeom <<
"number of rsectors : " << number_of_blocks << endl;
3773 fileGeom <<
"number of crystals transaxial : " << number_of_crystals_trans << endl;
3774 fileGeom <<
"number of crystals axial : " << number_of_crystals_axial << endl;
3776 fileGeom <<
""<< endl;
3777 fileGeom <<
"# The 4 following parameters could be defined in arrays (SizeLayer1,SizeLayer2,SizeLayer3,etc..) if their is more than one layer"<< endl;
3778 fileGeom <<
"crystals size depth : " << crystal_size_depth << endl;
3779 fileGeom <<
"crystals size transaxial : " << crystal_size_trans << endl;
3780 fileGeom <<
"crystals size axial : " << crystal_size_axial << endl;
3781 fileGeom <<
""<< endl;
3784 fileGeom <<
"rsectors first angle : " << block_first_angle << endl;
3785 fileGeom <<
"number of modules transaxial : " << number_of_blocks_trans << endl;
3786 fileGeom <<
"number of modules axial : " << number_of_blocks_axial << endl;
3787 fileGeom <<
"module gap transaxial : " << block_step_trans << endl;
3788 fileGeom <<
"module gap axial : " << block_step_axial << endl;
3789 fileGeom <<
"crystal gap transaxial : " << crystal_step_trans << endl;
3790 fileGeom <<
"crystal gap axial : " << crystal_step_axial << endl;
3791 fileGeom <<
"rotation direction : CCW " << endl;
3792 fileGeom <<
""<< endl;
3795 if(min_angle_diff > 0.) fileGeom <<
"min angle difference : " << min_angle_diff << endl;
3798 if(block_angular_span >= 360.0005 ||
3799 block_angular_span <= 359.9995 )
3801 block_angular_span *= (number_of_blocks+1)/number_of_blocks;
3802 fileGeom <<
"rsectors angular span : " << block_angular_span << endl;
3805 if(block_nb_zshifts > 0) fileGeom <<
"rsectors nbZShift :" << block_nb_zshifts << endl;
3806 if(!vec_block_Z_Shift.empty())
WriteVector(fileGeom,
"rsectors ZShift : ", vec_block_Z_Shift);
3810 Cout(
"Output geom file written at :" << a_pathGeom << endl);
3814 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Couldn't open geom file for writing "<< a_pathGeom <<
" !" << endl);
3839 string scanner_name =
GetFileFromPath(a_pathGeom.substr(0,a_pathGeom.find_first_of(
".geom")));
3840 FLTNB scanner_radius = -1.;
3841 string description =
"SPECT camera extracted from GATE macro: " + a_pathMac;
3844 string head_name =
"SPECThead";
3845 uint32_t number_of_heads = 0;
3846 FLTNB head_pos_X = 0.;
3847 FLTNB head_pos_Y = 0.;
3848 FLTNB head_first_angle = 0.;
3849 FLTNB head_angular_pitch = -1.;
3850 string head_orbit_name =
"";
3851 FLTNB head_rotation_speed = 0.;
3852 bool is_head_Y_axis =
false;
3855 string crystal_name =
"crystal";
3856 FLTNB crystal_size_trans = 0.;
3857 FLTNB crystal_size_axial = 0.;
3858 FLTNB crystal_depth = 0;
3861 string pixel_name =
"pixel";
3862 uint32_t number_of_pixels_trans = 1;
3863 uint32_t number_of_pixels_axial = 1;
3864 FLTNB pix_size_trans = 0.;
3865 FLTNB pix_size_axial = 0.;
3866 FLTNB pix_step_trans = 0.;
3867 FLTNB pix_step_axial = 0.;
3870 string focal_model_trs =
"constant";
3871 uint16_t nb_coeff_model_trs = 1;
3872 FLTNB coeff_model_trs = 0.;
3873 string focal_model_axl =
"constant";
3874 uint16_t nb_coeff_model_axl = 1;
3875 FLTNB coeff_model_axl = 0.;
3878 uint32_t voxels_number_trans;
3879 uint32_t voxels_number_axial;
3883 vector<string> path_mac_files;
3884 path_mac_files.push_back(a_pathMac);
3889 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Error occured when trying to recover paths to GATE macro files !" << endl);
3897 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Error occured when trying to recover aliases for the elements of the SPECThead !" << endl);
3902 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
3904 ifstream systemMac(path_mac_files[f].c_str(), ios::in);
3907 while(getline(systemMac, line))
3910 modality =
"SPECT_CONVERGENT";
3911 vector <string> values;
3915 entry =
"/gate/"+head_name+
"/placement/setTranslation";
3917 if (values.size()>0)
3922 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occured while trying to parse line: " << line<< endl);
3928 if(head_pos_X!=0 && head_pos_Y !=0)
3930 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occured while trying to parse line: " << line<< endl);
3931 Cerr(
" Block cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
3936 if(head_pos_Y!=0) is_head_Y_axis =
true;
3938 scanner_radius = is_head_Y_axis ? abs(head_pos_Y) : abs(head_pos_X) ;
3942 entry =
"/gate/"+head_name+
"/geometry/setZLength";
3944 if (values.size()>0)
3948 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occured while trying to parse line: " << line<< endl);
3952 voxels_number_axial = fov_axial/4 + 1;
3956 entry =
"/gate/"+head_name+
"/ring/setRepeatNumber";
3958 if (values.size()>0)
3962 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occured while trying to parse line: " << line<< endl);
3968 entry =
"/gate/"+head_name+
"/ring/setFirstAngle";
3970 if (values.size()>0)
3974 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occured while trying to parse line: " << line<< endl);
3980 entry =
"/gate/"+head_name+
"/ring/setAngularPitch";
3982 if (values.size()>0)
3986 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occured while trying to parse line: " << line<< endl);
3991 entry =
"/gate/"+head_name+
"/moves/insert";
3993 if (values.size()>0)
3997 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occured while trying to parse line: " << line<< endl);
4002 entry =
"/gate/"+head_orbit_name+
"/setSpeed";
4004 if (values.size()>0)
4008 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occured while trying to parse line: " << line<< endl);
4016 entry =
"/gate/"+crystal_name+
"/geometry/setXLength";
4018 if (values.size()>0)
4023 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
4028 crystal_size_trans = x_length;
4030 crystal_depth = x_length;
4033 entry =
"/gate/"+crystal_name+
"/geometry/setYLength";
4035 if (values.size()>0)
4040 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
4045 crystal_depth = y_length;
4047 crystal_size_trans = y_length;
4051 entry =
"/gate/"+crystal_name+
"/geometry/setZLength";
4053 if (values.size()>0)
4057 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
4067 entry = is_head_Y_axis ?
4068 "/gate/"+pixel_name+
"/cubicArray/setRepeatNumberX":
4069 "/gate/"+pixel_name+
"/cubicArray/setRepeatNumberY";
4073 if (values.size()>0)
4077 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
4082 entry =
"/gate/"+pixel_name+
"/cubicArray/setRepeatNumberZ";
4084 if (values.size()>0)
4088 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
4094 entry =
"/gate/"+pixel_name+
"/geometry/setXLength";
4096 if (values.size()>0)
4101 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
4106 pix_size_trans = x_length;
4109 entry =
"/gate/"+pixel_name+
"/geometry/setYLength";
4111 if (values.size()>0)
4116 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
4120 if (!is_head_Y_axis)
4121 pix_size_trans = y_length;
4125 entry =
"/gate/"+pixel_name+
"/geometry/setZLength";
4127 if (values.size()>0)
4131 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
4137 entry =
"/gate/"+pixel_name+
"/cubicArray/setRepeatVector";
4139 if (values.size()>0)
4141 string trs_step = is_head_Y_axis ?
4148 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
4155 entry = is_head_Y_axis ?
4156 "/gate/fanbeam/geometry/setFocalDistanceY":
4157 "/gate/fanbeam/geometry/setFocalDistanceX";
4159 entry =
"/gate/fanbeam/geometry/setFocalDistanceX";
4161 if (values.size()>0)
4165 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occured while trying to parse line: " << line<< endl);
4169 focal_model_trs =
"polynomial";
4177 fov_trans = scanner_radius/2;
4179 voxels_number_trans = fov_trans/2 + 1;
4181 uint32_t nb_pixels = number_of_pixels_axial * number_of_pixels_trans;
4183 pix_size_axial = nb_pixels>1 ? pix_size_axial : crystal_size_axial;
4184 pix_size_trans = nb_pixels>1 ? pix_size_trans : crystal_size_trans;
4187 if (pix_step_axial - pix_size_axial >= 0)
4188 pix_step_axial = pix_step_axial - pix_size_axial;
4190 if (pix_step_trans - pix_size_trans >= 0)
4191 pix_step_trans = pix_step_trans - pix_size_trans;
4195 head_first_angle = round(atan2f(head_pos_X , head_pos_Y) * 180. / M_PI)
4200 ofstream fileGeom(a_pathGeom.c_str(), ios::out | ios::trunc);
4204 fileGeom <<
"modality : " << modality << endl;
4205 fileGeom <<
"scanner name : " << scanner_name << endl;
4206 fileGeom <<
"number of detector heads : " << number_of_heads << endl;
4207 fileGeom <<
"trans number of pixels : " << number_of_pixels_trans << endl;
4208 fileGeom <<
"trans pixel size : " << pix_size_trans << endl;
4209 fileGeom <<
"trans gap size : " << pix_step_trans << endl;
4210 fileGeom <<
"axial number of pixels : " << number_of_pixels_axial << endl;
4211 fileGeom <<
"axial pixel size : " << pix_size_axial << endl;
4212 fileGeom <<
"axial gap size : " << pix_step_axial << endl;
4214 fileGeom <<
"detector depth : " << crystal_depth << endl;
4216 fileGeom <<
"scanner radius : " << scanner_radius;
4217 for(
size_t h=1 ; h<number_of_heads ; h++)
4218 fileGeom <<
"," << scanner_radius;
4221 fileGeom <<
"# Collimator configuration : "<< endl << endl;
4222 for(
size_t h=0 ; h<number_of_heads ; h++)
4224 fileGeom <<
"head" << h+1 <<
":" << endl;
4225 fileGeom <<
"trans focal model: " << focal_model_trs << endl;
4226 fileGeom <<
"trans number of coef model: " << nb_coeff_model_trs << endl;
4227 fileGeom <<
"trans parameters: " << coeff_model_trs << endl;
4228 fileGeom <<
"axial focal model: " << focal_model_axl << endl;
4229 fileGeom <<
"axial number of coef model: " << nb_coeff_model_axl << endl;
4230 fileGeom <<
"axial parameters: " << coeff_model_axl << endl;
4234 fileGeom <<
"" << endl;
4235 fileGeom <<
"# default reconstruction parameters" << endl;
4236 fileGeom <<
"voxels number transaxial : " << voxels_number_trans << endl;
4237 fileGeom <<
"voxels number axial : " << voxels_number_axial << endl;
4239 fileGeom <<
"field of view transaxial : " << fov_trans << endl;
4240 fileGeom <<
"field of view axial : " << fov_axial << endl << endl ;
4241 fileGeom <<
""<< endl;
4243 fileGeom <<
"# description" << endl;
4244 fileGeom <<
"description : " << description << endl;
4248 Cout(
"Output geom file written at :" << a_pathGeom << endl);
4252 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Couldn't open geom file for writing "<< a_pathGeom <<
" !" << endl);
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.
This header file is mainly used to declare some macro definitions and all includes needed from the st...
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 ...
This file gathers various function dedicated to data conversion in order to convert various type of G...
int IntfKeyGetRecurringValueFromFile(const string &a_pathToHeader, const string &a_key, T *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
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...
vector< string > CheckGATECommand(const string &a_key, const string &a_line)
Check if the line contains the provided GATE command. In this case, parse the line and returns the va...
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...
int GetGATEAliasesCylindrical(vector< string > path_mac_files, string &rsector_name, string &module_name, string &submodule_name, string &crystal_name, vector< string > &layers_name, int vb)
Loop over a list of path to GATE macro files passed in parameter to recover aliases of the different ...
int IntfKeyGetValueFromFile(const string &a_pathToHeader, const string &a_key, T *ap_return, int a_nbElts, int a_mandatoryFlag)
Look for "a_nbElts" elts in the "a_pathToHeader" interfile header matching the "a_keyword" key passed...
string GetFileFromPath(const string &a_pathToFile)
Simply return the file from a path string passed in parameter.
int ConvertFromString(const string &a_str, string *a_result)
Copy the 'a_str' string in the position pointed by 'a_result'.
int GetGATEMacFiles(const string &a_pathMac, vector< string > &ap_pathToMacFiles)
Extract the paths to each macro file contained in the main macro file.
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...
int ReadIntfSPECT(string a_pathIntf, float_t &a_distToDetector, uint32_t &a_nHeads, uint32_t &a_nPixAxl, uint32_t &a_nPixTrs, float_t &a_crystalSizeAxl, float_t &a_crystalSizeTrs, uint32_t &a_nProjectionsTot, uint32_t &a_nProjectionsByHead, float_t &a_head1stAngle, float_t &a_headAngPitchDeg, float_t &a_headAngStepDeg, int &a_headRotDirection, uint32_t &a_start_time_ms, uint32_t &a_duration_ms, int vb)
Recover informations about the scanner element of an ECAT system, and acquisition duration...
void ConvertValuesTomm(vector< string > &ap_v)
Check if the vector of strings passed in parameter contains the 'cm' unit In this case...
int ReadMacSPECT(string a_pathMac, float_t &a_distToDetector, uint32_t &a_nHeads, uint32_t &a_nPixAxl, uint32_t &a_nPixTrs, float_t &a_crystalSizeAxl, float_t &a_crystalSizeTrs, uint32_t &a_nProjectionsTot, uint32_t &a_nProjectionsByHead, float_t &a_head1stAngle, float_t &a_headAngPitch, float_t &a_headAngStepDeg, int &a_headRotDirection, uint32_t &a_start_time_ms, uint32_t &a_duration_ms, int vb)
Recover informations about the scanner element of an ECAT system, and acquisition duration...
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.
#define KEYWORD_MANDATORY
#define GATE_SYS_CYLINDRICAL
int GetGATEAliasesEcat(vector< string > path_mac_files, string &block_name, string &crystal_name, int vb)
Loop over a list of path to GATE macro files passed in parameter to recover aliases of the different ...
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.
string toString(T a_val)
Convert a value of any type into string.
string GetPathOfFile(const string &a_pathToFile)
Simply return the path to the directory of a file path string passed in parameter.
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...
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.
#define GATE_NB_MAX_LAYERS
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...
vector< string > Split(string a_line)
Split the line provided in parameter into a vector of strings (separator is blankspace) ...
int WriteVector(ofstream &file, const string &a_key, vector< T > a_vals)
Write the key and its values in the file provided in parameter.
int GetGATESystemType(const string &a_pathMac)
Read a GATE macro file and identify the system type from the 'gate/systems/' command lines...
int GetGATEAliasesSPECT(vector< string > path_mac_files, string &base_name, string &crystal_name, string &pixel_name, int vb)
Loop over a list of path to GATE macro files passed in parameter to recover aliases of the different ...