CASToR  2.0
Tomographic Reconstruction (PET/SPECT/CT)
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
gDataConversionUtilities.cc File Reference

Implementation of class gDataConversionUtilities functions. More...

#include "gVariables.hh"
#include "gDataConversionUtilities.hh"
#include <iomanip>

Go to the source code of this file.

Functions

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 values in a vector of strings. More...
 
vector< string > Split (string a_line)
 Split the line provided in parameter into a vector of strings (separator is blankspace) More...
 
void ConvertValuesTomm (vector< string > &ap_v)
 Check if the vector of strings passed in parameter contains the 'cm' unit In this case, convert all its values in mm. More...
 
template<class T >
int WriteVector (ofstream &file, const string &a_key, vector< T > a_vals)
 Write the key and its values in the file provided in parameter. More...
 
template int WriteVector (ofstream &file, const string &a_key, vector< double > a_vals)
 
int WriteVector (ofstream &file, const string &a_key, vector< string > a_vals)
 Write the key and its values in the file provided in parameter. More...
 
int WriteVector (ofstream &file, const string &a_key, vector< vector< string > > a_vals)
 Write the key and its values contained in a 2 level vector of strings in the file provided in parameter. More...
 
int GetGATEMacFiles (const string &a_pathMac, vector< string > &ap_pathToMacFiles)
 Extract the paths to each macro file contained in the main macro file. More...
 
int GetGATESystemType (const string &a_pathMac)
 Read a GATE macro file and identify the system type from the 'gate/systems/' command lines. More...
 
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 parts of a cylindricalPET. More...
 
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 parts of an ecat system. More...
 
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 parts of an ecat system. More...
 
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 layout. More...
 
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. More...
 
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. More...
 
uint32_t ConvertIDcylindrical (uint32_t nRsectorsAngPos, uint32_t nRsectorsAxial, int a_rsectorIdOrder, uint32_t nModulesTransaxial, uint32_t nModulesAxial, uint32_t nSubmodulesTransaxial, uint32_t nSubmodulesAxial, uint32_t nCrystalsTransaxial, uint32_t nCrystalsAxial, uint8_t nLayers, uint32_t *nCrystalPerLayer, vector< uint32_t > nLayersRptTransaxial, vector< uint32_t > nLayersRptAxial, int32_t layerID, int32_t crystalID, int32_t submoduleID, int32_t moduleID, int32_t rsectorID)
 Compute a CASToR crystal index of a GATE cylindricalPET system from its indexes (rsector/module/submodule/crystal) and the system layout. More...
 
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. More...
 
int ReadMacCylindrical (string a_pathMac, uint8_t &nLayers, uint32_t *nb_crystal_per_layer, uint32_t &nCrystalsTot, uint32_t &nCrystalsAxial, uint32_t &nCrystalsTransaxial, vector< uint32_t > &nLayersRptAxial, vector< uint32_t > &nLayersRptTransaxial, uint32_t &nSubmodulesAxial, uint32_t &nSubmodulesTransaxial, uint32_t &nModulesAxial, uint32_t &nModulesTransaxial, uint32_t &nRsectorsAxial, uint32_t &nRsectorsAngPos, int &rsector_id_order, uint32_t &start_time_ms, uint32_t &duration_ms, int vb)
 Recover informations about the scanner element of a cylindricalPET system and acquisition duration, from a GATE macro file. More...
 
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. More...
 
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, from a GATE macro file. More...
 
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, from a GATE macro file. More...
 
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 geom file. More...
 
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. More...
 
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 file. More...
 

Detailed Description

Implementation of class gDataConversionUtilities functions.

Definition in file gDataConversionUtilities.cc.

Function Documentation

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 values in a vector of strings.

Parameters
a_keystring containing a GATE command to recover
a_line: string containing the line to check

Values are converted in mm if 'cm' is found in the line

Returns
the vector of strings containing the elements of the line.

Definition at line 53 of file gDataConversionUtilities.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
eventID1
eventID2
comptonPhantom1
comptonPhantom2
rayleighPhantom1
rayleighPhantom2
Returns
kind of the coincidence : unknown (=0, default), true(=1), single scat(=2), multiple scat(=3), random(=4)) (default value =0)

Definition at line 995 of file gDataConversionUtilities.cc.

Here is the caller graph for this function:

uint32_t ConvertIDcylindrical ( uint32_t  nRsectorsAngPos,
uint32_t  nRsectorsAxial,
int  a_rsectorIdOrder,
uint32_t  nModulesTransaxial,
uint32_t  nModulesAxial,
uint32_t  nSubmodulesTransaxial,
uint32_t  nSubmodulesAxial,
uint32_t  nCrystalsTransaxial,
uint32_t  nCrystalsAxial,
uint8_t  nLayers,
uint32_t *  nCrystalPerLayer,
vector< uint32_t >  nLayersRptTransaxial,
vector< uint32_t >  nLayersRptAxial,
int32_t  layerID,
int32_t  crystalID,
int32_t  submoduleID,
int32_t  moduleID,
int32_t  rsectorID 
)

