CASToR  3.0
Tomographic Reconstruction (PET/SPECT/CT)
iDeformationTemplate.cc
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 #include "iDeformationTemplate.hh"
31 
32 // =====================================================================
33 // ---------------------------------------------------------------------
34 // ---------------------------------------------------------------------
35 // =====================================================================
36 /*
37  \fn iDeformationTemplate
38  \brief Constructor of iDeformationTemplate. Simply set all data members to default values.
39 */
41 {
42 }
43 
44 
45 
46 
47 // =====================================================================
48 // ---------------------------------------------------------------------
49 // ---------------------------------------------------------------------
50 // =====================================================================
51 /*
52  \fn ~iDeformationTemplate
53  \brief Destructor of iDeformationTemplate. Free memory from all allocated tabs.
54 */
56 {
57 }
58 
59 
60 
61 
62 // =====================================================================
63 // ---------------------------------------------------------------------
64 // ---------------------------------------------------------------------
65 // =====================================================================
71 {
72  // ===================================================================
73  // Here, display some help and guidance to how to use this deformation and what it does
74  // ===================================================================
75 
76  cout << "This class is a template class dedicated to add your own custom deformation model." << endl;
77 }
78 
79 
80 
81 
82 // =====================================================================
83 // ---------------------------------------------------------------------
84 // ---------------------------------------------------------------------
85 // =====================================================================
86 /*
87  \fn ReadAndCheckConfigurationFile
88  \param a_configurationFile
89  \brief This function is an implementation of the pure virtual mother function. It is used to read options from a configuration file.
90  \return 0 if success, other value otherwise.
91 */
93 {
94  if(m_verbose >=2) Cout("iDeformationTemplate::ReadAndCheckConfigurationFile ..."<< endl);
95 
96  // ===================================================================
97  // Implement here the reading of any options specific to this deformation model
98  // (i.e : parameters or path to deformation files), through a configuration file
99  // The ReadDataASCIIFile() functions could be helpful to recover data from a file
100  // ===================================================================
101 
102  // Normal end
103  return 0;
104 }
105 
106 
107 
108 
109 // =====================================================================
110 // ---------------------------------------------------------------------
111 // ---------------------------------------------------------------------
112 // =====================================================================
113 /*
114  \fn ReadAndCheckOptionsList
115  \param a_optionsList
116  \brief This function is an implementation of the pure virtual mother function. It is used to read options from a list of options.
117  \return 0 if success, other value otherwise.
118 */
119 int iDeformationTemplate::ReadAndCheckOptionsList(const string& a_listOptions)
120 {
121  if(m_verbose >=2) Cout("iDeformationTemplate::ReadAndCheckOptionsList ..."<< endl);
122 
123  // ===================================================================
124  // Implement here the reading of any options specific to this deformation model, through a list of options separated by commas
125  // The ReadStringOption() function could be helpful to parse the list of parameters in an array
126  // ===================================================================
127 
128  // Normal end
129  return 0;
130 }
131 
132 
133 
134 
135 // =====================================================================
136 // ---------------------------------------------------------------------
137 // ---------------------------------------------------------------------
138 // =====================================================================
139 /*
140  \fn CheckSpecificParameters
141  \brief This function is an implementation of the pure virtual mother function. It is used to
142  check parameters of the child deformation model before initialization.
143  \return 0 if success, other value otherwise.
144 */
146 {
147  if(m_verbose >=2) Cout("iDeformationTemplate::CheckSpecificParameters ..."<< endl);
148 
149  // ===================================================================
150  // Implement here checks over parameters which should be read using either
151  // ReadAndCheckConfigurationFile() and ReadAndCheckOptionsList() functions
152  // ===================================================================
153 
154  // Normal end
155  m_checked = true;
156  return 0;
157 }
158 
159 
160 
161 
162 // =====================================================================
163 // ---------------------------------------------------------------------
164 // ---------------------------------------------------------------------
165 // =====================================================================
166 /*
167  \fn Initialize
168  \brief This function is an implementation of the pure virtual mother function. It is used to
169  initialize specific stuff to the child deformation model.
170  \return 0 if success, other value otherwise.
171 */
173 {
174  if(m_verbose >=2) Cout("iDeformationTemplate::Initialize ..."<< endl);
175 
176  // ===================================================================
177  // Implement here the allocation/initialization of whatever member variables specifically used by this deformation model
178  // ===================================================================
179 
180  if (!m_checked)
181  {
182  Cerr("***** iDeformationTemplate::Initialize() -> Parameters should be checked before Initialize() !" << endl);
183  return 1;
184  }
185 
186  // Normal end
187  m_initialized = true;
188  return 0;
189 }
190 
191 
192 
193 
194 // =====================================================================
195 // ---------------------------------------------------------------------
196 // ---------------------------------------------------------------------
197 // =====================================================================
198 /*
199  \fn ApplyDeformations
200  \param ap_inputImage : input image to deform
201  \param ap_outputImage : image in which the output of the deformation should be recovered
202  \param a_direction : a direction for the deformation to perform (forward or backward)
203  \param a_defIdx : index of the deformation
204  \brief This function is an implementation of the pure virtual mother function. The actual deformation should be implemented here
205  \return 0 if success, other value otherwise.
206 */
207 int iDeformationTemplate::ApplyDeformations(FLTNB* ap_inputImage, FLTNB* ap_outputImage, int a_direction, int a_defIdx)
208 {
209  #ifdef CASTOR_VERBOSE
210  if(m_verbose >=4) Cout("iDeformationTemplate::ApplyDeformations ..."<< endl);
211  #endif
212 
213  // ===================================================================
214  // The deformation model should be implemented here, with the help of any private functions if required
215 
216  /* The 'a_defIdx' parameter defines the deformation index of the transformation
217  * The 'a_direction' parameter is an integer which indicates the direction of the deformation to perform, i.e :
218  * - FORWARD_DEFORMATION (from the reference position to the 'a_defIdx' position)
219  * - BACKWARD_DEFORMATION (from the 'a_defIdx' position to the reference position)
220  * The integers FORWARD_DEFORMATION & BACKWARD_DEFORMATION are macros defined in the beginning of vDeformation.hh
221  */
222 
223  // The deformation should be applied to the ap_inputImage matrix, and the resulting image should be recovered in ap_outputImage matrix
224 
225  /* IMAGE DIMENSIONS :
226  * For code efficiency and readability, the spatial index of a voxel is a cumulative 1D index. That is to say, given a voxel [indexX,indexY,indexZ],
227  * its cumulative 1D index is computed by 'index = indexZ*nbVoxXY + indexY*nbVoxX + indexX'.
228  *
229  * The image dimensions can be recovered from the mp_ID class
230  * Total number of voxels : mp_ID->GetNbVoxXYZ()
231  * Number of voxels in a slice : mp_ID->GetNbVoxXY()
232  * Number of voxels on the X-axis : mp_ID->GetNbVoxX()
233  */
234 
235  // Any error should return a value >0.
236  // ===================================================================
237 
238  // Normal end
239  return 0;
240 }
#define FLTNB
Definition: gVariables.hh:81
int CheckSpecificParameters()
This function is an implementation of the pure virtual mother function. It is used to check parameter...
Declaration of class iDeformationTemplate.
~iDeformationTemplate()
Destructor of iDeformationTemplate. Free memory from all allocated tabs.
int Initialize()
This function is an implementation of the pure virtual mother function. It is used to initialize spec...
#define Cerr(MESSAGE)
This is the mother class of image-based transformation class.
Definition: vDeformation.hh:64
int ReadAndCheckConfigurationFile(const string &a_fileOptions)
This function is an implementation of the pure virtual mother function. It is used to read options fr...
void ShowHelp()
This function is used to print out specific help about the deformation model and its options...
#define Cout(MESSAGE)
int ReadAndCheckOptionsList(const string &a_listOptions)
This function is an implementation of the pure virtual mother function. It is used to read options fr...
iDeformationTemplate()
Constructor of iDeformationTemplate. Simply set all data members to default values.
int ApplyDeformations(FLTNB *ap_inputImage, FLTNB *ap_outputImage, int a_direction, int a_defIdx)
This function is an implementation of the pure virtual mother function. The actual deformation should...