CASToR  2.0
Tomographic Reconstruction (PET/SPECT/CT)
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
iDataFilePET Class Reference

Inherit from vDataFile. Class that manages the reading of a PET input file (header + data). More...

#include <iDataFilePET.hh>

Inheritance diagram for iDataFilePET:
Inheritance graph
Collaboration diagram for iDataFilePET:
Collaboration graph

Public Member Functions

 iDataFilePET ()
 iDataFilePET constructor. Initialize the member variables to their default values. More...
 
 ~iDataFilePET ()
 iDataFilePET destructor. More...
 
int ReadSpecificInfoInHeader (bool a_affectQuantificationFlag)
 Read through the header file and gather specific PET information. More...
 
int WriteHeader ()
 Generate a header file according to the data output information. More...
 
int ComputeSizeEvent ()
 Computation of the size of each event according to the mandatory/optional correction fields. More...
 
int PrepareDataFile ()
 Store different kind of information inside arrays (data relative to specific correction as well as basic raw data for the case data is loaded in RAM)
Use the flag provided by the user to determine how the data has to be sorted (preloaded or read on the fly) More...
 
int WriteEvent (vEvent *ap_Event, int a_th)
 Write event according to the chosen type of data. More...
 
vEventGetEventSpecific (char *ap_buffer, int a_th)
 Read an event from the position pointed by 'ap_buffer', parse the generic or modality-specific information, and store them in the (multithreaded) 'm2p_BufferEvent' object. More...
 
void DescribeSpecific ()
 Implementation of the pure virtual eponym function that simply prints info about the datafile. More...
 
bool GetTOFInfoFlag ()
 
bool GetIgnoreTOFFlag ()
 
FLTNB GetTOFResolution ()
 
int GetNbTOFBins ()
 
FLTNB GetTOFBinSize ()
 
FLTNB GetTOFMeasurementRange ()
 
FLTNB GetMaxAxialDiffmm ()
 
void SetMaxNumberOfLinesPerEvent (uint16_t a_value)
 set the max number of line per event in the datafile More...
 
uint16_t GetMaxNumberOfLinesPerEvent ()
 
void SetIsotope (string a_value)
 initialize the isotope string value More...
 
string GetIsotope ()
 
void SetIgnoreTOFFlag (bool a_ignoreTOFFlag)
 Set a boolean that that if we ignore TOF information or not. More...
 
void SetEventKindFlagOn ()
 set to true the flag indicating the presence of the kind of a list-mode event in the datafile TODO check if consistent with datafile type More...
 
void SetAtnCorrectionFlagOn ()
 set to true the flag indicating the presence of attenuation correction factors in the datafile More...
 
void SetNormCorrectionFlagOn ()
 set to true the flag indicating the presence of normalization correction factors in the datafile More...
 
void SetScatterCorrectionFlagOn ()
 set to true the flag indicating the presence of scatter correction factors in the datafile More...
 
void SetRandomCorrectionFlagOn ()
 set to true the flag indicating the presence of random correction factors in the datafile More...
 
bool GetNormCorrectionFlag ()
 Simply return m_normCorrectionFlag. More...
 
bool GetAtnCorrectionFlag ()
 Simply return m_atnCorrectionFlag. More...
 
bool GetEventKindFlag ()
 Simply return m_eventKindFlag. More...
 
bool GetScatCorrectionFlag ()
 Simply return m_scatCorrectionFlag. More...
 
bool GetRandCorrectionFlag ()
 Simply return m_randCorrectionFlag. More...
 
int PROJ_InitFile ()
 Initialize the fstream objets for output writing as well as some other variables specific to the Projection script (Event-based correction flags, Estimated size of data file) More...
 
int PROJ_GetScannerSpecificParameters ()
 Get PET specific parameters for projections from the scanner object, through the scannerManager. More...
 
- Public Member Functions inherited from vDataFile
 vDataFile ()
 vDataFile constructor. More...
 
