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