CASToR  2.0
Tomographic Reconstruction (PET/SPECT/CT)
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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-2018 all CASToR contributors listed below:
18 
19  --> current contributors: Thibaut MERLIN, Simon STUTE, Didier BENOIT, Claude COMTAT, Marina FILIPOVIC, Mael MILLARDET
20  --> past contributors: Valentin VIELZEUF
21 
22 This is CASToR version 2.0.
23 */
24 
31 #ifndef OIMAGESPACE_HH
32 #define OIMAGESPACE_HH 1
33 
34 #include "gVariables.hh"
36 #include "oDeformationManager.hh"
37 #include "oInterfileIO.hh"
38 
39 class vOptimizer;
40 
62 {
63  // Constructor & Destructor
64  public:
69  oImageSpace();
73  ~oImageSpace();
74 
75 
76  // -------------------------------------------------------------------
77  // Public member functions
78  public:
79 
80  // Let these pointers public to simplify getting them in other classes
125  /*FLTNB* mp_visitedVoxelsImage; !< 1-D Dynamic array, containing binary information regarding which 3D voxels have been visited during the projection steps.
126  1 pointer:
127  3D voxels */
190  // -------------------------------------------------------------------
195  void InstantiateImage();
200  void DeallocateImage();
212  void DeallocateForwardImage();
219  void InstantiateBackwardImageFromDynamicBasis(int a_nbBackwardImages);
247  void InstantiateSensitivityImage(const string& a_pathToSensitivityImage);
272  int InitMultiModalImage(const vector<string>& a_pathToMultiModalImage);
285  int InitMaskImage(const string& a_pathToImage);
290  void DeallocateMaskImage();
291 
292 
300  void InstantiateOutputImage();
314  //void InstantiateSensImageForDeformation();
324  //void DeallocateBwdImageForDeformation();
334  void DeallocateOutputImage();
349  int InitImage(const string& a_pathToInitialImage, FLTNB a_value);
354  void InitBackwardImage();
365  int InitSensitivityImage(const string& a_pathToSensitivityImage);
372  //void InitBwdImageForDeformation();
377  //void InitSensImageForDeformation();
389  int LoadInitialImage(const string& a_pathToImage);
395  void ComputeOutputImage();
401  int ApplyOutputFOVMasking();
407  int ApplyOutputMaskImage();
419  int ApplyOutputFlip();
427  int SaveOutputImage(int a_iteration, int a_subset = -1);
433  void SaveDebugImage(const string& a_name);
440  int SaveSensitivityImage(const string& a_pathToSensitivityImage);
445  void PrepareForwardImage();
450  void Reduce();
457 
458 
459  // -------------------------------------------------------------------
460  // Functions for List-Mode Sensitivity Generation process
461 
467  void LMS_InstantiateImage();
485  void LMS_DeallocateImage();
512  int InitAttenuationImage(const string& a_pathToAtnImage);
518  void LMS_CopyAtnToImage();
526  void LMS_CopyAtnToForwardImage(bool a_use1stMotion, bool a_use2ndMotion);
547  void ReduceBackwardImage(int a_imageIndex, int a_timeIndex, int a_respIndex, int a_cardIndex);
553  int ApplyMaskToBackwardImage(int a_imageIndex, int a_timeIndex, int a_respIndex, int a_cardIndex);
562  int LMS_SaveSensitivityImage(const string& a_pathToSensitivityImage, oDeformationManager* ap_DeformationManager);
563 
564 
565  // -------------------------------------------------------------------
566  // Functions for ANALYTICAL PROJECTION process
567 
576  void PROJ_InstantiateProjectionImage(int a_nbProjs, int a_nbPixels);
584  void PROJ_DeallocateProjectionImage(int a_nbProjs);
591  int PROJ_InitImage(const string& a_pathToInitialImage);
598  int PROJ_LoadInitialImage(const string& a_pathToImage);
607 
608 
609  // -------------------------------------------------------------------
610  // Public Get and Set functions
611  public:
617  inline void SetVerbose(int a_verboseLevel)
618  {m_verbose = a_verboseLevel;}
624  inline void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification* ap_ImageDimensionsAndQuantification)
625  {mp_ID = ap_ImageDimensionsAndQuantification;}
630  inline int GetNbBackwardImages()
631  {return m_nbBackwardImages;}
636  inline bool IsLoadedSensitivity()
637  {return m_loadedSensitivity;}
641  inline bool IsLoadedMultiModal()
642  {return m_loadedMultiModal;}
647  inline bool IsLoadedMask()
648  {return m_loadedMask;}
654  inline bool Checked()
655  {return mp_ID!=NULL && m_verbose!=-1;}
661  {return m_nbMiscellaneousImages;}
662 
663 
664  // -------------------------------------------------------------------
665  // Data members
666  private:
668  int m_verbose;
674 };
675 
676 #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:88
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:559
FLTNB ** m2p_projectionImage
Definition: oImageSpace.hh:183
Declaration of class oImageDimensionsAndQuantification.
FLTNB **** m4p_refDynForwardImage
Definition: oImageSpace.hh:153
void DeallocateBackwardImageFromDynamicBasis()
Free memory for the backward image matrices.
Definition: oImageSpace.cc:266
int m_nbBackwardImages
Definition: oImageSpace.hh:672
void LMS_CopyAtnToForwardImage(bool a_use1stMotion, bool a_use2ndMotion)
Copy the attenuation image contained in the 'm2p_attenuation' 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:675
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:118
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:582
Declaration of class oDeformationManager.
bool IsLoadedSensitivity()
Definition: oImageSpace.hh:636
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:641
~oImageSpace()
oImageSpace destructor.
Definition: oImageSpace.cc:71
FLTNB ***** m5p_refDynBackwardImage
Definition: oImageSpace.hh:163
void DeallocateSensitivityImage()
Free memory for the sensitivity image matrices.
Definition: oImageSpace.cc:463
void InstantiateImage()
Allocate memory for the main image matrices.
Definition: oImageSpace.cc:82
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:221
int GetNbMiscellaneousImages()
Definition: oImageSpace.hh:660
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:669
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:388
FLTNB **** m4p_refDynSensitivityImage
Definition: oImageSpace.hh:174
oImageDimensionsAndQuantification * mp_ID
Definition: oImageSpace.hh:667
void LMS_CopyAtnToImage()
Copy the attenuation image contained in the 'm2p_attenuation' 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...
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:647
void DeallocateMaskImage()
Free memory for the mask image.
Definition: oImageSpace.cc:716
int PROJ_LoadInitialImage(const string &a_pathToImage)
Load the initial image for the analytical projection.
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.
FLTNB ****** m6p_backwardImage
Definition: oImageSpace.hh:95
FLTNB **** m4p_image
Definition: oImageSpace.hh:81
void InstantiateVisitedVoxelsImage()
Memory allocation and initialization for the image matrix containing binary information regarding whi...
void InitRefImagesForDeformation()
bool m_loadedMultiModal
Definition: oImageSpace.hh:670
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:671
void LMS_DeallocateSensitivityImage()
Free memory for the sensitivity image matrices (for list-mode sensitivity generation) ...
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:144
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:984
int GetNbBackwardImages()
Definition: oImageSpace.hh:630
bool IsLoadedMultiModal()
Definition: oImageSpace.hh:641
FLTNB ** m2p_miscellaneousImage
Definition: oImageSpace.hh:134
FLTNB * mp_maskImage
Definition: oImageSpace.hh:121
void InstantiateForwardImage()
Allocate memory for the forward image matrices.
Definition: oImageSpace.cc:151
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
set the pointer to the oImageDimensionsAndQuantification object
Definition: oImageSpace.hh:624
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:309
void SetVerbose(int a_verboseLevel)
set verbosity
Definition: oImageSpace.hh:617
void LMS_DeallocateAttenuationImage()
Free memory for the Attenuation image matrices (for analytical projection or list-mode sensitivity ge...
FLTNB ***** m5p_multiModalImage
Definition: oImageSpace.hh:113
void DeallocateOutputImage()
Free memory for the Image matrices dedicated to output writing on disk.
Definition: oImageSpace.cc:792
This class holds all the matrices in the image domain that can be used in the algorithm: image...
Definition: oImageSpace.hh:61
FLTNB * AllocateMiscellaneousImage()
Allocate a new miscellaneous image on m2p_miscellaneousImages and return the pointer to this image...
Definition: oImageSpace.cc:529
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:39
This group of functions manages Interfile image file format.
FLTNB **** m4p_attenuation
Definition: oImageSpace.hh:137
bool Checked()
Simply check that the image dimensions and verbosity has been set.
Definition: oImageSpace.hh:654
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:872
int m_nbMiscellaneousImages
Definition: oImageSpace.hh:673
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:345
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:187
FLTNB ***** m5p_sensitivity
Definition: oImageSpace.hh:105
void LMS_CopyBackwardToSensitivity()
FLTNB **** m4p_visitedVoxelsImage
Definition: oImageSpace.hh:128
void InstantiateOutputImage()
Instanciate Image matrices dedicated to output writing on disk.
Definition: oImageSpace.cc:745
void LMS_DeallocateForwardImage()
Free memory for the forward image matrices (for list-mode sensitivity generation) ...