CASToR  3.0
Tomographic Reconstruction (PET/SPECT/CT)
oImageSpace.hh
Go to the documentation of this file.
1 /*
2 This file is part of CASToR.
3 
4  CASToR is free software: you can redistribute it and/or modify it under the
5  terms of the GNU General Public License as published by the Free Software
6  Foundation, either version 3 of the License, or (at your option) any later
7  version.
8 
9  CASToR is distributed in the hope that it will be useful, but WITHOUT ANY
10  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  details.
13 
14  You should have received a copy of the GNU General Public License along with
15  CASToR (in file GNU_GPL.TXT). If not, see <http://www.gnu.org/licenses/>.
16 
17 Copyright 2017-2019 all CASToR contributors listed below:
18 
19  --> Didier BENOIT, Claude COMTAT, Marina FILIPOVIC, Thibaut MERLIN, Mael MILLARDET, Simon STUTE, Valentin VIELZEUF
20 
21 This is CASToR version 3.0.
22 */
23 
30 #ifndef OIMAGESPACE_HH
31 #define OIMAGESPACE_HH 1
32 
33 #include "gVariables.hh"
35 #include "oDeformationManager.hh"
36 #include "oInterfileIO.hh"
37 
38 class vOptimizer;
39 
61 {
62  // Constructor & Destructor
63  public:
68  oImageSpace();
72  ~oImageSpace();
73 
74 
75  // -------------------------------------------------------------------
76  // Public member functions
77  public:
78 
79  // Let these pointers public to simplify getting them in other classes
181  // -------------------------------------------------------------------
186  void InstantiateImage();
191  void DeallocateImage();
203  void DeallocateForwardImage();
210  void InstantiateBackwardImageFromDynamicBasis(int a_nbBackwardImages);
238  void InstantiateSensitivityImage(const string& a_pathToSensitivityImage);
263  int InitMultiModalImage(const vector<string>& a_pathToMultiModalImage);
276  int InitMaskImage(const string& a_pathToImage);
281  void DeallocateMaskImage();
282 
283 
291  void InstantiateOutputImage();
305  //void InstantiateSensImageForDeformation();
315  //void DeallocateBwdImageForDeformation();
325  void DeallocateOutputImage();
340  int InitImage(const string& a_pathToInitialImage, FLTNB a_value);
345  void InitBackwardImage();
356  int InitSensitivityImage(const string& a_pathToSensitivityImage);
363  //void InitBwdImageForDeformation();
368  //void InitSensImageForDeformation();
380  int LoadInitialImage(const string& a_pathToImage);
386  void ComputeOutputImage();
392  int ApplyOutputFOVMasking();
398  int ApplyOutputMaskImage();
410  int ApplyOutputFlip();
418  int SaveOutputImage(int a_iteration, int a_subset = -1);
426  int SaveOutputBasisCoefficientImage(int a_iteration, int a_subset = -1);
432  void SaveDebugImage(const string& a_name);
439  int SaveSensitivityImage(const string& a_pathToSensitivityImage);
444  void PrepareForwardImage();
449  void Reduce();
456 
457 
458  // -------------------------------------------------------------------
459  // Functions for List-Mode Sensitivity Generation process
460 
466  void LMS_InstantiateImage();
484  void LMS_DeallocateImage();
511  int InitAttenuationImage(const string& a_pathToAtnImage);
517  void LMS_CopyAtnToImage();
525  void LMS_CopyAtnToForwardImage(bool a_use1stMotion, bool a_use2ndMotion);
546  void ReduceBackwardImage(int a_imageIndex, int a_timeIndex, int a_respIndex, int a_cardIndex);
552  int ApplyMaskToBackwardImage(int a_imageIndex, int a_timeIndex, int a_respIndex, int a_cardIndex);
561  int LMS_SaveSensitivityImage(const string& a_pathToSensitivityImage, oDeformationManager* ap_DeformationManager);
562 
563 
564  // -------------------------------------------------------------------
565  // Functions for ANALYTICAL PROJECTION process
566 
575  void PROJ_InstantiateProjectionImage(int a_nbProjs, int a_nbPixels);
583  void PROJ_DeallocateProjectionImage(int a_nbProjs);
590  int PROJ_InitImage(const string& a_pathToInitialImage);
597  int PROJ_LoadInitialImage(const string& a_pathToImage);
606 
607 
608  // -------------------------------------------------------------------
609  // Public Get and Set functions
610  public:
616  inline void SetVerbose(int a_verboseLevel)
617  {m_verbose = a_verboseLevel;}
623  inline void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification* ap_ImageDimensionsAndQuantification)
624  {mp_ID = ap_ImageDimensionsAndQuantification;}
629  inline int GetNbBackwardImages()
630  {return m_nbBackwardImages;}
635  inline bool IsLoadedSensitivity()
636  {return m_loadedSensitivity;}
640  inline bool IsLoadedMultiModal()
641  {return m_loadedMultiModal;}
646  inline bool IsLoadedMask()
647  {return m_loadedMask;}
653  inline bool Checked()
654  {return mp_ID!=NULL && m_verbose!=-1;}
660  {return m_nbMiscellaneousImages;}
661 
662 
663  // -------------------------------------------------------------------
664  // Data members
665  private:
667  int m_verbose;
673 };
674 
675 #endif
int ApplyMaskToBackwardImage(int a_imageIndex, int a_timeIndex, int a_respIndex, int a_cardIndex)
Apply the mask to the backward image matrix of the first thread for the specific image / time / respi...
FLTNB **** m4p_forwardImage
Definition: oImageSpace.hh:87
void LMS_InstantiateImage()
Allocate memory for the main image matrices (for list-mode sensitivity generation) ...
This header file is mainly used to declare some macro definitions and all includes needed from the st...
void DeallocateMiscellaneousImage()
Deallocate all allocated miscellaneous images.
Definition: oImageSpace.cc:557
FLTNB ** m2p_projectionImage
Definition: oImageSpace.hh:174
Declaration of class oImageDimensionsAndQuantification.
FLTNB **** m4p_refDynForwardImage
Definition: oImageSpace.hh:144
void DeallocateBackwardImageFromDynamicBasis()
Free memory for the backward image matrices.
Definition: oImageSpace.cc:264
int m_nbBackwardImages
Definition: oImageSpace.hh:671
void LMS_CopyAtnToForwardImage(bool a_use1stMotion, bool a_use2ndMotion)
Copy the attenuation image contained in the &#39;m2p_attenuation&#39; matrix inside the m4p_forwardImage matr...
#define FLTNB
Definition: gVariables.hh:81
int InitMaskImage(const string &a_pathToImage)
Memory allocation and initialization for the mask image.
Definition: oImageSpace.cc:670
int PROJ_InitImage(const string &a_pathToInitialImage)
Load the initial image for the analytical projection.
int ApplyOutputMaskImage()
Mask the outside of the provided input mask image.
void DeallocateImage()
Free memory for the main image matrices.
Definition: oImageSpace.cc:116
int LMS_SaveSensitivityImage(const string &a_pathToSensitivityImage, oDeformationManager *ap_DeformationManager)
Call the interfile function to write the sensitivity image on disk.
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)
Memory allocation and initialization for the multimodal image matrices.
Definition: oImageSpace.cc:604
Declaration of class oDeformationManager.
bool IsLoadedSensitivity()
Definition: oImageSpace.hh:635
int ApplyOutputFOVMasking()
Mask the outside of the transaxial FOV based on the m_fovOutPercent.
void DeallocateMultiModalImage()
Free memory for the multimodal image.
Definition: oImageSpace.cc:651
~oImageSpace()
oImageSpace destructor.
Definition: oImageSpace.cc:69
FLTNB ***** m5p_refDynBackwardImage
Definition: oImageSpace.hh:154
void DeallocateSensitivityImage()
Free memory for the sensitivity image matrices.
Definition: oImageSpace.cc:461
void InstantiateImage()
Allocate memory for the main image matrices.
Definition: oImageSpace.cc:80
int PROJ_SaveProjectionImage()
Save an image of the projected data (for analytic projection)
void InstantiateBackwardImageFromDynamicBasis(int a_nbBackwardImages)
Allocate memory for the backward image matrices and set the number of backward images for the whole c...
Definition: oImageSpace.cc:219
int GetNbMiscellaneousImages()
Definition: oImageSpace.hh:659
int ApplyMaskToSensitivity()
Apply the mask to the sensitivity image (only for the first thread, the image must be reduced beforeh...
bool m_loadedSensitivity
Definition: oImageSpace.hh:668
void LMS_InstantiateForwardImage()
Allocate memory for the forward image matrices (for list-mode sensitivity generation) ...
void InstantiateSensitivityImage(const string &a_pathToSensitivityImage)
Allocate the sensitivity image matrices.
Definition: oImageSpace.cc:386
FLTNB **** m4p_refDynSensitivityImage
Definition: oImageSpace.hh:165
oImageDimensionsAndQuantification * mp_ID
Definition: oImageSpace.hh:666
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)
Memory allocation and initialisation for the attenuation image using either :
int InitImage(const string &a_pathToInitialImage, FLTNB a_value)
Initialize the main image, either using:
void DeallocateVisitedVoxelsImage()
Free memory for the image matrix containing binary information regarding which 3D voxels have been vi...
Definition: oImageSpace.cc:592
void SaveDebugImage(const string &a_name)
Just a debug function dedicated to write any kind of image on disk in raw format, for debugging purpo...
bool IsLoadedMask()
Definition: oImageSpace.hh:646
void DeallocateMaskImage()
Free memory for the mask image.
Definition: oImageSpace.cc:711
int PROJ_LoadInitialImage(const string &a_pathToImage)
Load the initial image for the analytical projection.
FLTNB * mp_visitedVoxelsImage
Definition: oImageSpace.hh:121
void PROJ_DeallocateProjectionImage(int a_nbProjs)
Free memory for the projection image for analytical projection.
void PrepareForwardImage()
Copy current image matrix in the forward-image buffer matrix.
int SaveOutputBasisCoefficientImage(int a_iteration, int a_subset=-1)
Call the interfile function to write output basis function coefficient image on disk.
FLTNB ****** m6p_backwardImage
Definition: oImageSpace.hh:94
FLTNB **** m4p_image
Definition: oImageSpace.hh:80
void InstantiateVisitedVoxelsImage()
Memory allocation and initialization for the image matrix containing binary information regarding whi...
Definition: oImageSpace.cc:580
void InitRefImagesForDeformation()
bool m_loadedMultiModal
Definition: oImageSpace.hh:669
void CleanNeverVisitedVoxels()
Based on the visitedVoxelsImage, clean the never visited voxels in the image. This function must be c...
bool m_loadedMask
Definition: oImageSpace.hh:670
void LMS_DeallocateSensitivityImage()
Free memory for the sensitivity image matrices (for list-mode sensitivity generation) ...
FLTNB ** m2p_multiModalImage
Definition: oImageSpace.hh:112
int SaveOutputImage(int a_iteration, int a_subset=-1)
Call the interfile function to write output image on disk.
void LMS_DeallocateImage()
Free memory for the main image matrices (for list-mode sensitivity generation)
void ComputeOutputImage()
int LoadInitialImage(const string &a_pathToImage)
Load the initial image provided by the user in the corresponding matrix.
FLTNB **** m4p_outputImage
Definition: oImageSpace.hh:135
void DeallocateRefImagesForDeformation()
Free memory for the buffer sensitivity image required for image-based deformation. This function is called from the Deformation Manager.
Definition: oImageSpace.cc:979
int GetNbBackwardImages()
Definition: oImageSpace.hh:629
bool IsLoadedMultiModal()
Definition: oImageSpace.hh:640
FLTNB ** m2p_miscellaneousImage
Definition: oImageSpace.hh:125
FLTNB * mp_maskImage
Definition: oImageSpace.hh:117
void InstantiateForwardImage()
Allocate memory for the forward image matrices.
Definition: oImageSpace.cc:149
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
set the pointer to the oImageDimensionsAndQuantification object
Definition: oImageSpace.hh:623
void PROJ_InstantiateProjectionImage(int a_nbProjs, int a_nbPixels)
Instanciate and initialize projection image for analytical projection.
void ReduceBackwardImage(int a_imageIndex, int a_timeIndex, int a_respIndex, int a_cardIndex)
Merge parallel results into the backward image matrix of the first thread for the specific image / ti...
This class is designed to generically described any iterative optimizer.
Definition: vOptimizer.hh:59
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.
Definition: oImageSpace.cc:307
void SetVerbose(int a_verboseLevel)
set verbosity
Definition: oImageSpace.hh:616
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.
Definition: oImageSpace.cc:787
This class holds all the matrices in the image domain that can be used in the algorithm: image...
Definition: oImageSpace.hh:60
FLTNB * AllocateMiscellaneousImage()
Allocate a new miscellaneous image on m2p_miscellaneousImages and return the pointer to this image...
Definition: oImageSpace.cc:527
This class is designed to manage all dimensions and quantification related stuff. ...
oImageSpace()
oImageSpace constructor. Initialize the member variables to their default values. ...
Definition: oImageSpace.cc:38
This group of functions manages Interfile image file format.
FLTNB **** m4p_attenuation
Definition: oImageSpace.hh:128
bool Checked()
Simply check that the image dimensions and verbosity has been set.
Definition: oImageSpace.hh:653
void InstantiateRefImagesForDeformation()
Allocate memory for the buffer sensitivity image required for image-based deformation. This function is called from the Deformation Manager.
Definition: oImageSpace.cc:867
int m_nbMiscellaneousImages
Definition: oImageSpace.hh:672
int SaveSensitivityImage(const string &a_pathToSensitivityImage)
Call the interfile function to write the sensitivity image on disk.
void DeallocateBackwardImageFromDynamicBins()
Free memory of the backward image matrices.
Definition: oImageSpace.cc:343
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)
Initialization for the sensitivity image matrices.
void LMS_InstantiateSensitivityImage()
Allocate memory for the sensitivity image matrices (for list-mode sensitivity generation) ...
void DeallocateForwardImage()
Free memory for the forward image matrices.
Definition: oImageSpace.cc:185
FLTNB ***** m5p_sensitivity
Definition: oImageSpace.hh:104
void LMS_CopyBackwardToSensitivity()
void InstantiateOutputImage()
Instanciate Image matrices dedicated to output writing on disk.
Definition: oImageSpace.cc:740
void LMS_DeallocateForwardImage()
Free memory for the forward image matrices (for list-mode sensitivity generation) ...