virtual ~vDataFile ()
 vDataFile destructor. More...
 
int ReadInfoInHeader (bool a_affectQuantificationFlag=true)
 Read and check general information from the header datafile
Call the ReadSpecificInformationInHeader() function implemented in child classes. More...
 
int SetParametersFrom (vDataFile *ap_DataFile)
 Initialize all parameters from the provided datafile. More...
 
int CheckParameters ()
 Check the initialization of member variables
Call the CheckSpecificParameters() function implemented in child classes. More...
 
int InitializeMappedFile ()
 Check the datafile existency, map it to memory and get the raw char* pointer.
. More...
 
int OpenFileForWriting (string a_suffix="")
 Open a binary file stream for writing, with eventually the suffix appended to the file name. More...
 
int CloseFile ()
 Close as many binary file stream for writing. More...
 
vEventGetEvent (int64_t a_eventIndex, int a_th=0)
 
void GetEventIndexStartAndStop (int64_t *ap_indexStart, int64_t *ap_indexStop, int a_subsetNum=0, int a_NbSubsets=1)
 Compute the index start and stop of the events loop with respect to the current subset and MPI size and rank. More...
 
int CheckConsistencyWithAnotherBedDataFile (vDataFile *ap_DataFile)
 Check consistency between 'this' and the provided datafile as two bed positions. More...
 
void Describe ()
 A function used to describe the generic parts of the datafile. More...
 
int PROJ_WriteData ()
 Write/Merge chunk of data in a general data file. More...
 
int PROJ_DeleteTmpDataFile ()
 Delete temporary datafile used for multithreaded output writing if needed. More...
 
vEventPROJ_GenerateEvent (int idx_elt1, int idx_elt2, int a_th)
 Generate a standard event and set up its ID
Used by the projection, list-mode sensitivity generation, and datafile converter scripts. More...
 
int GetBedIndex ()
 
int GetDataMode ()
 
string GetDataModeToString ()
 
int GetDataType ()
 
string GetDataTypeToString ()
 
int GetDataSpec ()
 
string GetDataSpecToString ()
 
int64_t GetSize ()
 
int64_t GetEventSize ()
 
string GetHeaderDataFileName ()
 
string GetDataFileName ()
 
int64_t GetStartTime ()
 
int64_t GetDuration ()
 
FLTNB GetCalibrationFactor ()
 
FLTNBGetPOIResolution ()
 
bool * GetPOIDirectionFlag ()
 
bool GetPOIInfoFlag ()
 
bool GetIgnorePOIFlag ()
 
virtual int GetMaxRingDiff ()
 Return an error by default.
This function is surcharged by the PET (and CT) scanner daughter class. More...
 
void SetDataMode (int a_dataMode)
 set the data mode More...
 
void SetDataType (int a_dataType)
 set the data type More...
 
void SetBedIndex (int a_bedIndex)
 set the bed index corresponding to this data file More...
 
bool GetBedPositionFlag ()
 
FLTNB GetRelativeBedPosition ()
 
void SetVerbose (int a_verboseLevel)
 set verbosity More...
 
int GetVerbose ()
 Get the verbose level. More...
 
