CASToR  3.2
Tomographic Reconstruction (PET/SPECT/CT)
code/include/management/gDataConversionUtilities.hh
Go to the documentation of this file.
1 
8 #ifndef UTILS_HH
9 #define UTILS_HH 1
10 
11 #include "gVariables.hh"
12 #include "gOptions.hh"
13 #include "iDataFilePET.hh"
14 #include "sOutputManager.hh"
15 #include "sScannerManager.hh"
16 #include "oInterfileIO.hh"
17 
18 #ifdef CASTOR_ROOT
19  #ifdef _WIN32
20  #include "Windows4Root.h"
21  #endif
22  #include "TROOT.h"
23  #include "TApplication.h"
24  #include "TGClient.h"
25  #include "TCanvas.h"
26  #include "TSystem.h"
27  #include "TTree.h"
28  #include "TBranch.h"
29  #include "TFile.h"
30 #endif
31 
40 #define GATE_SYS_UNKNOWN -1
41 
42 #define GATE_SYS_CYLINDRICAL 0
43 
44 #define GATE_SYS_ECAT 1
45 
46 #define GATE_SYS_SPECT 2
47 
50 #define GATE_NB_MAX_LAYERS 4 // Max number of layer in GATE = 4
51 
52 
62 vector<string> CheckGATECommand(const string& a_key, const string& a_line);
63 
70 vector<string> Split(string a_line);
71 
72 
79 void ConvertValuesTomm(vector<string>& values);
80 
81 
88 template <class T>
89 string toString(T a_val)
90 {
91  stringstream ss;
92  ss << a_val;
93  return ss.str();
94 }
95 
96 
105 template <typename T>
106 int WriteVector(ofstream& file, const string& a_key, vector <T> a_vals);
107 
116 int WriteVector(ofstream& file, const string& a_key, vector <string> a_vals);
117 
126 int WriteVector(ofstream& file, const string& a_key, vector <vector<string> > a_vals);
127 
128 
129 
136 int GetGATESystemType(const string& a_pathMac);
137 
138 
139 
140 
148 int GetGATEMacFiles(const string& a_pathMac, vector<string> &ap_pathToMacFiles);
149 
150 
151 
152 
171 int GetGATEAliasesCylindrical(vector<string> path_mac_files,
172  string& rsector_name,
173  string& module_name,
174  string& submodule_name,
175  string& crystal_name,
176  vector<string>& layers_name ,
177  int vb );
178 
179 
180 
181 
195 int GetGATEAliasesEcat(vector<string> path_mac_files,
196  string& block_name,
197  string& crystal_name,
198  int vb );
199 
200 
201 
202 
218 int GetGATEAliasesSPECT(vector<string> path_mac_files,
219  string& base_name,
220  string& crystal_name,
221  string& pixel_name,
222  int vb );
223 
224 
225 
226 
243 uint32_t ConvertIDecat(int32_t nBlocksPerRing,
244  int32_t nBlocksLine,
245  int32_t nCrystalsTransaxial,
246  int32_t nCrystalsAxial,
247  int32_t crystalID,
248  int32_t blockID);
249 
250 
251 
252 
253 
266 uint32_t ConvertIDSPECTRoot1( int32_t a_headID,
267  float_t a_rotAngle,
268  float_t a_angStep,
269  uint32_t a_nProjectionsByHead);
270 
271 
272 
303 uint32_t ConvertIDSPECTRoot2( uint32_t a_nbSimulatedPixels,
304  uint32_t a_nPixTrs,
305  uint32_t a_nPixAxl,
306  int32_t a_headID,
307  int32_t a_crystalID,
308  int32_t a_pixelID,
309  float_t a_rotAngle,
310  float_t a_headAngPitch,
311  float_t a_crystalSizeAxl,
312  float_t a_crystalSizeTrs,
313  float_t a_gPosX,
314  float_t a_gPosY,
315  float_t a_gPosZ);
316 
317 
318 
319 
362 uint32_t ConvertIDcylindrical(uint32_t nRsectorsAngPos,
363  uint32_t nRsectorsAxial,
364  bool a_invertDetOrder,
365  int a_rsectorIdOrder,
366  uint32_t nModulesTransaxial,
367  uint32_t nModulesAxial,
368  uint32_t nSubmodulesTransaxial,
369  uint32_t nSubmodulesAxial,
370  uint32_t nCrystalsTransaxial,
371  uint32_t nCrystalsAxial,
372  uint8_t nLayers,
373  uint32_t* nCrystalPerLayer,
374  vector<uint32_t> nLayersRptTransaxial,
375  vector<uint32_t> nLayersRptAxial,
376  int32_t layerID,
377  int32_t crystalID,
378  int32_t submoduleID,
379  int32_t moduleID,
380  int32_t rsectorID);
381 
395 int ComputeKindGATEEvent(int32_t eventID1, int32_t eventID2,
396  int comptonPhantom1, int comptonPhantom2,
397  int rayleighPhantom1, int rayleighPhantom2);
398 
399 
400 
422 int ReadMacECAT(string a_pathMac,
423  uint32_t &nCrystalsTot,
424  uint32_t &nCrystalsAxial,
425  uint32_t &nCrystalsTransaxial,
426  uint32_t &nBlocksLine,
427  uint32_t &nBlocksPerRing,
428  uint32_t &start_time_ms,
429  uint32_t &duration_ms,
430  FLTNB &pet_coinc_window,
431  int vb);
432 
433 
470 int ReadMacSPECT( string a_pathMac,
471  float_t &distToDetector,
472  uint32_t &nHeads,
473  uint32_t &nPixAxl,
474  uint32_t &nPixTrs,
475  float_t &crystalSizeAxl,
476  float_t &crystalSizeTrs,
477  uint32_t &nProjectionsTot,
478  uint32_t &nProjectionsByHead,
479  float_t &head1stAngle,
480  float_t &headAngPitch,
481  float_t &headAngStepDeg,
482  int &headRotDirection,
483  uint32_t &start_time_ms,
484  uint32_t &duration_ms,
485  int vb);
486 
487 
488 
489 
490 
526 int ReadIntfSPECT(string a_pathIntf,
527  float_t &ap_distToDetector,
528  uint32_t &ap_nHeads,
529  uint32_t &ap_nPixAxl,
530  uint32_t &ap_nPixTrs,
531  float_t &ap_crystalSizeAxl,
532  float_t &ap_crystalSizeTrs,
533  uint32_t &ap_nProjectionsTot,
534  uint32_t &ap_nProjectionsByHead,
535  float_t &ap_head1stAngle,
536  float_t &ap_headAngPitch,
537  float_t &headAngStepDeg,
538  int &ap_headRotDirection,
539  uint32_t &ap_start_time_ms,
540  uint32_t &ap_duration_ms,
541  int vb);
542 
543 
544 
545 
587 int ReadMacCylindrical( string a_pathMac,
588  uint8_t &nLayers,
589  uint32_t *nb_crystal_per_layer,
590  uint32_t &nCrystalsTot,
591  uint32_t &nCrystalsAxial,
592  uint32_t &nCrystalsTransaxial,
593  vector<uint32_t> &nLayersRptAxial,
594  vector<uint32_t> &nLayersRptTransaxial,
595  uint32_t &nSubmodulesAxial,
596  uint32_t &nSubmodulesTransaxial,
597  uint32_t &nModulesAxial,
598  uint32_t &nModulesTransaxial,
599  uint32_t &nRsectorsAxial,
600  uint32_t &nRsectorsAngPos,
601  bool &invert_det_order,
602  int &rsector_id_order,
603  uint32_t &start_time_ms,
604  uint32_t &duration_ms,
605  FLTNB &pet_coinc_window,
606  int vb);
607 
608 
609 
617 int CreateGeomWithECAT(string a_pathMac, string a_pathGeom);
618 
619 
620 
621 
629 int CreateGeomWithCylindrical(string a_pathMac, string a_pathGeom);
630 
631 
632 
633 
641 int CreateGeomWithSPECT(string a_pathMac, string a_pathGeom);
642 
643 #endif
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 ReadIntfSPECT(string a_pathIntf, float_t &ap_distToDetector, uint32_t &ap_nHeads, uint32_t &ap_nPixAxl, uint32_t &ap_nPixTrs, float_t &ap_crystalSizeAxl, float_t &ap_crystalSizeTrs, uint32_t &ap_nProjectionsTot, uint32_t &ap_nProjectionsByHead, float_t &ap_head1stAngle, float_t &ap_headAngPitch, float_t &headAngStepDeg, int &ap_headRotDirection, uint32_t &ap_start_time_ms, uint32_t &ap_duration_ms, int vb)
Recover informations about the scanner element of an ECAT system, and acquisition duration...
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, FLTNB &pet_coinc_window, int vb)
int GetGATEMacFiles(const string &a_pathMac, vector< string > &ap_pathToMacFiles)
Extract the paths to each macro file contained in the main macro file.
int GetGATESystemType(const string &a_pathMac)
Read a GATE macro file and identify the system type from the &#39;gate/systems/&#39; 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 ...
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...
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.
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 ...
uint32_t ConvertIDecat(int32_t nBlocksPerRing, int32_t nBlocksLine, int32_t nCrystalsTransaxial, int32_t nCrystalsAxial, int32_t crystalID, int32_t blockID)
Compute a CASToR crystal index of a GATE ecat system from its indexes (block/crystal) and the system ...
int 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...
This header file is mainly used to declare some macro definitions and all includes needed from the st...
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 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 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 ...
int ReadMacSPECT(string a_pathMac, float_t &distToDetector, uint32_t &nHeads, uint32_t &nPixAxl, uint32_t &nPixTrs, float_t &crystalSizeAxl, float_t &crystalSizeTrs, uint32_t &nProjectionsTot, uint32_t &nProjectionsByHead, float_t &head1stAngle, float_t &headAngPitch, float_t &headAngStepDeg, int &headRotDirection, uint32_t &start_time_ms, uint32_t &duration_ms, int vb)
Recover informations about the scanner element of an ECAT system, and acquisition duration...
int ComputeKindGATEEvent(int32_t eventID1, int32_t eventID2, int comptonPhantom1, int comptonPhantom2, int rayleighPhantom1, int rayleighPhantom2)
This file is used for all kind of different functions designed for options parsing and ASCII file rea...
void ConvertValuesTomm(vector< string > &values)
Check if the vector of strings passed in parameter contains the &#39;cm&#39; unit In this case...
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.
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...
Declaration of class sOutputManager.
vector< string > Split(string a_line)
Split the line provided in parameter into a vector of strings (separator is blankspace) ...
string toString(T a_val)
Convert a value of any type into string.
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, FLTNB &pet_coinc_window, int vb)