54 vector<string> values;
59 line = (line.find(
"#") != string::npos) ?
60 line.substr(0, line.find_first_of(
"#")) :
63 size_t foundAdress = line.find(a_key);
65 if (foundAdress != string::npos)
67 values =
Split(a_line);
68 values.erase (values.begin());
87 vector<string>
Split(
string a_line)
90 stringstream ss(a_line);
92 vector<string> tokens;
95 tokens.push_back(buf);
115 for(uint16_t i=0; i < ap_v.size(); i++)
119 for (
int j=0; j<i; j++)
141 int WriteVector(ofstream& file,
const string& a_key, vector <T> a_vals)
143 int n = a_vals.size();
148 for (
int i=0; i < n; i++)
153 file << ss.str() << endl;
155 file << ss.str() <<
",";
159 file << a_key <<
"0" <<endl;
164 template int WriteVector(ofstream& file,
const string& a_key, vector <double> a_vals);
180 int WriteVector(ofstream& file,
const string& a_key, vector <string> a_vals)
182 int n = a_vals.size();
187 for (
int i=0; i < n; i++)
190 file << a_vals[i] << endl;
192 file << a_vals[i] <<
",";
196 file << a_key <<
"0" <<endl;
215 int WriteVector(ofstream& file,
const string& a_key, vector <vector<string> > a_vals)
217 int n = a_vals.size();
219 for (
int i=0; i < n; i++)
220 for (
int j=0; j < 3; j++)
221 if (i == n-1 && j == 2)
222 file << a_vals[i][j] << endl;
224 file << a_vals[i][j] <<
",";
245 ifstream mac_file(a_pathMac, ios::in);
251 while(getline(mac_file, quickLine))
253 vector <string> values;
261 char first_char = values[0].at(0);
263 if(first_char ==
'/')
264 ap_pathToMacFiles.push_back(values[0]);
267 ap_pathToMacFiles.push_back(
GetPathOfFile(a_pathMac)+values[0]);
274 Cerr(
"***** GetGATEMacFiles() -> Couldn't open mac file "<< a_pathMac <<
" !" << endl);
300 vector<string> path_mac_files;
301 path_mac_files.push_back(a_pathMac);
305 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover paths to GATE macro files !" << endl);
309 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
310 cout << f <<
" : " << path_mac_files[f] << endl;
313 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
315 ifstream mac_file(path_mac_files[f], ios::in);
320 while(getline(mac_file, line))
323 if(line.find(
"/gate/systems/") != string::npos )
325 if(line.find(
"/gate/systems/ecat") != string::npos )
328 if(line.find(
"/gate/systems/cylindricalPET") != string::npos )
331 if(line.find(
"/gate/systems/SPECThead") != string::npos )
334 if(line.find(
"/gate/systems/OPET") != string::npos ||
335 line.find(
"/gate/systems/CTSCANNER") != string::npos ||
336 line.find(
"/gate/systems/CPET") != string::npos ||
337 line.find(
"/gate/systems/ecatAccel") != string::npos ||
338 line.find(
"/gate/systems/OpticalSystem") != string::npos )
340 Cerr(
"unsupported system detected (line = " << line <<
") ! "<< endl);
341 Cerr(
"supported systems for this script are cylindricalPET, SPECThead, and ecat" << endl);
348 Cerr(
"***** GetGATESystemType() -> Error : Couldn't open mac file "<< path_mac_files[f] <<
" !" << endl);
385 string& rsector_name,
387 string& submodule_name,
388 string& crystal_name,
389 vector<string>& layers_name,
394 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
396 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
401 while(getline(mac_file, quickLine))
403 vector <string> values;
405 values =
CheckGATECommand(
"/gate/systems/cylindricalPET/rsector/attach", quickLine);
409 rsector_name = values[0];
413 values =
CheckGATECommand(
"/gate/systems/cylindricalPET/module/attach", quickLine);
416 module_name = values[0];
420 values =
CheckGATECommand(
"/gate/systems/cylindricalPET/submodule/attach", quickLine);
423 submodule_name = values[0];
427 values =
CheckGATECommand(
"/gate/systems/cylindricalPET/crystal/attach", quickLine);
430 crystal_name = values[0];
439 values =
CheckGATECommand(
"/gate/systems/cylindricalPET/layer"+ss.str()+
"/attach", quickLine);
442 layers_name.push_back(values[0]);
451 Cerr(
"***** GetGATEAliasesCylindrical()->Couldn't open mac file "<< path_mac_files[f] <<
" !" << endl);
462 Cout(
"***** GetGATEAliasesCylindrical() :: Error : Missing elements in the system architecture" << endl <<
463 " At least two of the following lines are required :" << endl <<
464 " - /gate/systems/cylindricalPET/rsector/attach" << endl <<
465 " - /gate/systems/cylindricalPET/module/attach" << endl <<
466 " - /gate/systems/cylindricalPET/submodule/attach" << endl <<
467 " - /gate/systems/cylindricalPET/crystal/attach" << endl <<
468 " - /gate/systems/cylindricalPET/layeri[i=0..3]/attach" << endl);
474 if(rsector_name.empty())
476 if(module_name.empty())
479 rsector_name = submodule_name;
485 rsector_name = module_name;
492 if(!rsector_name.empty())
Cout(
"Detected rsector container's name : " << rsector_name << endl);
493 if(!module_name.empty())
Cout(
"Detected module container's name : " << module_name << endl);
494 if(!submodule_name.empty())
Cout(
"Detected submodule container's name : " << submodule_name << endl);
495 if(!crystal_name.empty())
Cout(
"Detected crystal container's name : " << crystal_name << endl);
496 for(
size_t l=0 ; l<layers_name.size() ; l++)
497 if(!layers_name[l].empty())
Cout(
"Detected layer #"<< l <<
" container's name : " << layers_name[l] << endl);
526 string& crystal_name,
531 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
533 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
539 while(getline(mac_file, quickLine))
541 vector <string> values;
546 block_name = values[0];
553 crystal_name = values[0];
560 Cerr(
"***** GetGATEAliasesEcat()-> Couldn't open mac file "<< path_mac_files[f].c_str()<<
" !" << endl);
569 Cerr(
"***** GetGATEAliasesEcat() :: Error : Missing elements in the system architecture" << endl
570 <<
" The following lines are required :" << endl
571 <<
" - /gate/systems/ecat/block/attach" << endl
572 <<
" - /gate/systems/ecat/crystal/attach" << endl);
578 Cout(
"First container's name (usually block) is : " << block_name << endl
579 <<
"Second container's name (usually crystal) is : " << crystal_name << endl);
610 string& crystal_name,
616 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
618 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
625 while(getline(mac_file, quickLine))
627 vector <string> values;
629 values =
CheckGATECommand(
"/gate/systems/SPECThead/base/attach", quickLine);
632 base_name = values[0];
636 values =
CheckGATECommand(
"/gate/systems/SPECThead/crystal/attach", quickLine);
639 crystal_name = values[0];
643 values =
CheckGATECommand(
"/gate/systems/SPECThead/pixel/attach", quickLine);
646 pixel_name = values[0];
654 Cerr(
"***** GetGATEAliasesSPECT()-> Couldn't open mac file "<< path_mac_files[f].c_str()<<
" !" << endl);
662 Cerr(
"***** GetGATEAliasesSPECT() :: Error : Missing elements in the system architecture" << endl
663 <<
" The following line is required :" << endl
664 <<
" - /gate/systems/SPECThead/crystal/attach" << endl);
670 Cout(
"Crystal container's name is : " << crystal_name << endl);
696 int32_t nCrystalsTransaxial,
697 int32_t nCrystalsAxial,
701 int32_t nCrystalsPerRing = nBlocksPerRing * nCrystalsTransaxial;
703 int32_t ringID = (int32_t)( blockID/nBlocksPerRing ) * nCrystalsAxial
704 + (int32_t)( crystalID/nCrystalsTransaxial );
706 int32_t castorID = nCrystalsPerRing * ringID
707 + nCrystalsTransaxial*( blockID % nBlocksPerRing )
708 + crystalID % nCrystalsTransaxial;
731 uint32_t a_nProjectionsByHead)
734 int32_t angID = round(a_rotAngle/a_angStep);
737 int32_t castorID = a_headID*a_nProjectionsByHead + angID;
774 float_t a_headAngPitch,
775 float_t a_crystalSizeAxl,
776 float_t a_crystalSizeTrs,
781 int32_t castorID = 0;
784 if (a_nbSimulatedPixels > 1)
786 castorID = a_pixelID;
793 FLTNB sizePixTrs = a_crystalSizeTrs/a_nPixTrs;
794 FLTNB sizePixAxl = a_crystalSizeAxl/a_nPixAxl;
797 uint32_t axialID = (uint32_t)(( a_gPosZ + a_nPixAxl/2*sizePixAxl) / sizePixAxl);
801 float_t ang = a_headID*a_headAngPitch + a_rotAngle;
804 float_t sin_a = sin(-ang*M_PI/180);
805 float_t cos_a = cos(-ang*M_PI/180);
806 float_t trs_pos = a_gPosX*sin_a + a_gPosY*cos_a ;
809 uint32_t transID = (uint32_t)(( trs_pos + a_nPixTrs/2*sizePixTrs) / sizePixTrs);
811 if ( axialID < a_nPixAxl && transID < a_nPixTrs )
813 castorID = axialID*a_nPixTrs + transID;
817 castorID = a_nPixAxl*a_nPixTrs;
829 uint32_t nRsectorsAxial,
830 bool a_invertDetOrder,
831 int a_rsectorIdOrder,
832 uint32_t nModulesTransaxial,
833 uint32_t nModulesAxial,
834 uint32_t nSubmodulesTransaxial,
835 uint32_t nSubmodulesAxial,
836 uint32_t nCrystalsTransaxial,
837 uint32_t nCrystalsAxial,
839 uint32_t* nCrystalPerLayer,
840 vector<uint32_t> nLayersRptTransaxial,
841 vector<uint32_t> nLayersRptAxial,
849 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 * nRsectorsAngPos;
871 int32_t rsectorAxlID = 0 ;
872 int32_t rsectorTrsID = 0 ;
875 if(a_rsectorIdOrder == 0)
877 rsectorAxlID = rsectorID/nRsectorsAngPos ;
878 rsectorTrsID = (int32_t)(rsectorID%nRsectorsAngPos) ;
882 rsectorAxlID = rsectorID%nRsectorsAxial ;
883 rsectorTrsID = (int32_t)(rsectorID/nRsectorsAxial) ;
888 int32_t ringID = rsectorAxlID * nModulesAxial * nSubmodulesAxial * nCrystalsAxial
889 + (int32_t)(moduleID/nModulesTransaxial) * nSubmodulesAxial * nCrystalsAxial
890 + (int32_t)(submoduleID/nSubmodulesTransaxial) * nCrystalsAxial
891 + (int32_t)(crystalID/nCrystalsTransaxial);
894 moduleID = moduleID % nModulesTransaxial;
895 submoduleID = submoduleID % nSubmodulesTransaxial;
896 crystalID = crystalID % nCrystalsTransaxial;
899 if( a_invertDetOrder )
901 moduleID = nModulesTransaxial-1 - moduleID;
902 submoduleID = nSubmodulesTransaxial-1 - submoduleID;
903 crystalID = nCrystalsTransaxial-1 - crystalID;
907 castorID += nCrystalsPerRing * ringID
908 + nTrsCrystalsPerRsector * rsectorTrsID
909 + nTrsCrystalsPerModule * moduleID
910 + nTrsCrystalsPerSubmodule * submoduleID
919 uint32_t sum_detectors_prev_layers = 0;
924 while ( layerID >= (int32_t)( sum_detectors_prev_layers
925 + ( nLayersRptTransaxial[layer]
926 * nLayersRptAxial[layer]) ) )
929 sum_detectors_prev_layers += nLayersRptTransaxial[layer]
930 * nLayersRptAxial[layer];
938 if (layer>0)layerID -= sum_detectors_prev_layers;
942 for(
int l=0 ; l<layer ; l++)
943 castorID += nCrystalPerLayer[l];
945 int32_t nTrsCrystalsPerSubmodule = nCrystalsTransaxial * nLayersRptTransaxial[layer];
946 int32_t nTrsCrystalsPerModule = nTrsCrystalsPerSubmodule * nSubmodulesTransaxial;
947 int32_t nTrsCrystalsPerRsector = nTrsCrystalsPerModule * nModulesTransaxial;
948 int32_t nCrystalsPerRing = nTrsCrystalsPerRsector * nRsectorsAngPos;
952 int32_t rsectorAxlID = 0 ;
953 int32_t rsectorTrsID = 0 ;
956 if(a_rsectorIdOrder == 0)
958 rsectorAxlID = rsectorID/nRsectorsAngPos ;
959 rsectorTrsID = (int32_t)(rsectorID%nRsectorsAngPos) ;
963 rsectorAxlID = rsectorID%nRsectorsAxial ;
964 rsectorTrsID = (int32_t)(rsectorID/nRsectorsAxial) ;
969 int32_t ringID = rsectorAxlID * nModulesAxial * nSubmodulesAxial * nCrystalsAxial * nLayersRptAxial[layer]
970 + (int32_t)(moduleID/nModulesTransaxial) * nSubmodulesAxial * nCrystalsAxial * nLayersRptAxial[layer]
971 + (int32_t)(submoduleID/nSubmodulesTransaxial) * nCrystalsAxial * nLayersRptAxial[layer]
972 + (int32_t)(crystalID/nCrystalsTransaxial) * nLayersRptAxial[layer];
975 if(!nLayersRptTransaxial.empty() )
976 ringID += (int32_t)(layerID/nLayersRptTransaxial[layer]);
980 moduleID = moduleID % nModulesTransaxial;
981 submoduleID = submoduleID % nSubmodulesTransaxial;
982 crystalID = crystalID % nCrystalsTransaxial;
983 layerID = layerID % nLayersRptTransaxial[layer];
986 if( a_invertDetOrder )
988 moduleID = nModulesTransaxial-1 - moduleID;
989 submoduleID = nSubmodulesTransaxial-1 - submoduleID;
990 crystalID = nCrystalsTransaxial-1 - crystalID;
991 layerID = nLayersRptTransaxial[layer]-1 - layerID;
995 castorID += nCrystalsPerRing * ringID
996 + nTrsCrystalsPerRsector * rsectorTrsID
997 + nTrsCrystalsPerModule * moduleID
998 + nTrsCrystalsPerSubmodule * submoduleID
1024 int comptonPhantom1,
int comptonPhantom2,
1025 int rayleighPhantom1,
int rayleighPhantom2)
1027 if (eventID1 != eventID2)
1032 if (comptonPhantom1 == 0 && comptonPhantom2 == 0 &&
1033 rayleighPhantom1 == 0 && rayleighPhantom2 == 0)
1038 if (comptonPhantom1 == 1 || comptonPhantom2 == 1 ||
1039 rayleighPhantom1 == 1 || rayleighPhantom2 == 1)
1042 if (comptonPhantom1 > 1 || comptonPhantom2 > 1 ||
1043 rayleighPhantom1 > 1 || rayleighPhantom2 > 1)
1082 uint32_t *nb_crystal_per_layer,
1083 uint32_t &nCrystalsTot,
1084 uint32_t &nCrystalsAxial,
1085 uint32_t &nCrystalsTransaxial,
1086 vector<uint32_t> &nLayersRptAxial,
1087 vector<uint32_t> &nLayersRptTransaxial,
1088 uint32_t &nSubmodulesAxial,
1089 uint32_t &nSubmodulesTransaxial,
1090 uint32_t &nModulesAxial,
1091 uint32_t &nModulesTransaxial,
1092 uint32_t &nRsectorsAxial,
1093 uint32_t &nRsectorsAngPos,
1094 bool &invert_det_order,
1095 int &rsector_id_order,
1096 uint32_t &start_time_ms,
1097 uint32_t &duration_ms,
1100 vector<string> path_mac_files;
1101 path_mac_files.push_back(a_pathMac);
1106 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover paths to GATE macro files !" << endl);
1110 string rsector_name =
"";
1111 string module_name =
"";
1112 string submodule_name =
"";
1113 string crystal_name =
"";
1114 string mod_rptr_type =
"cubicArray";
1115 string smod_rptr_type =
"cubicArray";
1116 string cry_rptr_type =
"cubicArray";
1117 string lay_rptr_type =
"cubicArray";
1119 vector <string> layers_name;
1120 bool is_rsector_Y_axis =
false;
1123 if(
GetGATEAliasesCylindrical(path_mac_files, rsector_name, module_name, submodule_name, crystal_name, layers_name, vb) )
1125 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover aliases for the elements of the cylindricalPET !" << endl);
1130 nLayers = layers_name.size();
1133 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
1135 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
1138 double time_start =-1.,
1142 while(getline(mac_file, line))
1144 vector <string> values;
1150 kword =
"/gate/"+rsector_name+
"/placement/setTranslation";
1154 if (values.size()>0)
1156 FLTNB rsector_pos_X =0.,
1162 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1167 if(rsector_pos_Y!=0) is_rsector_Y_axis =
true;
1173 if(rsector_pos_Y > 0 || rsector_pos_X < 0)
1174 invert_det_order =
true;
1179 kword =
"/gate/"+rsector_name+
"/ring/setRepeatNumber";
1181 if (values.size()>0)
1185 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1192 kword =
"/gate/"+rsector_name+
"/linear/setRepeatNumber";
1194 if (values.size()>0)
1198 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1205 kword =
"/gate/"+rsector_name+
"/cubicArray/setRepeatNumberZ";
1208 if (values.size()>0)
1212 rsector_id_order = nRsectorsAngPos>1 ? 1 : 0 ;
1216 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1227 kword = is_rsector_Y_axis ?
1228 "/gate/"+module_name+
"/cubicArray/setRepeatNumberX":
1229 "/gate/"+module_name+
"/cubicArray/setRepeatNumberY";
1232 if (values.size()>0)
1236 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1241 kword =
"/gate/"+module_name+
"/cubicArray/setRepeatNumberZ";
1243 if (values.size()>0)
1247 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1253 kword =
"/gate/"+module_name+
"/linear/setRepeatNumber";
1255 if (values.size()>0)
1259 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1267 kword = is_rsector_Y_axis ?
1268 "/gate/"+submodule_name+
"/cubicArray/setRepeatNumberX":
1269 "/gate/"+submodule_name+
"/cubicArray/setRepeatNumberY";
1272 if (values.size()>0)
1276 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1281 kword =
"/gate/"+submodule_name+
"/cubicArray/setRepeatNumberZ";
1283 if (values.size()>0)
1287 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1293 kword =
"/gate/"+submodule_name+
"/linear/setRepeatNumber";
1295 if (values.size()>0)
1299 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1308 kword = is_rsector_Y_axis ?
1309 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberX":
1310 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
1313 if (values.size()>0)
1317 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1322 kword =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberZ";
1324 if (values.size()>0)
1328 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1335 kword =
"/gate/"+crystal_name+
"/linear/setRepeatNumber";
1337 if (values.size()>0)
1341 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1350 for(
int l=0 ; l<nLayers ; l++)
1352 kword = is_rsector_Y_axis ?
1353 "/gate/"+layers_name[l]+
"/cubicArray/setRepeatNumberX":
1354 "/gate/"+layers_name[l]+
"/cubicArray/setRepeatNumberY";
1357 if (values.size()>0)
1362 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1365 nLayersRptTransaxial.push_back(val);
1368 kword =
"/gate/"+layers_name[l]+
"/cubicArray/setRepeatNumberZ";
1370 if (values.size()>0)
1375 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1378 nLayersRptAxial.push_back(val);
1382 kword =
"/gate/"+layers_name[l]+
"/linear/setRepeatNumber";
1384 if (values.size()>0)
1389 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1392 nLayersRptAxial.push_back(val);
1399 kword =
"/gate/application/setTimeStart";
1401 if (values.size()>0)
1405 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1410 if (values.size()>1)
1412 if(values[1] ==
"s") time_start *= 1000;
1415 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1417 start_time_ms = time_start;
1420 kword =
"/gate/application/setTimeStop";
1422 if (values.size()>0)
1426 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1431 if (values.size()>1)
1433 if(values[1] ==
"s") time_stop *= 1000;
1436 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1439 kword =
"/gate/application/addSlice";
1441 if (values.size()>0)
1443 double time_slice_tmp=0;
1447 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1452 if (values.size()>1)
1454 if(values[1] ==
"s") time_slice_tmp *= 1000;
1457 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1459 time_slices += time_slice_tmp;
1464 duration_ms = (time_slices>0) ?
1465 (uint32_t)(time_slices-time_start) :
1468 duration_ms = (time_start>=0 && time_stop>=0) ?
1469 (uint32_t)(time_stop-time_start) :
1478 nCrystalsTot = nRsectorsAngPos * nRsectorsAxial
1479 * nModulesTransaxial * nModulesAxial
1480 * nSubmodulesTransaxial * nSubmodulesAxial
1481 * nCrystalsTransaxial * nCrystalsAxial;
1484 for(
int l=0 ; l<nLayers ; l++)
1486 uint32_t nb_crystals_layer = nRsectorsAngPos * nRsectorsAxial
1487 * nModulesTransaxial * nModulesAxial
1488 * nSubmodulesTransaxial * nSubmodulesAxial
1489 * nCrystalsTransaxial * nCrystalsAxial;
1492 if(nLayersRptTransaxial.size()>0 || nLayersRptAxial.size()>0 )
1493 nb_crystals_layer *= nLayersRptTransaxial[l] * nLayersRptAxial[l];
1495 nb_crystal_per_layer[l] = nb_crystals_layer;
1497 nCrystalsTot += nb_crystals_layer;
1504 Cout(
"-----------------------------------------------------------" << endl);
1505 Cout(
"ReadMacCylindrical()-> Information recovered from mac file:" << endl);
1506 Cout(
"-----------------------------------------------------------" << endl);
1507 Cout(
"Number of rsectors angular position: " << nRsectorsAngPos << endl);
1508 Cout(
"Number of axial rsectors: " << nRsectorsAxial << endl);
1509 Cout(
"Number of axial modules: " << nModulesAxial << endl);
1510 Cout(
"Number of transaxial modules: " << nModulesTransaxial << endl);
1511 Cout(
"Number of axial submodules: " << nSubmodulesAxial << endl);
1512 Cout(
"Number of transaxial submodules: " << nSubmodulesTransaxial << endl);
1513 Cout(
"Number of axial crystals: " << nCrystalsAxial << endl);
1514 Cout(
"Number of transaxial crystals: " << nCrystalsTransaxial << endl);
1517 Cout(
"Number of layers: " << (uint16_t)nLayers << endl);
1518 for(
int l=0 ; l<nLayers ; l++)
1519 Cout(
"Layer "<< l <<
" : Number of crystals: " << nb_crystal_per_layer[l] << endl);
1521 Cout(
"Total number of crystals (including layers): " << nCrystalsTot << endl);
1522 Cout(
"Acquisition start time (ms): " << start_time_ms << endl);
1523 Cout(
"Acquisition duration (ms): " << duration_ms << endl);
1524 Cout(
"-----------------------------------------------------------" << endl << endl);
1550 uint32_t &nCrystalsTot,
1551 uint32_t &nCrystalsAxial,
1552 uint32_t &nCrystalsTransaxial,
1553 uint32_t &nBlocksLine,
1554 uint32_t &nBlocksPerRing,
1555 uint32_t &start_time_ms,
1556 uint32_t &duration_ms,
1560 vector<string> path_mac_files;
1561 path_mac_files.push_back(a_pathMac);
1564 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover paths to GATE macro files !" << endl);
1568 string block_name =
"block";
1569 string crystal_name =
"crystal";
1570 bool is_block_Y_axis =
false;
1575 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover aliases for the elements of the ecat !" << endl);
1581 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
1583 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
1586 double time_start=-1.,
1590 while(getline(mac_file, line))
1592 vector <string> values;
1595 kword =
"/gate/"+block_name+
"/placement/setTranslation";
1597 if (values.size()>0)
1599 FLTNB block_pos_X=0.,
1605 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
1610 if(block_pos_Y!=0) is_block_Y_axis =
true;
1613 kword =
"/gate/"+block_name+
"/ring/setRepeatNumber";
1615 if (values.size()>0)
1619 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1624 kword =
"/gate/"+block_name+
"/linear/setRepeatNumber";
1626 if (values.size()>0)
1630 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1635 kword = is_block_Y_axis ?
1636 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberX":
1637 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
1640 if (values.size()>0)
1644 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1649 kword =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberZ";
1651 if (values.size()>0)
1655 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1661 kword =
"/gate/application/setTimeStart";
1663 if (values.size()>0)
1667 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1672 if (values.size()>1)
1674 if(values[1] ==
"s") time_start *= 1000;
1677 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1679 start_time_ms = time_start;
1682 kword =
"/gate/application/setTimeStop";
1684 if (values.size()>0)
1688 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1693 if (values.size()>1)
1695 if(values[1] ==
"s") time_stop *= 1000;
1698 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1701 kword =
"/gate/application/addSlice";
1703 if (values.size()>0)
1705 double time_slice_tmp=0;
1709 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1714 if (values.size()>1)
1716 if(values[1] ==
"s") time_slice_tmp *= 1000;
1719 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1721 time_slices = time_slice_tmp;
1726 duration_ms = (time_slices>0) ?
1727 (uint32_t)(time_slices-time_start) :
1730 duration_ms = (time_start>=0 && time_stop>=0) ?
1731 (uint32_t)(time_stop-time_start) :
1738 nCrystalsTot = nCrystalsTransaxial * nCrystalsAxial
1739 * nBlocksLine * nBlocksPerRing;
1745 Cout(
"-----------------------------------------------------" << endl);
1746 Cout(
"ReadMacECAT()-> Information recovered from mac file:" << endl);
1747 Cout(
"-----------------------------------------------------" << endl);
1748 Cout(
"Number of blocks per ring: " << nBlocksPerRing << endl);
1749 Cout(
"Number of axial blocks: " << nBlocksLine << endl);
1750 Cout(
"Number of axial crystals: " << nCrystalsAxial << endl);
1751 Cout(
"Number of transaxial crystals: " << nCrystalsTransaxial << endl);
1752 Cout(
"Total number of crystals: " << nCrystalsTot << endl);
1753 Cout(
"Acquisition start time (ms): " << start_time_ms << endl);
1754 Cout(
"Acquisition duration (ms): " << duration_ms << endl);
1755 Cout(
"-----------------------------------------------------" << endl << endl);
1787 float_t &a_distToDetector,
1789 uint32_t &a_nPixAxl,
1790 uint32_t &a_nPixTrs,
1791 float_t &a_crystalSizeAxl,
1792 float_t &a_crystalSizeTrs,
1793 uint32_t &a_nProjectionsTot,
1794 uint32_t &a_nProjectionsByHead,
1795 float_t &a_head1stAngle,
1796 float_t &a_headAngPitch,
1797 float_t &a_headAngStepDeg,
1798 int &a_headRotDirection,
1799 uint32_t &a_start_time_ms,
1800 uint32_t &a_duration_ms,
1804 vector<string> path_mac_files;
1805 path_mac_files.push_back(a_pathMac);
1809 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover paths to GATE macro files !" << endl);
1813 string head_name =
"SPECThead";
1814 string crystal_name =
"crystal";
1815 string pixel_name =
"pixel";
1816 string head_orbit_name =
"";
1817 bool is_head_Y_axis =
false;
1822 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover aliases for the elements of the ecat !" << endl);
1827 double time_start=-1.,
1832 head_rot_speed =-1.;
1835 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
1837 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
1841 while(getline(mac_file, line))
1843 vector <string> values;
1845 kword =
"/gate/"+head_name+
"/placement/setTranslation";
1847 if (values.size()>0)
1849 FLTNB head_pos_X=0.,
1855 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
1860 if(head_pos_Y!=0) is_head_Y_axis =
true;
1862 a_distToDetector = is_head_Y_axis ? abs(head_pos_Y) : abs(head_pos_X) ;
1867 kword =
"/gate/"+head_name+
"/ring/setRepeatNumber";
1869 if (values.size()>0)
1873 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
1878 kword =
"/gate/"+head_name+
"/ring/setFirstAngle";
1880 if (values.size()>0)
1884 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
1889 kword =
"/gate/"+head_name+
"/ring/setAngularPitch";
1891 if (values.size()>0)
1895 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
1900 kword =
"/gate/"+head_name+
"/moves/insert";
1902 if (values.size()>0)
1906 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
1911 kword =
"/gate/"+head_name+
"/"+head_orbit_name+
"/setSpeed";
1913 if (values.size()>0)
1917 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
1922 kword =
"/gate/"+head_name+
"/"+head_orbit_name+
"/setPoint2";
1924 if (values.size()>0)
1929 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
1937 kword = is_head_Y_axis ?
1938 "/gate/"+crystal_name+
"/geometry/setXLength":
1939 "/gate/"+crystal_name+
"/geometry/setYLength";
1942 if (values.size()>0)
1946 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1952 kword =
"/gate/"+crystal_name+
"/geometry/setZLength";
1954 if (values.size()>0)
1958 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1965 kword = is_head_Y_axis ?
1966 "/gate/"+pixel_name+
"/cubicArray/setRepeatNumberX":
1967 "/gate/"+pixel_name+
"/cubicArray/setRepeatNumberY";
1971 if (values.size()>0)
1975 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1980 kword =
"/gate/"+pixel_name+
"/cubicArray/setRepeatNumberZ";
1982 if (values.size()>0)
1986 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1991 kword =
"/gate/application/setTimeStart";
1993 if (values.size()>0)
1997 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2002 if (values.size()>1)
2004 if(values[1] ==
"s") time_start *= 1000;
2007 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2009 a_start_time_ms = time_start;
2012 kword =
"/gate/application/setTimeSlice";
2014 if (values.size()>0)
2018 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2023 if (values.size()>1)
2025 if(values[1] ==
"s") time_slice *= 1000;
2028 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2030 time_slice_ms = time_slice;
2033 kword =
"/gate/application/setTimeStop";
2035 if (values.size()>0)
2039 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2044 if (values.size()>1)
2046 if(values[1] ==
"s") time_stop *= 1000;
2049 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2052 kword =
"/gate/application/addSlice";
2054 if (values.size()>0)
2056 double time_slice_tmp=0;
2060 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2065 if (values.size()>1)
2067 if(values[1] ==
"s") time_slice_tmp *= 1000;
2070 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2072 time_slices = time_slice_tmp;
2079 a_duration_ms = (time_slices>0) ?
2080 (uint32_t)(time_slices-time_start) :
2084 a_duration_ms = (time_start>=0 && time_stop>=0) ?
2085 (uint32_t)(time_stop-time_start) :
2090 a_nProjectionsByHead = a_duration_ms / time_slice_ms;
2091 a_nProjectionsTot = a_nHeads*a_nProjectionsByHead;
2094 a_headAngPitch = (a_headAngPitch<0) ?
2098 a_headAngStepDeg = head_rot_speed*time_slice_ms/1000.;
2100 if(head_rot_speed<0)
2102 Cerr(
"***** GetGATESystemType() -> Error couldn't find line '/gate/"+head_name+
"/"+head_orbit_name+
"/setSpeed' !" << endl);
2103 Cerr(
" This information is mandatory to compute the projection angle step." << endl);
2109 Cerr(
"***** GetGATESystemType() -> Error couldn't find line '/gate/application/setTimeSlice' !" << endl);
2110 Cerr(
" This information is mandatory to compute the projection angle step." << endl);
2114 if(a_duration_ms == 0)
2118 Cerr(
"***** GetGATESystemType() -> Error couldn't compute acquisition find line '/gate/application/setTimeStop' !" << endl);
2119 Cerr(
" This information is mandatory to compute the acquisition duration." << endl);
2124 Cerr(
"***** GetGATESystemType() -> Error couldn't compute acquisition find line '/gate/application/setTimeStart' !" << endl);
2125 Cerr(
" This information is mandatory to compute the acquisition duration." << endl);
2136 Cout(
"-----------------------------------------------------" << endl);
2137 Cout(
"ReadMacSPECT()-> Information recovered from mac file:" << endl);
2138 Cout(
"-----------------------------------------------------" << endl);
2139 Cout(
"Distance to detector: " << a_distToDetector << endl);
2140 Cout(
"Number of heads: " << a_nHeads << endl);
2141 Cout(
"Number of axial pixels: " << a_nPixAxl << endl);
2142 Cout(
"Number of transaxial pixels: " << a_nPixTrs << endl);
2143 Cout(
"Crystal axial size: " << a_crystalSizeAxl << endl);
2144 Cout(
"Crystal transaxial size: " << a_crystalSizeTrs << endl);
2145 Cout(
"Number of projections per head: " << a_nProjectionsByHead << endl);
2146 Cout(
"Total number of projections: " << a_nProjectionsTot << endl);
2147 Cout(
"Head(s) first transaxial angle: " << a_head1stAngle << endl);
2148 Cout(
"Head(s) angular pitch: " << a_headAngPitch << endl);
2149 Cout(
"Angular step between projections (deg): " << a_headAngStepDeg << endl);
2150 Cout(
"Rotation direction (0=CW, 1=CCW): " << a_headRotDirection << endl);
2151 Cout(
"Acquisition start time (ms): " << a_start_time_ms << endl);
2152 Cout(
"Acquisition duration (ms): " << a_duration_ms << endl);
2153 Cout(
"-----------------------------------------------------" << endl << endl);
2186 float_t &a_distToDetector,
2188 uint32_t &a_nPixAxl,
2189 uint32_t &a_nPixTrs,
2190 float_t &a_crystalSizeAxl,
2191 float_t &a_crystalSizeTrs,
2192 uint32_t &a_nProjectionsTot,
2193 uint32_t &a_nProjectionsByHead,
2194 float_t &a_head1stAngle,
2195 float_t &a_headAngPitchDeg,
2196 float_t &a_headAngStepDeg,
2197 int &a_headRotDirection,
2198 uint32_t &a_start_time_ms,
2199 uint32_t &a_duration_ms,
2206 key =
"matrix size [1]";
2209 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2210 Cerr(
" Either key not found or conversion error" << endl);
2214 key =
"matrix size [2]";
2217 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2218 Cerr(
" Either key not found or conversion error" << endl);
2222 FLTNB size_pix_trs = 1.,
2225 key =
"scaling factor (mm/pixel) [1]";
2228 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2229 Cerr(
" Either key not found or conversion error" << endl);
2233 key =
"scaling factor (mm/pixel) [2]";
2236 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2237 Cerr(
" Either key not found or conversion error" << endl);
2241 key =
"total number of images";
2244 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2245 Cerr(
" Either key not found or conversion error" << endl);
2249 key =
"number of projections";
2252 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2253 Cerr(
" Either key not found or conversion error" << endl);
2257 key =
"number of detector heads";
2260 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2261 Cerr(
" Either key not found or conversion error" << endl);
2265 key =
"study duration (sec)";
2268 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2269 Cerr(
" Either key not found or conversion error" << endl);
2273 a_duration_ms *= 1000;
2276 FLTNB size_crystal_X =0.,
2279 key =
"crystal x dimension (cm)";
2282 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2283 Cerr(
" Either key not found or conversion error" << endl);
2287 key =
"crystal y dimension (cm)";
2290 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2291 Cerr(
" Either key not found or conversion error" << endl);
2295 key =
"crystal z dimension (cm)";
2298 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2299 Cerr(
" Either key not found or conversion error" << endl);
2305 if(size_crystal_X>0 && size_crystal_Y>0)
2306 a_crystalSizeTrs = (size_crystal_X>size_crystal_Y) ? size_crystal_X*10. : size_crystal_Y*10.;
2307 a_crystalSizeAxl = (a_crystalSizeAxl>0) ? a_crystalSizeAxl*10. : a_crystalSizeAxl ;
2310 FLTNB head_pos_X =-1.,
2314 key =
"head x translation (cm)";
2317 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2318 Cerr(
" Either key not found or conversion error" << endl);
2322 key =
"head y translation (cm)";
2325 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2326 Cerr(
" Either key not found or conversion error" << endl);
2330 key =
"head z translation (cm)";
2333 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2334 Cerr(
" Either key not found or conversion error" << endl);
2339 if(head_pos_X > head_pos_Y)
2340 a_distToDetector = head_pos_X > head_pos_Z ? head_pos_X*10 : head_pos_Z*10;
2342 a_distToDetector = head_pos_Y > head_pos_Z ? head_pos_Y*10 : head_pos_Z*10;
2345 key =
"direction of rotation";
2349 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2350 Cerr(
" Either key not found or conversion error" << endl);
2358 key =
"start angle";
2361 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2362 Cerr(
" Either key not found or conversion error" << endl);
2366 key =
"extent of rotation";
2367 uint32_t extent_rotation =360;
2370 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2371 Cerr(
" Either key not found or conversion error" << endl);
2375 a_headAngStepDeg = (
FLTNB)extent_rotation / a_nProjectionsByHead;
2377 float_t first_angle = 0;
2378 float_t second_angle = extent_rotation;
2380 key =
"start angle";
2383 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2384 Cerr(
" Either key not found or conversion error" << endl);
2388 key =
"start angle";
2391 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2392 Cerr(
" Either key not found or conversion error" << endl);
2396 a_headAngPitchDeg = second_angle - first_angle;
2421 string scanner_name =
GetFileFromPath(a_pathGeom.substr(0,a_pathGeom.find(
".geom")));
2422 double scanner_radius = 0.;
2423 uint32_t number_of_elements = 0;
2424 string description =
"PET system extracted from GATE macro: " + a_pathMac;
2427 string rsector_name =
"";
2428 uint32_t number_of_rsectors_ang = 1;
2429 uint32_t number_of_rsectors_axl = 1;
2430 double rsector_step_axl = 0.;
2431 double rsector_gap_axl = 0.;
2432 double rsector_first_angle = 0.;
2433 double rsector_angular_span = 360.;
2434 double rsector_pos_X = 0.;
2435 double rsector_pos_Y = 0.;
2436 uint32_t rsector_nb_zshifts = 0;
2437 vector <double> vec_rsector_Z_Shift;
2438 bool is_rsector_Y_axis =
false;
2439 double rsector_size_trs;
2440 double rsector_size_axl;
2443 string module_name =
"";
2444 uint32_t number_of_modules_trs = 1;
2445 uint32_t number_of_modules_axl = 1;
2446 double module_step_trs = 0.;
2447 double module_step_axl = 0.;
2448 double module_gap_trs = 0.;
2449 double module_gap_axl = 0.;
2450 double module_size_trs;
2451 double module_size_axl;
2454 string submodule_name =
"";
2455 uint32_t number_of_submodules_trs = 1;
2456 uint32_t number_of_submodules_axl = 1;
2457 double submodule_step_trs = 0.;
2458 double submodule_step_axl = 0.;
2459 double submodule_gap_trs = 0.;
2460 double submodule_gap_axl = 0.;
2461 double submodule_size_trs;
2462 double submodule_size_axl;
2465 string crystal_name =
"";
2466 uint32_t number_of_crystals_trs = 1;
2467 uint32_t number_of_crystals_axl = 1;
2468 double crystal_step_trs = 0.;
2469 double crystal_step_axl = 0.;
2470 double crystal_gap_trs = 0.;
2471 double crystal_gap_axl = 0.;
2472 double crystal_size_depth = 0.;
2473 double crystal_size_trs = 0.;
2474 double crystal_size_axl = 0.;
2478 int number_of_layers = 0;
2479 string n_layers =
"1";
2480 vector <uint32_t> number_of_lyr_elts_trs;
2481 vector <uint32_t> number_of_lyr_elts_axl;
2483 vector <string> layers_names;
2484 vector <vector <double> > layers_positions;
2485 vector <double> layers_size_depth;
2486 vector <double> layers_size_trs;
2487 vector <double> layers_size_axl;
2489 vector <double> layers_step_trs;
2490 vector <double> layers_step_axl;
2493 uint32_t voxels_number_trs;
2494 uint32_t voxels_number_axl;
2497 double mean_depth_of_interaction = -1.;
2498 double min_angle_diff = 0.;
2503 vector <string> vec_scanner_radius;
2506 vector <string> vec_number_of_rsectors_ang;
2507 vector <string> vec_number_of_rsectors_axl;
2508 vector <string> vec_rsector_gap_trs;
2509 vector <string> vec_rsector_gap_axl;
2510 vector <string> vec_rsector_first_angle;
2514 vector <string> vec_number_of_modules_trs;
2515 vector <string> vec_number_of_modules_axl;
2516 vector <string> vec_module_gap_trs;
2517 vector <string> vec_module_gap_axl;
2520 vector <string> vec_number_of_submodules_trs;
2521 vector <string> vec_number_of_submodules_axl;
2522 vector <string> vec_submodule_gap_trs;
2523 vector <string> vec_submodule_gap_axl;
2526 vector <string> vec_number_of_crystals_trs;
2527 vector <string> vec_number_of_crystals_axl;
2528 vector <string> vec_crystal_gap_trs;
2529 vector <string> vec_crystal_gap_axl;
2532 vector <string> vec_mean_depth_of_interaction;
2533 vector <string> vec_min_angle_diff;
2535 vector<string> path_mac_files;
2536 path_mac_files.push_back(a_pathMac);
2541 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover paths to GATE macro files !" << endl);
2546 if(
GetGATEAliasesCylindrical(path_mac_files, rsector_name, module_name, submodule_name, crystal_name, layers_names, 2) )
2548 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover aliases for the elements of the cylindricalPET !" << endl);
2553 n_layers = layers_names.size();
2557 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
2559 ifstream systemMac(path_mac_files[f].c_str(), ios::in);
2563 while(getline(systemMac, line))
2565 vector <string> values;
2572 entry =
"/gate/"+rsector_name+
"/placement/setTranslation";
2576 if (values.size()>0)
2581 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2587 if(rsector_pos_X!=0 && rsector_pos_Y !=0)
2589 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2590 Cerr(
" Rsector cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
2595 if(rsector_pos_Y!=0) is_rsector_Y_axis =
true;
2598 scanner_radius += is_rsector_Y_axis ? abs(rsector_pos_Y) : abs(rsector_pos_X) ;
2623 entry = is_rsector_Y_axis ?
2624 "/gate/"+rsector_name+
"/geometry/setXLength":
2625 "/gate/"+rsector_name+
"/geometry/setYLength";
2628 if (values.size()>0)
2632 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2641 entry =
"/gate/"+rsector_name+
"/ring/setModuloNumber";
2643 if (values.size()>0)
2647 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2652 entry =
"/gate/"+rsector_name+
"/ring/setRepeatNumber";
2654 if (values.size()>0)
2658 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2666 entry =
"/gate/"+rsector_name+
"/linear/setRepeatNumber";
2668 if (values.size()>0)
2672 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2680 entry =
"/gate/"+rsector_name+
"/linear/setRepeatVector";
2682 if (values.size()>0)
2686 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2693 entry = is_rsector_Y_axis ?
2694 "/gate/"+rsector_name+
"/cubicArray/setRepeatNumberX":
2695 "/gate/"+rsector_name+
"/cubicArray/setRepeatNumberY";
2698 if (values.size()>0)
2700 uint32_t number_of_rsectors_trs;
2704 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2711 if(number_of_rsectors_trs>1)
2713 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Error while trying to parse line: " << line<< endl);
2714 Cerr(
" The GATE system contains more than one 'transaxial' rsector " << endl);
2715 Cerr(
" The current implementation does not support such cylindricalPET model" << endl);
2716 Cerr(
" Manual implementation of the system is required (ex: model the transaxial rsectors as modules)" << endl);
2722 entry =
"/gate/"+rsector_name+
"/cubicArray/setRepeatNumberZ";
2725 if (values.size()>0)
2729 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2735 entry =
"/gate/"+rsector_name+
"/cubicArray/setRepeatVector";
2737 if (values.size()>0)
2741 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2749 entry =
"/gate/"+rsector_name+
"/geometry/setZLength";
2751 if (values.size()>0)
2755 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2762 entry =
"/gate/"+rsector_name+
"/ring/setFirstAngle";
2764 if (values.size()>0)
2768 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2773 entry =
"/gate/"+rsector_name+
"/ring/setAngularSpan";
2775 if (values.size()>0)
2779 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2785 for (
int i=1; i <8; i++)
2787 entry =
"/gate/"+rsector_name+
"/ring/setZShift"+
toString(i);
2789 if (values.size()>0)
2794 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2798 vec_rsector_Z_Shift.push_back(zshift);
2807 entry =
"/gate/"+module_name+
"/placement/setTranslation";
2810 FLTNB module_pos_X =0.,
2814 if (values.size()>0)
2819 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2825 if(module_pos_X!=0 && module_pos_Y !=0)
2827 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2828 Cerr(
" Module cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
2833 scanner_radius += is_rsector_Y_axis ? abs(module_pos_Y) : abs(module_pos_X) ;
2837 entry = is_rsector_Y_axis ?
2838 "/gate/"+module_name+
"/cubicArray/setRepeatNumberX":
2839 "/gate/"+module_name+
"/cubicArray/setRepeatNumberY";
2842 if (values.size()>0)
2846 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2854 entry =
"/gate/"+module_name+
"/cubicArray/setRepeatNumberZ";
2857 if (values.size()>0)
2861 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2867 entry = is_rsector_Y_axis ?
2868 "/gate/"+module_name+
"/geometry/setXLength":
2869 "/gate/"+module_name+
"/geometry/setYLength";
2872 if (values.size()>0)
2876 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2882 entry =
"/gate/"+module_name+
"/geometry/setZLength";
2884 if (values.size()>0)
2888 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2893 entry =
"/gate/"+module_name+
"/cubicArray/setRepeatVector";
2895 if (values.size()>0)
2897 string trs_step = is_rsector_Y_axis ?
2904 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2913 entry =
"/gate/"+module_name+
"/linear/setRepeatNumber";
2916 if (values.size()>0)
2920 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2925 entry =
"/gate/"+module_name+
"/linear/setRepeatVector";
2927 if (values.size()>0)
2931 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2940 entry =
"/gate/"+submodule_name+
"/placement/setTranslation";
2943 FLTNB submodule_pos_X =0.,
2944 submodule_pos_Y =0.;
2947 if (values.size()>0)
2952 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2958 if(submodule_pos_X!=0 && submodule_pos_Y !=0)
2960 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2961 Cerr(
" Submodule cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
2966 scanner_radius += is_rsector_Y_axis ? abs(submodule_pos_Y) : abs(submodule_pos_X) ;
2971 entry = is_rsector_Y_axis ?
2972 "/gate/"+submodule_name+
"/cubicArray/setRepeatNumberX":
2973 "/gate/"+submodule_name+
"/cubicArray/setRepeatNumberY";
2977 if (values.size()>0)
2981 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2986 entry =
"/gate/"+submodule_name+
"/cubicArray/setRepeatNumberZ";
2988 if (values.size()>0)
2992 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3000 entry = is_rsector_Y_axis ?
3001 "/gate/"+submodule_name+
"/geometry/setXLength":
3002 "/gate/"+submodule_name+
"/geometry/setYLength";
3005 if (values.size()>0)
3009 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3014 entry =
"/gate/"+submodule_name+
"/geometry/setZLength";
3016 if (values.size()>0)
3020 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3025 entry =
"/gate/"+submodule_name+
"/cubicArray/setRepeatVector";
3027 if (values.size()>0)
3029 string trs_step = is_rsector_Y_axis ?
3036 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3044 entry =
"/gate/"+submodule_name+
"/linear/setRepeatNumber";
3047 if (values.size()>0)
3051 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3057 entry =
"/gate/"+submodule_name+
"/linear/setRepeatVector";
3059 if (values.size()>0)
3063 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3074 entry =
"/gate/"+crystal_name+
"/placement/setTranslation";
3077 FLTNB crystal_pos_X =0.,
3081 if (values.size()>0)
3086 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3092 if(crystal_pos_X!=0 && crystal_pos_Y !=0)
3094 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3095 Cerr(
" Crystal cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
3100 scanner_radius += is_rsector_Y_axis ? abs(crystal_pos_Y) : abs(crystal_pos_X) ;
3105 entry = is_rsector_Y_axis ?
3106 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberX":
3107 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
3111 if (values.size()>0)
3115 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3120 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberZ";
3122 if (values.size()>0)
3126 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3132 entry =
"/gate/"+crystal_name+
"/geometry/setXLength";
3134 if (values.size()>0)
3139 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3143 if (is_rsector_Y_axis)
3144 crystal_size_trs = x_length;
3146 crystal_size_depth = x_length;
3149 entry =
"/gate/"+crystal_name+
"/geometry/setYLength";
3151 if (values.size()>0)
3156 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3160 if (is_rsector_Y_axis)
3161 crystal_size_depth = y_length;
3163 crystal_size_trs = y_length;
3167 entry =
"/gate/"+crystal_name+
"/geometry/setZLength";
3169 if (values.size()>0)
3173 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3178 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatVector";
3180 if (values.size()>0)
3182 string trs_step = is_rsector_Y_axis ?
3189 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3195 entry =
"/gate/"+crystal_name+
"/linear/setRepeatNumber";
3198 if (values.size()>0)
3202 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3207 entry =
"/gate/"+crystal_name+
"/linear/setRepeatVector";
3209 if (values.size()>0)
3213 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3220 entry =
"/gate/"+crystal_name+
"/daughters/name";
3222 if (values.size()>0)
3224 layers_names.push_back(values[0]);
3229 for (
int i=0; i < number_of_layers; i++)
3232 entry =
"/gate/"+layers_names[i]+
"/placement/setTranslation";
3235 if (values.size()>0)
3237 vector<double> layer_pos;
3238 for(
int d=0 ; d<3 ; d++)
3243 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3246 layer_pos.push_back(pos);
3249 if(is_rsector_Y_axis)
3251 double pos = layer_pos[1];
3252 layer_pos[1] = layer_pos[0];
3256 layers_positions.push_back(layer_pos);
3261 entry =
"/gate/"+layers_names[i]+
"/geometry/setXLength";
3264 if (values.size()>0)
3269 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3273 if (is_rsector_Y_axis)
3274 layers_size_trs.push_back(xlength);
3276 layers_size_depth.push_back(xlength);
3280 entry =
"/gate/"+layers_names[i]+
"/geometry/setYLength";
3282 if (values.size()>0)
3287 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3290 if (is_rsector_Y_axis)
3291 layers_size_depth.push_back(ylength);
3293 layers_size_trs.push_back(ylength);
3296 entry =
"/gate/"+layers_names[i]+
"/geometry/setZLength";
3298 if (values.size()>0)
3303 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3306 layers_size_axl.push_back(zlength);
3312 entry = is_rsector_Y_axis ?
3313 "/gate/"+layers_names[i]+
"/cubicArray/setRepeatNumberX":
3314 "/gate/"+layers_names[i]+
"/cubicArray/setRepeatNumberY";
3317 if (values.size()>0)
3322 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3325 number_of_lyr_elts_trs.push_back(step_trs);
3328 entry =
"/gate/"+layers_names[i]+
"/cubicArray/setRepeatNumberZ";
3330 if (values.size()>0)
3335 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3338 number_of_lyr_elts_axl.push_back(step_axl);
3341 entry =
"/gate/"+layers_names[i]+
"/cubicArray/setRepeatVector";
3343 if (values.size()>0)
3345 string trs_step = is_rsector_Y_axis ?
3349 double step_trs, step_axl;
3353 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3358 layers_step_trs.push_back(step_trs);
3359 layers_step_axl.push_back(step_axl);
3364 entry =
"/gate/"+layers_names[i]+
"/linear/setRepeatNumber";
3367 if (values.size()>0)
3372 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3375 number_of_lyr_elts_axl.push_back(step_axl);
3379 entry =
"/gate/"+layers_names[i]+
"/linear/setRepeatVector";
3381 if (values.size()>0)
3386 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3390 layers_step_axl.push_back(step_axl);
3395 entry =
"/gate/digitizer/Coincidences/minSectorDifference";
3397 if (values.size()>0)
3399 FLTNB min_sector_diff= 0.;
3403 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3407 min_angle_diff = 360./number_of_rsectors_ang*min_sector_diff;
3416 if(number_of_layers == 0)
3418 number_of_elements = number_of_rsectors_ang
3419 * number_of_rsectors_axl
3420 * number_of_modules_trs
3421 * number_of_modules_axl
3422 * number_of_submodules_trs
3423 * number_of_submodules_axl
3424 * number_of_crystals_trs
3425 * number_of_crystals_axl;
3428 for(
int l=0 ; l<number_of_layers ; l++)
3430 int32_t nb_crystals_layer = number_of_rsectors_ang
3431 * number_of_rsectors_axl
3432 * number_of_modules_trs
3433 * number_of_modules_axl
3434 * number_of_submodules_trs
3435 * number_of_submodules_axl
3436 * number_of_crystals_trs
3437 * number_of_crystals_axl;
3440 if(number_of_lyr_elts_trs.size()>0 || number_of_lyr_elts_axl.size()>0 )
3441 nb_crystals_layer *= number_of_lyr_elts_trs[l] * number_of_lyr_elts_axl[l];
3443 number_of_elements += nb_crystals_layer;
3450 if (crystal_step_axl - crystal_size_axl >= 0)
3451 crystal_gap_axl = crystal_step_axl - crystal_size_axl;
3453 if (crystal_step_trs - crystal_size_trs >= 0)
3454 crystal_gap_trs = crystal_step_trs - crystal_size_trs;
3457 submodule_size_axl = crystal_size_axl*number_of_crystals_axl + crystal_gap_axl*(number_of_crystals_axl-1);
3458 submodule_size_trs = crystal_size_trs*number_of_crystals_trs + crystal_gap_trs*(number_of_crystals_trs-1);
3461 if (submodule_step_axl - submodule_size_axl >= 0)
3462 submodule_gap_axl = submodule_step_axl - submodule_size_axl;
3464 if (submodule_step_trs - submodule_size_trs >= 0)
3465 submodule_gap_trs = submodule_step_trs - submodule_size_trs;
3468 module_size_axl = submodule_size_axl*number_of_submodules_axl + submodule_gap_axl*(number_of_submodules_axl-1);
3469 module_size_trs = submodule_size_trs*number_of_submodules_trs + submodule_gap_trs*(number_of_submodules_trs-1);
3472 if (module_step_axl - module_size_axl >= 0)
3473 module_gap_axl = module_step_axl - module_size_axl;
3475 if (module_step_trs - module_size_trs >= 0)
3476 module_gap_trs = module_step_trs - module_size_trs;
3479 rsector_size_axl = module_size_axl*number_of_modules_axl + module_gap_axl*(number_of_modules_axl-1);
3480 rsector_size_trs = module_size_trs*number_of_modules_trs + module_gap_trs*(number_of_modules_trs-1);
3484 if (rsector_step_axl - rsector_size_axl >= 0)
3485 rsector_gap_axl = rsector_step_axl - rsector_size_axl;
3489 fov_axl = rsector_size_axl * number_of_rsectors_axl
3490 + (number_of_rsectors_axl-1)*rsector_gap_axl;
3494 voxels_number_axl = ( number_of_crystals_axl
3495 * number_of_submodules_axl
3496 * number_of_modules_axl
3497 * number_of_rsectors_axl )
3501 fov_trs = (2*scanner_radius ) / 1.5;
3505 voxels_number_trs = ( number_of_crystals_trs
3506 * number_of_submodules_trs
3507 * number_of_modules_trs
3508 * number_of_rsectors_ang )
3514 rsector_first_angle -= round(atan2f(rsector_pos_X , rsector_pos_Y) * 180. / M_PI);
3517 if (number_of_layers > 0)
3519 for (
int l=0; l < number_of_layers ; l++)
3522 vec_scanner_radius.push_back(
toString(scanner_radius
3523 +layers_positions[ l ][ 0 ]
3524 -layers_size_depth[ l ] / 2. ) );
3527 vec_number_of_rsectors_ang.push_back(
toString(number_of_rsectors_ang) );
3528 vec_number_of_rsectors_axl.push_back(
toString(number_of_rsectors_axl) );
3529 vec_rsector_gap_axl.push_back(
toString(rsector_gap_axl) );
3530 vec_rsector_first_angle.push_back(
toString(rsector_first_angle) );
3533 vec_number_of_modules_trs.push_back(
toString(number_of_modules_trs) );
3534 vec_number_of_modules_axl.push_back(
toString(number_of_modules_axl) );
3535 vec_module_gap_trs.push_back(
toString(module_gap_trs) );
3536 vec_module_gap_axl.push_back(
toString(module_gap_axl) );
3539 vec_number_of_submodules_trs.push_back(
toString(number_of_submodules_trs) );
3540 vec_number_of_submodules_axl.push_back(
toString(number_of_submodules_axl) );
3541 vec_submodule_gap_trs.push_back(
toString(submodule_gap_trs) );
3542 vec_submodule_gap_axl.push_back(
toString(submodule_gap_axl) );
3545 uint32_t nb_tot_trs_cry = (number_of_lyr_elts_trs.size()>0) ?
3546 number_of_lyr_elts_trs[l]*number_of_crystals_trs :
3547 number_of_crystals_trs ;
3549 uint32_t nb_tot_axl_cry = (number_of_lyr_elts_axl.size()>0) ?
3550 number_of_lyr_elts_axl[l]*number_of_crystals_axl :
3551 number_of_crystals_axl ;
3553 vec_number_of_crystals_trs.push_back(
toString(nb_tot_trs_cry) );
3554 vec_number_of_crystals_axl.push_back(
toString(nb_tot_axl_cry) );
3559 if(layers_step_trs.size()>0 ||
3560 layers_step_axl.size()>0)
3562 if (layers_step_trs[l] - layers_size_trs[l] >= 0)
3563 crystal_gap_trs = layers_step_trs[l] - layers_size_trs[l];
3565 if (layers_step_axl[l] - layers_size_axl[l] >= 0)
3566 crystal_gap_axl = layers_step_axl[l] - layers_size_axl[l];
3569 vec_crystal_gap_trs.push_back(
toString(crystal_gap_trs) );
3570 vec_crystal_gap_axl.push_back(
toString(crystal_gap_axl) );
3573 vec_mean_depth_of_interaction.push_back(
toString(mean_depth_of_interaction) );
3574 vec_min_angle_diff.push_back(
toString(min_angle_diff) );
3580 layers_size_depth.push_back( crystal_size_depth );
3581 layers_size_trs.push_back( crystal_size_trs );
3582 layers_size_axl.push_back( crystal_size_axl );
3586 vec_scanner_radius.push_back(
toString(scanner_radius - crystal_size_depth/2) );
3589 vec_number_of_rsectors_ang.push_back(
toString(number_of_rsectors_ang) );
3590 vec_number_of_rsectors_axl.push_back(
toString(number_of_rsectors_axl) );
3591 vec_rsector_gap_axl.push_back(
toString(rsector_gap_axl) );
3592 vec_rsector_first_angle.push_back(
toString(rsector_first_angle) );
3595 vec_number_of_modules_trs.push_back(
toString(number_of_modules_trs) );
3596 vec_number_of_modules_axl.push_back(
toString(number_of_modules_axl) );
3597 vec_module_gap_trs.push_back(
toString(module_gap_trs) );
3598 vec_module_gap_axl.push_back(
toString(module_gap_axl) );
3601 vec_number_of_submodules_trs.push_back(
toString(number_of_submodules_trs) );
3602 vec_number_of_submodules_axl.push_back(
toString(number_of_submodules_axl) );
3603 vec_submodule_gap_trs.push_back(
toString(submodule_gap_trs) );
3604 vec_submodule_gap_axl.push_back(
toString(submodule_gap_axl) );
3607 vec_number_of_crystals_trs.push_back(
toString(number_of_crystals_trs) );
3608 vec_number_of_crystals_axl.push_back(
toString(number_of_crystals_axl) );
3609 vec_crystal_gap_trs.push_back(
toString(crystal_gap_trs) );
3610 vec_crystal_gap_axl.push_back(
toString(crystal_gap_axl) );
3613 vec_mean_depth_of_interaction.push_back(
toString(mean_depth_of_interaction) );
3614 vec_min_angle_diff.push_back(
toString(min_angle_diff) );
3617 number_of_layers = 1;
3622 ofstream fileGeom(a_pathGeom.c_str(), ios::out | ios::trunc);
3625 fileGeom <<
"# comments" << endl;
3626 fileGeom <<
"# Y _________ "<< endl;
3627 fileGeom <<
"# | / _ \\ \\ "<< endl;
3628 fileGeom <<
"# | | / \\ | |"<< endl;
3629 fileGeom <<
"# |_____ Z | | | | |"<< endl;
3630 fileGeom <<
"# \\ | | | | |" << endl;
3631 fileGeom <<
"# \\ | \\_/ | |" << endl;
3632 fileGeom <<
"# X \\___/_____/" << endl;
3633 fileGeom <<
"# Left-handed axis orientation"<< endl;
3634 fileGeom <<
"# scanner axis is z" << endl;
3635 fileGeom <<
"# positions in millimeters"<< endl;
3636 fileGeom <<
"# Use comma without space as separator in the tables." << endl;
3638 fileGeom <<
""<< endl;
3641 fileGeom <<
"# MANDATORY FIELDS"<< endl;
3642 fileGeom <<
"modality : " << modality << endl;
3643 fileGeom <<
"scanner name : " << scanner_name << endl;
3644 fileGeom <<
"number of elements : " << number_of_elements << endl;
3645 fileGeom <<
"number of layers : " << number_of_layers << endl;
3646 fileGeom <<
"" << endl;
3647 fileGeom <<
"voxels number transaxial : " << voxels_number_trs << endl;
3648 fileGeom <<
"voxels number axial : " << voxels_number_axl << endl;
3650 fileGeom <<
"field of view transaxial : " << fov_trs << endl;
3651 fileGeom <<
"field of view axial : " << fov_axl << endl << endl;
3652 fileGeom <<
"description : " << description << endl;
3653 fileGeom <<
"" << endl;
3654 WriteVector(fileGeom,
"scanner radius : ",vec_scanner_radius);
3655 WriteVector(fileGeom,
"number of rsectors : ",vec_number_of_rsectors_ang);
3656 WriteVector(fileGeom,
"number of crystals transaxial : ",vec_number_of_crystals_trs);
3657 WriteVector(fileGeom,
"number of crystals axial : ",vec_number_of_crystals_axl);
3658 fileGeom <<
""<< endl;
3659 WriteVector(fileGeom,
"crystals size depth : ", layers_size_depth);
3660 WriteVector(fileGeom,
"crystals size transaxial : ", layers_size_trs);
3661 WriteVector(fileGeom,
"crystals size axial : ", layers_size_axl);
3662 fileGeom <<
""<< endl;
3663 fileGeom <<
""<< endl;
3666 fileGeom <<
"# OPTIONAL FIELDS"<< endl;
3667 WriteVector(fileGeom,
"rsectors first angle : ",vec_rsector_first_angle);
3668 WriteVector(fileGeom,
"number of rsectors axial : ",vec_number_of_rsectors_axl);
3669 WriteVector(fileGeom,
"rsector gap transaxial : ",vec_rsector_gap_trs);
3670 WriteVector(fileGeom,
"rsector gap axial : ",vec_rsector_gap_axl);
3671 WriteVector(fileGeom,
"number of modules transaxial : ",vec_number_of_modules_trs);
3672 WriteVector(fileGeom,
"number of modules axial : ",vec_number_of_modules_axl);
3673 WriteVector(fileGeom,
"module gap transaxial : ",vec_module_gap_trs);
3674 WriteVector(fileGeom,
"module gap axial : ",vec_module_gap_axl);
3675 WriteVector(fileGeom,
"number of submodules transaxial : ",vec_number_of_submodules_trs);
3676 WriteVector(fileGeom,
"number of submodules axial : ",vec_number_of_submodules_axl);
3677 WriteVector(fileGeom,
"submodule gap transaxial : ",vec_submodule_gap_trs);
3678 WriteVector(fileGeom,
"submodule gap axial : ",vec_submodule_gap_axl);
3679 WriteVector(fileGeom,
"crystal gap transaxial : ",vec_crystal_gap_trs);
3680 WriteVector(fileGeom,
"crystal gap axial : ",vec_crystal_gap_axl);
3681 WriteVector(fileGeom,
"mean depth of interaction : ", vec_mean_depth_of_interaction);
3682 fileGeom <<
"rotation direction : CCW " << endl;
3683 fileGeom <<
""<< endl;
3686 if(min_angle_diff > 0.) fileGeom <<
"min angle difference : " << min_angle_diff << endl;
3689 if(rsector_angular_span >= 360.0005 ||
3690 rsector_angular_span <= 359.9995 )
3692 rsector_angular_span *= (double)number_of_rsectors_ang/(
double)(number_of_rsectors_ang-1);
3693 fileGeom <<
"rsectors angular span : " << rsector_angular_span << endl;
3696 if(rsector_nb_zshifts > 0) fileGeom <<
"rsectors nbZShift :" << rsector_nb_zshifts << endl;
3697 if(!vec_rsector_Z_Shift.empty())
WriteVector(fileGeom,
"rsectors ZShift : ", vec_rsector_Z_Shift);
3701 cout <<
"Output geom file written at :" << a_pathGeom << endl;
3705 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Couldn't open geom file for writing "<< a_pathGeom <<
" !" << endl);
3733 string scanner_name =
GetFileFromPath(a_pathGeom.substr(0,a_pathGeom.find_first_of(
".geom")));
3734 double scanner_radius = 0.;
3735 uint32_t number_of_elements = 0;
3736 string description =
"ECAT system extracted from GATE macro: " + a_pathMac;
3739 string block_name =
"block";
3740 uint32_t number_of_blocks = 1;
3741 uint32_t number_of_blocks_trs = 1;
3742 uint32_t number_of_blocks_axl = 1;
3743 double block_step_trs = 0.;
3744 double block_step_axl = 0.;
3745 double block_gap_trs = 0.;
3746 double block_gap_axl = 0.;
3747 double block_size_Y;
3748 double block_size_Z;
3749 double block_pos_X = 0.;
3750 double block_pos_Y = 0.;
3751 double block_first_angle = 0.;
3752 double block_angular_span = 360.;
3753 uint32_t block_nb_zshifts = 0;
3754 vector <double> vec_block_Z_Shift;
3755 bool is_block_Y_axis =
false;
3760 string crystal_name =
"crystal";
3761 uint32_t number_of_crystals_trs = 1;
3762 uint32_t number_of_crystals_axl = 1;
3763 double crystal_step_trs = 0.;
3764 double crystal_step_axl = 0.;
3765 double crystal_gap_trs = 0.;
3766 double crystal_gap_axl = 0.;
3767 double crystal_size_depth = 0.;
3768 double crystal_size_trs = 0.;
3769 double crystal_size_axl = 0.;
3772 uint32_t voxels_number_trs;
3773 uint32_t voxels_number_axl;
3776 double min_angle_diff = 0.;
3778 vector<string> path_mac_files;
3779 path_mac_files.push_back(a_pathMac);
3784 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()->Error occurred when trying to recover paths to GATE macro files !" << endl);
3792 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()->Error occurred when trying to recover aliases for the elements of the ecat !" << endl);
3798 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
3800 ifstream systemMac(path_mac_files[f].c_str(), ios::in);
3803 while(getline(systemMac, line))
3807 vector <string> values;
3811 entry =
"/gate/"+block_name+
"/placement/setTranslation";
3813 if (values.size()>0)
3818 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
3824 if(block_pos_X!=0 && block_pos_Y !=0)
3826 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
3827 Cerr(
" Block cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
3832 if(block_pos_Y!=0) is_block_Y_axis =
true;
3834 scanner_radius += is_block_Y_axis ? abs(block_pos_Y) : abs(block_pos_X) ;
3859 entry =
"/gate/"+block_name+
"/geometry/setZLength";
3861 if (values.size()>0)
3865 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
3869 voxels_number_axl = fov_axl/4 + 1;
3874 entry =
"/gate/"+block_name+
"/ring/setRepeatNumber";
3876 if (values.size()>0)
3880 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
3886 entry =
"/gate/"+block_name+
"/ring/setFirstAngle";
3888 if (values.size()>0)
3892 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
3898 entry =
"/gate/"+block_name+
"/ring/setAngularSpan";
3900 if (values.size()>0)
3904 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
3909 entry =
"/gate/"+block_name+
"/ring/setModuloNumber";
3911 if (values.size()>0)
3915 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3920 for (
int i=1; i<8; i++)
3922 entry =
"/gate/"+block_name+
"/ring/setZShift"+
toString(i);
3924 if (values.size()>0)
3929 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
3932 vec_block_Z_Shift.push_back(zshift);
3940 entry =
"/gate/"+block_name+
"/linear/setRepeatNumber";
3942 if (values.size()>0)
3946 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
3952 entry =
"/gate/"+block_name+
"/linear/setRepeatVector";
3954 if (values.size()>0)
3958 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
3967 entry =
"/gate/"+crystal_name+
"/placement/setTranslation";
3970 FLTNB crystal_pos_X =0.,
3973 if (values.size()>0)
3978 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
3984 if(crystal_pos_X!=0 && crystal_pos_Y !=0)
3986 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
3987 Cerr(
" Block cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
3991 scanner_radius += is_block_Y_axis ? abs(crystal_pos_Y) : abs(crystal_pos_X) ;
3995 entry = is_block_Y_axis ?
3996 "/gate/"+crystal_name+
"/geometry/setYLength" :
3997 "/gate/"+crystal_name+
"/geometry/setXLength";
4000 if (values.size()>0)
4002 double crystal_size = 0.;
4005 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4009 scanner_radius -= crystal_size/2;
4015 entry = is_block_Y_axis ?
4016 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberX":
4017 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
4020 if (values.size()>0)
4024 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4029 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberZ";
4031 if (values.size()>0)
4035 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4041 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatVector";
4043 if (values.size()>0)
4045 string trs_step = is_block_Y_axis ?
4052 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4059 entry =
"/gate/"+crystal_name+
"/geometry/setXLength";
4061 if (values.size()>0)
4066 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4070 if (is_block_Y_axis)
4071 crystal_size_trs = x_length;
4073 crystal_size_depth = x_length;
4078 entry =
"/gate/"+crystal_name+
"/geometry/setYLength";
4080 if (values.size()>0)
4085 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4089 if (is_block_Y_axis)
4090 crystal_size_depth = y_length;
4092 crystal_size_trs = y_length;
4095 entry =
"/gate/"+crystal_name+
"/geometry/setZLength";
4097 if (values.size()>0)
4101 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4109 entry =
"/gate/digitizer/Coincidences/minSectorDifference";
4111 if (values.size()>0)
4113 double min_sector_diff;
4116 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4119 min_angle_diff = 360/number_of_blocks*min_sector_diff;
4126 number_of_elements = number_of_blocks *
4127 number_of_blocks_axl *
4128 number_of_crystals_trs *
4129 number_of_crystals_axl;
4134 fov_trs = (2*scanner_radius ) / 1.5;
4137 voxels_number_trs = ( number_of_crystals_trs
4138 * number_of_blocks_trs)
4142 if (crystal_step_axl - crystal_size_axl >= 0)
4143 crystal_gap_axl = crystal_step_axl - crystal_size_axl;
4145 if (crystal_step_trs - crystal_size_trs >= 0)
4146 crystal_gap_trs = crystal_step_trs - crystal_size_trs;
4150 block_size_Z = crystal_size_axl*number_of_crystals_axl + crystal_gap_axl*(number_of_crystals_axl-1);
4151 block_size_Y = crystal_size_trs*number_of_crystals_trs + crystal_gap_trs*(number_of_crystals_trs-1);
4154 if (block_step_axl - block_size_Z >= 0)
4155 block_gap_axl = block_step_axl - block_size_Z;
4157 if (block_step_trs - block_size_Y >= 0)
4158 block_gap_trs = block_step_trs - block_size_Y;
4161 block_first_angle -= round(atan2f(block_pos_X , block_pos_Y) * 180. / M_PI);
4165 ofstream fileGeom(a_pathGeom.c_str(), ios::out | ios::trunc);
4169 fileGeom <<
"# comments" << endl;
4170 fileGeom <<
"# Y _________ "<< endl;
4171 fileGeom <<
"# | / _ \\ \\ "<< endl;
4172 fileGeom <<
"# | | / \\ | |"<< endl;
4173 fileGeom <<
"# |_____ Z | | | | |"<< endl;
4174 fileGeom <<
"# \\ | | | | |" << endl;
4175 fileGeom <<
"# \\ | \\_/ | |" << endl;
4176 fileGeom <<
"# X \\___/_____/" << endl;
4177 fileGeom <<
"# Left-handed axis orientation"<< endl;
4178 fileGeom <<
"# scanner axis is z" << endl;
4179 fileGeom <<
"# positions in millimeters"<< endl;
4180 fileGeom <<
"# Use comma without space as separator in the tables." << endl;
4183 fileGeom <<
"modality : " << modality << endl;
4184 fileGeom <<
"scanner name : " << scanner_name << endl;
4185 fileGeom <<
"number of elements : " << number_of_elements << endl;
4186 fileGeom <<
"number of layers : " <<
"1" << endl;
4187 fileGeom <<
"" << endl;
4188 fileGeom <<
"# default reconstruction parameters" << endl;
4189 fileGeom <<
"voxels number transaxial : " << voxels_number_trs << endl;
4190 fileGeom <<
"voxels number axial : " << voxels_number_axl << endl;
4192 fileGeom <<
"field of view transaxial : " << fov_trs << endl;
4193 fileGeom <<
"field of view axial : " << fov_axl << endl;
4194 fileGeom <<
"" << endl;
4195 fileGeom <<
"description : " << description << endl;
4196 fileGeom <<
"" << endl;
4197 fileGeom <<
"scanner radius : " << scanner_radius << endl;
4198 fileGeom <<
"number of rsectors : " << number_of_blocks << endl;
4199 fileGeom <<
"number of crystals transaxial : " << number_of_crystals_trs << endl;
4200 fileGeom <<
"number of crystals axial : " << number_of_crystals_axl << endl;
4202 fileGeom <<
""<< endl;
4203 fileGeom <<
"# The 4 following parameters could be defined in arrays (SizeLayer1,SizeLayer2,SizeLayer3,etc..) if their is more than one layer"<< endl;
4204 fileGeom <<
"crystals size depth : " << crystal_size_depth << endl;
4205 fileGeom <<
"crystals size transaxial : " << crystal_size_trs << endl;
4206 fileGeom <<
"crystals size axial : " << crystal_size_axl << endl;
4207 fileGeom <<
""<< endl;
4210 fileGeom <<
"rsectors first angle : " << block_first_angle << endl;
4211 fileGeom <<
"number of modules transaxial : " << number_of_blocks_trs << endl;
4212 fileGeom <<
"number of modules axial : " << number_of_blocks_axl << endl;
4213 fileGeom <<
"module gap transaxial : " << block_gap_trs << endl;
4214 fileGeom <<
"module gap axial : " << block_gap_axl << endl;
4215 fileGeom <<
"crystal gap transaxial : " << crystal_gap_trs << endl;
4216 fileGeom <<
"crystal gap axial : " << crystal_gap_axl << endl;
4217 fileGeom <<
"rotation direction : CCW " << endl;
4218 fileGeom <<
""<< endl;
4221 if(min_angle_diff > 0.) fileGeom <<
"min angle difference : " << min_angle_diff << endl;
4224 if(block_angular_span >= 360.0005 ||
4225 block_angular_span <= 359.9995 )
4227 block_angular_span *= (double)(number_of_blocks)/(double)(number_of_blocks-1);
4228 fileGeom <<
"rsectors angular span : " << block_angular_span << endl;
4231 if(block_nb_zshifts > 0) fileGeom <<
"rsectors nbZShift :" << block_nb_zshifts << endl;
4232 if(!vec_block_Z_Shift.empty())
WriteVector(fileGeom,
"rsectors ZShift : ", vec_block_Z_Shift);
4236 Cout(
"Output geom file written at :" << a_pathGeom << endl);
4240 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Couldn't open geom file for writing "<< a_pathGeom <<
" !" << endl);
4265 string scanner_name =
GetFileFromPath(a_pathGeom.substr(0,a_pathGeom.find_first_of(
".geom")));
4266 FLTNB scanner_radius = -1.;
4267 string description =
"SPECT camera extracted from GATE macro: " + a_pathMac;
4270 string head_name =
"SPECThead";
4271 uint32_t number_of_heads = 0;
4272 FLTNB head_pos_X = 0.;
4273 FLTNB head_pos_Y = 0.;
4274 FLTNB head_first_angle = 0.;
4275 FLTNB head_angular_pitch = -1.;
4276 string head_orbit_name =
"";
4277 FLTNB head_rotation_speed = 0.;
4278 bool is_head_Y_axis =
false;
4281 string crystal_name =
"crystal";
4282 FLTNB crystal_size_trs = 0.;
4283 FLTNB crystal_size_axl = 0.;
4284 FLTNB crystal_depth = 0;
4287 string pixel_name =
"pixel";
4288 uint32_t number_of_pixels_trs = 1;
4289 uint32_t number_of_pixels_axl = 1;
4290 FLTNB pix_size_trs = 0.;
4291 FLTNB pix_size_axl = 0.;
4292 FLTNB pix_step_trs = 0.;
4293 FLTNB pix_step_axl = 0.;
4294 FLTNB pix_gap_trs = 0.;
4295 FLTNB pix_gap_axl = 0.;
4298 string focal_model_trs =
"constant";
4299 uint16_t nb_coeff_model_trs = 1;
4300 FLTNB coeff_model_trs = 0.;
4301 string focal_model_axl =
"constant";
4302 uint16_t nb_coeff_model_axl = 1;
4303 FLTNB coeff_model_axl = 0.;
4306 uint32_t voxels_number_trs;
4307 uint32_t voxels_number_axl;
4311 vector<string> path_mac_files;
4312 path_mac_files.push_back(a_pathMac);
4317 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()->Error occurred when trying to recover paths to GATE macro files !" << endl);
4325 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()->Error occurred when trying to recover aliases for the elements of the SPECThead !" << endl);
4330 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
4332 ifstream systemMac(path_mac_files[f].c_str(), ios::in);
4335 while(getline(systemMac, line))
4338 modality =
"SPECT_CONVERGENT";
4339 vector <string> values;
4343 entry =
"/gate/"+head_name+
"/placement/setTranslation";
4345 if (values.size()>0)
4350 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4356 if(head_pos_X!=0 && head_pos_Y !=0)
4358 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4359 Cerr(
" Block cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
4364 if(head_pos_Y!=0) is_head_Y_axis =
true;
4366 scanner_radius = is_head_Y_axis ? abs(head_pos_Y) : abs(head_pos_X) ;
4370 entry =
"/gate/"+head_name+
"/geometry/setZLength";
4372 if (values.size()>0)
4376 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4380 voxels_number_axl = fov_axl/4 + 1;
4384 entry =
"/gate/"+head_name+
"/ring/setRepeatNumber";
4386 if (values.size()>0)
4390 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4396 entry =
"/gate/"+head_name+
"/ring/setFirstAngle";
4398 if (values.size()>0)
4402 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4408 entry =
"/gate/"+head_name+
"/ring/setAngularPitch";
4410 if (values.size()>0)
4414 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4419 entry =
"/gate/"+head_name+
"/moves/insert";
4421 if (values.size()>0)
4425 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4430 entry =
"/gate/"+head_orbit_name+
"/setSpeed";
4432 if (values.size()>0)
4436 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4444 entry =
"/gate/"+crystal_name+
"/geometry/setXLength";
4446 if (values.size()>0)
4451 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4456 crystal_size_trs = x_length;
4458 crystal_depth = x_length;
4461 entry =
"/gate/"+crystal_name+
"/geometry/setYLength";
4463 if (values.size()>0)
4468 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4473 crystal_depth = y_length;
4475 crystal_size_trs = y_length;
4479 entry =
"/gate/"+crystal_name+
"/geometry/setZLength";
4481 if (values.size()>0)
4485 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4495 entry = is_head_Y_axis ?
4496 "/gate/"+pixel_name+
"/cubicArray/setRepeatNumberX":
4497 "/gate/"+pixel_name+
"/cubicArray/setRepeatNumberY";
4501 if (values.size()>0)
4505 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4510 entry =
"/gate/"+pixel_name+
"/cubicArray/setRepeatNumberZ";
4512 if (values.size()>0)
4516 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4522 entry =
"/gate/"+pixel_name+
"/geometry/setXLength";
4524 if (values.size()>0)
4529 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4534 pix_size_trs = x_length;
4537 entry =
"/gate/"+pixel_name+
"/geometry/setYLength";
4539 if (values.size()>0)
4544 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4548 if (!is_head_Y_axis)
4549 pix_size_trs = y_length;
4553 entry =
"/gate/"+pixel_name+
"/geometry/setZLength";
4555 if (values.size()>0)
4559 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4565 entry =
"/gate/"+pixel_name+
"/cubicArray/setRepeatVector";
4567 if (values.size()>0)
4569 string trs_step = is_head_Y_axis ?
4576 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4583 entry = is_head_Y_axis ?
4584 "/gate/fanbeam/geometry/setFocalDistanceY":
4585 "/gate/fanbeam/geometry/setFocalDistanceX";
4587 entry =
"/gate/fanbeam/geometry/setFocalDistanceX";
4589 if (values.size()>0)
4593 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4597 focal_model_trs =
"polynomial";
4605 fov_trs = scanner_radius/2;
4607 voxels_number_trs = fov_trs/2 + 1;
4609 uint32_t nb_pixels = number_of_pixels_axl * number_of_pixels_trs;
4611 pix_size_axl = nb_pixels>1 ? pix_size_axl : crystal_size_axl;
4612 pix_size_trs = nb_pixels>1 ? pix_size_trs : crystal_size_trs;
4615 if (pix_step_axl - pix_size_axl >= 0)
4616 pix_gap_axl = pix_step_axl - pix_size_axl;
4618 if (pix_step_trs - pix_size_trs >= 0)
4619 pix_gap_trs = pix_step_trs - pix_size_trs;
4623 head_first_angle = round(atan2f(head_pos_X , head_pos_Y) * 180. / M_PI)
4628 ofstream fileGeom(a_pathGeom.c_str(), ios::out | ios::trunc);
4632 fileGeom <<
"modality : " << modality << endl;
4633 fileGeom <<
"scanner name : " << scanner_name << endl;
4634 fileGeom <<
"number of detector heads : " << number_of_heads << endl;
4635 fileGeom <<
"trans number of pixels : " << number_of_pixels_trs << endl;
4636 fileGeom <<
"trans pixel size : " << pix_size_trs << endl;
4637 fileGeom <<
"trans gap size : " << pix_gap_trs << endl;
4638 fileGeom <<
"axial number of pixels : " << number_of_pixels_axl << endl;
4639 fileGeom <<
"axial pixel size : " << pix_size_axl << endl;
4640 fileGeom <<
"axial gap size : " << pix_gap_axl << endl;
4642 fileGeom <<
"detector depth : " << crystal_depth << endl;
4644 fileGeom <<
"scanner radius : " << scanner_radius;
4645 for(
size_t h=1 ; h<number_of_heads ; h++)
4646 fileGeom <<
"," << scanner_radius;
4649 fileGeom <<
"# Collimator configuration : "<< endl << endl;
4650 for(
size_t h=0 ; h<number_of_heads ; h++)
4652 fileGeom <<
"head" << h+1 <<
":" << endl;
4653 fileGeom <<
"trans focal model: " << focal_model_trs << endl;
4654 fileGeom <<
"trans number of coef model: " << nb_coeff_model_trs << endl;
4655 fileGeom <<
"trans parameters: " << coeff_model_trs << endl;
4656 fileGeom <<
"axial focal model: " << focal_model_axl << endl;
4657 fileGeom <<
"axial number of coef model: " << nb_coeff_model_axl << endl;
4658 fileGeom <<
"axial parameters: " << coeff_model_axl << endl;
4662 fileGeom <<
"" << endl;
4663 fileGeom <<
"# default reconstruction parameters" << endl;
4664 fileGeom <<
"voxels number transaxial : " << voxels_number_trs << endl;
4665 fileGeom <<
"voxels number axial : " << voxels_number_axl << endl;
4667 fileGeom <<
"field of view transaxial : " << fov_trs << endl;
4668 fileGeom <<
"field of view axial : " << fov_axl << endl << endl ;
4669 fileGeom <<
""<< endl;
4671 fileGeom <<
"# description" << endl;
4672 fileGeom <<
"description : " << description << endl;
4676 Cout(
"Output geom file written at :" << a_pathGeom << endl);
4680 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)
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...
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 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, bool &invert_det_order, 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...
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...
uint32_t ConvertIDcylindrical(uint32_t nRsectorsAngPos, uint32_t nRsectorsAxial, bool a_invertDetOrder, 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...
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 ...