CASToR  3.2
Tomographic Reconstruction (PET/SPECT/CT)
code/include/image/oImageDimensionsAndQuantification.hh
Go to the documentation of this file.
1 
8 #ifndef OIMAGEDIMENSIONSANDQUANTIFICATION_HH
9 #define OIMAGEDIMENSIONSANDQUANTIFICATION_HH 1
10 
11 #include "gVariables.hh"
12 #include "sOutputManager.hh"
13 #include "gOptions.hh"
14 #include "oDynamicDataManager.hh"
15 #include "oArterialInputCurve.hh"
16 // #include "oDynamicModelManager.hh"
17 
18 
27 #define STATIC_RECO 0
28 
29 #define DYN_RECO_FRAMING 1
30 
31 #define DYN_RECO_GATING 2
32 
33 #define DYN_RECO_MCGATING 3
34 
35 #define DYN_RECO_IPMC 4
36 
48 {
49  // -----------------------------------------------------------------------------------------
50  // Constructor & Destructor
51  public:
66 
67 
68  // -----------------------------------------------------------------------------------------
69  // Public member functions
70  public:
76  void SetDefault();
84  int CheckParameters();
94  int Initialize();
111  int DealWithBedPositions(vDataFile** a2p_DataFile);
112 
113  // -----------------------------------------------------------------------------------------
114  // Private member functions
115  private:
132  // int InitializeTimeBasisFunctions();
141  // int InitializeRespBasisFunctions();
150  // int InitializeCardBasisFunctions();
160 
161 
162  // -----------------------------------------------------------------------------------------
163  // Public dynamic data management functions
164  public:
183  int InitDynamicData( string a_pathTo4DDataSplittingFile,
184  int a_respMotionCorrectionFlag, int a_cardMotionCorrectionFlag, int a_invMotionCorrectionFlag,
185  int a_nbRespGates, int a_nbCardGates );
192  int CheckDynamicParameters(int64_t a_nbEvents);
202  inline int DynamicSwitch( int64_t a_currentEventIndex, uint32_t a_currentTime, int a_bed, int a_th )
203  {return mp_DynamicDataManager->DynamicSwitch(a_currentEventIndex, a_currentTime, a_bed, a_th);}
204 
205 
211  inline bool IsRespMotionEnabled()
218  inline bool IsCardMotionEnabled()
225  inline bool IsPMotionEnabled()
227 
228  // -----------------------------------------------------------------------------------------
229  // Public Get & Set functions related to the dynamic data management
230  public:
235  inline void SetRespMotionFlagOn()
241  inline void SetCardMotionFlagOn()
247  inline void SetPMotionFlagOn()
255  inline int GetCurrentRespGate(int a_th)
263  inline int GetCurrentCardGate(int a_th)
271  inline int GetPMotionFirstIndexForFrame(int a_fr)
273 
280  inline int GetPMotionLastIndexForFrame(int a_fr)
282 
289  inline int GetNb1stMotImgsForLMS(int a_fr)
298 
299 
305  inline FLTNB GetListPMotionWeightInFrameForLMS(int a_fr, int a_pmsset)
307 
308 
309 
316  inline int GetCurrentRespImage(int a_th)
324  inline int GetCurrentCardImage(int a_th)
332  inline int GetCurrentTimeFrame(int a_th)
340  inline int GetCurrentPMotionIndex(int a_th)
342 
350 
356  inline HPFLTNB GetdurationPerGate(int a_fr, int a_respGate)
357  {return mp_DynamicDataManager->GetDurationPerGate(a_fr,a_respGate);}
358 
363  inline bool GateDurationProvided()
365 
370  inline int GetDynRecoType()
371  {return m_dynRecoTypeFlag;}
372 
373 
374  // -----------------------------------------------------------------------------------------
375  // Get & Set functions
376  public:
382  inline void SetVerbose(int a_verbose)
383  {m_verbose = a_verbose;}
390  {return m_nbThreadsForProjection;}
403  inline int GetNbThreadsMax()
405  else return m_nbThreadsForImageComputation; }
414  int SetNbThreads(const string& a_nbThreads);
421  inline void SetMPIRankAndSize(int a_mpiRank, int a_mpiSize)
422  {m_mpiRank = a_mpiRank; m_mpiSize = a_mpiSize;}
428  inline int GetMPISize()
429  {return m_mpiSize;}
435  inline int GetMPIRank()
436  {return m_mpiRank;}
442  inline int GetNbBeds()
443  {return m_nbBeds;}
449  inline void SetNbBeds(int a_nbBeds)
450  {m_nbBeds = a_nbBeds; if (mp_bedPositions!=NULL) free(mp_bedPositions); mp_bedPositions = (FLTNB*)calloc(m_nbBeds,sizeof(FLTNB));}
457  inline FLTNB GetBedPosition(int a_bedIndex)
458  {return mp_bedPositions[a_bedIndex];}
470  inline int GetNbTimeFrames()
471  {return m_nbTimeFrames;}
478  {return m_nbTimeBasisFunctions;}
486  inline FLTNB GetTimeBasisCoefficient(int a_timeBasisFunction, int a_timeFrame)
487  {return m2p_timeBasisFunctions[a_timeBasisFunction][a_timeFrame];}
495  inline FLTNB GetFrameDurationInSec(int a_bed, int a_frame)
496  {return ((FLTNB)(m2p_frameDurationsInMs[a_bed][a_frame]))/1000.;}
504  inline FLTNB GetFrameTimeStartInSec(int a_bed, int a_frame)
505  {return ((FLTNB)(m2p_frameTimeStartInMs[a_bed][a_frame]))/1000.;}
513  inline FLTNB GetFrameTimeStopInSec(int a_bed, int a_frame)
514  {return ((FLTNB)(m2p_frameTimeStopInMs[a_bed][a_frame]))/1000.;}
521  inline FLTNB GetFinalTimeStopInSec(int a_bed)
522  {return ((FLTNB)(m2p_frameTimeStopInMs[a_bed][m_nbTimeFrames-1]))/1000.;}
530  inline uint32_t GetFrameDurationInMs(int a_bed, int a_frame)
531  {return m2p_frameDurationsInMs[a_bed][a_frame];}
539  inline uint32_t GetFrameTimeStartInMs(int a_bed, int a_frame)
540  {return m2p_frameTimeStartInMs[a_bed][a_frame];}
548  inline uint32_t GetFrameTimeStopInMs(int a_bed, int a_frame)
549  {return m2p_frameTimeStopInMs[a_bed][a_frame];}
556  inline uint32_t GetFinalTimeStopInMs(int a_bed)
557  {return m2p_frameTimeStopInMs[a_bed][m_nbTimeFrames-1];}
564  inline uint32_t* GetFramesTimeStartsArray(int a_bed)
565  {return m2p_frameTimeStartInMs[a_bed];}
572  inline uint32_t* GetFramesTimeStopArray(int a_bed)
573  {return m2p_frameTimeStopInMs[a_bed];}
580  inline uint32_t* GetFramesTimeDurationsArray(int a_bed)
581  {return m2p_frameDurationsInMs[a_bed];}
587  inline void SetFrames(const string& a_frameList)
588  {m_frameList = a_frameList;}
594  // TODO: Remove this function and option from castor-recon
595  inline void SetNbTimeBasisFunctions(int a_nbTimeBasisFunctions)
596  {m_nbTimeBasisFunctions = a_nbTimeBasisFunctions;}
602  inline void SetTimeBasisFunctions(FLTNB** a_m2pTimeBasisFunctions)
603  {m2p_timeBasisFunctions = a_m2pTimeBasisFunctions;}
609  inline void SetRespBasisFunctions(FLTNB** a_m2pRespBasisFunctions)
610  {m2p_respBasisFunctions = a_m2pRespBasisFunctions;}
616  inline void SetCardBasisFunctions(FLTNB** a_m2pCardBasisFunctions)
617  {m2p_cardBasisFunctions = a_m2pCardBasisFunctions;}
628  int SetAcquisitionTime(int a_bed, FLTNB a_timeStartInSec, FLTNB a_durationInSec, string a_GateListDurationsInSec);
634  inline bool GetTimeStaticFlag()
635  {return m_timeStaticFlag;}
641  inline int GetNbRespGates()
642  {return m_nbRespGates;}
649  {return m_nbRespBasisFunctions;}
657  inline FLTNB GetRespBasisCoefficient(int a_respBasisFunction, int a_respGate)
658  {return m2p_respBasisFunctions[a_respBasisFunction][a_respGate];}
664  inline void SetNbRespGates(int a_nbRespGates)
665  {m_nbRespGates = a_nbRespGates;}
671  inline void SetNbRespBasisFunctions(int a_nbRespBasisFunctions)
672  {m_nbRespBasisFunctions = a_nbRespBasisFunctions;}
678  inline void SetRespBasisFunctionsFile(const string& a_respBasisFunctionsFile)
679  {m_respBasisFunctionsFile = a_respBasisFunctionsFile;}
685  inline bool GetRespStaticFlag()
686  {return m_respStaticFlag;}
692  inline int GetNbCardGates()
693  {return m_nbCardGates;}
700  {return m_nbCardBasisFunctions;}
708  inline FLTNB GetCardBasisCoefficient(int a_cardBasisFunction, int a_cardGate)
709  {return m2p_cardBasisFunctions[a_cardBasisFunction][a_cardGate];}
715  inline void SetNbCardGates(int a_nbCardGates)
716  {m_nbCardGates = a_nbCardGates;}
722  inline void SetNbCardBasisFunctions(int a_nbCardBasisFunctions)
723  {m_nbCardBasisFunctions = a_nbCardBasisFunctions;}
729  inline void SetCardBasisFunctionsFile(const string& a_cardBasisFunctionsFile)
730  {m_cardBasisFunctionsFile = a_cardBasisFunctionsFile;}
736  inline bool GetCardStaticFlag()
737  {return m_cardStaticFlag;}
743  inline INTNB GetNbVoxX()
744  {return m_nbVoxX;}
750  inline INTNB GetNbVoxY()
751  {return m_nbVoxY;}
757  inline INTNB GetNbVoxZ()
758  {return m_nbVoxZ;}
764  inline INTNB GetNbVoxXY()
765  {return m_nbVoxXY;}
772  {return m_nbVoxXYZ;}
779  { return ((INTNB)(sqrt( ((FLTNB)m_nbVoxX) * ((FLTNB)m_nbVoxX) +
780  ((FLTNB)m_nbVoxY) * ((FLTNB)m_nbVoxY) +
781  ((FLTNB)m_nbVoxZ) * ((FLTNB)m_nbVoxZ) ))); }
787  inline void SetNbVoxX(INTNB a_nbVoxX)
788  {m_nbVoxX = a_nbVoxX;}
794  inline void SetNbVoxY(INTNB a_nbVoxY)
795  {m_nbVoxY = a_nbVoxY;}
801  inline void SetNbVoxZ(INTNB a_nbVoxZ)
802  {m_nbVoxZ = a_nbVoxZ;}
809  {return m_voxSizeX;}
816  {return m_voxSizeY;}
823  {return m_voxSizeZ;}
830  {return m_fovSizeX;}
837  {return m_fovSizeY;}
844  {return m_fovSizeZ;}
850  inline void SetVoxSizeX(FLTNB a_voxSizeX)
851  {m_voxSizeX = a_voxSizeX;}
857  inline void SetVoxSizeY(FLTNB a_voxSizeY)
858  {m_voxSizeY = a_voxSizeY;}
864  inline void SetVoxSizeZ(FLTNB a_voxSizeZ)
865  {m_voxSizeZ = a_voxSizeZ;}
871  inline void SetFOVSizeX(FLTNB a_fovSizeX)
872  {m_fovSizeX = a_fovSizeX;}
878  inline void SetFOVSizeY(FLTNB a_fovSizeY)
879  {m_fovSizeY = a_fovSizeY;}
885  inline void SetFOVSizeZ(FLTNB a_fovSizeZ)
886  {m_fovSizeZ = a_fovSizeZ;}
893  inline void SetFOVOutMasking(FLTNB a_fovOutPercent, INTNB a_nbSliceOutMask)
894  {m_fovOutPercent = a_fovOutPercent; m_nbSliceOutMask = a_nbSliceOutMask;}
901  {return m_fovOutPercent;}
908  {return m_nbSliceOutMask;}
915  int SetFlipOut(const string& a_flipOut);
921  inline bool GetFlipOutX()
922  {return m_flipOutX;}
928  inline bool GetFlipOutY()
929  {return m_flipOutY;}
935  inline bool GetFlipOutZ()
936  {return m_flipOutZ;}
942  inline FLTNB GetOffsetX()
943  {return m_offsetX;}
949  inline FLTNB GetOffsetY()
950  {return m_offsetY;}
956  inline FLTNB GetOffsetZ()
957  {return m_offsetZ;}
963  inline void SetOffsetX(FLTNB a_offsetX)
964  {m_offsetX = a_offsetX;}
970  inline void SetOffsetY(FLTNB a_offsetY)
971  {m_offsetY = a_offsetY;}
977  inline void SetOffsetZ(FLTNB a_offsetZ)
978  {m_offsetZ = a_offsetZ;}
987  FLTNB GetQuantificationFactor(int a_bed, int a_frame, int a_respGate, int a_cardGate);
992  inline long double GetLambda() {return m_lambda;}
1001  int SetCalibrationFactor(int a_bed, FLTNB a_calibrationFactor);
1010  int SetPETIsotope(int a_bed, const string& a_isotope);
1019  int SetSPECTIsotope(int a_bed, const string& a_isotope);
1027  int SetDynamicSpecificQuantificationFactors(const string& a_quantificationFile);
1028 
1029  int ProcessAndSetMask(FLTNB* ap_maskImage);
1030  bool IsVoxelMasked(INTNB a_voxIndex);
1031 
1037  inline void SetIgnoredCorrections(const string& a_ignoredCorrectionsList)
1038  {m_ignoredCorrectionsList = a_ignoredCorrectionsList;}
1045  {return m_ignoreAttnCorrectionFlag;}
1052  {return m_ignoreNormCorrectionFlag;}
1059  {return m_ignoreScatCorrectionFlag;}
1066  {return m_ignoreRandCorrectionFlag;}
1073  {return m_ignoreDecaCorrectionFlag;}
1080  {return m_ignoreBratCorrectionFlag;}
1087  {return m_ignoreFdurCorrectionFlag;}
1094  {return m_ignoreCaliCorrectionFlag;}
1101  {return m_nbMultiModalImages;}
1107  inline int GetNbFramesToSkip()
1108  {return m_nbFramesToSkip;}
1114  inline void SetNbMultiModalImages(int a_nbMultiModalImages)
1115  {m_nbMultiModalImages = a_nbMultiModalImages;}
1121  inline void SetTimeStaticFlag(bool a_flag)
1122  {m_timeStaticFlag = a_flag ;}
1128  inline void SetRespStaticFlag(bool a_flag)
1129  {m_respStaticFlag = a_flag ;}
1135  inline void SetCardStaticFlag(bool a_flag)
1136  {m_cardStaticFlag = a_flag ;}
1142  inline void SetnbFramesToSkip(int a_FramesToSkip)
1143  {m_nbFramesToSkip = a_FramesToSkip ;}
1148  inline bool IsInitialized() {return m_initialized;}
1153  inline bool HasMask() {return m_hasMask;}
1154 
1155 
1156 
1157 
1158  // -----------------------------------------------------------------------------------------
1159  // Data members
1160  private:
1162  // oDynamicModelManager* mp_DynamicModelManager; /*!< oDynamicModelManager object related to dynamic model management*/
1163  // Number of threads
1166  // MPI size and rank
1169  // Number of beds
1170  int m_nbBeds;
1173  // Framing of the acquisition
1174  string m_frameList;
1186  // Quantification
1197  long double m_lambda;
1198  // Respiratory gating
1204  // Cardiac gating
1210  // Image discretization
1225  // Percentage of transaxial FOV unmasked before saving
1228  // Output flip
1229  bool m_flipOutX;
1230  bool m_flipOutY;
1231  bool m_flipOutZ;
1232  // Parameters checked
1233  bool m_checked;
1234  // Object initialized
1236  // Verbose
1239  // Bool mask to exclude voxels from computations (projection, convolution, etc.)
1241  bool* mp_mask;
1242 };
1243 
1244 #endif
void SetCardMotionFlagOn()
Call the eponym function from the oDynamicDataManager class using the member object.
int InitializeFramingAndQuantification()
A function used to initialize the framing and quantification tables.
int GetCurrentRespGate(int a_th)
Return the index indicating the current respiratory gate for this thread.
This class is designed to be a mother virtual class for DataFile.
FLTNB GetListPMotionWeightInFrameForLMS(int a_fr, int a_pmsset)
oImageDimensionsAndQuantification()
The constructor of oImageDimensionsAndQuantification.
void SetRespMotionFlagOn()
set the respiratory motion flag to &#39;true&#39;
int GetNbCardBasisFunctions()
Get the number of cardiac basis functions.
void SetCardMotionFlagOn()
set the cardiac motion flag to &#39;true&#39;
bool GetIgnoreBratCorrectionFlag()
Get the boolean that says if the branching ratio correction is ignored or not.
FLTNB GetVoxSizeX()
Get the voxel&#39;s size along the X axis, in mm.
FLTNB GetTimeBasisCoefficient(int a_timeBasisFunction, int a_timeFrame)
This class gathers the information about the dynamic splitting of the data.
FLTNB GetFOVOutPercent()
Get the percentage of transaxial unmasked FOV.
void ResetCurrentDynamicIndices()
Reset to 0 the multithreaded dynamic arrays gathering the indices of current frame, gates and involuntary motion.
FLTNB GetVoxSizeZ()
Get the voxel&#39;s size along the Z axis, in mm.
int SetCalibrationFactor(int a_bed, FLTNB a_calibrationFactor)
void CheckNumberOfProjectionThreadsConsistencyWithDataFileSize(vDataFile **a2p_DataFile)
FLTNB GetFOVSizeZ()
Get the size of the field-of-view along the Z axis, in mm.
bool GetIgnoreAttnCorrectionFlag()
Get the boolean that says if the attenuation correction is ignored or not.
bool IsInitialized()
Returns true if the object has been initialized.
int GetNbMultiModalImages()
Get the number of additional multimodal images.
int GetNbIPatMotionSubsets()
return the number of involuntary patient motion transformations
int GetNbTimeBasisFunctions()
Get the number of time basis functions.
FLTNB GetFOVSizeY()
Get the size of the field-of-view along the Y axis, in mm.
int DynamicSwitch(int64_t a_currentEventIndex, uint32_t a_currentTime, int a_bed, int a_th)
FLTNB GetFOVSizeX()
Get the size of the field-of-view along the X axis, in mm.
bool GetProvidedBedPositionFlag()
Say if the bed relative position was provided from the datafile or not.
~oImageDimensionsAndQuantification()
The destructor of oImageDimensionsAndQuantification.
bool GetRespStaticFlag()
Get the respiratory static flag that says if the reconstruction has only one respiratory gate or not...
bool GetIgnoreNormCorrectionFlag()
Get the boolean that says if the normalization correction is ignored or not.
void SetPMotionFlagOn()
Call the eponym function from the oDynamicDataManager class using the member object.
bool GetIgnoreRandCorrectionFlag()
Get the boolean that says if the random correction is ignored or not.
int DynamicSwitch(int64_t a_index, uint32_t a_time, int a_bed, int a_th)
int GetNb2ndMotImgsForLMS()
return the number of secundary motion (typically cardiac) images to be used in the ImageSpace matrice...
bool GetIgnoreCaliCorrectionFlag()
Get the boolean that says if the calibration correction is ignored or not.
bool GetIgnoreFdurCorrectionFlag()
Get the boolean that says if the frame duration correction is ignored or not.
int CheckParameters()
A function used to check the parameters settings.
FLTNB GetVoxSizeY()
Get the voxel&#39;s size along the Y axis, in mm.
void SetRespMotionFlagOn()
Call the eponym function from the oDynamicDataManager class using the member object.
bool GetCardStaticFlag()
Get the cardiac static flag that says if the reconstruction has only one cardiac gate or not...
int GetNbIPatMotionSubsets()
call the eponym function from the oDynamicDataManager object
FLTNB GetRespBasisCoefficient(int a_respBasisFunction, int a_respGate)
int Initialize()
A function used to initialize all that is needed.
bool GetIgnoreDecaCorrectionFlag()
Get the boolean that says if the decay correction is ignored or not.
int GetNbThreadsMax()
Get the maximum between the number of threads used for projections and image operations.
int GetMPISize()
Get the MPI size (the number of MPI instances)
int GetCurrentTimeFrame(int a_th)
Return the index indicating the current time frame for this thread.
void ResetCurrentDynamicIndices()
Call the eponym function from the oDynamicDataManager class using the member object.
FLTNB GetCardBasisCoefficient(int a_cardBasisFunction, int a_cardGate)
FLTNB GetQuantificationFactor(int a_bed, int a_frame, int a_respGate, int a_cardGate)
int InitDynamicData(string a_pathTo4DDataSplittingFile, int a_respMotionCorrectionFlag, int a_cardMotionCorrectionFlag, int a_invMotionCorrectionFlag, int a_nbRespGates, int a_nbCardGates)
bool GetTimeStaticFlag()
Get the time static flag that says if the reconstruction has only one frame or not.
void SetIgnoredCorrections(const string &a_ignoredCorrectionsList)
void SetFOVOutMasking(FLTNB a_fovOutPercent, INTNB a_nbSliceOutMask)
FLTNB GetOffsetY()
Get the image offset along the Y axis, in mm.
bool GetFlipOutX()
Get the boolean saying if the output image must be flipped along the X axis.
bool GetFlipOutY()
Get the boolean saying if the output image must be flipped along the Y axis.
INTNB GetNbVoxDiagonal()
Get an estimation of the number of voxels along the image diagonal.
FLTNB GetOffsetZ()
Get the image offset along the Z axis, in mm.
void SetCardBasisFunctionsFile(const string &a_cardBasisFunctionsFile)
int GetNbThreadsForImageComputation()
Get the number of threads used for image operations.
int GetNb2ndMotImgsForLMS()
call the eponym function from the oDynamicDataManager object
This class is designed to manage all dimensions and quantification related stuff. ...
int GetNbThreadsForProjection()
Get the number of threads used for projections.
bool GetIgnoreScatCorrectionFlag()
Get the boolean that says if the scatter correction is ignored or not.
HPFLTNB GetDurationPerGate(int a_fr, int a_respGate)
FLTNB GetOffsetX()
Get the image offset along the X axis, in mm.
INTNB GetNbVoxX()
Get the number of voxels along the X axis.
INTNB GetNbVoxZ()
Get the number of voxels along the Z axis.
void SetDefault()
A function used to set number of threads and MPI instances to 1 and bypass the CheckParameters() func...
bool GetFlipOutZ()
Get the boolean saying if the output image must be flipped along the Z axis.
int SetAcquisitionTime(int a_bed, FLTNB a_timeStartInSec, FLTNB a_durationInSec, string a_GateListDurationsInSec)
int InitializeIgnoredCorrections()
A function used to initialize the ignored corrections.
int GetNbRespBasisFunctions()
Get the number of respiratory basis functions.
void SetRespBasisFunctionsFile(const string &a_respBasisFunctionsFile)
INTNB GetNbSliceOutMask()
Get the number of extrem slices that will be masked at each side.
INTNB GetNbVoxY()
Get the number of voxels along the Y axis.
void SetPMotionFlagOn()
set the involuntary patient motion flag to &#39;true&#39;
int SetDynamicSpecificQuantificationFactors(const string &a_quantificationFile)