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