void SetImageDimensionsAndQuantification (oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
 set the pointer to the oImageDimensionsAndQuantification object More...
 
void SetPOIResolution (FLTNB ap_value[3])
 initialize the POI resolution (for list-mode) More...
 
void SetIgnorePOIFlag (bool a_ignorePOIFlag)
 Set a boolean that that if we ignore POI information or not. More...
 
void SetHeaderDataFileName (const string &a_headerFileName)
 set the data header file name More...
 
void SetBinaryDataFileName (const string &a_dataFileName)
 set the data binary file name More...
 
void SetCalibrationFactor (FLTNB a_value)
 initialize the global calibration factor with a FLTNB value More...
 
void SetNbEvents (int64_t a_value)
 initialize the number of events with a int64_t value More...
 
void SetStartTime (FLTNB a_value)
 
void SetDuration (FLTNB a_value)
 
string GetScannerName ()
 
virtual int Shuffle (int64_t)
 !!!\ This function has been modified to be used specifically with a More...
 

Private Member Functions

int SetSpecificParametersFrom (vDataFile *ap_DataFile)
 Initialize all parameters specific to PET from the provided datafile. More...
 
int CheckSpecificParameters ()
 Check parameters specific to PET data. More...
 
int WriteListEvent (iEventListPET *ap_Event, int a_th=0)
 Write a PET list-mode event. More...
 
int WriteHistoEvent (iEventHistoPET *ap_Event, int a_th)
 Write a PET histogram event. More...
 
int CheckFileSizeConsistency ()
 This function is implemented in child classes
Check if file size is consistent. More...
 
int CheckSpecificConsistencyWithAnotherDataFile (vDataFile *ap_DataFile)
 Check consistency between 'this' and the provided datafile, for specific characteristics. More...
 

Private Attributes

uint16_t m_maxNumberOfLinesPerEvent
 
FLTNB m_maxAxialDiffmm
 
string m_isotope
 
bool m_eventKindFlag
 
bool m_atnCorrectionFlag
 
bool m_ignoreAttnCorrectionFlag
 
bool m_normCorrectionFlag
 
bool m_ignoreNormCorrectionFlag
 
bool m_scatCorrectionFlag
 
bool m_ignoreScatCorrectionFlag
 
bool m_randCorrectionFlag
 
bool m_ignoreRandCorrectionFlag
 
bool m_TOFInfoFlag
 
bool m_ignoreTOFFlag
 
FLTNB m_resolutionTOF
 
int m_nbBinsTOF
 
FLTNB m_binSizeTOF
 
FLTNB m_TOFMeasurementRange
 

Additional Inherited Members

- Protected Attributes inherited from vDataFile
oImageDimensionsAndQuantificationmp_ID
 
int m_verbose
 
string m_headerFileName
 
string m_dataFileName
 
int64_t m_nbEvents
 
int m_dataMode
 
int m_dataType
 
int m_dataSpec
 
FLTNB m_startTimeInSec
 
FLTNB m_durationInSec
 
FLTNB m_calibrationFactor
 
int m_bedIndex
 
FLTNB m_relativeBedPosition
 
bool m_bedPositionFlag
 
string m_scannerName
 
bool m_POIInfoFlag
 
bool m_ignorePOIFlag
 
bool mp_POIDirectionFlag [3]
 
FLTNB mp_POIResolution [3]
 
int64_t m_sizeEvent
 
fstream ** m2p_dataFile
 
vEvent ** m2p_BufferEvent
 
int64_t m_mpi1stEvent
 
int64_t m_mpiLastEvent
 
int64_t m_mpiNbEvents
 
oMemoryMappedmp_MappedFile
 
char * mp_mappedMemory
 

Detailed Description

Inherit from vDataFile. Class that manages the reading of a PET input file (header + data).

It contains several arrays corresponding to the different kind of informations the data file could contain.
As many booleans as arrays say if the data are here or not. The data file can be either completely loaded, or read event by event during reconstruction.
MPI is coming here to cut the data file into peaces (also either can be loaded or read on-the-fly).

Definition at line 44 of file iDataFilePET.hh.

Constructor & Destructor Documentation

iDataFilePET::iDataFilePET ( )

iDataFilePET constructor. Initialize the member variables to their default values.

Definition at line 39 of file iDataFilePET.cc.

iDataFilePET::~iDataFilePET ( )

iDataFilePET destructor.

Definition at line 69 of file iDataFilePET.cc.

Member Function Documentation

int iDataFilePET::CheckFileSizeConsistency ( )
privatevirtual

This function is implemented in child classes
Check if file size is consistent.

Returns
0 if success, and positive value otherwise.

Implements vDataFile.

Definition at line 663 of file iDataFilePET.cc.

int iDataFilePET::CheckSpecificConsistencyWithAnotherDataFile ( vDataFile ap_DataFile)
privatevirtual

Check consistency between 'this' and the provided datafile, for specific characteristics.

Parameters
vDataFile*ap_DataFile

Implementation of the pure virtual function from vDataFile. It checks correction flags, etc.

Returns
0 if the provided datafile is consistent with 'this', another value otherwise

Implements vDataFile.

Definition at line 724 of file iDataFilePET.cc.

Here is the call graph for this function:

int iDataFilePET::CheckSpecificParameters ( )
privatevirtual

Check parameters specific to PET data.

Returns
0 if success, and positive value otherwise.

Implements vDataFile.

Definition at line 590 of file iDataFilePET.cc.

int iDataFilePET::ComputeSizeEvent ( )
virtual

Computation of the size of each event according to the mandatory/optional correction fields.

Returns
0 is success, positive value otherwise

Implements vDataFile.

Definition at line 139 of file iDataFilePET.cc.

Here is the caller graph for this function:

void iDataFilePET::DescribeSpecific ( )
virtual

Implementation of the pure virtual eponym function that simply prints info about the datafile.

Implements vDataFile.

Definition at line 557 of file iDataFilePET.cc.

iDataFilePET::GetAtnCorrectionFlag ( )
inline

Simply return m_atnCorrectionFlag.

Returns
m_atnCorrectionFlag

Definition at line 239 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::GetEventKindFlag ( )
inline

Simply return m_eventKindFlag.

Returns
m_eventKindFlag

Definition at line 246 of file iDataFilePET.hh.

Here is the caller graph for this function:

vEvent * iDataFilePET::GetEventSpecific ( char *  ap_buffer,
int  a_th 
)
virtual

Read an event from the position pointed by 'ap_buffer', parse the generic or modality-specific information, and store them in the (multithreaded) 'm2p_BufferEvent' object.

Parameters
ap_buffer: address pointing to the event to recover
a_th: index of the thread from which the function was called
Returns
the thread-specific 'm2p_BufferEvent' object containing the modality-specific information for the event

Implements vDataFile.

Definition at line 355 of file iDataFilePET.cc.

Here is the call graph for this function:

iDataFilePET::GetIgnoreTOFFlag ( )
inline
Returns
m_ignoreTOFFlag

Definition at line 125 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::GetIsotope ( )
inline
Returns
the isotope string value

Definition at line 182 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::GetMaxAxialDiffmm ( )
inline
Returns
max ring difference in the acquisition

Definition at line 155 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::GetMaxNumberOfLinesPerEvent ( )
inline
Returns
the max number of line per event in the datafile

Definition at line 167 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::GetNbTOFBins ( )
inline
Returns
number of TOF bins in the acquisition

Definition at line 137 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::GetNormCorrectionFlag ( )
inline

Simply return m_normCorrectionFlag.

Returns
m_normCorrectionFlag

Definition at line 232 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::GetRandCorrectionFlag ( )
inline

Simply return m_randCorrectionFlag.

Returns
m_randCorrectionFlag

Definition at line 260 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::GetScatCorrectionFlag ( )
inline

Simply return m_scatCorrectionFlag.

Returns
m_scatCorrectionFlag

Definition at line 253 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::GetTOFBinSize ( )
inline
Returns
size of TOF bins in the acquisition

Definition at line 143 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::GetTOFInfoFlag ( )
inline
Returns
m_TOFInfoFlag

Definition at line 119 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::GetTOFMeasurementRange ( )
inline
Returns
Maximum range of values for TOF delta measurements

Definition at line 149 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::GetTOFResolution ( )
inline
Returns
TOF resolution for the acquisition

Definition at line 131 of file iDataFilePET.hh.

Here is the caller graph for this function:

int iDataFilePET::PrepareDataFile ( )
virtual

Store different kind of information inside arrays (data relative to specific correction as well as basic raw data for the case data is loaded in RAM)
Use the flag provided by the user to determine how the data has to be sorted (preloaded or read on the fly)

Returns
0 is success, positive value otherwise

Implements vDataFile.

Definition at line 212 of file iDataFilePET.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int iDataFilePET::PROJ_GetScannerSpecificParameters ( )
virtual

Get PET specific parameters for projections from the scanner object, through the scannerManager.

Returns
0 if success, positive value otherwise

Implements vDataFile.

Definition at line 1177 of file iDataFilePET.cc.

Here is the call graph for this function:

int iDataFilePET::PROJ_InitFile ( )
virtual

Initialize the fstream objets for output writing as well as some other variables specific to the Projection script (Event-based correction flags, Estimated size of data file)

Returns
0 if success, and positive value otherwise.

Implements vDataFile.

Definition at line 816 of file iDataFilePET.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int iDataFilePET::ReadSpecificInfoInHeader ( bool  a_affectQuantificationFlag)
virtual

Read through the header file and gather specific PET information.

Parameters
boola_affectQuantificationFlag

If the parameter flag is on, then affect the quantification factors from the oImageDimensionsAndQuantification after reading relevant information

Returns
0 is success, positive value otherwise

Implements vDataFile.

Definition at line 76 of file iDataFilePET.cc.

Here is the call graph for this function:

void iDataFilePET::SetAtnCorrectionFlagOn ( )
inline

set to true the flag indicating the presence of attenuation correction factors in the datafile

This function is dedicated to datafile conversion scripts

Definition at line 204 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::SetEventKindFlagOn ( )
inline

set to true the flag indicating the presence of the kind of a list-mode event in the datafile TODO check if consistent with datafile type

This function is dedicated to datafile conversion scripts

Definition at line 197 of file iDataFilePET.hh.

iDataFilePET::SetIgnoreTOFFlag ( bool  a_ignoreTOFFlag)
inline

Set a boolean that that if we ignore TOF information or not.

Parameters
a_flag

Definition at line 189 of file iDataFilePET.hh.

iDataFilePET::SetIsotope ( string  a_value)
inline

initialize the isotope string value

Parameters
a_value

The name should corresponds to one corresponding tag in the isotope configuration file in config/. This function is dedicated to datafile conversion scripts

Definition at line 176 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::SetMaxNumberOfLinesPerEvent ( uint16_t  a_value)
inline

set the max number of line per event in the datafile

Definition at line 161 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::SetNormCorrectionFlagOn ( )
inline

set to true the flag indicating the presence of normalization correction factors in the datafile

This function is dedicated to datafile conversion scripts

Definition at line 211 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::SetRandomCorrectionFlagOn ( )
inline

set to true the flag indicating the presence of random correction factors in the datafile

This function is dedicated to datafile conversion scripts

Definition at line 225 of file iDataFilePET.hh.

Here is the caller graph for this function:

iDataFilePET::SetScatterCorrectionFlagOn ( )
inline

set to true the flag indicating the presence of scatter correction factors in the datafile

This function is dedicated to datafile conversion scripts

Definition at line 218 of file iDataFilePET.hh.

Here is the caller graph for this function:

int iDataFilePET::SetSpecificParametersFrom ( vDataFile ap_DataFile)
privatevirtual

Initialize all parameters specific to PET from the provided datafile.

Returns
0 if success, and positive value otherwise

Implements vDataFile.

Definition at line 114 of file iDataFilePET.cc.

Here is the call graph for this function:

int iDataFilePET::WriteEvent ( vEvent ap_Event,
int  a_th 
)
virtual

Write event according to the chosen type of data.

Parameters
ap_Event: event containing the data to write
a_th: index of the thread from which the function was called
Returns
0 if success, and positive value otherwise.

Implements vDataFile.

Definition at line 890 of file iDataFilePET.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int iDataFilePET::WriteHeader ( )
virtual

Generate a header file according to the data output information.

Returns
0 if success, and positive value otherwise.

Implements vDataFile.

Definition at line 1087 of file iDataFilePET.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int iDataFilePET::WriteHistoEvent ( iEventHistoPET ap_Event,
int  a_th 
)
private

Write a PET histogram event.

Parameters
ap_Event: event containing the data to write
a_th: index of the thread from which the function was called
Returns
0 if success, and positive value otherwise.

Definition at line 920 of file iDataFilePET.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int iDataFilePET::WriteListEvent ( iEventListPET ap_Event,
int  a_th = 0 
)
private

Write a PET list-mode event.

Parameters
ap_Event: event containing the data to write
a_th: index of the thread from which the function was called
Returns
0 if success, and positive value otherwise.

Definition at line 988 of file iDataFilePET.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

bool iDataFilePET::m_atnCorrectionFlag
private

Flag that says if attenuation correction terms are included in the data. Default = false

Definition at line 333 of file iDataFilePET.hh.

FLTNB iDataFilePET::m_binSizeTOF
private

Size of TOF bins for histogram mode. Default = -1.0

Definition at line 345 of file iDataFilePET.hh.

bool iDataFilePET::m_eventKindFlag
private

Flag for informations about the event nature (true, scatter, random) in the data. Default = false

Definition at line 332 of file iDataFilePET.hh.

bool iDataFilePET::m_ignoreAttnCorrectionFlag
private

Flag to say if we ignore the attenuation correction even if present. Default = false

Definition at line 334 of file iDataFilePET.hh.

bool iDataFilePET::m_ignoreNormCorrectionFlag
private

Flag to say if we ignore the normalization correction even if present. Default = false

Definition at line 336 of file iDataFilePET.hh.

bool iDataFilePET::m_ignoreRandCorrectionFlag
private

Flag to say if we ignore the random correction even if present. Default = false

Definition at line 340 of file iDataFilePET.hh.

bool iDataFilePET::m_ignoreScatCorrectionFlag
private

Flag to say if we ignore the scatter correction even if present. Default = false

Definition at line 338 of file iDataFilePET.hh.

bool iDataFilePET::m_ignoreTOFFlag
private

Flag to say if we ignore the TOF data even if present, or not. Default = false

Definition at line 342 of file iDataFilePET.hh.

string iDataFilePET::m_isotope
private

Isotope. Default = unknown

Definition at line 331 of file iDataFilePET.hh.

FLTNB iDataFilePET::m_maxAxialDiffmm
private

Max axial difference in mm between 2 crystals in a LOR. Default value calculated from the scanner files

Definition at line 330 of file iDataFilePET.hh.

uint16_t iDataFilePET::m_maxNumberOfLinesPerEvent
private

Number of lines in each event in the datafile. Default = 1

Definition at line 329 of file iDataFilePET.hh.

int iDataFilePET::m_nbBinsTOF
private

Number of TOF bins for histogram mode. Default = 1

Definition at line 344 of file iDataFilePET.hh.

bool iDataFilePET::m_normCorrectionFlag
private

Flag that says if normalization correction terms are included in the data. Default = false

Definition at line 335 of file iDataFilePET.hh.

bool iDataFilePET::m_randCorrectionFlag
private

Flag that says if random correction terms are included in the data. Default = false

Definition at line 339 of file iDataFilePET.hh.

FLTNB iDataFilePET::m_resolutionTOF
private

TOF resolution in ps. Default = -1.0

Definition at line 343 of file iDataFilePET.hh.

bool iDataFilePET::m_scatCorrectionFlag
private

Flag that says if scatter correction terms are included in the data. Default = false

Definition at line 337 of file iDataFilePET.hh.

bool iDataFilePET::m_TOFInfoFlag
private

Flag that says if TOF information is included in the data. Default = false

Definition at line 341 of file iDataFilePET.hh.

FLTNB iDataFilePET::m_TOFMeasurementRange
private

Maximum range of values for TOF delta time measurements (delta t max - delta t min) in ps

Definition at line 346 of file iDataFilePET.hh.


The documentation for this class was generated from the following files: