CASToR  1.1
Tomographic Reconstruction (PET/SPECT)
 All Classes Files Functions Variables Typedefs Macros Groups Pages
vDataFile.hh
Go to the documentation of this file.
1 
9 #ifndef VDATAFILE_HH
10 #define VDATAFILE_HH 1
11 
12 #include "gVariables.hh"
13 #include "vEvent.hh"
14 #include "iEventPET.hh"
15 #include "iEventListPET.hh"
16 #include "iEventHistoPET.hh"
17 #include "iEventSPECT.hh"
18 #include "iEventTransmission.hh"
19 #include "iEventNorm.hh"
20 #include "sOutputManager.hh"
21 #include "sScannerManager.hh"
23 
32 #define MODE_UNKNOWN -1
33 
34 #define MODE_LIST 0
35 
36 #define MODE_HISTOGRAM 1
37 
38 #define MODE_NORMALIZATION 2
39 
49 #define TYPE_UNKNOWN -1
50 
51 #define TYPE_PET 0
52 
53 #define TYPE_SPECT 1
54 
55 #define TYPE_TRANSMISSION 2
56 
67 class vDataFile
68 {
69  // -------------------------------------------------------------------
70  // Constructor & Destructor
71  public:
76  vDataFile ();
80  virtual ~vDataFile();
81 
82  // -------------------------------------------------------------------
83  // Public member functions
84  public:
94  int ReadInfoInHeader(bool a_affectQuantificationFlag = true);
101  int CheckParameters();
108  int InitializeFile();
115  virtual int ComputeSizeEvent() = 0;
123  virtual int PrepareDataFile() = 0;
130  void ResetBufferRange();
138  int FillBuffer(int64_t a_eventIndex);
151  vEvent* GetEventWithAscendingOrderAssumption(int64_t a_eventIndex, int64_t a_eventIndexLimit, int a_th);
164  vEvent* GetEventWithoutOrderAssumption(int64_t a_eventIndex, int a_th);
172  vEvent* GetEventFromFile(int64_t a_eventIndex, int a_th);
181  virtual vEvent* GetEventFromBuffer(char* ap_buffer, int a_th) = 0;
190  void GetEventIndexStartAndStop(int64_t* ap_indexStart, int64_t* ap_indexStop, int a_subsetNum = 0, int a_NbSubsets = 1);
201 
202  // -------------------------------------------------------------------
203  // Functions dedicated to analytical projections
204  public:
211  virtual int PROJ_InitFile() = 0;
219  virtual int PROJ_GetScannerSpecificParameters() = 0;
228  virtual int PROJ_WriteEvent(vEvent* ap_Event, int a_th) = 0;
229 
230 
237  virtual int PROJ_WriteHeader() = 0;
238 
239 
240 
241 
248  int PROJ_WriteData();
265  vEvent* PROJ_GenerateEvent(int idx_elt1, int idx_elt2, int a_th);
266 
267  // -------------------------------------------------------------------
268  // Public Get & Set FUNCTIONS
269  public:
274  inline int GetBedIndex()
275  {return m_bedIndex;}
280  inline int GetDataMode()
281  {return m_dataMode;}
286  inline int GetDataType()
287  {return m_dataType;}
292  int64_t GetSize()
293  {return m_totalNbEvents;}
298  int64_t GetEventSize() {return m_sizeEvent;}
303  inline string GetHeaderDataFileName()
304  {return m_headerFileName;};
309  inline string GetDataFileName()
310  {return m_dataFileName;};
315  inline int64_t GetStartTime()
316  {return m_startTimeInSec;};
321  inline int64_t GetDuration()
322  {return m_durationInSec;};
328  {return m_calibrationFactor;}
334  {return mp_POIResolution;}
339  inline bool GetPOIInfoFlag()
340  {return m_POIInfoFlag;}
345  inline bool GetIgnorePOIFlag()
346  {return m_ignorePOIFlag;}
353  virtual int GetMaxRingDiff();
359  inline void SetDataMode(int a_dataMode)
360  {m_dataMode = a_dataMode;}
366  inline void SetDataType(int a_dataType)
367  {m_dataType = a_dataType;}
373  inline void SetBedIndex(int a_bedIndex)
374  {m_bedIndex = a_bedIndex;}
380  inline void SetPercentageLoad(int a_percentageLoad)
381  {m_percentageLoad = a_percentageLoad;}
387  inline int GetPercentageLoad()
388  {return m_percentageLoad;}
394  inline void SetVerbose(int a_verboseLevel)
395  {m_verbose = a_verboseLevel;}
401  inline int GetVerbose()
402  {return m_verbose;}
408  inline void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification* ap_ImageDimensionsAndQuantification)
409  {mp_ID = ap_ImageDimensionsAndQuantification;}
416  inline void SetPOIResolution(FLTNB ap_value[3])
417  {for (int i=0 ; i<3 ; i++) mp_POIResolution[i] = ap_value[i];}
423  inline void SetIgnorePOIFlag(bool a_ignorePOIFlag)
424  {m_ignorePOIFlag = a_ignorePOIFlag;}
431  inline void SetHeaderDataFileName(const string& a_headerFileName)
432  {m_headerFileName = a_headerFileName;}
439  inline void SetCalibrationFactor(FLTNB a_value)
440  {m_calibrationFactor = a_value;}
447  inline void SetNbEvents(int64_t a_value)
448  {m_totalNbEvents = a_value;}
455  inline void SetStartTime(FLTNB a_value)
456  {m_startTimeInSec = a_value;}
463  inline void SetDuration(FLTNB a_value)
464  {m_durationInSec = a_value;}
469  inline string GetScannerName()
470  {return m_scannerName;}
471 
472  // -------------------------------------------------------------------
473  // Private member functions
474  private:
481  virtual int CheckSpecificParameters() = 0;
488  virtual int CheckFileSizeConsistency() = 0;
498  virtual int ReadSpecificInfoInHeader(bool a_affectQuantificationFlag = true) = 0;
506  virtual int CheckSpecificConsistencyWithAnotherDatafile(vDataFile* ap_Datafile) = 0;
507 
508  virtual int Shuffle( int64_t );
509 
510 
511  // -------------------------------------------------------------------
512  // Data members
513  protected:
515  int m_verbose;
517  // Variables related to the acquisition
518  fstream** m2p_dataFile;
520  string m_dataFileName;
521  int64_t m_totalNbEvents;
528  int64_t m_sizeEvent;
529  string m_scannerName;
531  // POI: Position Of Interaction
537  // Variable related to Buffer/Container arrays
541  int64_t m_mpi1stEvent;
542  int64_t m_mpiLastEvent;
543  int64_t m_mpiNbEvents;
553 };
554 
555 #endif
void SetDataMode(int a_dataMode)
set the data mode
Definition: vDataFile.hh:359
int64_t GetEventSize()
Definition: vDataFile.hh:298
void SetIgnorePOIFlag(bool a_ignorePOIFlag)
Set a boolean that that if we ignore POI information or not.
Definition: vDataFile.hh:423
This class is designed to be a mother virtual class for Datafile.
Definition: vDataFile.hh:67
This header file is mainly used to declare some macro definitions and all includes needed from the st...
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 a...
Definition: vDataFile.cc:873
Declaration of class oImageDimensionsAndQuantification.
int64_t m_sizeEvent
Definition: vDataFile.hh:528
bool mp_POIDirectionFlag[3]
Definition: vDataFile.hh:534
string m_dataFileName
Definition: vDataFile.hh:520
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 direc...
Definition: vDataFile.cc:734
#define FLTNB
Definition: gVariables.hh:55
int CheckParameters()
Check the initialization of member variables Call the CheckSpecificParameters() function implemente...
Definition: vDataFile.cc:269
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...
FLTNB GetCalibrationFactor()
Definition: vDataFile.hh:327
bool GetPOIInfoFlag()
Definition: vDataFile.hh:339
bool * mp_overBufferRange
Definition: vDataFile.hh:551
int64_t m_1stIdxArrayEvents
Definition: vDataFile.hh:544
virtual int CheckFileSizeConsistency()=0
int ReadInfoInHeader(bool a_affectQuantificationFlag=true)
Read and check general information from the header datafile Call the ReadSpecificInformationInHeade...
Definition: vDataFile.cc:134
FLTNB m_durationInSec
Definition: vDataFile.hh:525
virtual int PROJ_WriteHeader()=0
This function is implemented in child classes. Generate a header file according to the projection a...
void SetVerbose(int a_verboseLevel)
set verbosity
Definition: vDataFile.hh:394
int64_t GetSize()
Definition: vDataFile.hh:292
string m_headerFileName
Definition: vDataFile.hh:519
void SetDuration(FLTNB a_value)
Definition: vDataFile.hh:463
char * mp_arrayEvents
Definition: vDataFile.hh:539
virtual int ComputeSizeEvent()=0
This function is implemented in child classes Computation of the size of each event according to th...
int m_dataMode
Definition: vDataFile.hh:522
bool m_requestBufferFilling
Definition: vDataFile.hh:548
Declaration of class iEventTransmission.
virtual ~vDataFile()
vDataFile destructor.
Definition: vDataFile.cc:79
virtual int GetMaxRingDiff()
Return an error by default. This function is surcharged by the PET (and CT) scanner daughter class...
Definition: vDataFile.cc:906
FLTNB m_startTimeInSec
Definition: vDataFile.hh:524
int64_t m_mpi1stEvent
Definition: vDataFile.hh:541
Declaration of class iEventSPECT.
void SetPOIResolution(FLTNB ap_value[3])
initialize the POI resolution (for list-mode)
Definition: vDataFile.hh:416
Declaration of class iEventHistoPET.
int PROJ_WriteData()
Write/Merge chunk of data in a general data file.
Definition: vDataFile.cc:928
string GetHeaderDataFileName()
Definition: vDataFile.hh:303
int64_t m_mpiLastEvent
Definition: vDataFile.hh:542
bool GetIgnorePOIFlag()
Definition: vDataFile.hh:345
bool m_ignorePOIFlag
Definition: vDataFile.hh:533
int64_t m_sizeArrayEvents
Definition: vDataFile.hh:546
virtual int CheckSpecificParameters()=0
This function is implemented in child classes Check specific parameters of child classes...
void SetStartTime(FLTNB a_value)
Definition: vDataFile.hh:455
vDataFile()
vDataFile constructor.
Definition: vDataFile.cc:26
void SetDataType(int a_dataType)
set the data type
Definition: vDataFile.hh:366
void SetCalibrationFactor(FLTNB a_value)
initialize the global calibration factor with a FLTNB value
Definition: vDataFile.hh:439
void ResetBufferRange()
Simply set the m_1stIdxArrayEvents and m_lastIdxArrayEvents to -1 only if the percentage load is stri...
Definition: vDataFile.cc:491
int m_dataType
Definition: vDataFile.hh:523
oImageDimensionsAndQuantification * mp_ID
Definition: vDataFile.hh:514
int CheckConsistencyWithAnotherBedDatafile(vDataFile *ap_Datafile)
Check consistency between 'this' and the provided datafile as two bed positions.
Definition: vDataFile.cc:339
Declaration of class sScannerManager.
virtual int ReadSpecificInfoInHeader(bool a_affectQuantificationFlag=true)=0
This function is implemented in child classes Read and check modality-specific information from the...
Declaration of class vEvent.
virtual int PrepareDataFile()=0
This function is implemented in child classes Store different kind of information inside arrays (da...
fstream ** m2p_dataFile
Definition: vDataFile.hh:518
FLTNB * GetPOIResolution()
Definition: vDataFile.hh:333
int m_percentageLoad
Definition: vDataFile.hh:547
int GetDataType()
Definition: vDataFile.hh:286
int GetBedIndex()
Definition: vDataFile.hh:274
void SetHeaderDataFileName(const string &a_headerFileName)
set the data header file name
Definition: vDataFile.hh:431
int64_t * mp_nbEventsReadFromFile
Definition: vDataFile.hh:552
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...
string GetScannerName()
Definition: vDataFile.hh:469
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 generatio...
Definition: vDataFile.cc:1056
int m_bedIndex
Definition: vDataFile.hh:527
int PROJ_DeleteTmpDatafile()
Delete temporary datafile used for multithreaded output writing if needed.
Definition: vDataFile.cc:1008
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 direc...
Definition: vDataFile.cc:609
bool m_currentlyFillingBuffer
Definition: vDataFile.hh:549
vEvent * GetEventFromFile(int64_t a_eventIndex, int a_th)
Return the a_eventIndex event from the datafile.
Definition: vDataFile.cc:849
int GetPercentageLoad()
Get the percentage of the data file that will be loaded in memory.
Definition: vDataFile.hh:387
virtual int CheckSpecificConsistencyWithAnotherDatafile(vDataFile *ap_Datafile)=0
Check consistency between 'this' and the provided datafile, for specific characteristics.
int FillBuffer(int64_t a_eventIndex)
Fill 'mp_arrayEvents' from the 'a_eventIndex' position in the data file. The filling process stops ...
Definition: vDataFile.cc:513
void SetNbEvents(int64_t a_value)
initialize the number of events with a int64_t value
Definition: vDataFile.hh:447
FLTNB mp_POIResolution[3]
Definition: vDataFile.hh:535
bool * mp_currentlyReadingBuffer
Definition: vDataFile.hh:550
Declaration of class iEventListPET.
void SetBedIndex(int a_bedIndex)
set the bed index corresponding to this data file
Definition: vDataFile.hh:373
Declaration of class sOutputManager.
Mother class for the Event objects.
Definition: vEvent.hh:23
Declaration of class iEventPET.
int GetDataMode()
Definition: vDataFile.hh:280
vEvent ** m2p_BufferEvent
Definition: vDataFile.hh:538
string GetDataFileName()
Definition: vDataFile.hh:309
bool m_POIInfoFlag
Definition: vDataFile.hh:532
This class is designed to manage all dimensions and quantification related stuff. ...
int64_t m_mpiNbEvents
Definition: vDataFile.hh:543
int InitializeFile()
Instantiate the fstream objets for input reading and check if the related datafile's existence and co...
Definition: vDataFile.cc:412
Declaration of class iEventNorm.
char ** m2p_bufferEventFromFile
Definition: vDataFile.hh:540
string m_scannerName
Definition: vDataFile.hh:529
FLTNB m_calibrationFactor
Definition: vDataFile.hh:526
virtual int PROJ_GetScannerSpecificParameters()=0
This function is implemented in child classes It is used to set several variables of the datafile w...
int64_t m_lastIdxArrayEvents
Definition: vDataFile.hh:545
int GetVerbose()
Get the verbose level.
Definition: vDataFile.hh:401
virtual int Shuffle(int64_t)
Definition: vDataFile.cc:568
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
set the pointer to the oImageDimensionsAndQuantification object
Definition: vDataFile.hh:408
int64_t GetDuration()
Definition: vDataFile.hh:321
void SetPercentageLoad(int a_percentageLoad)
Set the percentage of the data file that will be loaded in memory.
Definition: vDataFile.hh:380
virtual int PROJ_InitFile()=0
This function is implemented in child classes Initialize the fstream objets for output writing as w...
int m_verbose
Definition: vDataFile.hh:515
int64_t m_totalNbEvents
Definition: vDataFile.hh:521
int64_t GetStartTime()
Definition: vDataFile.hh:315