CASToR  3.2
Tomographic Reconstruction (PET/SPECT/CT)
src/image/oDeformationManager.cc
Go to the documentation of this file.
1 
8 #include "oDeformationManager.hh"
9 #include "sAddonManager.hh"
10 
11 // =====================================================================
12 // ---------------------------------------------------------------------
13 // ---------------------------------------------------------------------
14 // =====================================================================
15 /*
16  \fn oDeformationManager
17  \brief Constructor of oDeformationManager. Simply set all data members to default values.
18 */
20 {
21  // Image dimensions
22  mp_ID = NULL;
23  // Options for deformation
24  m_options = "";
25 
26  // Deformation objects and associated bool
27  mp_Deformation = NULL;
28 
29  m_UseDeformationResp = false;
30  m_UseDeformationCard = false;
31  m_UseDeformationIPat = false;
32 
33  // Variable indicating the number of transformations
35 
36  // Verbosity
37  m_verbose = -1;
38  // Data mode
39  m_dataMode = -1;
40  // Not checked yet
41  m_checked = false;
42  // Not initialized yet
43  m_initialized = false;
44 
45  #ifdef CASTOR_OMP
46  // Barrier for multithreaded reconstruction
47  mp_deformationRequirement = NULL;
48  #endif
49 }
50 
51 // =====================================================================
52 // ---------------------------------------------------------------------
53 // ---------------------------------------------------------------------
54 // =====================================================================
55 /*
56  \fn ~oDeformationManager
57  \brief Destructor of oDeformationManager. Free memory from all allocated tabs.
58 */
60 {
61  // Delete deformation objects
62  if (m_initialized)
63  if (mp_Deformation!= NULL) delete mp_Deformation;
64 
65  #ifdef CASTOR_OMP
66  if (mp_deformationRequirement) delete[] mp_deformationRequirement;
67  #endif
68 }
69 
70 
71 
72 // =====================================================================
73 // ---------------------------------------------------------------------
74 // ---------------------------------------------------------------------
75 // =====================================================================
76 /*
77  \fn oDeformationManager::SetMotionType
78  \param a_motionType
79  \brief Set the nature of motion correction (Deformation type macro)
80 */
81 void oDeformationManager::SetMotionType(int a_motionType)
82 {
83  switch (a_motionType)
84  {
85  case DEF_RESP_MOT : m_UseDeformationResp = true; break;
86  case DEF_CARD_MOT : m_UseDeformationCard = true; break;
87  case DEF_IPAT_MOT : m_UseDeformationIPat = true; break;
88  case DEF_DUAL_MOT : {m_UseDeformationResp = true; m_UseDeformationCard = true;} break;
89  default : {m_UseDeformationResp = false;
90  m_UseDeformationCard = false;
91  m_UseDeformationIPat = false;}
92  }
93 }
94 
95 
96 
97 
98 // =====================================================================
99 // ---------------------------------------------------------------------
100 // ---------------------------------------------------------------------
101 // =====================================================================
102 /*
103  \fn CheckParameters
104  \brief This function is used to check parameters after the latter
105  have been all set using Set functions.
106  \return 0 if success, positive value otherwise.
107 */
109 {
110  // Verbose
111  if (m_verbose>=VERBOSE_DEBUG_NORMAL) Cout("oDeformationManager::CheckParameters() -> Check parameters before initialization"<< endl);
112  // Check image dimensions
113  if (mp_ID==NULL)
114  {
115  Cerr("***** oDeformationManager::CheckParameters() -> No image dimensions provided !" << endl);
116  return 1;
117  }
118  // Check resp gates
119  if (m_nbTransformations<0)
120  {
121  Cerr("***** oDeformationManager::CheckParameters() -> Wrong number of respiratory gates !" << endl);
122  return 1;
123  }
124  // Check verbosity
125  if (m_verbose<0)
126  {
127  Cerr("***** oDeformationManager::CheckParameters() -> Wrong verbosity level provided !" << endl);
128  return 1;
129  }
130  // Check data mode
131  if (m_dataMode<0)
132  {
133  Cerr("***** oDeformationManager::CheckParameters() -> Wrong data mode provided ! (should be =0 (list-mode) or =1 (histogram)" << endl);
134  return 1;
135  }
136  // Normal end
137  m_checked = true;
138  return 0;
139 }
140 
141 
142 // =====================================================================
143 // ---------------------------------------------------------------------
144 // ---------------------------------------------------------------------
145 // =====================================================================
146 /*
147  \fn Initialize
148  \brief Set the flags for the different motion types and instanciate/initialize deformation objects
149  through the ParseOptionsAndInitializeDeformations() private function.
150  \return 0 if success, positive value otherwise.
151 */
153 {
154  // Forbid initialization without check
155  if (!m_checked)
156  {
157  Cerr("***** oDeformationManager::Initialize() -> Must call CheckParameters() before Initialize() !" << endl);
158  return 1;
159  }
160 
161  // Initialize current gate/involuntary motion index
162  m_curMotIdx = 0;
163 
164  #ifdef CASTOR_OMP
165  // initialize flags for managing parallel execution when image deformation is required
166  mp_deformationRequirement = new bool[mp_ID->GetNbThreadsForProjection()];
167  for(INTNB th=0 ; th < mp_ID->GetNbThreadsForProjection() ; th++) mp_deformationRequirement[th] = false;
168  #endif
169 
170  // Return if no deformation
172  {
173  m_initialized = true;
174  return 0;
175  }
176 
177  // Verbose
178  if (m_verbose>=VERBOSE_NORMAL) Cout("oDeformationManager::Initialize() -> Initialize deformations" << endl);
179 
180  // Parse deformation options and initialize them
182  {
183  Cerr("***** oDeformationManager::Initialize() -> A problem occurred while parsing deformation options and initializing them !" << endl);
184  return 1;
185  }
186 
187  // Normal end
188  m_initialized = true;
189  return 0;
190 }
191 
192 // =====================================================================
193 // ---------------------------------------------------------------------
194 // ---------------------------------------------------------------------
195 // =====================================================================
196 /*
197  \fn ParseOptionsAndInitializeProjectors
198  \brief Parse respiratory/cardiac/involuntary patient motion options contained in the previously provided
199  strings. This function is called inside the Initialize() function.
200  \details Manage the options reading and initialize specific vDeformation
201  Options are a string containing first the name of the deformation,
202  then either a ':' and a configuration file specific to the deformation
203  - or - as many ',' as needed parameters for this deformation.
204  Specific pure virtual functions of the vDeformation are used to read parameters and initialize them.
205  \todo Some cleaning if we merge respiratory and cardiac motion objects
206  \return 0 if success, positive value otherwise
207 */
209 {
210  if (m_verbose>=VERBOSE_DETAIL) Cout("oDeformationManager::ParseOptionsAndInitializeDeformations ..."<< endl);
211 
212  string deformation = "";
213  string list_options = "";
214  string file_options = "";
215 
216  // This is for the automatic initialization of the deformations
217  typedef vDeformation *(*maker_deformation) ();
218 
219  // Get deformation's list from addon manager
220  std::map <string,maker_deformation> list = sAddonManager::GetInstance()->mp_listOfDeformations;
221 
222  size_t colon, comma;
223 
224  // ---------------------------------------------------------------------------------------------------
225  // Manage deformation for respiratory motion
226  // ---------------------------------------------------------------------------------------------------
228  {
229  // ______________________________________________________________________________
230  // Get the deformation name in the options and isolate the real deformation's options
231 
232  // Search for a colon ":", this indicates that a configuration file is provided after the deformation name
233  colon = m_options.find_first_of(":");
234  comma = m_options.find_first_of(",");
235 
236  // Case 1: we have a colon
237  if (colon!=string::npos)
238  {
239  // Get the deformation name before the colon
240  deformation = m_options.substr(0,colon);
241  // Get the configuration file after the colon
242  file_options = m_options.substr(colon+1);
243  // List of options is empty
244  list_options = "";
245  }
246  // Case 2: we have a comma
247  else if (comma!=string::npos)
248  {
249  // Get the deformation name before the first comma
250  deformation = m_options.substr(0,comma);
251  // Get the list of options after the first comma
252  list_options = m_options.substr(comma+1);
253  // Configuration file is empty
254  file_options = "";
255  }
256  // Case 3: no colon and no comma (a single deformation name)
257  else
258  {
259  // Get the deformation name
260  deformation = m_options;
261  // Configuration file is empty
262  file_options = "";
263  // List of options is empty
264  list_options = "";
265  }
266 
267  // Create the deformation
268  if (list[deformation]) mp_Deformation = list[deformation]();
269  else
270  {
271  Cerr("***** oDeformationManager::ParseOptionsAndInitializeDeformations() -> Deformation '" << deformation << "' does not exist !" << endl);
273  return 1;
274  }
275  // Set parameters
279 
280  // Provide configuration file if any
281  if (file_options!="" && mp_Deformation->ReadAndCheckConfigurationFile(file_options))
282  {
283  Cerr("***** oDeformationManager::ParseOptionsAndInitializeDeformations() -> A problem occurred while reading and checking respiratory deformation's configuration file !" << endl);
284  return 1;
285  }
286  // Provide options if any
287  if (list_options!="" && mp_Deformation->ReadAndCheckOptionsList(list_options))
288  {
289  Cerr("***** oDeformationManager::ParseOptionsAndInitializeDeformations() -> A problem occurred while parsing and reading respiratory deformation's options !" << endl);
290  return 1;
291  }
292 
293  // Check parameters
295  {
296  Cerr("***** oDeformationManager::ParseOptionsAndInitializeDeformations() -> A problem occurred while checking respiratory deformation parameters !" << endl);
297  return 1;
298  }
299  // Initialize the deformation
300  if (mp_Deformation->Initialize())
301  {
302  Cerr("***** oDeformationManager::ParseOptionsAndInitializeDeformations() -> A problem occurred while initializing respiratory deformation !" << endl);
303  return 1;
304  }
305 
306  }
307 
308 
309  // Normal end
310  return 0;
311 }
312 
313 
314 
315 // =====================================================================
316 // ---------------------------------------------------------------------
317 // ---------------------------------------------------------------------
318 // =====================================================================
319 /*
320  \fn InstantiateImageForDeformation
321  \param oImageSpace* ap_Image : required to call oImageSpace instanciation functions
322  \brief If deformation is enabled, ask the Image Space to Instantiate the temporary backward image for deformation
323  If reconstruction is in histogram mode, the temporal sensitivity image is instanciated as well
324 */
326 {
330  {
331  // Verbose
332  if(m_verbose>=VERBOSE_DETAIL) Cout("oDeformationManager::InstantiateImageForDeformation() -> Instantiate buffer images"<< endl);
333  // Instantiate reference forward/backward images
335  }
336 }
337 
338 // =====================================================================
339 // ---------------------------------------------------------------------
340 // ---------------------------------------------------------------------
341 // =====================================================================
342 /*
343  \fn DeallocateImageForDeformation
344  \param oImageSpace* ap_Image : required to call oImageSpace deallocation functions
345  \brief If deformation is enabled, ask the Image Space to free memory of the temporary backward image for deformation
346  If reconstruction is in histogram mode, the temporal sensitivity image is deallocated as well
347 */
349 {
351  {
352  // Verbose
353  if(m_verbose>=VERBOSE_DETAIL) Cout("oDeformationManager::DeallocateImageForDeformation() -> Deallocate buffer images"<< endl);
354 
355  // Free reference forward/backward images
357  }
358 }
359 
360 // =====================================================================
361 // ---------------------------------------------------------------------
362 // ---------------------------------------------------------------------
363 // =====================================================================
364 /*
365  \fn InitImageForDeformation
366  \param oImageSpace* ap_Image : required to call oImageSpace initialization functions
367  \brief If deformation is enabled, ask the Image Space to initialize the temporary backward image for deformation
368  If reconstruction is in histogram mode, the temporal sensitivity image is initialized as well
369 */
371 {
373  {
374  // Reset motion idx
375  m_curMotIdx = 0;
376 
377  if(m_verbose>=VERBOSE_DETAIL) Cout("oDeformationManager::InitImageForDeformation() -> Initialize buffer images"<< endl);
378 
379  // Init reference forward/backward images
380  ap_Image->InitRefImagesForDeformation();
381 
382  // For cyclic motion, perform deformation of the forward image
383  // on each potential dynamic image
387  {
388  if(m_verbose >=VERBOSE_DETAIL) Cout("oDeformationManager::InitImageForDeformation()-> Apply forward image deformation of the forward image(s) for each dynamic image (is any) " << endl);
389 
390  // Deformation of the forward image for each dynamic image
391  for(int fr=0; fr<mp_ID->GetNbTimeBasisFunctions(); fr++)
392  for(int rimg=0; rimg<mp_ID->GetNbRespBasisFunctions(); rimg++)
393  for(int cimg=0; cimg<mp_ID->GetNbCardBasisFunctions(); cimg++)
394  if (mp_Deformation->ApplyDeformations(ap_Image->m4p_refDynForwardImage[ fr ][ rimg ][ cimg ],
395  ap_Image->m4p_forwardImage[ fr ][ rimg ][ cimg ],
397  // cyclic motion: transformation params #0
398  // patient motion-> first transformation params for the frame fr (note: rimg & cimg=0)
399  0 + mp_ID->GetPMotionFirstIndexForFrame( fr ) )
400  )
401  {
402  Cerr("***** oDeformationManager::InitImageForDeformation()-> An error occurred while performing image deformation during the reconstruction !" << endl);
403  return 1;
404  }
405  }
406  }
407 
408  return 0;
409 }
410 
411 
412 
413 // =====================================================================
414 // ---------------------------------------------------------------------
415 // ---------------------------------------------------------------------
416 // =====================================================================
417 /*
418  \fn ApplyDeformationForSensitivityGeneration
419  \param oImageSpace* ap_Image : required to access oImageSpace image matrices
420  \param int a_defDirection : direction of the deformation (forward/backward)
421  //\param int a_defType : Nature of the motion (Respiratory/Cardiac/Involuntary Patient)
422  \param int idx
423  \param int fr
424  \param int rg
425  \param int cg
426  \brief Apply deformations during the list-mode sensitivity image generation
427  \details Perform deformation on the forward_image or the backward_image matrices corresponding to the current fr, rg, cg (if any), and depending on the defDirection.
428  \todo Some changes required if we merge respiratory/cardiac motion objects
429  \todo Check and implement patient motion
430  \return 0 if success, positive value otherwise
431 */
432 int oDeformationManager::ApplyDeformationForSensitivityGeneration(oImageSpace* ap_Image, int a_defDirection, int idx, int fr, int rg, int cg)
433 {
434  #ifdef CASTOR_DEBUG
435  if (!m_initialized)
436  {
437  Cerr("***** oDeformationManager::ApplyDeformationForSensitivityGeneration() -> Called while not initialized !" << endl);
438  Exit(EXIT_DEBUG);
439  }
440  #endif
441 
443  idx = rg;
444  else if (m_UseDeformationCard)
445  idx = cg;
446  else if (m_UseDeformationIPat)
447  idx += rg; // First motion parameter for the fr + motion image index
448  else
449  return 0; // no deformation to perform
450 
451 
452  // --- DEFORMATION MANAGEMENT ---
453 
455  {
456  Cout("oDeformationManager::ApplyDeformationForSensitivityGeneration(): ");
457 
458  if(a_defDirection==BACKWARD_DEFORMATION)
459  Cout("->BACKWARD Deformation of the sensitivity image with transformation parameter "<<idx<<", (respiratory gate "<<rg << " and card gate " <<cg<< ")." <<endl);
460  else
461  Cout("->FORWARD Deformation of the sensitivity image with transformation parameter "<<idx<<", (respiratory gate "<<rg << " and card gate " <<cg<< ")." <<endl);
462  }
463 
464  if (mp_Deformation->PerformSensitivityDeformation(ap_Image, a_defDirection, idx, fr, rg, cg) )
465  {
466  Cerr("***** oDeformationManager::ApplyDeformationForSensitivityGeneration()-> An error occurred while performing deformation for respiratory motion correction for the sensitivity image generation !" << endl);
467  return 1;
468  }
469 
470  return 0;
471 }
472 
473 
474 
475 // =====================================================================
476 // ---------------------------------------------------------------------
477 // ---------------------------------------------------------------------
478 // =====================================================================
479 /*
480  \fn PerformDeformation
481  \param oImageSpace* ap_Image : required to access oImageSpace image matrices
482  \brief Apply deformations during reconstruction
483  \details Call the eponym function for the deformation object,
484  as well as PerformHistoSensitivityDeformation() if data mode is histogram.
485  \todo why the check on frames ?
486  \return 0 if success, positive value otherwise
487 */
489 {
490  #ifdef CASTOR_DEBUG
491  if (!m_initialized)
492  {
493  Cerr("***** oDeformationManager::PerformDeformation() -> Called while not initialized !" << endl);
494  Exit(EXIT_DEBUG);
495  }
496  #endif
497 
498  // Get the deformation index corresponding to the motion
499  int idx = -1;
500 
502  idx = mp_ID->GetCurrentRespGate(0);
503  else if (m_UseDeformationCard)
504  idx = mp_ID->GetCurrentCardGate(0);
505  else if (m_UseDeformationIPat)
506  idx = mp_ID->GetCurrentPMotionIndex(0);
507  else
508  return 0; // no deformation to perform
509 
510 
511  // --- DEFORMATION MANAGEMENT ---
512 
513  //int fr = mp_ID->GetCurrentTimeFrame(0); // Done via time_basis_coef
514  int rimg = mp_ID->GetCurrentRespImage(0);
515  int cimg = mp_ID->GetCurrentCardImage(0);
516 
517  // This loop is only required when intrinsic temporal basis functions are used
518  // The image matrices are then not independent for each frame, but for each basis functions.
519  // In this case, the deformation operations are performed for each image matrix
520  // In normal case, the loop is simply ignored as only one frame has time basis coefficient == 1
521  // (Technically, it is has using identity intrinsic basis functions)
522  for (int tbf=0; tbf<mp_ID->GetNbTimeBasisFunctions(); tbf++)
523  {
524  FLTNB time_basis_coef = mp_ID->GetTimeBasisCoefficient(tbf, mp_ID->GetCurrentTimeFrame(0));
525  if (time_basis_coef==0.) continue;
526 
527  // Perform deformation if the motion index has been changed
528  if ( m_curMotIdx != (idx+1) )
529  {
530  if(m_verbose >=VERBOSE_DETAIL) Cout("oDeformationManager::PerformDeformation-> Transformation parameter # " << idx
531  << ", for resp image " <<rimg
532  << " and card image " <<cimg<<"."
533  << " Frame # " << tbf << endl);
534  if(mp_Deformation->PerformDeformation(ap_Image, idx, tbf, rimg, cimg) )
535  {
536  Cerr("***** oDeformationManager::PerformDeformation()-> An error occurred while performing image deformation during the reconstruction !" << endl);
537  return 1;
538  }
539 
540  // Perform deformation of the sensitivity image ((PET) MODE_HISTOGRAM)
542  && mp_Deformation->PerformHistoSensitivityDeformation(ap_Image, idx, tbf, rimg, cimg) )
543  {
544  Cerr("***** oDeformationManager::PerformDeformation()-> An error occurred while performing sensitivity image deformation (histogram mode) during the reconstruction !" << endl);
545  return 1;
546  }
547 
548  // Update the current index
549  m_curMotIdx = idx;
550  }
551  }
552 
553  return 0;
554 }
555 
556 
557 
558 
559 // =====================================================================
560 // ---------------------------------------------------------------------
561 // ---------------------------------------------------------------------
562 // =====================================================================
563 /*
564  \fn ApplyDeformationsToBackwardImage
565  \param oImageSpace* ap_Image : required to access oImageSpace image matrices
566  \brief Apply final backward deformations on the backward image
567  \details Call the eponym function for the deformation object, as well as >ApplyDeformationsToHistoSensitivityImage() if data mode is histogram.
568  Then reinitialize the temporary backup deformation images (the backward image, and the sensitivity image if data mode is histogram)
569  \return 0 if success, positive value otherwise
570 */
572 {
573  #ifdef CASTOR_DEBUG
574  if (!m_initialized)
575  {
576  Cerr("***** oDeformationManager::ApplyDeformationsToBackwardImage() -> Called while not initialized !" << endl);
577  Exit(EXIT_DEBUG);
578  }
579  #endif
580 
581  // Get the deformation index corresponding to the motion
582  int idx = -1;
583 
584  // Loop on each dynamic frames
585  for(int fr=0; fr<mp_ID->GetNbTimeBasisFunctions(); fr++)
586  {
588  idx = mp_ID->GetCurrentRespGate(0);
589  else if (m_UseDeformationCard)
590  idx = mp_ID->GetCurrentCardGate(0);
591  else if (m_UseDeformationIPat)
593  else
594  return 0; // no deformation to perform
595 
596  // --- DEFORMATION MANAGEMENT ---
597 
598  if(m_verbose >=VERBOSE_DETAIL) Cout("oDeformationManager::ApplyDeformationsToBackwardImage-> Transformation parameter #" << idx<< "." <<endl);
599 
600  if(mp_Deformation->ApplyDeformationsToBackwardImage(ap_Image, fr, idx) )
601  {
602  Cerr("***** oDeformationManager::ApplyDeformationsToBackwardImage()-> An error occurred while performing final backward image deformation !" << endl);
603  return 1;
604  }
605 
606  // Perform deformation of the sensitivity image ((PET) MODE_HISTOGRAM)
609  {
610  Cerr("***** oDeformationManager::ApplyDeformationsToBackwardImage()-> An error occurred while performing final backward image deformation of the sensitivity image !" << endl);
611  return 1;
612  }
613  }
614 
615  // Init reference forward/backward images
616  ap_Image->InitRefImagesForDeformation();
617 
618  return 0;
619 }
620 
621 
622 
623 
624 // =====================================================================
625 // ---------------------------------------------------------------------
626 // ---------------------------------------------------------------------
627 // =====================================================================
628 /*
629  \fn TestDeformationOnImage
630  \param ap_inputImage : input image to deform
631  \param ap_outputImage : image in which the output of the deformation should be recovered
632  \param a_direction : a direction for the deformation to perform (forward or backward)
633  \param a_defIdx : index of the deformation
634  \brief Apply deformation specified by arguments on provided input image, for testing purposes
635  \return 0 if success, positive value otherwise
636 */
637 int oDeformationManager::TestDeformationOnImage(FLTNB* ap_inputImage, FLTNB* ap_outputImage, int a_direction, int a_defIdx)
638 {
639  if (m_verbose>=VERBOSE_DETAIL) Cout("oDeformationManager::TestDeformationOnImage ..."<< endl);
640 
641  if(mp_Deformation->ApplyDeformations(ap_inputImage, ap_outputImage, a_direction, a_defIdx) )
642  {
643  Cerr("***** oDeformationManager::TestDeformationOnImage()-> An error occurred while testing deformation !" << endl);
644  return 1;
645  }
646 
647  return 0;
648 }
649 
650 #ifdef CASTOR_OMP
651 // =====================================================================
652 // ---------------------------------------------------------------------
653 // ---------------------------------------------------------------------
654 // =====================================================================
655 /*
656  \fn oDeformationManager::AllThreadsRequireDeformation
657  \brief Do all the threads require an image deformation?
658  \return True if all the threads require a deformation, false otherwise
659 */
660 
661 bool oDeformationManager::AllThreadsRequireDeformation()
662 {
663  for (INTNB th=0 ; th < mp_ID->GetNbThreadsForProjection() ; th++)
664  if (!mp_deformationRequirement[th])
665  return false;
666  return true;
667 }
668 
669 // =====================================================================
670 // ---------------------------------------------------------------------
671 // ---------------------------------------------------------------------
672 // =====================================================================
673 /*
674  \fn oDeformationManager::UnsetDeformationRequirements
675  \brief Unset deformation requirements for all the threads
676 */
677 
678 void oDeformationManager::UnsetDeformationRequirements()
679 {
680  for (INTNB th=0 ; th < mp_ID->GetNbThreadsForProjection() ; th++)
681  mp_deformationRequirement[th] = false;
682 }
683 #endif
void SetVerbose(int a_verbose)
#define MODE_HISTOGRAM
int PerformDeformation(oImageSpace *ap_Image)
int GetNbCardBasisFunctions()
Get the number of cardiac basis functions.
virtual int ApplyDeformationsToBackwardImage(oImageSpace *ap_Image, int a_fr, int a_defIdx)
int ParseOptionsAndInitializeDeformations()
Parse respiratory/cardiac/involuntary patient motion options contained in the previously provided str...
void SetNbTransformations(int a_nbTransformations)
#define Cerr(MESSAGE)
void ShowHelpDeformation()
Show help about all implemented deformations.
#define FORWARD_DEFORMATION
FLTNB GetTimeBasisCoefficient(int a_timeBasisFunction, int a_timeFrame)
virtual int PerformDeformation(oImageSpace *ap_Image, int a_defIdx, int a_fr, int a_rimg, int a_cimg)
#define BACKWARD_DEFORMATION
int ApplyDeformationForSensitivityGeneration(oImageSpace *ap_Image, int a_defDirection, int idx, int fr, int rg, int cg)
virtual int PerformHistoSensitivityDeformation(oImageSpace *ap_Image, int a_defIdx, int fr, int rimg, int cimg)
virtual int Initialize()=0
This function is used to initialize specific data related to the child deformation model...
int GetNbTimeBasisFunctions()
Get the number of time basis functions.
int ApplyDeformationsToBackwardImage(oImageSpace *ap_Image)
void Exit(int code)
virtual int CheckParameters()
This function is used to check parameters after the latter have been all set using Set functions...
int InitImageForDeformation(oImageSpace *ap_Image)
std::map< string, maker_deformation > mp_listOfDeformations
static sAddonManager * GetInstance()
virtual int ApplyDeformations(FLTNB *ap_inputImage, FLTNB *ap_outputImage, int a_direction, int a_defIdx)=0
void DeallocateRefImagesForDeformation()
Free memory for the buffer sensitivity image required for image-based deformation. This function is called from the Deformation Manager.
This is the mother class of image-based transformation class.
void InstantiateImageForDeformation(oImageSpace *ap_Image)
int CheckParameters()
This function is used to check parameters after the latter have been all set using Set functions...
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
~oDeformationManager()
Destructor of oDeformationManager. Free memory from all allocated tabs.
virtual int PerformSensitivityDeformation(oImageSpace *ap_Image, int a_defDirection, int a_defIdx, int fr, int rg, int cg)
int Initialize()
Set the flags for the different motion types and instanciate/initialize deformation objects through t...
This class holds all the matrices in the image domain that can be used in the algorithm: image...
int TestDeformationOnImage(FLTNB *ap_inputImage, FLTNB *ap_outputImage, int a_direction, int a_defIdx)
int GetNbThreadsForProjection()
Get the number of threads used for projections.
virtual int ReadAndCheckConfigurationFile(const string &a_fileOptions)=0
oDeformationManager()
Constructor of oDeformationManager. Simply set all data members to default values.
virtual int ReadAndCheckOptionsList(const string &a_listOptions)=0
void InstantiateRefImagesForDeformation()
Allocate memory for the buffer sensitivity image required for image-based deformation. This function is called from the Deformation Manager.
oImageDimensionsAndQuantification * mp_ID
void DeallocateImageForDeformation(oImageSpace *ap_Image)
#define Cout(MESSAGE)
int GetNbRespBasisFunctions()
Get the number of respiratory basis functions.
virtual int ApplyDeformationsToHistoSensitivityImage(oImageSpace *ap_Image, int a_fr, int a_defIdx)