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