CASToR  2.0
Tomographic Reconstruction (PET/SPECT/CT)
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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-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 VDEFORMATION_HH
32 #define VDEFORMATION_HH 1
33 
34 #include "gVariables.hh"
35 
36 // These definitions are used to simply discriminate between forward and backward deformation
37 #define FORWARD_DEFORMATION 0
38 #define BACKWARD_DEFORMATION 1
39 
40 class oImageSpace;
42 
66 {
67  // -----------------------------------------------------------------------------------------
68  // Constructor & Destructor
69  public:
74  vDeformation();
79  virtual ~vDeformation();
80 
81 
82  // -----------------------------------------------------------------------------------------
83  // Public member functions
84  public:
90  inline void SetImageDimensionsAndQuantification( oImageDimensionsAndQuantification* ap_ImageDimensionsAndQuantification )
91  {mp_ID = ap_ImageDimensionsAndQuantification;}
97  inline void SetVerbose( int a_verbose )
98  {m_verbose = a_verbose;}
105  inline void SetNbTransformations( int a_nbTransformations )
106  {m_nbTransformations = a_nbTransformations;}
113  virtual int CheckParameters();
120  virtual int CheckSpecificParameters() = 0;
128  virtual int ReadAndCheckConfigurationFile( const string& a_fileOptions ) = 0;
136  virtual int ReadAndCheckOptionsList( const string& a_listOptions ) = 0;
143  virtual int Initialize() = 0;
149  virtual void ShowHelp() = 0;
150 
151 
152  // -----------------------------------------------------------------------------------------
153  // Reconstruction deformation function
154  public:
169  virtual int PerformDeformation( oImageSpace* ap_Image, int a_defIdx, int a_fr, int a_rimg, int a_cimg );
184  virtual int PerformDeformationBis(oImageSpace* ap_Image, int a_defIdx, int a_fr, int a_rimg, int a_cimg);
185 
186  virtual int PerformHistoSensitivityDeformation( oImageSpace* ap_Image, int a_defIdx, int fr, int rimg, int cimg );
198  virtual int ApplyDeformationsToBackwardImage( oImageSpace* ap_Image, int a_fr, int a_defIdx );
210  virtual int ApplyDeformationsToHistoSensitivityImage( oImageSpace* ap_Image, int a_fr, int a_defIdx );
225  virtual int PerformSensitivityDeformation( oImageSpace* ap_Image, int a_defDirection, int a_defIdx, int fr, int rg, int cg );
236  virtual int ApplyDeformations( FLTNB* ap_inputImage, FLTNB* ap_outputImage, int a_direction, int a_defIdx ) = 0;
237 
238 
239  /*
240  \fn Tlerp
241  \param ap_inputImage : input image matrix
242  \param ap_outputImage : output image matrix
243  \param iov : index of the voxel to interpolate in the output image
244  \param iiv : index of the input image central voxel for interpolation
245  \param dx : x-axis difference between output voxel cartesian position after transformation and center of estimated vox position
246  \param dy : y-axis difference between output voxel cartesian position after transformation and center of estimated vox position
247  \param dz : z-axis difference between output voxel cartesian position after transformation and center of estimated vox position
248  \brief This function performs a trilinear interpolation for a specific voxel
249  \todo : perhaps use padded image in order to avoid if statements
250  \return 0 if success, other value otherwise.
251  */
252  int Tlerp(HPFLTNB *ap_inputImage, HPFLTNB *ap_outputImage, uint32_t iov, uint32_t iiv, FLTNB dX, FLTNB dY, FLTNB dZ);
253 
254 
255 
256 
257  // -----------------------------------------------------------------------------------------
258  // Data members
259  protected:
261  int m_verbose;
263  int m_checked;
265 };
266 
267 
268 // ----------------------------------------------------------------------
269 // Part of code that manages the auto declaration of children classes
270 // ----------------------------------------------------------------------
271 
272 // Macro for the function that creates the object
273 #define FUNCTION_DEFORMATION(CLASS) \
274  static vDeformation *make_deformation() { return new CLASS(); };
275 
276 // Macro for the class that links the appropriate function to the map of objects
277 #define CLASS_DEFORMATION(NAME,CLASS) \
278  class NAME##DeformationCreator \
279  { \
280  public: \
281  NAME##DeformationCreator() \
282  { sAddonManager::GetInstance()->mp_listOfDeformations[#NAME] = CLASS::make_deformation; } \
283  }; \
284  static NAME##DeformationCreator DeformationCreator##NAME;
285 
286 #endif
void SetVerbose(int a_verbose)
Set the verbose level.
Definition: vDeformation.hh:97
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:43
virtual ~vDeformation()
Destructor of vDeformation.
Definition: vDeformation.cc:63
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:78
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...
virtual int PerformDeformationBis(oImageSpace *ap_Image, int a_defIdx, int a_fr, int a_rimg, int a_cimg)
This is the mother class of image-based transformation class.
Definition: vDeformation.hh:65
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the image dimensions in use.
Definition: vDeformation.hh:90
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:61
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) ...