CASToR
1.1
Tomographic Reconstruction (PET/SPECT)
|
This class is designed to be a mother virtual class for Datafile. More...
#include <vDataFile.hh>
Public Member Functions | |
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 | CheckParameters () |
Check the initialization of member variables Call the CheckSpecificParameters() function implemented in child classes. More... | |
int | InitializeFile () |
Instantiate the fstream objets for input reading and check if the related datafile's existence and consistency. Also init the char* buffers for event read directly from files. More... | |
virtual int | ComputeSizeEvent ()=0 |
This function is implemented in child classes Computation of the size of each event according to the mandatory/optional correction fields. More... | |
virtual int | PrepareDataFile ()=0 |
This function is implemented in child classes 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... | |
void | ResetBufferRange () |
Simply set the m_1stIdxArrayEvents and m_lastIdxArrayEvents to -1 only if the percentage load is strictly between 0 and 100. More... | |
int | FillBuffer (int64_t a_eventIndex) |
Fill 'mp_arrayEvents' from the 'a_eventIndex' position in the data file. The filling process stops after 'm_sizeArrayEvents' new events have been added, or if we reach the last event of the datafile. More... | |
vEvent * | GetEventWithAscendingOrderAssumption (int64_t a_eventIndex, int64_t a_eventIndexLimit, int a_th) |
According to the current part of the datafile loaded in memory, either read from this buffer or directly from datafile. More... | |
vEvent * | GetEventWithoutOrderAssumption (int64_t a_eventIndex, int a_th) |
According to the current part of the datafile loaded in memory, either read from this buffer or directly from datafile. More... | |
vEvent * | GetEventFromFile (int64_t a_eventIndex, int a_th) |
Return the a_eventIndex event from the datafile. More... | |
virtual vEvent * | GetEventFromBuffer (char *ap_buffer, int a_th)=0 |
This function is implemented in child classes 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 | 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... | |
virtual int | PROJ_InitFile ()=0 |
This function is implemented in child classes Initialize the fstream objets for output writing as well as some other variables specific to the Projection script. More... | |
virtual int | PROJ_GetScannerSpecificParameters ()=0 |
This function is implemented in child classes It is used to set several variables of the datafile when using the projection script. Get modality specific parameters from the scanner object, through the scannerManager. More... | |
virtual int | PROJ_WriteEvent (vEvent *ap_Event, int a_th)=0 |
This function is implemented in child classes Write event according to the chosen type of data. More... | |
virtual int | PROJ_WriteHeader ()=0 |
This function is implemented in child classes. Generate a header file according to the projection and data output informations. 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... | |
vEvent * | PROJ_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 () |
int | GetDataType () |
int64_t | GetSize () |
int64_t | GetEventSize () |
string | GetHeaderDataFileName () |
string | GetDataFileName () |
int64_t | GetStartTime () |
int64_t | GetDuration () |
FLTNB | GetCalibrationFactor () |
FLTNB * | GetPOIResolution () |
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... | |
void | SetPercentageLoad (int a_percentageLoad) |
Set the percentage of the data file that will be loaded in memory. More... | |
int | GetPercentageLoad () |
Get the percentage of the data file that will be loaded in memory. More... | |
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 | 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 () |
Protected Attributes | |
oImageDimensionsAndQuantification * | mp_ID |
int | m_verbose |
fstream ** | m2p_dataFile |
string | m_headerFileName |
string | m_dataFileName |
int64_t | m_totalNbEvents |
int | m_dataMode |
int | m_dataType |
FLTNB | m_startTimeInSec |
FLTNB | m_durationInSec |
FLTNB | m_calibrationFactor |
int | m_bedIndex |
int64_t | m_sizeEvent |
string | m_scannerName |
bool | m_POIInfoFlag |
bool | m_ignorePOIFlag |
bool | mp_POIDirectionFlag [3] |
FLTNB | mp_POIResolution [3] |
vEvent ** | m2p_BufferEvent |
char * | mp_arrayEvents |
char ** | m2p_bufferEventFromFile |
int64_t | m_mpi1stEvent |
int64_t | m_mpiLastEvent |
int64_t | m_mpiNbEvents |
int64_t | m_1stIdxArrayEvents |
int64_t | m_lastIdxArrayEvents |
int64_t | m_sizeArrayEvents |
int | m_percentageLoad |
bool | m_requestBufferFilling |
bool | m_currentlyFillingBuffer |
bool * | mp_currentlyReadingBuffer |
bool * | mp_overBufferRange |
int64_t * | mp_nbEventsReadFromFile |
Private Member Functions | |
virtual int | CheckSpecificParameters ()=0 |
This function is implemented in child classes Check specific parameters of child classes. More... | |
virtual int | CheckFileSizeConsistency ()=0 |
virtual int | ReadSpecificInfoInHeader (bool a_affectQuantificationFlag=true)=0 |
This function is implemented in child classes Read and check modality-specific information from the header datafile. More... | |
virtual int | CheckSpecificConsistencyWithAnotherDatafile (vDataFile *ap_Datafile)=0 |
Check consistency between 'this' and the provided datafile, for specific characteristics. More... | |
virtual int | Shuffle (int64_t) |
This class is designed to be a mother virtual class for Datafile.
This class manages the reading of the generic input file (header + data).
It uses some events as buffers to get data informations during run-time.
Definition at line 67 of file vDataFile.hh.
vDataFile::vDataFile | ( | ) |
vDataFile constructor.
Initialize the member variables to their default values.
Definition at line 26 of file vDataFile.cc.
|
virtual |
vDataFile destructor.
Definition at line 79 of file vDataFile.cc.
int vDataFile::CheckConsistencyWithAnotherBedDatafile | ( | vDataFile * | ap_Datafile | ) |
Check consistency between 'this' and the provided datafile as two bed positions.
vDataFile* | ap_Datafile |
It checks data type, mode, number of events if histogram, event size, calibration factor, and scanner. For characteristics specific to the modality, it finally calls the pure virtual CheckSpecificConsistyWithAnotherBedDatafile() function implemented by children.
Definition at line 339 of file vDataFile.cc.
|
privatepure virtual |
Implemented in iDataFilePET, iDataFileSPECT, and iDataFileTransmission.
int vDataFile::CheckParameters | ( | ) |
Check the initialization of member variables
Call the CheckSpecificParameters() function implemented in child classes.
Definition at line 269 of file vDataFile.cc.
|
privatepure virtual |
Check consistency between 'this' and the provided datafile, for specific characteristics.
vDataFile* | ap_Datafile |
Pure virtual function implemented by children. It checks correction flags, etc.
Implemented in iDataFilePET, iDataFileSPECT, and iDataFileTransmission.
|
privatepure virtual |
This function is implemented in child classes
Check specific parameters of child classes.
Implemented in iDataFilePET, iDataFileSPECT, and iDataFileTransmission.
|
pure virtual |
This function is implemented in child classes
Computation of the size of each event according to the mandatory/optional correction fields.
Implemented in iDataFileSPECT, iDataFilePET, and iDataFileTransmission.
int vDataFile::FillBuffer | ( | int64_t | a_eventIndex | ) |
Fill 'mp_arrayEvents' from the 'a_eventIndex' position in the data file.
The filling process stops after 'm_sizeArrayEvents' new events have been added, or if we reach the last event of the datafile.
a_eventIndex | : long int containing a position index in the data file, from which events should be loaded in the buffer |
Definition at line 513 of file vDataFile.cc.
|
inline |
Definition at line 274 of file vDataFile.hh.
|
inline |
Definition at line 327 of file vDataFile.hh.
|
inline |
Definition at line 309 of file vDataFile.hh.
|
inline |
Definition at line 280 of file vDataFile.hh.
|
inline |
Definition at line 286 of file vDataFile.hh.
|
inline |
Definition at line 321 of file vDataFile.hh.
|
pure virtual |
This function is implemented in child classes
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.
ap_buffer | : address pointing to the event to recover in the event buffer array |
a_th | : index of the thread from which the function was called |
Implemented in iDataFileSPECT, iDataFilePET, and iDataFileTransmission.
vEvent * vDataFile::GetEventFromFile | ( | int64_t | a_eventIndex, |
int | a_th | ||
) |
Return the a_eventIndex event from the datafile.
a_eventIndex | : index of the event to recover |
a_th | : index of the thread from which the function was called |
Definition at line 849 of file vDataFile.cc.
void vDataFile::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.
ap_indexStart | : pointer to recover the index of the first event |
ap_indexStop | : pointer to recover the index of the last event |
a_subsetNum | : actual subset index of the iteration (0 if no subsets) |
a_nbSubsets | : max number of subsets in this iteration (1 if no subsets) |
Definition at line 873 of file vDataFile.cc.
|
inline |
vEvent * vDataFile::GetEventWithAscendingOrderAssumption | ( | int64_t | a_eventIndex, |
int64_t | a_eventIndexLimit, | ||
int | a_th | ||
) |
According to the current part of the datafile loaded in memory, either read from this buffer or directly from datafile.
a_eventIndex | : index of the event to recover |
a_eventIndexLimit | : index over which we consider the thread will soon finish |
a_th | : index of the thread from which the function was called |
This function can be used only inside a loop on events in the ascending order, because it uses this assumption to increase efficiency. Only the thread 0 manages the buffer, if out-of-range, it waits for all other threads to be 'after' this current buffer range to fill the next part. These parts of datafiles are computed based on the provided m_percentageLoad. The file is loaded into the mp_arrayEvents. See the implementation of this function for more detailed information in the comment sections.
Definition at line 609 of file vDataFile.cc.
vEvent * vDataFile::GetEventWithoutOrderAssumption | ( | int64_t | a_eventIndex, |
int | a_th | ||
) |
According to the current part of the datafile loaded in memory, either read from this buffer or directly from datafile.
a_eventIndex | : index of the event to recover |
a_th | : index of the thread from which the function was called |
This function can be used inside a loop on events without any assumption on the order. Only the thread 0 manages the buffer, if out-of-range, it requests to fill the buffer and waits for all other threads to stop reading from the buffer. Once done, it fills the buffer, the file being loaded into the mp_arrayEvents. These parts of datafiles are computed based on the provided m_percentageLoad. With this function, it is possible that the thread 0 is ahead of others threads so in an ascending order, these other threads will be late and always read from file. If this function is used inside a loop on events in the ascending order, then please use the GetEventWithAscendingOrderAssumption() function.
Definition at line 734 of file vDataFile.cc.
|
inline |
Definition at line 303 of file vDataFile.hh.
|
inline |
Definition at line 345 of file vDataFile.hh.
|
virtual |
Return an error by default.
This function is surcharged by the PET (and CT) scanner daughter class.
Reimplemented in iDataFilePET.
Definition at line 906 of file vDataFile.cc.
|
inline |
Get the percentage of the data file that will be loaded in memory.
Definition at line 387 of file vDataFile.hh.
|
inline |
Definition at line 339 of file vDataFile.hh.
|
inline |
Definition at line 333 of file vDataFile.hh.
|
inline |
Definition at line 469 of file vDataFile.hh.
|
inline |
Definition at line 292 of file vDataFile.hh.
|
inline |
Definition at line 315 of file vDataFile.hh.
|
inline |
int vDataFile::InitializeFile | ( | ) |
Instantiate the fstream objets for input reading and check if the related datafile's existence and consistency.
Also init the char* buffers for event read directly from files.
Definition at line 412 of file vDataFile.cc.
|
pure virtual |
This function is implemented in child classes
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)
Implemented in iDataFileSPECT, iDataFilePET, and iDataFileTransmission.
int vDataFile::PROJ_DeleteTmpDatafile | ( | ) |
Delete temporary datafile used for multithreaded output writing if needed.
Definition at line 1008 of file vDataFile.cc.
vEvent * vDataFile::PROJ_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.
idx_elt1 | : first ID of the event |
idx_elt2 | : second ID of the event |
a_th | : index of the thread from which the function was called |
Definition at line 1056 of file vDataFile.cc.
|
pure virtual |
This function is implemented in child classes
It is used to set several variables of the datafile when using the projection script.
Get modality specific parameters from the scanner object, through the scannerManager.
Implemented in iDataFilePET, iDataFileSPECT, and iDataFileTransmission.
|
pure virtual |
This function is implemented in child classes
Initialize the fstream objets for output writing as well as some other variables specific to the Projection script.
Implemented in iDataFilePET, iDataFileSPECT, and iDataFileTransmission.
int vDataFile::PROJ_WriteData | ( | ) |
Write/Merge chunk of data in a general data file.
Definition at line 928 of file vDataFile.cc.
|
pure virtual |
This function is implemented in child classes
Write event according to the chosen type of data.
ap_Event | : Event to write |
a_th | : index of the thread from which the function was called |
Implemented in iDataFilePET, iDataFileSPECT, and iDataFileTransmission.
|
pure virtual |
This function is implemented in child classes.
Generate a header file according to the projection and data output informations.
Implemented in iDataFilePET, iDataFileSPECT, and iDataFileTransmission.
int vDataFile::ReadInfoInHeader | ( | bool | a_affectQuantificationFlag = true | ) |
Read and check general information from the header datafile
Call the ReadSpecificInformationInHeader() function implemented in child classes.
bool | a_affectQuantificationFlag = true |
If the parameter flag is on, then affect the quantification factors from the oImageDimensionsAndQuantification after reading relevant information
Definition at line 134 of file vDataFile.cc.
|
privatepure virtual |
This function is implemented in child classes
Read and check modality-specific information from the header datafile.
bool | a_affectQuantificationFlag = true |
If the parameter flag is on, then affect the quantification factors from the oImageDimensionsAndQuantification after reading relevant information
Implemented in iDataFileSPECT, iDataFilePET, and iDataFileTransmission.
void vDataFile::ResetBufferRange | ( | ) |
Simply set the m_1stIdxArrayEvents and m_lastIdxArrayEvents to -1 only if the percentage load is strictly between 0 and 100.
The purpose of this function is to be called at before a loop over the datafile so that any thread will have an event index always inside or above the buffer range when the GetEventWithAscendingOrderAssumption() is used to get events.
Definition at line 491 of file vDataFile.cc.
|
inline |
set the bed index corresponding to this data file
a_bedIndex |
Definition at line 373 of file vDataFile.hh.
|
inline |
initialize the global calibration factor with a FLTNB value
a_value |
This function is dedicated to datafile conversion scripts
Definition at line 439 of file vDataFile.hh.
|
inline |
set the data mode
a_dataMode |
Definition at line 359 of file vDataFile.hh.
|
inline |
set the data type
a_dataType |
Definition at line 366 of file vDataFile.hh.
|
inline |
|
inline |
set the data header file name
const | string& a_headerFileName |
This function is dedicated to datafile conversion scripts
Definition at line 431 of file vDataFile.hh.
|
inline |
Set a boolean that that if we ignore POI information or not.
a_flag |
Definition at line 423 of file vDataFile.hh.
|
inline |
set the pointer to the oImageDimensionsAndQuantification object
ap_ImageDimensionsAndQuantification |
Definition at line 408 of file vDataFile.hh.
|
inline |
initialize the number of events with a int64_t value
a_value |
This function is dedicated to datafile conversion scripts
Definition at line 447 of file vDataFile.hh.
|
inline |
Set the percentage of the data file that will be loaded in memory.
a_percentageLoad |
Definition at line 380 of file vDataFile.hh.
|
inline |
initialize the POI resolution (for list-mode)
ap_value | : vector of 3 elements (x,y,z) |
This function is dedicated to datafile conversion scripts
Definition at line 416 of file vDataFile.hh.
|
inline |
|
inline |
set verbosity
a_verboseLevel |
Definition at line 394 of file vDataFile.hh.
|
privatevirtual |
Definition at line 568 of file vDataFile.cc.
|
protected |
vEvent structure, used to read and transfer the raw data to each part of the algorithm (multithreaded)
Definition at line 538 of file vDataFile.hh.
|
protected |
Buffer used to recover one event from the datafile (multithreaded)
Definition at line 540 of file vDataFile.hh.
|
protected |
File associated to the raw data file (multithreaded)
Definition at line 518 of file vDataFile.hh.
|
protected |
Index of the first event contained in the 'mp_arrayEvents' buffer
Definition at line 544 of file vDataFile.hh.
|
protected |
Bed position index corresponding to this data file
Definition at line 527 of file vDataFile.hh.
|
protected |
Calibration factor for the data. Default value =1.0
Definition at line 526 of file vDataFile.hh.
|
protected |
File buffer is being filled by the first thread
Definition at line 549 of file vDataFile.hh.
|
protected |
String containing the path to the raw datafile
Definition at line 520 of file vDataFile.hh.
|
protected |
Flag indicating if the data is List (=0) or Histogram (=1) mode
Definition at line 522 of file vDataFile.hh.
|
protected |
Flag indicating if the data is PET (=0),SPECT (=1) or TRANSMISSION type (=2)
Definition at line 523 of file vDataFile.hh.
|
protected |
Duration of the acquisition (s)
Definition at line 525 of file vDataFile.hh.
|
protected |
String containing the path to the header file
Definition at line 519 of file vDataFile.hh.
|
protected |
Flag to say if we ignore the POI data if present, or not. Default = false
Definition at line 533 of file vDataFile.hh.
|
protected |
Index of the last event contained in the 'mp_arrayEvents' buffer
Definition at line 545 of file vDataFile.hh.
|
protected |
First index managed by this MPI instance
Definition at line 541 of file vDataFile.hh.
|
protected |
Last index (included) managed by this MPI instance
Definition at line 542 of file vDataFile.hh.
|
protected |
Number of events managed by this MPI instance
Definition at line 543 of file vDataFile.hh.
|
protected |
Percentage of the data file that is loaded
Definition at line 547 of file vDataFile.hh.
|
protected |
Flag to say if POI information is included in the datafile for each event
Definition at line 532 of file vDataFile.hh.
|
protected |
The first thread is requesting and waiting to fill the buffer
Definition at line 548 of file vDataFile.hh.
|
protected |
Scanner name
Definition at line 529 of file vDataFile.hh.
|
protected |
Size of the 'mp_arrayEvents' buffer
Definition at line 546 of file vDataFile.hh.
|
protected |
Size of an event in the datafile (calculated from mandatory and optional fields)
Definition at line 528 of file vDataFile.hh.
|
protected |
Start time of the acquisition (s)
Definition at line 524 of file vDataFile.hh.
|
protected |
Total number of events in the raw data
Definition at line 521 of file vDataFile.hh.
|
protected |
Verbosity
Definition at line 515 of file vDataFile.hh.
|
protected |
Buffer used to store parts of, or the entire, raw data file. Its size depends of 'm_sizeArrayEvents'
Definition at line 539 of file vDataFile.hh.
|
protected |
One bool per thread (except first thread), saying that the thread is currently reading from the file buffer
Definition at line 550 of file vDataFile.hh.
|
protected |
Pointer to the oImageDimensionsAndQuantification object
Definition at line 514 of file vDataFile.hh.
|
protected |
Counters of how many events were read directly from file, one for each thread
Definition at line 552 of file vDataFile.hh.
|
protected |
One bool per thread (except first thread), saying that the thread is currently under the buffer range or not
Definition at line 551 of file vDataFile.hh.
|
protected |
Flag to say which direction is included in the POI for each event; radial, tangential and axial
Definition at line 534 of file vDataFile.hh.
|
protected |
POI resolution (position of interaction) for each direction: radial, tangential and axial
Definition at line 535 of file vDataFile.hh.