CASToR  1.0
Tomographic Reconstruction (PET/SPECT)
gDataConversionUtilities.hh
Go to the documentation of this file.
00001 
00009 #ifndef UTILS_HH
00010 #define UTILS_HH 1
00011 
00012 #include "gVariables.hh"
00013 #include "gOptions.hh"
00014 #include "iDataFilePET.hh"
00015 #include "sOutputManager.hh"
00016 #include "sScannerManager.hh"
00017 #include "oInterfileIO.hh"
00018 
00019 #ifdef CASTOR_ROOT
00020   #include "TROOT.h"
00021   #include "TApplication.h"
00022   #include "TGClient.h"
00023   #include "TCanvas.h"
00024   #include "TSystem.h"
00025   #include "TTree.h"
00026   #include "TBranch.h"
00027   #include "TFile.h"
00028 #endif
00029 
00030 
00031 
00039 #define GATE_SYS_UNKNOWN -1
00040 
00041 #define GATE_SYS_CYLINDRICAL 0
00042 
00043 #define GATE_SYS_ECAT 1
00044 
00045 #define GATE_SYS_SPECT 2
00046 
00049 #define GATE_NB_MAX_LAYERS 4 // Max number of layer in GATE = 4
00050 
00051 
00061 vector<string> CheckGATECommand(const string& a_key, const string& a_line);
00062 
00069 vector<string> Split(string a_line);
00070 
00071 
00078 void ConvertValuesTomm(vector<string>& values);
00079 
00080 
00087 template <class T>
00088 string toString(T a_val)
00089 {
00090   stringstream ss;
00091   ss << a_val;
00092   return ss.str();
00093 }
00094 
00095 
00104 template <typename T>
00105 int WriteVector(ofstream& file, const string& a_key, vector <T> a_vals);
00106 
00115 int WriteVector(ofstream& file, const string& a_key, vector <string> a_vals);
00116 
00125 int WriteVector(ofstream& file, const string& a_key, vector <vector<string> > a_vals);
00126 
00127 
00128 
00135 int GetGATESystemType(const string& a_pathMac);
00136 
00137 
00138 
00139 
00147 int GetGATEMacFiles(const string& a_pathMac, vector<string> &ap_pathToMacFiles);
00148 
00149 
00150 
00151 
00170 int GetGATEAliasesCylindrical(vector<string>  path_mac_files,
00171                               string&         rsector_name,
00172                               string&         module_name,
00173                               string&         submodule_name,
00174                               string&         crystal_name,
00175                               vector<string>& layers_name ,
00176                               int             vb );
00177                               
00178                               
00179                               
00180 
00194 int GetGATEAliasesEcat(vector<string> path_mac_files,
00195                        string&        block_name,
00196                        string&        crystal_name,
00197                        int            vb );
00198                        
00199                        
00200                        
00201 
00217 int GetGATEAliasesSPECT(vector<string> path_mac_files,
00218                         string&        base_name,
00219                         string&        crystal_name,
00220                         string&        pixel_name,
00221                         int            vb );
00222                         
00223                         
00224                         
00225                         
00237 uint32_t ConvertIDecat(int32_t nBlocksPerRing, 
00238                        int32_t nBlocksLine, 
00239                        int32_t nCrystalsTransaxial, 
00240                        int32_t nCrystalsAxial, 
00241                        int32_t crystalID, 
00242                        int32_t blockID);
00243 
00244 
00245 
00246 
00247 
00257 uint32_t ConvertIDSPECTRoot1( int32_t  a_headID,
00258                               float_t  a_rotAngle,
00259                               float_t  a_angStep,
00260                               uint32_t a_nProjectionsByHead);
00261                               
00262                               
00263                               
00282 uint32_t ConvertIDSPECTRoot2( uint32_t a_nbSimulatedPixels,
00283                               uint32_t a_nPixTrs, 
00284                               uint32_t a_nPixAxl, 
00285                               int32_t a_headID,
00286                               int32_t a_crystalID,
00287                               int32_t a_pixelID,
00288                               float_t a_rotAngle,
00289                               float_t a_headAngPitch,
00290                               float_t a_crystalSizeAxl,
00291                               float_t a_crystalSizeTrs,
00292                               float_t a_gPosX,
00293                               float_t a_gPosY,
00294                               float_t a_gPosZ);
00295                              
00296                              
00297                              
00298                              
00335 uint32_t ConvertIDcylindrical(uint32_t  nRsectorsPerRing,
00336                               uint32_t  nModulesTransaxial,
00337                               uint32_t  nModulesAxial,
00338                               uint32_t  nSubmodulesTransaxial,
00339                               uint32_t  nSubmodulesAxial,
00340                               uint32_t  nCrystalsTransaxial, 
00341                               uint32_t  nCrystalsAxial, 
00342                               uint8_t   nLayers,
00343                               uint32_t* nCrystalPerLayer, 
00344                        vector<uint32_t> nLayersRptTransaxial,
00345                        vector<uint32_t> nLayersRptAxial,
00346                                int32_t  layerID,
00347                                int32_t  crystalID, 
00348                                int32_t  submoduleID, 
00349                                int32_t  moduleID, 
00350                                int32_t  rsectorID);
00351 
00363 int ComputeKindGATEEvent(uint32_t eventID1, uint32_t eventID2,
00364                               int comptonPhantom1, int comptonPhantom2, 
00365                               int rayleighPhantom1, int rayleighPhantom2);
00366 
00367 
00368 
00389 int ReadMacECAT(string a_pathMac,
00390               uint32_t &nCrystalsTot,
00391               uint32_t &nCrystalsAxial,
00392               uint32_t &nCrystalsTransaxial,
00393               uint32_t &nBlocksLine,
00394               uint32_t &nBlocksPerRing,
00395               uint32_t &start_time_ms,
00396               uint32_t &duration_ms,
00397                    int vb);
00398 
00399 
00421 int ReadMacSPECT( string   a_pathMac,
00422                   float_t  &distToDetector,
00423                   uint32_t &nHeads,
00424                   uint32_t &nPixAxl,
00425                   uint32_t &nPixTrs,
00426                   float_t  &crystalSizeAxl,
00427                   float_t  &crystalSizeTrs,
00428                   uint32_t &nProjectionsTot,
00429                   uint32_t &nProjectionsByHead,
00430                   float_t  &head1stAngle,
00431                   float_t  &headAngPitch,
00432                   float_t  &headAngStepDeg,
00433                   int      &headRotDirection,
00434                   uint32_t &start_time_ms,
00435                   uint32_t &duration_ms,
00436                        int vb);
00437                        
00438                        
00439                        
00440 
00441 
00462 int ReadIntfSPECT(string      a_pathIntf,
00463                   float_t     &ap_distToDetector,
00464                   uint32_t    &ap_nHeads,
00465                   uint32_t    &ap_nPixAxl,
00466                   uint32_t    &ap_nPixTrs,
00467                   float_t     &ap_crystalSizeAxl,
00468                   float_t     &ap_crystalSizeTrs,
00469                   uint32_t    &ap_nProjectionsTot,
00470                   uint32_t    &ap_nProjectionsByHead,
00471                   float_t     &ap_head1stAngle,
00472                   float_t     &ap_headAngPitch,
00473                   float_t     &headAngStepDeg,
00474                   int         &ap_headRotDirection,
00475                   uint32_t    &ap_start_time_ms,
00476                   uint32_t    &ap_duration_ms,
00477                   int         vb);
00478                   
00479                   
00480                   
00481                    
00513 int ReadMacCylindrical( string a_pathMac,
00514                       uint8_t  &nLayers,
00515                       uint32_t *nb_crystal_per_layer,
00516                       uint32_t &nCrystalsTot,
00517                       uint32_t &nCrystalsAxial,
00518                       uint32_t &nCrystalsTransaxial, 
00519               vector<uint32_t> &nLayersRptAxial,
00520               vector<uint32_t> &nLayersRptTransaxial,
00521                       uint32_t &nSubmodulesAxial, 
00522                       uint32_t &nSubmodulesTransaxial,
00523                       uint32_t &nModulesAxial, 
00524                       uint32_t &nModulesTransaxial,
00525                       uint32_t &nRsectorsPerRing, 
00526                       uint32_t &start_time_ms, 
00527                       uint32_t &duration_ms,
00528                            int vb);
00529 
00530 
00531 
00539 int CreateGeomWithECAT(string a_pathMac, string a_pathGeom);
00540 
00541 
00542 
00543 
00551 int CreateGeomWithCylindrical(string a_pathMac, string a_pathGeom);
00552 
00553 
00554 
00555 
00556 /*
00557   \fn      CreateGeomWithSPECT()
00558   \param   a_pathMac : string containing the path to a GATE macro file
00559   \param   a_pathGeom : string containing the path to a CASToR output geom file
00560   \brief   Read a GATE macro file containing the description of a SPECThead system, and convert it to a geom file
00561   \return  0 if success, positive value otherwise
00562 */
00563 int CreateGeomWithSPECT(string a_pathMac, string a_pathGeom);
00564 
00565 #endif
 All Classes Files Functions Variables Typedefs Defines