Compute a CASToR crystal index of a GATE cylindricalPET system from its indexes (rsector/module/submodule/crystal) and the system layout.

Parameters
nRsectorsAngPos
nRsectorsAxial
a_rsectorIdOrder
nModulesTransaxial
nModulesAxial
nSubmodulesTransaxial
nSubmodulesAxial
nCrystalsTransaxial
nCrystalsAxial
nLayers
nb_crystal_per_layer
nLayersRptTransaxial
nLayersRptAxial
layerID
crystalID
submoduleID
moduleID
rsectorID
Returns
CASToR crystal index

Definition at line 845 of file gDataConversionUtilities.cc.

Here is the caller graph for this function:

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 layout.

Parameters
nBlocksPerRing
nBlocksLine
nCrystalsTransaxial
nCrystalsAxial
crystalID
blockID
Returns
CASToR crystal index

Definition at line 684 of file gDataConversionUtilities.cc.

Here is the caller graph for this function:

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.

Parameters
a_headID: head index as provided in the root file
a_rotAngle: rotation angle (deg) as provided in the root file
a_angStep: angular step (deg) computed from the macro file
a_nProjectionsByHead: total number of projections for each head
Returns
CASToR projection index for a SPECThead system

Definition at line 718 of file gDataConversionUtilities.cc.

Here is the caller graph for this function:

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.

Parameters
a_nbSimulatedPixels
a_nPixTrs
a_nPixAxl
a_headID
a_crystalID
a_pixelID
a_rotAngle
a_headAngPitch
a_crystalSizeAxl
a_crystalSizeTrs
a_gPosX
a_gPosY
a_gPosZ
Returns
CASToR crystal index. Return a higher number than the max index if error

Definition at line 757 of file gDataConversionUtilities.cc.

Here is the caller graph for this function:

void ConvertValuesTomm ( vector< string > &  ap_v)

Check if the vector of strings passed in parameter contains the 'cm' unit In this case, convert all its values in mm.

Parameters
ap_v: vector of strings

Definition at line 113 of file gDataConversionUtilities.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 geom file.

Parameters
a_pathMac: string containing the path to a GATE macro file
a_pathGeom: string containing the path to a CASToR output geom file
Returns
0 if success, positive value otherwise

Definition at line 2378 of file gDataConversionUtilities.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
a_pathMac: string containing the path to a GATE macro file
a_pathGeom: string containing the path to a CASToR output geom file
Returns
0 if success, positive value otherwise

Definition at line 3592 of file gDataConversionUtilities.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 file.

Parameters
a_pathMac: string containing the path to a GATE macro file
a_pathGeom: string containing the path to a CASToR output geom file
Returns
0 if success, positive value otherwise

Definition at line 4078 of file gDataConversionUtilities.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 parts of a cylindricalPET.

Parameters
path_mac_files
rsector_name
module_name
submodule_name
crystal_name
layers_name
Returns
0 if success, positive value otherwise

Definition at line 374 of file gDataConversionUtilities.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 parts of an ecat system.

Parameters
path_mac_files
block_name
crystal_name
vb
Returns
0 if success, positive value otherwise

Definition at line 514 of file gDataConversionUtilities.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 parts of an ecat system.

Parameters
path_mac_files
base_name
crystal_name
pixel_name
vb
Returns
0 if success, positive value otherwise

Definition at line 598 of file gDataConversionUtilities.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int GetGATEMacFiles ( const string &  a_pathMac,
vector< string > &  ap_pathToMacFiles 
)

Extract the paths to each macro file contained in the main macro file.

Parameters
a_pathMac: path to a GATE main macro file
ap_pathToMacFiles: array containing the paths of macro files
Returns
0 if success, positive value otherwise

Definition at line 244 of file gDataConversionUtilities.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int GetGATESystemType ( const string &  a_pathMac)

Read a GATE macro file and identify the system type from the 'gate/systems/' command lines.

Parameters
a_pathMac: path to a GATE macro file
Returns
system type, as described by the macro GATE_SYS_TYPE, -1 if error

Definition at line 285 of file gDataConversionUtilities.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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, from a GATE macro file.

Parameters
a_pathIntf: path to the interfile header
distToDetector: distance between center of rotation and detector surface
nHeads: nb of cameras
nPixAxl: nb of transaxial pixels
nPixTrs: nb of axial pixels
crystalSizeAxl: crystal axial dimension
crystalSizeTrs: crystal transaxial dimension
head1stAngle: head first angle
headAngPitch: angular pitch between heads
headRotSpeed: angle between projection
headRotDirection: rotation direction of the head (CW or CCW)
start_time_ms: acquisition start time converted in ms
duration_ms: acquisition duration converted in ms
Intf_fiels: Interfile key structure to initialize with projection image parameters
vb: verbosity
Returns
0 if success, positive value otherwise

