CASToR  3.2
Tomographic Reconstruction (PET/SPECT/CT)
code/include/image/oImageSpace.hh
Go to the documentation of this file.
1 
8 #ifndef OIMAGESPACE_HH
9 #define OIMAGESPACE_HH 1
10 
11 #include "gVariables.hh"
13 #include "oDeformationManager.hh"
14 #include "oInterfileIO.hh"
15 
16 class vOptimizer;
17 
39 {
40  // Constructor & Destructor
41  public:
46  oImageSpace();
50  ~oImageSpace();
51 
52 
53  // -------------------------------------------------------------------
54  // Public member functions
55  public:
56 
57  // Let these pointers public to simplify getting them in other classes
159  // -------------------------------------------------------------------
164  void InstantiateImage();
169  void DeallocateImage();
181  void DeallocateForwardImage();
188  void InstantiateBackwardImageFromDynamicBasis(int a_nbBackwardImages);
216  void InstantiateSensitivityImage(const string& a_pathToSensitivityImage);
241  int InitMultiModalImage(const vector<string>& a_pathToMultiModalImage);
254  int InitMaskImage(const string& a_pathToImage);
259  void DeallocateMaskImage();
260 
261 
269  void InstantiateOutputImage();
283  //void InstantiateSensImageForDeformation();
293  //void DeallocateBwdImageForDeformation();
303  void DeallocateOutputImage();
318  int InitImage(const string& a_pathToInitialImage, FLTNB a_value);
323  void InitBackwardImage();
334  int InitSensitivityImage(const string& a_pathToSensitivityImage);
341  //void InitBwdImageForDeformation();
346  //void InitSensImageForDeformation();
358  int LoadInitialImage(const string& a_pathToImage);
364  void ComputeOutputImage();
370  int ApplyOutputFOVMasking();
376  int ApplyOutputMaskImage();
388  int ApplyOutputFlip();
396  int SaveOutputImage(int a_iteration, int a_subset = -1);
404  int SaveOutputBasisCoefficientImage(int a_iteration, int a_subset = -1);
410  void SaveDebugImage(const string& a_name);
417  int SaveSensitivityImage(const string& a_pathToSensitivityImage);
422  void PrepareForwardImage();
427  void Reduce();
434 
435 
436  // -------------------------------------------------------------------
437  // Functions for List-Mode Sensitivity Generation process
438 
444  void LMS_InstantiateImage();
462  void LMS_DeallocateImage();
489  int InitAttenuationImage(const string& a_pathToAtnImage);
495  void LMS_CopyAtnToImage();
503  void LMS_CopyAtnToForwardImage(bool a_use1stMotion, bool a_use2ndMotion);
524  void ReduceBackwardImage(int a_imageIndex, int a_timeIndex, int a_respIndex, int a_cardIndex);
530  int ApplyMaskToBackwardImage(int a_imageIndex, int a_timeIndex, int a_respIndex, int a_cardIndex);
539  int LMS_SaveSensitivityImage(const string& a_pathToSensitivityImage, oDeformationManager* ap_DeformationManager);
540 
541 
542  // -------------------------------------------------------------------
543  // Functions for ANALYTICAL PROJECTION process
544 
553  void PROJ_InstantiateProjectionImage(int a_nbProjs, int a_nbPixels);
561  void PROJ_DeallocateProjectionImage(int a_nbProjs);
568  int PROJ_InitImage(const string& a_pathToInitialImage);
575  int PROJ_LoadInitialImage(const string& a_pathToImage);
584 
585 
586  // -------------------------------------------------------------------
587  // Public Get and Set functions
588  public:
594  inline void SetVerbose(int a_verboseLevel)
595  {m_verbose = a_verboseLevel;}
601  inline void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification* ap_ImageDimensionsAndQuantification)
602  {mp_ID = ap_ImageDimensionsAndQuantification;}
607  inline int GetNbBackwardImages()
608  {return m_nbBackwardImages;}
613  inline bool IsLoadedSensitivity()
614  {return m_loadedSensitivity;}
618  inline bool IsLoadedMultiModal()
619  {return m_loadedMultiModal;}
624  inline bool IsLoadedMask()
625  {return m_loadedMask;}
631  inline bool Checked()
632  {return mp_ID!=NULL && m_verbose!=-1;}
638  {return m_nbMiscellaneousImages;}
639 
640 
641  // -------------------------------------------------------------------
642  // Data members
643  private:
645  int m_verbose;
651 };
652 
653 #endif
int ApplyMaskToBackwardImage(int a_imageIndex, int a_timeIndex, int a_respIndex, int a_cardIndex)
void LMS_InstantiateImage()
Allocate memory for the main image matrices (for list-mode sensitivity generation) ...
void DeallocateMiscellaneousImage()
Deallocate all allocated miscellaneous images.
This group of functions manages Interfile image file format.
void DeallocateBackwardImageFromDynamicBasis()
Free memory for the backward image matrices.
void LMS_CopyAtnToForwardImage(bool a_use1stMotion, bool a_use2ndMotion)
int InitMaskImage(const string &a_pathToImage)
int PROJ_InitImage(const string &a_pathToInitialImage)
int ApplyOutputMaskImage()
Mask the outside of the provided input mask image.
void DeallocateImage()
Free memory for the main image matrices.
int LMS_SaveSensitivityImage(const string &a_pathToSensitivityImage, oDeformationManager *ap_DeformationManager)
void LMS_PrepareForwardImage()
Copy current image in forward-image buffer (for list-mode sensitivity generation) ...
void Reduce()
Merge parallel results into the matrix of the backward image matrix of the first thread. Also for MPI.
int InitMultiModalImage(const vector< string > &a_pathToMultiModalImage)
int ApplyOutputFOVMasking()
Mask the outside of the transaxial FOV based on the m_fovOutPercent.
void DeallocateMultiModalImage()
Free memory for the multimodal image.
~oImageSpace()
oImageSpace destructor.
void DeallocateSensitivityImage()
Free memory for the sensitivity image matrices.
void InstantiateImage()
Allocate memory for the main image matrices.
int PROJ_SaveProjectionImage()
Save an image of the projected data (for analytic projection)
void InstantiateBackwardImageFromDynamicBasis(int a_nbBackwardImages)
int ApplyMaskToSensitivity()
Apply the mask to the sensitivity image (only for the first thread, the image must be reduced beforeh...
void LMS_InstantiateForwardImage()
Allocate memory for the forward image matrices (for list-mode sensitivity generation) ...
void InstantiateSensitivityImage(const string &a_pathToSensitivityImage)
void LMS_CopyAtnToImage()
Copy the attenuation image contained in the &#39;m2p_attenuation&#39; matrix inside the m2p_image matrix...
int InitAttenuationImage(const string &a_pathToAtnImage)
int InitImage(const string &a_pathToInitialImage, FLTNB a_value)
void DeallocateVisitedVoxelsImage()
Free memory for the image matrix containing binary information regarding which 3D voxels have been vi...
void SaveDebugImage(const string &a_name)
void DeallocateMaskImage()
Free memory for the mask image.
int PROJ_LoadInitialImage(const string &a_pathToImage)
void PROJ_DeallocateProjectionImage(int a_nbProjs)
void PrepareForwardImage()
Copy current image matrix in the forward-image buffer matrix.
int SaveOutputBasisCoefficientImage(int a_iteration, int a_subset=-1)
void InstantiateVisitedVoxelsImage()
Memory allocation and initialization for the image matrix containing binary information regarding whi...
void CleanNeverVisitedVoxels()
Based on the visitedVoxelsImage, clean the never visited voxels in the image. This function must be c...
void LMS_DeallocateSensitivityImage()
Free memory for the sensitivity image matrices (for list-mode sensitivity generation) ...
Declaration of class oDeformationManager.
int SaveOutputImage(int a_iteration, int a_subset=-1)
void LMS_DeallocateImage()
Free memory for the main image matrices (for list-mode sensitivity generation)
int LoadInitialImage(const string &a_pathToImage)
void DeallocateRefImagesForDeformation()
Free memory for the buffer sensitivity image required for image-based deformation. This function is called from the Deformation Manager.
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
void InstantiateForwardImage()
Allocate memory for the forward image matrices.
void PROJ_InstantiateProjectionImage(int a_nbProjs, int a_nbPixels)
void ReduceBackwardImage(int a_imageIndex, int a_timeIndex, int a_respIndex, int a_cardIndex)
This class is designed to generically described any iterative optimizer.
int ApplyOutputFlip()
Just flip the output image.
This class is designed to manage the image-based deformation part of the reconstruction.
void InstantiateBackwardImageFromDynamicBins()
Allocate memory for the backward image matrices and initialize them.
void LMS_DeallocateAttenuationImage()
Free memory for the Attenuation image matrices (for analytical projection or list-mode sensitivity ge...
void DeallocateOutputImage()
Free memory for the Image matrices dedicated to output writing on disk.
This class holds all the matrices in the image domain that can be used in the algorithm: image...
FLTNB * AllocateMiscellaneousImage()
Allocate a new miscellaneous image on m2p_miscellaneousImages and return the pointer to this image...
This class is designed to manage all dimensions and quantification related stuff. ...
Declaration of class oImageDimensionsAndQuantification.
oImageSpace()
oImageSpace constructor. Initialize the member variables to their default values. ...
bool Checked()
Simply check that the image dimensions and verbosity has been set.
void InstantiateRefImagesForDeformation()
Allocate memory for the buffer sensitivity image required for image-based deformation. This function is called from the Deformation Manager.
int SaveSensitivityImage(const string &a_pathToSensitivityImage)
void DeallocateBackwardImageFromDynamicBins()
Free memory of the backward image matrices.
oImageDimensionsAndQuantification * mp_ID
void InitBackwardImage()
Initialize each voxel of the backward images to 0, also for sensitivity if not loaded (estimated on t...
int InitSensitivityImage(const string &a_pathToSensitivityImage)
void LMS_InstantiateSensitivityImage()
Allocate memory for the sensitivity image matrices (for list-mode sensitivity generation) ...
void DeallocateForwardImage()
Free memory for the forward image matrices.
void SetVerbose(int a_verboseLevel)
void InstantiateOutputImage()
Instanciate Image matrices dedicated to output writing on disk.
void LMS_DeallocateForwardImage()
Free memory for the forward image matrices (for list-mode sensitivity generation) ...