CASToR  3.2
Tomographic Reconstruction (PET/SPECT/CT)
code/include/datafile/vDataFile.hh
Go to the documentation of this file.
1 
8 #ifndef VDATAFILE_HH
9 #define VDATAFILE_HH 1
10 
11 #include "gVariables.hh"
12 #include "vEvent.hh"
13 #include "iEventPET.hh"
14 #include "iEventListPET.hh"
15 #include "iEventHistoPET.hh"
16 #include "iEventSPECT.hh"
17 #include "iEventCT.hh"
18 #include "iEventNorm.hh"
19 #include "sOutputManager.hh"
20 #include "sScannerManager.hh"
21 #include "oImageDimensionsAndQuantification.hh"
22 #include "oMemoryMapped.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_CT 2
56 
66 #define SPEC_UNKNOWN -1
67 
68 #define SPEC_EMISSION 0
69 
70 #define SPEC_TRANSMISSION 1
71 
80 class vDataFile
81 {
82  // -------------------------------------------------------------------
83  // Constructor & Destructor
84  public:
89  vDataFile ();
93  virtual ~vDataFile();
94 
95  // -------------------------------------------------------------------
96  // Public member functions
97  public:
107  int ReadInfoInHeader(bool a_affectQuantificationFlag = true);
114  int SetParametersFrom(vDataFile* ap_DataFile);
121  int CheckParameters();
127  int InitializeMappedFile();
134  virtual int ComputeSizeEvent() = 0;
142  virtual int PrepareDataFile() = 0;
150  int OpenFileForWriting(string a_suffix="");
157  int CloseFile();
164  virtual int WriteHeader() = 0;
173  virtual int WriteEvent(vEvent* ap_Event, int a_th=0) = 0;
181  vEvent* GetEvent(int64_t a_eventIndex, int a_th = 0);
190  virtual vEvent* GetEventSpecific(char* ap_buffer, int a_th) = 0;
199  void GetEventIndexStartAndStop(int64_t* ap_indexStart, int64_t* ap_indexStop, int a_subsetNum = 0, int a_NbSubsets = 1);
214  void Describe();
219  virtual void DescribeSpecific() = 0;
220 
221  // -------------------------------------------------------------------
222  // Functions dedicated to analytical projections
223  public:
230  virtual int PROJ_InitFile() = 0;
238  virtual int PROJ_GetScannerSpecificParameters() = 0;
245  int PROJ_WriteData();
262  vEvent* PROJ_GenerateEvent(int idx_elt1, int idx_elt2, int a_th);
263 
264  // -------------------------------------------------------------------
265  // Public Get & Set FUNCTIONS
266  public:
271  inline int GetBedIndex()
272  {return m_bedIndex;}
277  inline int GetDataMode()
278  {return m_dataMode;}
283  string GetDataModeToString();
288  inline int GetDataType()
289  {return m_dataType;}
294  string GetDataTypeToString();
299  inline int GetDataSpec()
300  {return m_dataSpec;}
305  string GetDataSpecToString();
310  int64_t GetSize()
311  {return m_nbEvents;}
316  int64_t GetEventSize() {return m_sizeEvent;}
321  inline string GetHeaderDataFileName()
322  {return m_headerFileName;};
327  inline string GetDataFileName()
328  {return m_dataFileName;};
334  {return m_startTimeInSec;};
340  {return m_durationInSec;};
346  {return m_calibrationFactor;}
352  {return mp_POIResolution;}
357  inline bool* GetPOIDirectionFlag()
358  {return mp_POIDirectionFlag;}
363  inline bool GetPOIInfoFlag()
364  {return m_POIInfoFlag;}
369  inline bool GetIgnorePOIFlag()
370  {return m_ignorePOIFlag;}
377  virtual int GetMaxRingDiff();
383  inline void SetDataMode(int a_dataMode)
384  {m_dataMode = a_dataMode;}
390  inline void SetDataType(int a_dataType)
391  {m_dataType = a_dataType;}
397  inline void SetBedIndex(int a_bedIndex)
398  {m_bedIndex = a_bedIndex;}
403  inline bool GetBedPositionFlag()
404  {return m_bedPositionFlag;}
410  {return m_relativeBedPosition;}
416  inline void SetVerbose(int a_verboseLevel)
417  {m_verbose = a_verboseLevel;}
423  inline int GetVerbose()
424  {return m_verbose;}
430  inline void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification* ap_ImageDimensionsAndQuantification)
431  {mp_ID = ap_ImageDimensionsAndQuantification;}
438  inline void SetPOIResolution(FLTNB ap_value[3])
439  {for (int i=0 ; i<3 ; i++) mp_POIResolution[i] = ap_value[i];}
445  inline void SetIgnorePOIFlag(bool a_ignorePOIFlag)
446  {m_ignorePOIFlag = a_ignorePOIFlag;}
453  inline void SetHeaderDataFileName(const string& a_headerFileName)
454  {m_headerFileName = a_headerFileName;}
461  inline void SetBinaryDataFileName(const string& a_dataFileName)
462  {m_dataFileName = a_dataFileName;}
469  inline void SetCalibrationFactor(FLTNB a_value)
470  {m_calibrationFactor = a_value;}
477  inline void SetNbEvents(int64_t a_value)
478  {m_nbEvents = a_value;}
485  inline void SetStartTime(FLTNB a_value)
486  {m_startTimeInSec = a_value;}
493  inline void SetDuration(FLTNB a_value)
494  {m_durationInSec = a_value;}
499  inline string GetScannerName()
500  {return m_scannerName;}
501 
502  virtual int Shuffle( int64_t );
503 
504  // -------------------------------------------------------------------
505  // Private member functions
506  private:
513  virtual int SetSpecificParametersFrom(vDataFile* ap_DataFile) = 0;
520  virtual int CheckSpecificParameters() = 0;
527  virtual int CheckFileSizeConsistency() = 0;
537  virtual int ReadSpecificInfoInHeader(bool a_affectQuantificationFlag = true) = 0;
545  virtual int CheckSpecificConsistencyWithAnotherDataFile(vDataFile* ap_DataFile) = 0;
546 
547  // -------------------------------------------------------------------
548  // Data members
549  protected:
551  int m_verbose;
553  // Variables related to the acquisition
555  string m_dataFileName;
556  int64_t m_nbEvents;
566  string m_scannerName;
568  // POI: Position Of Interaction
574  // Members for I/O actions
575  int64_t m_sizeEvent;
576  fstream** m2p_dataFile;
578  int64_t m_mpi1stEvent;
579  int64_t m_mpiLastEvent;
580  int64_t m_mpiNbEvents;
583 };
584 
585 #endif
void SetDataMode(int a_dataMode)
void SetIgnorePOIFlag(bool a_ignorePOIFlag)
This class is designed to be a mother virtual class for DataFile.
void GetEventIndexStartAndStop(int64_t *ap_indexStart, int64_t *ap_indexStop, int a_subsetNum=0, int a_NbSubsets=1)
Implementation of file to memory mapping.
Declaration of class iEventPET.
Declaration of class vEvent.
Declaration of class iEventHistoPET.
int CheckParameters()
Check the initialization of member variables Call the CheckSpecificParameters() function implemente...
virtual int WriteHeader()=0
This function is implemented in child classes. Generate a header file according to the data output ...
virtual int CheckFileSizeConsistency()=0
int SetParametersFrom(vDataFile *ap_DataFile)
virtual int WriteEvent(vEvent *ap_Event, int a_th=0)=0
int ReadInfoInHeader(bool a_affectQuantificationFlag=true)
void SetVerbose(int a_verboseLevel)
virtual int ReadSpecificInfoInHeader(bool a_affectQuantificationFlag=true)=0
void SetDuration(FLTNB a_value)
Declaration of class iEventNorm.
virtual int ComputeSizeEvent()=0
This function is implemented in child classes Computation of the size of each event according to th...
int CheckConsistencyWithAnotherBedDataFile(vDataFile *ap_DataFile)
virtual ~vDataFile()
vDataFile destructor.
virtual int GetMaxRingDiff()
Return an error by default. This function is surcharged by the PET (and CT) scanner daughter class...
int InitializeMappedFile()
Check the datafile existency, map it to memory and get the raw char* pointer. .
virtual int CheckSpecificConsistencyWithAnotherDataFile(vDataFile *ap_DataFile)=0
void SetPOIResolution(FLTNB ap_value[3])
int PROJ_WriteData()
Write/Merge chunk of data in a general data file.
vEvent * GetEvent(int64_t a_eventIndex, int a_th=0)
int CloseFile()
Close as many binary file stream for writing.
void SetBinaryDataFileName(const string &a_dataFileName)
virtual int CheckSpecificParameters()=0
This function is implemented in child classes Check specific parameters of child classes...
void SetStartTime(FLTNB a_value)
vDataFile()
vDataFile constructor.
void SetDataType(int a_dataType)
void SetCalibrationFactor(FLTNB a_value)
virtual int PrepareDataFile()=0
This function is implemented in child classes Store different kind of information inside arrays (da...
void SetHeaderDataFileName(const string &a_headerFileName)
int OpenFileForWriting(string a_suffix="")
vEvent * PROJ_GenerateEvent(int idx_elt1, int idx_elt2, int a_th)
Declaration of class iEventListPET.
virtual void DescribeSpecific()=0
A pure virtual function used to describe the specific parts of the datafile.
Declaration of class iEventSPECT.
void SetNbEvents(int64_t a_value)
void SetBedIndex(int a_bedIndex)
Mother class for the Event objects.
void Describe()
A function used to describe the generic parts of the datafile.
This class is designed to manage all dimensions and quantification related stuff. ...
virtual vEvent * GetEventSpecific(char *ap_buffer, int a_th)=0
Portable read-only memory mapping (Windows and Linux)
int PROJ_DeleteTmpDataFile()
Delete temporary datafile used for multithreaded output writing if needed.
virtual int PROJ_GetScannerSpecificParameters()=0
This function is implemented in child classes It is used to set several variables of the datafile w...
int GetVerbose()
Get the verbose level.
virtual int Shuffle(int64_t)
!!!\ This function has been modified to be used specifically with a
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Declaration of class iEventCT.
virtual int SetSpecificParametersFrom(vDataFile *ap_DataFile)=0
virtual int PROJ_InitFile()=0
This function is implemented in child classes Initialize the fstream objets for output writing as w...
oImageDimensionsAndQuantification * mp_ID