CASToR  2.0
Tomographic Reconstruction (PET/SPECT/CT)
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vDeformation.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 "vDeformation.hh"
33 #include "oImageSpace.hh"
34 
35 // =====================================================================
36 // ---------------------------------------------------------------------
37 // ---------------------------------------------------------------------
38 // =====================================================================
39 /*
40  \fn vDeformation
41  \brief Constructor of vDeformation. Simply set all data members to default values.
42 */
44 {
45  mp_ID = NULL;
47  m_verbose = -1;
48  m_checked = false;
49  m_initialized = false;
50 }
51 
52 
53 
54 
55 // =====================================================================
56 // ---------------------------------------------------------------------
57 // ---------------------------------------------------------------------
58 // =====================================================================
59 /*
60  \fn ~vDeformation
61  \brief Destructor of vDeformation.
62 */
64 
65 
66 
67 
68 // =====================================================================
69 // ---------------------------------------------------------------------
70 // ---------------------------------------------------------------------
71 // =====================================================================
79 {
80  if(m_verbose>=2) Cout("vDeformation::CheckParameters ..."<< endl);
81 
82  // Check image dimensions
83  if (mp_ID==NULL)
84  {
85  Cerr("***** vDeformation::CheckParameters() -> No image dimensions provided !" << endl);
86  return 1;
87  }
88 
89  // Check verbosity
90  if (m_verbose<0)
91  {
92  Cerr("***** vDeformation::CheckParameters() -> Wrong verbosity level provided !" << endl);
93  return 1;
94  }
95 
96  // Check number of basis functions
97  if (m_nbTransformations <0)
98  {
99  Cerr("***** vDeformation::CheckParameters() -> Number of transformations in the deformation has not been initialized !" << endl);
100  return 1;
101  }
102 
103  // Check parameters of the child class (if this function is overloaded)
105  {
106  Cerr("***** vDeformation::CheckParameters() -> An error occurred while checking parameters of the child dynamic class !" << endl);
107  return 1;
108  }
109 
110  // Normal end
111  m_checked = true;
112  return 0;
113 }
114 
115 
116 
117 
118 
119 
120 
121 // =====================================================================
122 // ---------------------------------------------------------------------
123 // ---------------------------------------------------------------------
124 // =====================================================================
125 /*
126  \fn ApplyDeformationsToBackwardImage
127  \param ap_Image : required to access the backward image and its deformation backup matrice
128  \param a_fr : frame index
129  \param a_defIdx : index of the deformation
130  \brief Apply backward transformation of the backward image to the reference position
131  \details Loop on frames
132  Recover any potential data stored in the backup matrice m2p_defTmpBackwardImage
133  \return 0 if success, positive value otherwise
134 */
135 int vDeformation::ApplyDeformationsToBackwardImage(oImageSpace* ap_Image, int a_fr, int a_defIdx)
136 {
137  if(m_verbose >= 2) Cout("vDeformation::ApplyDeformationsToBackwardImage ... " <<endl);
138 
139  #ifdef CASTOR_DEBUG
140  if (!m_initialized)
141  {
142  Cerr("***** vDeformation::ApplyDeformationsToBackwardImage() -> Called while not initialized !" << endl);
143  Exit(EXIT_DEBUG);
144  }
145  #endif
146 
147  for(int bimg=0; bimg<ap_Image->GetNbBackwardImages(); bimg++)
148  //for(int fr=0; fr<mp_ID->GetNbTimeFrames(); fr++)
149  for(int rimg=0; rimg<mp_ID->GetNbRespGates(); rimg++)
150  for(int cimg=0; cimg<mp_ID->GetNbCardGates(); cimg++)
151  {
152  /*
153  int r;
154  scanf("%d", &r);
155 
156  for(int v=0 ; v<mp_ID->GetNbVoxXYZ() ; v=v+mp_ID->GetNbVoxX())
157  cout << ap_Image->m6p_backwardImage[bimg][0][fr][rimg][cimg][v] << endl;
158 
159 
160  scanf("%d", &r);*/
161 
162  // Perform backward deformation
163  if(a_defIdx > 0 // a_defIdx == 0 -> reference position, no need for transformation
164  && ApplyDeformations(ap_Image->m6p_backwardImage[bimg][0][a_fr][rimg][cimg], ap_Image->m6p_backwardImage[bimg][0][a_fr][rimg][cimg], BACKWARD_DEFORMATION, a_defIdx-1) )
165  {
166  Cerr("***** vDeformation::ApplyDeformationsToBackwardImage()-> An error occured while performing backward deformation of the backward image !" << endl);
167  Cerr("***** frame index " << a_fr << " respiratory image index " << rimg<< " cardiac image index " << cimg<< " !" << endl);
168  return 1;
169  }
170  /*
171  for(int v=0 ; v<mp_ID->GetNbVoxXYZ() ; v=v+mp_ID->GetNbVoxX())
172  cout << ap_Image->m6p_backwardImage[bimg][0][fr][rimg][cimg][v] << endl;
173 
174 
175  scanf("%d", &r);*/
176 
177 
178  // Recover the content of the temporary backup deformation image to the backward image
179  for(int v=0; v<mp_ID->GetNbVoxXYZ(); v++)
180  ap_Image->m6p_backwardImage[bimg][0][a_fr][rimg][cimg][v] += ap_Image->m5p_refDynBackwardImage[bimg][a_fr][rimg][cimg][v] ;
181  }
182 
183  return 0;
184 }
185 
186 
187 
188 
189 // =====================================================================
190 // ---------------------------------------------------------------------
191 // ---------------------------------------------------------------------
192 // =====================================================================
193 /*
194  \fn ApplyDeformationsToHistoSensitivityImage
195  \param ap_Image : required to access the backward image and its deformation backup matrice
196  \param a_fr : frame index
197  \param a_defIdx : index of the deformation
198  \brief Apply backward transformations of the sensitivity image to the reference position (histogram mode)
199  \details Loop on frames
200  Recover any potential data stored in the backup matrice m4p_defTmpSensitivityImage
201  \return 0 if success, positive value otherwise
202 */
204 {
205  if(m_verbose >= 2) Cout("vDeformation::ApplyDeformationsToHistoSensitivityImage ... " <<endl);
206 
207  #ifdef CASTOR_DEBUG
208  if (!m_initialized)
209  {
210  Cerr("***** vDeformation::ApplyDeformationsToHistoSensitivityImage() -> Called while not initialized !" << endl);
211  Exit(EXIT_DEBUG);
212  }
213  #endif
214 
215  //for(int fr=0; fr<mp_ID->GetNbTimeFrames(); fr++)
216  for(int rimg=0; rimg<mp_ID->GetNbRespGates() ; rimg++)
217  for(int cimg=0; cimg<mp_ID->GetNbCardGates() ; cimg++)
218  {
219  // Perform backward deformation
220  if( a_defIdx > 0 // a_defIdx == 0 -> reference position, no need for transformation
221  && ApplyDeformations(ap_Image->m5p_sensitivity[0][a_fr][rimg][cimg], ap_Image->m5p_sensitivity[0][a_fr][rimg][cimg], BACKWARD_DEFORMATION, a_defIdx-1) )
222  {
223  Cerr("***** vDeformation::ApplyDeformationsToHistoSensitivityImage()-> An error occured while performing backward deformation of the backward image !" << endl);
224  Cerr("***** frame index " << a_fr << " respiratory image index " << rimg<< " cardiac image index " << cimg<< " !" << endl);
225  return 1;
226  }
227 
228  // Recover the content of the temporary backup deformation image in the sensitivity image
229  for(int v=0; v<mp_ID->GetNbVoxXYZ(); v++)
230  ap_Image->m5p_sensitivity[0][a_fr][rimg][cimg][v] += ap_Image->m4p_refDynSensitivityImage[a_fr][rimg][cimg][v];
231  }
232 
233  return 0;
234 }
235 
236 
237 
238 
239 // =====================================================================
240 // ---------------------------------------------------------------------
241 // ---------------------------------------------------------------------
242 // =====================================================================
243 /*
244  \fn PerformDeformation
245  \param ap_Image : required to access oImageSpace image matrices
246  \param a_defIdx : index of the deformation
247  \param a_fr : frame index
248  \param a_rimg : respiratory image index
249  \param a_cimg : cardiac image index
250  \brief Apply deformations during reconstruction
251  \details 1. Recover all the data of the multithreaded backward image matrices in the first one (thread index 0)
252  2. Perform backward deformation of the backward image to the reference position with defIdx-1
253  3. Add coefficients of the backward image matrice to the temporary backup image matrice & reset backward image
254  4. Apply forward deformation of the forward image (backward deformation to the reference position with defIdx-1, and forward deformation with defIdx)
255  \return 0 if success, positive value otherwise
256 */
257 int vDeformation::PerformDeformation(oImageSpace* ap_Image, int a_defIdx, int a_fr, int a_rimg, int a_cimg)
258 {
259  if(m_verbose >= 3) Cout("vDeformation::PerformDeformation, deformation #" << a_defIdx+1 << endl);
260 
261  #ifdef CASTOR_DEBUG
262  if (!m_initialized)
263  {
264  Cerr("***** vDeformation::PerformDeformation() -> Called while not initialized !" << endl);
265  Exit(EXIT_DEBUG);
266  }
267  #endif
268 
269  // REDUCE
270  for (int bimg=0; bimg<ap_Image->GetNbBackwardImages(); bimg++)
271  {
272  for (int th=1 ; th<mp_ID->GetNbThreadsForProjection() ; th++) //TODO add loops
273  {
274  // Synchronization of the multi-threaded backwardImages inside the first image Reduce)
275  for(int v=0; v<mp_ID->GetNbVoxXYZ(); v++)
276  ap_Image->m6p_backwardImage[bimg][0][a_fr][a_rimg][a_cimg][v] += ap_Image->m6p_backwardImage[bimg][th][a_fr][a_rimg][a_cimg][v];
277  }
278 
279  // BACKWARD DEFORMATION of the backward image //TODO add loops
280  if (a_defIdx > 1 // a_defIdx == 1 -> already in reference position, no need for transformation
281  && ApplyDeformations(ap_Image->m6p_backwardImage[bimg][0][a_fr][a_rimg][a_cimg], ap_Image->m6p_backwardImage[bimg][0][a_fr][a_rimg][a_cimg], BACKWARD_DEFORMATION, a_defIdx-2) )
282  {
283  Cerr("***** vDeformation::ApplyDeformations()-> An error occured while performing backward deformation of the backward image !" << endl);
284  Cerr("***** frame index " << a_fr << " respiratory image index " << a_rimg<< " cardiac image index " << a_cimg<< " !" << endl);
285  return 1;
286  }
287 
288  // Store Backward deformation update coefficients in the temporary backup image //TODO add loops
289  for (int v=0; v<mp_ID->GetNbVoxXYZ(); v++)
290  {
291  ap_Image->m5p_refDynBackwardImage[bimg][a_fr][a_rimg][a_cimg][v] += ap_Image->m6p_backwardImage[bimg][0][a_fr][a_rimg][a_cimg][v];
292  }
293  }
294 
295  // Reset the backward images (i.e set all voxels to the specific fr/rimg/cimg to 0)
296  for (int bimg=0; bimg<ap_Image->GetNbBackwardImages(); bimg++)
297  for(int th=0 ; th<mp_ID->GetNbThreadsForProjection() ; th++)
298  for (int v=0; v<mp_ID->GetNbVoxXYZ(); v++)
299  ap_Image->m6p_backwardImage[bimg][th][a_fr][a_rimg][a_cimg][v] = 0.;
300 
301  /*
302  int r;
303  scanf("%d", &r);
304  cout << "ApplyDef forward Image AVT" << endl;
305  for(int v=0 ; v<mp_ID->GetNbVoxXYZ() ; v=v+mp_ID->GetNbVoxX())
306  if(ap_Image->m4p_forwardImage[fr][rimg][cimg][v] != 1)cout << ap_Image->m4p_forwardImage[fr][rimg][cimg][v] << endl;
307 
308 
309  scanf("%d", &r);*/
310 
311 
312  // FORWARD DEFORMATION of the Forward image
313  /*
314  if (ApplyDeformations(ap_Image->m4p_forwardImage[fr][rimg][cimg], ap_Image->m4p_forwardImage[fr][rimg][cimg], FORWARD_DEFORMATION, a_defIdx) )
315  {
316  Cerr("***** vDeformation::ApplyDeformations()-> An error occured while performing forward deformation of the forward image !" << endl);
317  Cerr("***** frame index " << fr << " respiratory image index " << rimg<< " cardiac image index " << cimg<< " !" << endl);
318  return 1;
319  }
320  */
321 
322  if (ApplyDeformations(ap_Image->m4p_refDynForwardImage[a_fr][a_rimg][a_cimg], ap_Image->m4p_forwardImage[a_fr][a_rimg][a_cimg], FORWARD_DEFORMATION, a_defIdx-1) )
323  {
324  Cerr("***** vDeformation::ApplyDeformations()-> An error occured while performing forward deformation of the forward image !" << endl);
325  Cerr("***** frame index " << a_fr << " respiratory image index " << a_rimg<< " cardiac image index " << a_cimg<< " !" << endl);
326  return 1;
327  }
328  /*
329  cout << "ApplyDef forward Image APS" << endl;
330  scanf("%d", &r);
331  for(int v=0 ; v<mp_ID->GetNbVoxXYZ() ; v=v+mp_ID->GetNbVoxX())
332  if(ap_Image->m4p_forwardImage[fr][rimg][cimg][v] != 1)cout << ap_Image->m4p_forwardImage[fr][rimg][cimg][v] << endl;
333 
334 
335  scanf("%d", &r);*/
336 
337  return 0;
338 }
339 
340 
341 
342 
343 
344 
345 
346 int vDeformation::PerformDeformationBis(oImageSpace* ap_Image, int a_defIdx, int a_fr, int a_rimg, int a_cimg)
347 {
348  if(m_verbose >= 3) Cout("vDeformation::PerformDeformationBis, deformation #" << a_defIdx+1 << endl);
349 
350  #ifdef CASTOR_DEBUG
351  if (!m_initialized)
352  {
353  Cerr("***** vDeformation::PerformDeformation() -> Called while not initialized !" << endl);
354  Exit(EXIT_DEBUG);
355  }
356  #endif
357 
358 
359 
360  if (ApplyDeformations(ap_Image->m4p_refDynForwardImage[a_fr][a_rimg][a_cimg], ap_Image->m4p_forwardImage[a_fr][a_rimg][a_cimg], FORWARD_DEFORMATION, a_defIdx-1) )
361  {
362  Cerr("***** vDeformation::ApplyDeformationsBis()-> An error occured while performing forward deformation of the forward image !" << endl);
363  Cerr("***** frame index " << a_fr << " respiratory image index " << a_rimg<< " cardiac image index " << a_cimg<< " !" << endl);
364  return 1;
365  }
366 
367  return 0;
368 }
369 
370 
371 
372 
373 
374 
375 
376 
377 
378 
379 
380 // =====================================================================
381 // ---------------------------------------------------------------------
382 // ---------------------------------------------------------------------
383 // =====================================================================
384 /*
385  \fn PerformHistoSensitivityDeformation
386  \param ap_Image : required to access oImageSpace image matrices
387  \param a_defIdx : index of the deformation
388  \param fr : frame index
389  \param rimg : respiratory image index
390  \param cimg : cardiac image index
391  \brief Apply deformations on the sensitivity image during reconstruction in histogram mode
392  \details 1. Recover all the data of the multithreaded sensitivity image matrice in the first one (thread index 0)
393  2. Perform backward deformation of the sensitivity image to the reference position with defIdx-1
394  3. Add coefficients of the sensitivity image matrice to the temporary backup image matrice & reset sensitivity image
395  \return 0 if success, positive value otherwise
396 */
397 int vDeformation::PerformHistoSensitivityDeformation(oImageSpace* ap_Image, int a_defIdx, int fr, int rimg, int cimg)
398 {
399  if(m_verbose >= 2) Cout("vDeformation::PerformHistoSensitivityDeformation ... " <<endl);
400 
401  #ifdef CASTOR_DEBUG
402  if (!m_initialized)
403  {
404  Cerr("***** vDeformation::PerformHistoSensitivityDeformation() -> Called while not initialized !" << endl);
405  Exit(EXIT_DEBUG);
406  }
407  #endif
408 
409  // REDUCE
410  for (int th=1 ; th<mp_ID->GetNbThreadsForProjection() ; th++)
411  {
412  // Synchronisation of the multi-threaded sensitivity images inside the first image )
413  for(int v=0; v<mp_ID->GetNbVoxXYZ(); v++)
414  ap_Image->m5p_sensitivity[0][fr][rimg][cimg][v] += ap_Image->m5p_sensitivity[th][fr][rimg][cimg][v];
415  }
416 
417  // BACKWARD DEFORMATION of the sensitivity image
418  if (a_defIdx > 1 // a_defIdx == 1 -> already in reference position, no need for transformation
419  && ApplyDeformations(ap_Image->m5p_sensitivity[0][fr][rimg][cimg], ap_Image->m5p_sensitivity[0][fr][rimg][cimg], BACKWARD_DEFORMATION, a_defIdx-2) )
420  {
421  Cerr("***** vDeformation::PerformHistoSensitivityDeformation()-> An error occured while performing backward deformation of the sensitivity image !" << endl);
422  Cerr("***** frame index " << fr << " respiratory image index " << rimg<< " cardiac image index " << cimg<< " !" << endl);
423  return 1;
424  }
425 
426  // Store Backward deformation update coefficients in temporary image
427  for (int v=0; v<mp_ID->GetNbVoxXYZ(); v++)
428  {
429  ap_Image->m4p_refDynSensitivityImage[fr][rimg][cimg][v] += ap_Image->m5p_sensitivity[0][fr][rimg][cimg][v];
430  }
431 
432  // Reset the sensitivity images (i.e set all voxels to the specific fr/rimg/cimg to 0)
433  for (int th=0; th<mp_ID->GetNbThreadsForProjection(); th++)
434  for (int v=0; v<mp_ID->GetNbVoxXYZ(); v++)
435  ap_Image->m5p_sensitivity[th][fr][rimg][cimg][v] = 0.;
436 
437  return 0;
438 }
439 
440 
441 
442 
443 // =====================================================================
444 // ---------------------------------------------------------------------
445 // ---------------------------------------------------------------------
446 // =====================================================================
447 /*
448  \fn PerformSensitivityDeformation
449  \param ap_Image : required to access oImageSpace image matrices
450  \param a_defDirection : a direction for the deformation to perform (forward or backward)
451  \param a_defIdx : index of the deformation
452  \param fr : frame index
453  \param rg : respiratory gate index
454  \param cg : cardiac gate index
455  \brief Apply image deformations during sensitivity image generation for list-mode
456  \details Depending on the deformation direction (forward or backward):
457  Forward : Perform forward deformation of the forward image to the deformation index position
458  Backward: Perform backward deformation of the backward image to the reference position
459  \return 0 if success, positive value otherwise
460 */
461 int vDeformation::PerformSensitivityDeformation(oImageSpace* ap_Image, int a_defDirection, int a_defIdx, int fr, int rg, int cg)
462 {
463  if(m_verbose >= 2) Cout("vDeformation::PerformSensitivityDeformation ... " << a_defDirection << ";" << a_defIdx << endl);
464 
465  #ifdef CASTOR_DEBUG
466  if (!m_initialized)
467  {
468  Cerr("***** vDeformation::PerformSensitivityDeformation() -> Called while not initialized !" << endl);
469  Exit(EXIT_DEBUG);
470  }
471  #endif
472 
473  // Idx 0 == reference (no deformation)
474  if(a_defIdx == 0)
475  return 0;
476 
477  // tranformations are numbered from 0 to nbTransformations-1
478  a_defIdx--;
479 
480  if (a_defDirection == FORWARD_DEFORMATION)
481  {
482  if (ApplyDeformations(ap_Image->m4p_forwardImage[fr][rg][cg], ap_Image->m4p_forwardImage[fr][rg][cg], a_defDirection, a_defIdx) )
483  //if (ApplyDeformations(ap_Image->m4p_forwardImage[fr][0][cg], ap_Image->m4p_forwardImage[fr][a_defIdx][cg], a_defDirection, a_defIdx) )
484  {
485  Cerr("***** vDeformation::PerformSensitivityDeformation -> An error occured while performing forward deformation !" << endl);
486  Cerr("***** frame index " << fr << " respiratory gate index " << rg<< " cardiac gate index " << cg<< " !" << endl);
487  return 1;
488  }
489  }
490  else if (a_defDirection == BACKWARD_DEFORMATION)
491  {
492  if (ApplyDeformations(ap_Image->m6p_backwardImage[0][0][fr][rg][cg], ap_Image->m6p_backwardImage[0][0][fr][rg][cg], a_defDirection, a_defIdx) )
493  //if (ApplyDeformations(ap_Image->m6p_backwardImage[0][0][fr][a_defIdx][cg], ap_Image->m6p_backwardImage[0][0][fr][a_defIdx][cg], a_defDirection, a_defIdx) )
494  {
495  Cerr("***** vDeformation::PerformSensitivityDeformation -> An error occured while performing backward deformation !" << endl);
496  Cerr("***** frame index " << fr << " respiratory gate index " << rg<< " cardiac gate index " << cg<< " !" << endl);
497  return 1;
498  }
499  }
500  else
501  {
502  Cerr("***** vDeformation::PerformDeformation -> Unknown type of deformation !" << endl);
503  return 1;
504  }
505 
506  return 0;
507 }
508 
509 
510 
511 
512 /*
513  \fn Tlerp
514  \param ap_inputImage : input image matrix
515  \param ap_outputImage : output image matrix
516  \param iov : index of the voxel to interpolate in the output image
517  \param iiv : index of the input image central voxel for interpolation
518  \param dx : x-axis difference between output voxel cartesian position after transformation and center of estimated vox position
519  \param dy : y-axis difference between output voxel cartesian position after transformation and center of estimated vox position
520  \param dz : z-axis difference between output voxel cartesian position after transformation and center of estimated vox position
521  \brief This function performs a trilinear interpolation for a specific voxel
522  \todo : perhaps use padded image in order to avoid if statements
523  \return 0 if success, other value otherwise.
524 */
525 int vDeformation::Tlerp(HPFLTNB *ap_inputImage, HPFLTNB *ap_outputImage, uint32_t iov, uint32_t iiv, FLTNB dX, FLTNB dY, FLTNB dZ)
526 {
527  // Trilinear interpolation
528  // Todo : Use padded image in order to avoid 'if' statements ?
529  int incX = dX>0 ? 1 : -1;
530  int incY = dY>0 ? mp_ID->GetNbVoxX() : -mp_ID->GetNbVoxX();
531  int incZ = dZ>0 ? mp_ID->GetNbVoxXY() : -mp_ID->GetNbVoxXY();
532 
533  dX = (dX>=0) ? dX : -dX;
534  dY = (dY>=0) ? dY : -dY;
535  dZ = (dZ>=0) ? dZ : -dZ;
536 
537  uint32_t nb_tot_vox = (uint32_t)mp_ID->GetNbVoxXYZ();
538 
539  if ((iiv < nb_tot_vox)
540  && (iiv >= 0))
541  ap_outputImage[iov] += ap_inputImage[iiv] * (1.-dX)*(1.-dY)*(1.-dZ);
542 
543  if ((iiv+incX < nb_tot_vox)
544  && (iiv+incX >= 0))
545  ap_outputImage[iov] += ap_inputImage[iiv+incX] * dX*(1.-dY)*(1.-dZ);
546 
547  if ((iiv+incY < nb_tot_vox )
548  && (iiv+incY >= 0))
549  ap_outputImage[iov] += ap_inputImage[iiv +incY] * (1.-dX)*dY*(1.-dZ);
550 
551  if ((iiv+incX+incY < nb_tot_vox)
552  && ( iiv+incX+incY >= 0))
553  ap_outputImage[iov] += ap_inputImage[iiv+incX+incY] * dX*dY*(1.-dZ);
554 
555  if ((iiv+incZ < nb_tot_vox)
556  && (iiv+incZ) >= 0)
557  ap_outputImage[iov] += ap_inputImage[iiv+incZ] * (1.-dX)*(1.-dY)*dZ;
558 
559  if ((iiv+incX+incZ) < nb_tot_vox
560  && (iiv+incX+incZ) >=0 )
561  ap_outputImage[iov] += ap_inputImage[iiv+incX+incZ] * dX*(1.-dY)*dZ;
562 
563  if ((iiv+incY+incZ < nb_tot_vox)
564  && (iiv+incY+incZ >= 0))
565  ap_outputImage[iov] += ap_inputImage[iiv+incY+incZ] * (1.-dX)*dY*dZ;
566 
567  if ((iiv+incX+incY+incZ < nb_tot_vox)
568  && (iiv+incX+incY+incZ >= 0))
569  ap_outputImage[iov] += ap_inputImage[iiv+incX+incY+incZ] *dX*dY*dZ;
570 
571 
572  return 0;
573 }
FLTNB **** m4p_forwardImage
Definition: oImageSpace.hh:88
Declaration of class oImageDimensionsAndQuantification.
vDeformation()
Constructor of vDeformation. Simply set all data members to default values.
Definition: vDeformation.cc:43
FLTNB **** m4p_refDynForwardImage
Definition: oImageSpace.hh:153
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
int m_nbTransformations
#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.
FLTNB ***** m5p_refDynBackwardImage
Definition: oImageSpace.hh:163
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.
FLTNB **** m4p_refDynSensitivityImage
Definition: oImageSpace.hh:174
virtual int CheckParameters()
This function is used to check parameters after the latter have been all set using Set functions...
Definition: vDeformation.cc:78
void Exit(int code)
int Tlerp(HPFLTNB *ap_inputImage, HPFLTNB *ap_outputImage, uint32_t iov, uint32_t iiv, FLTNB dX, FLTNB dY, FLTNB dZ)
#define Cerr(MESSAGE)
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...
FLTNB ****** m6p_backwardImage
Definition: oImageSpace.hh:95
virtual int PerformDeformationBis(oImageSpace *ap_Image, int a_defIdx, int a_fr, int a_rimg, int a_cimg)
#define BACKWARD_DEFORMATION
Definition: vDeformation.hh:38
int GetNbBackwardImages()
Definition: oImageSpace.hh:630
INTNB GetNbVoxXY()
Get the number of voxels in a slice.
Declaration of class vDeformation.
Declaration of class oImageSpace.
int GetNbCardGates()
Get the number of cardiac gates.
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
INTNB GetNbVoxXYZ()
Get the total number of voxels.
#define EXIT_DEBUG
Definition: gVariables.hh:97
int GetNbThreadsForProjection()
Get the number of threads used for projections.
INTNB GetNbVoxX()
Get the number of voxels along the X axis.
virtual int CheckSpecificParameters()=0
This function is used to check the parameters of the child functions before initialization if require...
int GetNbRespGates()
Get the number of respiratory gates.
#define Cout(MESSAGE)
#define FORWARD_DEFORMATION
Definition: vDeformation.hh:37
FLTNB ***** m5p_sensitivity
Definition: oImageSpace.hh:105
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) ...