CASToR  3.0
Tomographic Reconstruction (PET/SPECT/CT)
vDeformation.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 VDEFORMATION_HH
31 #define VDEFORMATION_HH 1
32 
33 #include "gVariables.hh"
34 
35 // These definitions are used to simply discriminate between forward and backward deformation
36 #define FORWARD_DEFORMATION 0
37 #define BACKWARD_DEFORMATION 1
38 
39 class oImageSpace;
41 
65 {
66  // -----------------------------------------------------------------------------------------
67  // Constructor & Destructor
68  public:
73  vDeformation();
78  virtual ~vDeformation();
79 
80 
81  // -----------------------------------------------------------------------------------------
82  // Public member functions
83  public:
89  inline void SetImageDimensionsAndQuantification( oImageDimensionsAndQuantification* ap_ImageDimensionsAndQuantification )
90  {mp_ID = ap_ImageDimensionsAndQuantification;}
96  inline void SetVerbose( int a_verbose )
97  {m_verbose = a_verbose;}
104  inline void SetNbTransformations( int a_nbTransformations )
105  {m_nbTransformations = a_nbTransformations;}
112  virtual int CheckParameters();
119  virtual int CheckSpecificParameters() = 0;
127  virtual int ReadAndCheckConfigurationFile( const string& a_fileOptions ) = 0;
135  virtual int ReadAndCheckOptionsList( const string& a_listOptions ) = 0;
142  virtual int Initialize() = 0;
148  virtual void ShowHelp() = 0;
149 
150 
151  // -----------------------------------------------------------------------------------------
152  // Reconstruction deformation function
153  public:
168  virtual int PerformDeformation( oImageSpace* ap_Image, int a_defIdx, int a_fr, int a_rimg, int a_cimg );
169 
170 
184  virtual int PerformHistoSensitivityDeformation( oImageSpace* ap_Image, int a_defIdx, int fr, int rimg, int cimg );
196  virtual int ApplyDeformationsToBackwardImage( oImageSpace* ap_Image, int a_fr, int a_defIdx );
208  virtual int ApplyDeformationsToHistoSensitivityImage( oImageSpace* ap_Image, int a_fr, int a_defIdx );
223  virtual int PerformSensitivityDeformation( oImageSpace* ap_Image, int a_defDirection, int a_defIdx, int fr, int rg, int cg );
234  virtual int ApplyDeformations( FLTNB* ap_inputImage, FLTNB* ap_outputImage, int a_direction, int a_defIdx ) = 0;
235 
236 
237  /*
238  \fn Tlerp
239  \param ap_inputImage : input image matrix
240  \param ap_outputImage : output image matrix
241  \param iov : index of the voxel to interpolate in the output image
242  \param iiv : index of the input image central voxel for interpolation
243  \param dx : x-axis difference between output voxel cartesian position after transformation and center of estimated vox position
244  \param dy : y-axis difference between output voxel cartesian position after transformation and center of estimated vox position
245  \param dz : z-axis difference between output voxel cartesian position after transformation and center of estimated vox position
246  \brief This function performs a trilinear interpolation for a specific voxel
247  \todo : perhaps use padded image in order to avoid if statements
248  \return 0 if success, other value otherwise.
249  */
250  int Tlerp(HPFLTNB *ap_inputImage, HPFLTNB *ap_outputImage, uint32_t iov, uint32_t iiv, FLTNB dX, FLTNB dY, FLTNB dZ);
251 
252 
253 
254 
255  // -----------------------------------------------------------------------------------------
256  // Data members
257  protected:
259  int m_verbose;
261  int m_checked;
263 };
264 
265 
266 // ----------------------------------------------------------------------
267 // Part of code that manages the auto declaration of children classes
268 // ----------------------------------------------------------------------
269 
270 // Macro for the function that creates the object
271 #define FUNCTION_DEFORMATION(CLASS) \
272  static vDeformation *make_deformation() { return new CLASS(); };
273 
274 // Macro for the class that links the appropriate function to the map of objects
275 #define CLASS_DEFORMATION(NAME,CLASS) \
276  class NAME##DeformationCreator \
277  { \
278  public: \
279  NAME##DeformationCreator() \
280  { sAddonManager::GetInstance()->mp_listOfDeformations[#NAME] = CLASS::make_deformation; } \
281  }; \
282  static NAME##DeformationCreator DeformationCreator##NAME;
283 
284 #endif
void SetVerbose(int a_verbose)
Set the verbose level.
Definition: vDeformation.hh:96
This header file is mainly used to declare some macro definitions and all includes needed from the st...
vDeformation()
Constructor of vDeformation. Simply set all data members to default values.
Definition: vDeformation.cc:42
virtual ~vDeformation()
Destructor of vDeformation.
Definition: vDeformation.cc:62
oImageDimensionsAndQuantification * mp_ID
virtual int ApplyDeformationsToBackwardImage(oImageSpace *ap_Image, int a_fr, int a_defIdx)
Apply backward transformation of the backward image to the reference position.
#define FLTNB
Definition: gVariables.hh:81
void SetNbTransformations(int a_nbTransformations)
Set the number of transformation in the data to be performed on the dataset (equal to the number of g...
int m_nbTransformations
virtual int ReadAndCheckConfigurationFile(const string &a_fileOptions)=0
This function is used to read options from a configuration file. It is pure virtual so must be impl...
#define HPFLTNB
Definition: gVariables.hh:83
virtual int PerformDeformation(oImageSpace *ap_Image, int a_defIdx, int a_fr, int a_rimg, int a_cimg)
Apply deformations during reconstruction.
virtual int PerformHistoSensitivityDeformation(oImageSpace *ap_Image, int a_defIdx, int fr, int rimg, int cimg)
Apply deformations on the sensitivity image during reconstruction in histogram mode.
virtual int Initialize()=0
This function is used to initialize specific data related to the child deformation model...
virtual int CheckParameters()
This function is used to check parameters after the latter have been all set using Set functions...
Definition: vDeformation.cc:77
int Tlerp(HPFLTNB *ap_inputImage, HPFLTNB *ap_outputImage, uint32_t iov, uint32_t iiv, FLTNB dX, FLTNB dY, FLTNB dZ)
virtual int ApplyDeformations(FLTNB *ap_inputImage, FLTNB *ap_outputImage, int a_direction, int a_defIdx)=0
This function prepares the deformation to perform It is a virtual pure deformation function to be i...
This is the mother class of image-based transformation class.
Definition: vDeformation.hh:64
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the image dimensions in use.
Definition: vDeformation.hh:89
virtual int PerformSensitivityDeformation(oImageSpace *ap_Image, int a_defDirection, int a_defIdx, int fr, int rg, int cg)
Apply image deformations during sensitivity image generation for list-mode.
This class holds all the matrices in the image domain that can be used in the algorithm: image...
Definition: oImageSpace.hh:60
This class is designed to manage all dimensions and quantification related stuff. ...
virtual int ReadAndCheckOptionsList(const string &a_listOptions)=0
This function is used to read parameters from a string. It is pure virtual so must be implemented b...
virtual int CheckSpecificParameters()=0
This function is used to check the parameters of the child functions before initialization if require...
virtual void ShowHelp()=0
This function is used to print out specific help about the deformation and its options. It is pure virtual so must be implemented by children.
virtual int ApplyDeformationsToHistoSensitivityImage(oImageSpace *ap_Image, int a_fr, int a_defIdx)
Apply backward transformations of the sensitivity image to the reference position (histogram mode) ...