Definition at line 2148 of file gDataConversionUtilities.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int ReadMacCylindrical ( string  a_pathMac,
uint8_t &  nLayers,
uint32_t *  nb_crystal_per_layer,
uint32_t &  nCrystalsTot,
uint32_t &  nCrystalsAxial,
uint32_t &  nCrystalsTransaxial,
vector< uint32_t > &  nLayersRptAxial,
vector< uint32_t > &  nLayersRptTransaxial,
uint32_t &  nSubmodulesAxial,
uint32_t &  nSubmodulesTransaxial,
uint32_t &  nModulesAxial,
uint32_t &  nModulesTransaxial,
uint32_t &  nRsectorsAxial,
uint32_t &  nRsectorsAngPos,
int &  rsector_id_order,
uint32_t &  start_time_ms,
uint32_t &  duration_ms,
int  vb 
)

Recover informations about the scanner element of a cylindricalPET system and acquisition duration, from a GATE macro file.

Parameters
a_pathMac: path to a main macro file
nLayers: nb of crystal layers
nCrystalsAxial: nb of axial crystals (in a submodule)
nCrystalsTransaxial: nb of transaxial crystals (in a submodule)
nCrystalLayersAxial: Array containing the number of axial crystals in each layer
nCrystalLayersTransaxial: Array containing the number of transaxial crystals in each layer
nSubmodulesAxial: nb of axial submodules (in a module)
nSubmodulesTransaxial: nb of transaxial submodules (in a module)
nModulesAxial: nb of axial modules (in a rsector)
nModulesTransaxial: nb of transaxial modules (in a rsector)
nRsectorsAxial: nb of axial rsectors
nRsectorsAngPos: nb of rsectors per ring
rsector_id_order: ordering of rsector id
start_time_ms: acquisition start time converted in ms
duration_ms: acquisition duration converted in ms
vb: verbosity
Returns
0 if success, positive value otherwise

Definition at line 1051 of file gDataConversionUtilities.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
a_pathMac: path to a main macro file
nCrystalsAxial: nb of axial crystals
nCrystalsTransaxial: nb of transaxial crystals
nBlocksLine: nb of axial blocks
nBlocksPerRing: nb of blocks per ring
start_time_ms: acquisition start time converted in ms
duration_ms: acquisition duration converted in ms
vb: verbosity
Returns
0 if success, positive value otherwise

Definition at line 1512 of file gDataConversionUtilities.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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, from a GATE macro file.

Parameters
a_pathMac: path to a macro file
distToDetector: distance between center of rotation and detector surface
nHeads: nb of cameras
nPixAxl: nb of transaxial pixels
nPixTrs: nb of axial pixels
crystalSizeAxl: crystal axial dimension
crystalSizeTrs: crystal transaxial dimension
nProjectionsTot: total number of projections (cumulated over each head)
nProjectionsByHead: total number of projections for each head
head1stAngle: head first angle
headAngPitch: angular pitch between heads
headAngStepDeg: angular step between each projection
headRotDirection: rotation direction of the head (CW or CCW)
start_time_ms: acquisition start time converted in ms
duration_ms: acquisition duration converted in ms
vb: verbosity
Returns
0 if success, positive value otherwise

Definition at line 1749 of file gDataConversionUtilities.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

vector<string> Split ( string  a_line)

Split the line provided in parameter into a vector of strings (separator is blankspace)

Parameters
a_line: string to split
Returns
vector of string containing the splitted elements of the line

Definition at line 88 of file gDataConversionUtilities.cc.

Here is the caller graph for this function:

template<class T >
int WriteVector ( ofstream &  file,
const string &  a_key,
vector< T >  a_vals 
)

Write the key and its values in the file provided in parameter.

Parameters
file: the output file
a_key: key to write
a_vals: vector containing the key values
Returns
0 if success, positive value otherwise

Definition at line 142 of file gDataConversionUtilities.cc.

Here is the caller graph for this function:

template int WriteVector ( ofstream &  file,
const string &  a_key,
vector< double >  a_vals 
)
int WriteVector ( ofstream &  file,
const string &  a_key,
vector< string >  a_vals 
)

Write the key and its values in the file provided in parameter.

Parameters
file: the output file
a_key: key to write
a_vals: vector containing the key values
Returns
0 if success, positive value otherwise

Definition at line 181 of file gDataConversionUtilities.cc.

int WriteVector ( ofstream &  file,
const string &  a_key,
vector< vector< string > >  a_vals 
)

Write the key and its values contained in a 2 level vector of strings in the file provided in parameter.

Parameters
file: the output file
a_key: key to write
a_vals: vector containing the key values
Returns
0 if success, positive value otherwise

Definition at line 216 of file gDataConversionUtilities.cc.