CASToR  2.0
Tomographic Reconstruction (PET/SPECT/CT)
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
oDeformationManager.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 "oDeformationManager.hh"
32 #include "sAddonManager.hh"
33 
34 // =====================================================================
35 // ---------------------------------------------------------------------
36 // ---------------------------------------------------------------------
37 // =====================================================================
38 /*
39  \fn oDeformationManager
40  \brief Constructor of oDeformationManager. Simply set all data members to default values.
41 */
43 {
44  // Image dimensions
45  mp_ID = NULL;
46  // Options for deformation
47  m_options = "";
48 
49  // Deformation objects and associated bool
50  mp_Deformation = NULL;
51 
52  m_UseDeformationResp = false;
53  m_UseDeformationCard = false;
54  m_UseDeformationIPat = false;
55 
56  // Variable indicating the number of transformations
58 
59  mp_curPatMotIdx = NULL;
60 
61  // Verbosity
62  m_verbose = -1;
63  // Data mode
64  m_dataMode = -1;
65  // Not checked yet
66  m_checked = false;
67  // Not initialized yet
68  m_initialized = false;
69 }
70 
71 // =====================================================================
72 // ---------------------------------------------------------------------
73 // ---------------------------------------------------------------------
74 // =====================================================================
75 /*
76  \fn ~oDeformationManager
77  \brief Destructor of oDeformationManager. Free memory from all allocated tabs.
78 */
80 {
81  // Delete deformation objects
82  if (m_initialized)
83  if (mp_Deformation!= NULL) delete mp_Deformation;
84 
85  if(mp_curPatMotIdx) delete[] mp_curPatMotIdx;
86 }
87 
88 
89 
90 // =====================================================================
91 // ---------------------------------------------------------------------
92 // ---------------------------------------------------------------------
93 // =====================================================================
94 /*
95  \fn oDeformationManager::SetMotionType
96  \param a_motionType
97  \brief Set the nature of motion correction (Deformation type macro)
98 */
99 void oDeformationManager::SetMotionType(int a_motionType)
100 {
101  switch (a_motionType)
102  {
103  case DEF_RESP_MOT : m_UseDeformationResp = true; break;
104  case DEF_CARD_MOT : m_UseDeformationCard = true; break;
105  case DEF_IPAT_MOT : m_UseDeformationIPat = true; break;
106  case DEF_DUAL_MOT : {m_UseDeformationResp = true; m_UseDeformationCard = true;} break;
107  default : {m_UseDeformationResp = false;
108  m_UseDeformationCard = false;
109  m_UseDeformationIPat = false;}
110  }
111 }
112 
113 
114 
115 
116 // =====================================================================
117 // ---------------------------------------------------------------------
118 // ---------------------------------------------------------------------
119 // =====================================================================
120 /*
121  \fn CheckParameters
122  \brief This function is used to check parameters after the latter
123  have been all set using Set functions.
124  \return 0 if success, positive value otherwise.
125 */
127 {
128  // Verbose
129  if (m_verbose>=4) Cout("oDeformationManager::CheckParameters() -> Check parameters before initialization"<< endl);
130  // Check image dimensions
131  if (mp_ID==NULL)
132  {
133  Cerr("***** oDeformationManager::CheckParameters() -> No image dimensions provided !" << endl);
134  return 1;
135  }
136  // Check resp gates
137  if (m_nbTransformations<0)
138  {
139  Cerr("***** oDeformationManager::CheckParameters() -> Wrong number of respiratory gates !" << endl);
140  return 1;
141  }
142  // Check verbosity
143  if (m_verbose<0)
144  {
145  Cerr("***** oDeformationManager::CheckParameters() -> Wrong verbosity level provided !" << endl);
146  return 1;
147  }
148  // Check data mode
149  if (m_dataMode<0)
150  {
151  Cerr("***** oDeformationManager::CheckParameters() -> Wrong data mode provided ! (should be =0 (list-mode) or =1 (histogram)" << endl);
152  return 1;
153  }
154  // Normal end
155  m_checked = true;
156  return 0;
157 }
158 
159 
160 // =====================================================================
161 // ---------------------------------------------------------------------
162 // ---------------------------------------------------------------------
163 // =====================================================================
164 /*
165  \fn Initialize
166  \brief Set the flags for the different motion types and instanciate/initialize deformation objects
167  through the ParseOptionsAndInitializeDeformations() private function.
168  \return 0 if success, positive value otherwise.
169 */
171 {
172  // Forbid initialization without check
173  if (!m_checked)
174  {
175  Cerr("***** oDeformationManager::Initialize() -> Must call CheckParameters() before Initialize() !" << endl);
176  return 1;
177  }
178 
179  // Initialize current gate/involuntary motion index
180  m_curMotIdx = 0;
181 
182  mp_curPatMotIdx = new int16_t[mp_ID->GetNbTimeFrames()];
183  for(int fr=0 ; fr<mp_ID->GetNbTimeFrames() ; fr++)
184  mp_curPatMotIdx[fr] = 0;
185 
186  // Return if no deformation
188  {
189  m_initialized = true;
190  return 0;
191  }
192 
193  // Verbose
194  if (m_verbose>=1) Cout("oDeformationManager::Initialize() -> Initialize deformations" << endl);
195 
196  // Parse deformation options and initialize them
198  {
199  Cerr("***** oDeformationManager::Initialize() -> A problem occured while parsing deformation options and initializing them !" << endl);
200  return 1;
201  }
202 
203  // Normal end
204  m_initialized = true;
205  return 0;
206 }
207 
208 // =====================================================================
209 // ---------------------------------------------------------------------
210 // ---------------------------------------------------------------------
211 // =====================================================================
212 /*
213  \fn ParseOptionsAndInitializeProjectors
214  \brief Parse respiratory/cardiac/involuntary patient motion options contained in the previously provided
215  strings. This function is called inside the Initialize() function.
216  \details Manage the options reading and initialize specific vDeformation
217  Options are a string containing first the name of the deformation,
218  then either a ':' and a configuration file specific to the deformation
219  - or - as many ',' as needed parameters for this deformation.
220  Specific pure virtual functions of the vDeformation are used to read parameters and initialize them.
221  \todo Some cleaning if we merge respiratory and cardiac motion objects
222  \return 0 if success, positive value otherwise
223 */
225 {
226  if (m_verbose>=2) Cout("oDeformationManager::ParseOptionsAndInitializeDeformations ..."<< endl);
227 
228  string deformation = "";
229  string list_options = "";
230  string file_options = "";
231 
232  // This is for the automatic initialization of the deformations
233  typedef vDeformation *(*maker_deformation) ();
234 
235  // Get deformation's list from addon manager
236  std::map <string,maker_deformation> list = sAddonManager::GetInstance()->mp_listOfDeformations;
237 
238  size_t colon, comma;
239 
240  // ---------------------------------------------------------------------------------------------------
241  // Manage deformation for respiratory motion
242  // ---------------------------------------------------------------------------------------------------
244  {
245  // ______________________________________________________________________________
246  // Get the deformation name in the options and isolate the real deformation's options
247 
248  // Search for a colon ":", this indicates that a configuration file is provided after the deformation name
249  colon = m_options.find_first_of(":");
250  comma = m_options.find_first_of(",");
251 
252  // Case 1: we have a colon
253  if (colon!=string::npos)
254  {
255  // Get the deformation name before the colon
256  deformation = m_options.substr(0,colon);
257  // Get the configuration file after the colon
258  file_options = m_options.substr(colon+1);
259  // List of options is empty
260  list_options = "";
261  }
262  // Case 2: we have a comma
263  else if (comma!=string::npos)
264  {
265  // Get the deformation name before the first comma
266  deformation = m_options.substr(0,comma);
267  // Get the list of options after the first comma
268  list_options = m_options.substr(comma+1);
269  // Configuration file is empty
270  file_options = "";
271  }
272  // Case 3: no colon and no comma (a single deformation name)
273  else
274  {
275  // Get the deformation name
276  deformation = m_options;
277  // Configuration file is empty
278  file_options = "";
279  // List of options is empty
280  list_options = "";
281  }
282 
283  // Create the deformation
284  if (list[deformation]) mp_Deformation = list[deformation]();
285  else
286  {
287  Cerr("***** oDeformationManager::ParseOptionsAndInitializeDeformations() -> Deformation '" << deformation << "' does not exist !" << endl);
289  return 1;
290  }
291  // Set parameters
295 
296  // Provide configuration file if any
297  if (file_options!="" && mp_Deformation->ReadAndCheckConfigurationFile(file_options))
298  {
299  Cerr("***** oDeformationManager::ParseOptionsAndInitializeDeformations() -> A problem occured while reading and checking respiratory deformation's configuration file !" << endl);
300  return 1;
301  }
302  // Provide options if any
303  if (list_options!="" && mp_Deformation->ReadAndCheckOptionsList(list_options))
304  {
305  Cerr("***** oDeformationManager::ParseOptionsAndInitializeDeformations() -> A problem occured while parsing and reading respiratory deformation's options !" << endl);
306  return 1;
307  }
308 
309  // Check parameters
311  {
312  Cerr("***** oDeformationManager::ParseOptionsAndInitializeDeformations() -> A problem occured while checking respiratory deformation parameters !" << endl);
313  return 1;
314  }
315  // Initialize the deformation
316  if (mp_Deformation->Initialize())
317  {
318  Cerr("***** oDeformationManager::ParseOptionsAndInitializeDeformations() -> A problem occured while initializing respiratory deformation !" << endl);
319  return 1;
320  }
321 
322  }
323 
324 
325  // Normal end
326  return 0;
327 }
328 
329 
330 
331 // =====================================================================
332 // ---------------------------------------------------------------------
333 // ---------------------------------------------------------------------
334 // =====================================================================
335 /*
336  \fn InstantiateImageForDeformation
337  \param oImageSpace* ap_Image : required to call oImageSpace instanciation functions
338  \brief If deformation is enabled, ask the Image Space to Instantiate the temporary backward image for deformation
339  If reconstruction is in histogram mode, the temporal sensitivity image is instanciated as well
340 */
342 {
344  {
345  // Verbose
346  if(m_verbose>=2) Cout("oDeformationManager::InstantiateImageForDeformation() -> Instantiate buffer images"<< endl);
347  // Instantiate reference forward/backward images
349  // In histogram mode, need another buffer image for sensitivity deformation
350  //if (m_dataMode == MODE_HISTOGRAM) ap_Image->InstantiateSensImageForDeformation();
351  }
352 }
353 
354 // =====================================================================
355 // ---------------------------------------------------------------------
356 // ---------------------------------------------------------------------
357 // =====================================================================
358 /*
359  \fn DeallocateImageForDeformation
360  \param oImageSpace* ap_Image : required to call oImageSpace deallocation functions
361  \brief If deformation is enabled, ask the Image Space to free memory of the temporary backward image for deformation
362  If reconstruction is in histogram mode, the temporal sensitivity image is deallocated as well
363 */
365 {
367  {
368  // Verbose
369  if(m_verbose>=2) Cout("oDeformationManager::DeallocateImageForDeformation() -> Deallocate buffer images"<< endl);
370 
371  //ap_Image->DeallocateBwdImageForDeformation();
372  // Free reference forward/backward images
374  // In histogram mode, deallocate sensitivity buffer image
375  //if (m_dataMode == MODE_HISTOGRAM) ap_Image->DeallocateSensImageForDeformation();
376  }
377 }
378 
379 // =====================================================================
380 // ---------------------------------------------------------------------
381 // ---------------------------------------------------------------------
382 // =====================================================================
383 /*
384  \fn InitImageForDeformation
385  \param oImageSpace* ap_Image : required to call oImageSpace initialization functions
386  \brief If deformation is enabled, ask the Image Space to initialize the temporary backward image for deformation
387  If reconstruction is in histogram mode, the temporal sensitivity image is initialized as well
388 */
390 {
392  {
393  // Reset motion idx
394  m_curMotIdx = 0;
395 
396  if(m_verbose>=2) Cout("oDeformationManager::InitImageForDeformation() -> Initialize buffer images"<< endl);
397  //ap_Image->InitBwdImageForDeformation();
398  // Init reference forward/backward images
399  ap_Image->InitRefImagesForDeformation();
400  }
401 }
402 
403 
404 
405 // =====================================================================
406 // ---------------------------------------------------------------------
407 // ---------------------------------------------------------------------
408 // =====================================================================
409 /*
410  \fn ApplyDeformationForSensitivityGeneration
411  \param oImageSpace* ap_Image : required to access oImageSpace image matrices
412  \param int a_defDirection : direction of the deformation (forward/backward)
413  //\param int a_defType : Nature of the motion (Respiratory/Cardiac/Involuntary Patient)
414  \param int idx
415  \param int fr
416  \param int rg
417  \param int cg
418  \brief Apply deformations during the list-mode sensitivity image generation
419  \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.
420  \todo Some changes required if we merge respiratory/cardiac motion objects
421  \todo Check and implement patient motion
422  \return 0 if success, positive value otherwise
423 */
424 int oDeformationManager::ApplyDeformationForSensitivityGeneration(oImageSpace* ap_Image, int a_defDirection, int idx, int fr, int rg, int cg)
425 {
426  #ifdef CASTOR_DEBUG
427  if (!m_initialized)
428  {
429  Cerr("***** oDeformationManager::ApplyDeformationForSensitivityGeneration() -> Called while not initialized !" << endl);
430  Exit(EXIT_DEBUG);
431  }
432  #endif
433 
434 
435  // TODO : Ipat motion management
436 
438  idx = rg;
439  else if (m_UseDeformationCard)
440  idx = cg;
441  else if (m_UseDeformationIPat)
442  idx = idx;
443  else
444  return 0; // no deformation to perform
445 
446 
447  // --- DEFORMATION MANAGEMENT ---
448 
449  if (m_verbose>=2)
450  {
451  Cout("oDeformationManager::ApplyDeformationForSensitivityGeneration(): " << endl);
452 
453  if(a_defDirection==BACKWARD_DEFORMATION)
454  Cout("->BACKWARD Deformation for respiratory motion, for resp gate "<<rg << " and card gate " <<cg<< " and patient motion subset " <<idx<<"." <<endl);
455  else
456  Cout("->FORWARD Deformation for respiratory motion, for resp gate "<<rg << " and card gate " <<cg<< " and patient motion subset " <<idx<<"." <<endl);
457  }
458 
459  if (mp_Deformation->PerformSensitivityDeformation(ap_Image, a_defDirection, idx, fr, rg, cg) )
460  {
461  Cerr("***** oDeformationManager::ApplyDeformationForSensitivityGeneration()-> An error occured while performing deformation for respiratory motion correction for the sensitivity image generation !" << endl);
462  return 1;
463  }
464 
465  return 0;
466 }
467 
468 
469 
470 // =====================================================================
471 // ---------------------------------------------------------------------
472 // ---------------------------------------------------------------------
473 // =====================================================================
474 /*
475  \fn PerformDeformation
476  \param oImageSpace* ap_Image : required to access oImageSpace image matrices
477  \brief Apply deformations during reconstruction
478  \details Call the eponym function for the deformation object,
479  as well as PerformHistoSensitivityDeformation() if data mode is histogram.
480  \todo why the check on frames ?
481  \return 0 if success, positive value otherwise
482 */
484 {
485  #ifdef CASTOR_DEBUG
486  if (!m_initialized)
487  {
488  Cerr("***** oDeformationManager::PerformDeformation() -> Called while not initialized !" << endl);
489  Exit(EXIT_DEBUG);
490  }
491  #endif
492 
493  int fr = mp_ID->GetCurrentTimeFrame(0);
494  int rimg = mp_ID->GetCurrentRespImage(0);
495  int cimg = mp_ID->GetCurrentCardImage(0);
496 
497  //fr = (fr<0) ? 0 : fr ;
498 
499  // Get the deformation index corresponding to the motion
500  int idx = -1;
501 
503  idx = mp_ID->GetCurrentRespGate(0);
504  else if (m_UseDeformationCard)
505  idx = mp_ID->GetCurrentCardGate(0);
506  else if (m_UseDeformationIPat)
507  idx = mp_ID->GetCurrentPMotionIndex(0);
508  else
509  return 0; // no deformation to perform
510 
511 
512  // --- DEFORMATION MANAGEMENT ---
513  if ( m_curMotIdx != (idx+1) )
514  {
515  if(m_verbose >=3) Cout("oDeformationManager::PerformDeformation-> Gate/motion subset # " << idx
516  << ", for resp image " <<rimg
517  << " and card image " <<cimg<<"."
518  << " Frame # " << fr << endl);
519  if(mp_Deformation->PerformDeformation(ap_Image, idx, fr, rimg, cimg) )
520  {
521  Cerr("***** oDeformationManager::PerformDeformation()-> An error occured while performing image deformation during the reconstruction !" << endl);
522  return 1;
523  }
524 
525  // Perform deformation of the sensitivity image ((PET) MODE_HISTOGRAM)
527  && mp_Deformation->PerformHistoSensitivityDeformation(ap_Image, idx, fr, rimg, cimg) )
528  {
529  Cerr("***** oDeformationManager::PerformDeformation()-> An error occured while performing sensitivity image deformation (histogram mode) during the reconstruction !" << endl);
530  return 1;
531  }
532 
533  // In case of a timestamp-based deformation, the forward image of each following frame must be transformed
534  // TODO: Should be done only to following frames occuring before the next motion timestamp
535 
536 
538  {
539  mp_curPatMotIdx[fr] = idx;
540 
541  for(int f=fr+1 ; f<mp_ID->GetNbTimeFrames(); f++)
542  {
543  if(mp_Deformation->PerformDeformationBis(ap_Image, idx, f, rimg, cimg) )
544  {
545  Cerr("***** oDeformationManager::PerformDeformation()-> An error occured while performing image deformation during the reconstruction !" << endl);
546  return 1;
547  }
548  /*
549  // Perform deformation of the sensitivity image ((PET) MODE_HISTOGRAM)
550  if(m_dataMode == MODE_HISTOGRAM
551  && mp_Deformation->PerformHistoSensitivityDeformation(ap_Image, idx, f, rimg, cimg) )
552  {
553  Cerr("***** oDeformationManager::PerformDeformation()-> An error occured while performing sensitivity image deformation (histogram mode) during the reconstruction !" << endl);
554  return 1;
555  }
556  */
557  mp_curPatMotIdx[f] = idx;
558  }
559  }
560 
561 
562  m_curMotIdx = idx;
563  }
564 
565  return 0;
566 }
567 
568 
569 
570 
571 // =====================================================================
572 // ---------------------------------------------------------------------
573 // ---------------------------------------------------------------------
574 // =====================================================================
575 /*
576  \fn ApplyDeformationsToBackwardImage
577  \param oImageSpace* ap_Image : required to access oImageSpace image matrices
578  \brief Apply final backward deformations on the backward image
579  \details Call the eponym function for the deformation object, as well as >ApplyDeformationsToHistoSensitivityImage() if data mode is histogram.
580  Then reinitialize the temporary backup deformation images (the backward image, and the sensitivity image if data mode is histogram)
581  \return 0 if success, positive value otherwise
582 */
584 {
585  #ifdef CASTOR_DEBUG
586  if (!m_initialized)
587  {
588  Cerr("***** oDeformationManager::ApplyDeformationsToBackwardImage() -> Called while not initialized !" << endl);
589  Exit(EXIT_DEBUG);
590  }
591  #endif
592 
593  // Get the deformation index corresponding to the motion
594  int idx = -1;
595 
596  for(int fr=0; fr<mp_ID->GetNbTimeFrames(); fr++)
597  {
599  idx = mp_ID->GetCurrentRespGate(0);
600  else if (m_UseDeformationCard)
601  idx = mp_ID->GetCurrentCardGate(0);
602  else if (m_UseDeformationIPat)
603  //idx = mp_ID->GetCurrentPMotionIndex(0);
604  idx = mp_curPatMotIdx[fr];
605  else
606  return 0; // no deformation to perform
607 
608  // --- DEFORMATION MANAGEMENT ---
609 
610  //if (m_UseDeformationResp)
611  //{
612  if(m_verbose >=3) Cout("oDeformationManager::ApplyDeformationsToBackwardImage-> Deformation for gate #" << idx<< "." <<endl);
613 
614  if(mp_Deformation->ApplyDeformationsToBackwardImage(ap_Image, fr, idx) )
615  {
616  Cerr("***** oDeformationManager::ApplyDeformationsToBackwardImage()-> An error occured while performing final backward image deformation !" << endl);
617  return 1;
618  }
619 
620  // Perform deformation of the sensitivity image ((PET) MODE_HISTOGRAM)
623  {
624  Cerr("***** oDeformationManager::ApplyDeformationsToBackwardImage()-> An error occured while performing final backward image deformation of the sensitivity image !" << endl);
625  return 1;
626  }
627 
628  // reset
629  mp_curPatMotIdx[fr] = 0;
630  }
631 
632  ap_Image->InitRefImagesForDeformation();
633 
634  //ap_Image->InitBwdImageForDeformation();
635 
636  //if(m_dataMode == MODE_HISTOGRAM)
637  // ap_Image->InitSensImageForDeformation();
638 
639  return 0;
640 }
641 
642 
643 
644 
645 // =====================================================================
646 // ---------------------------------------------------------------------
647 // ---------------------------------------------------------------------
648 // =====================================================================
649 /*
650  \fn TestDeformationOnImage
651  \param ap_inputImage : input image to deform
652  \param ap_outputImage : image in which the output of the deformation should be recovered
653  \param a_direction : a direction for the deformation to perform (forward or backward)
654  \param a_defIdx : index of the deformation
655  \brief Apply deformation specified by arguments on provided input image, for testing purposes
656  \return 0 if success, positive value otherwise
657 */
658 int oDeformationManager::TestDeformationOnImage(FLTNB* ap_inputImage, FLTNB* ap_outputImage, int a_direction, int a_defIdx)
659 {
660  if (m_verbose>=2) Cout("oDeformationManager::TestDeformationOnImage ..."<< endl);
661 
662  if(mp_Deformation->ApplyDeformations(ap_inputImage, ap_outputImage, a_direction, a_defIdx) )
663  {
664  Cerr("***** oDeformationManager::TestDeformationOnImage()-> An error occured while testing deformation !" << endl);
665  return 1;
666  }
667 
668  return 0;
669 }
void SetVerbose(int a_verbose)
Set the verbose level.
Definition: vDeformation.hh:97
int GetCurrentCardImage(int a_th)
call the eponym function from the oDynamicDataManager object
int GetCurrentCardGate(int a_th)
call the eponym function from the oDynamicDataManager object
#define MODE_HISTOGRAM
Definition: vDataFile.hh:59
int PerformDeformation(oImageSpace *ap_Image)
Apply deformations during reconstruction.
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.
int ParseOptionsAndInitializeDeformations()
Parse respiratory/cardiac/involuntary patient motion options contained in the previously provided str...
#define FLTNB
Definition: gVariables.hh:81
int GetCurrentPMotionIndex(int a_th)
call the eponym function from the oDynamicDataManager object
void SetNbTransformations(int a_nbTransformations)
Set the number of transformation in the data to be performed on the dataset (equal to the number of g...
void ShowHelpDeformation()
Show help about all implemented deformations.
virtual int ReadAndCheckConfigurationFile(const string &a_fileOptions)=0
This function is used to read options from a configuration file. It is pure virtual so must be impl...
virtual int PerformDeformation(oImageSpace *ap_Image, int a_defIdx, int a_fr, int a_rimg, int a_cimg)
Apply deformations during reconstruction.
Declaration of class oDeformationManager.
int ApplyDeformationForSensitivityGeneration(oImageSpace *ap_Image, int a_defDirection, int idx, int fr, int rg, int cg)
Apply deformations during the list-mode sensitivity image generation.
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.
void SetMotionType(int a_motionType)
Set the nature of motion correction (Deformation type macro)
virtual int Initialize()=0
This function is used to initialize specific data related to the child deformation model...
int ApplyDeformationsToBackwardImage(oImageSpace *ap_Image)
Apply final backward deformations on the backward image.
int GetCurrentRespGate(int a_th)
call the eponym function from the oDynamicDataManager object
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)
static sAddonManager * GetInstance()
#define DEF_DUAL_MOT
#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...
void InitRefImagesForDeformation()
virtual int PerformDeformationBis(oImageSpace *ap_Image, int a_defIdx, int a_fr, int a_rimg, int a_cimg)
#define DEF_RESP_MOT
#define BACKWARD_DEFORMATION
Definition: vDeformation.hh:38
void DeallocateRefImagesForDeformation()
Free memory for the buffer sensitivity image required for image-based deformation. This function is called from the Deformation Manager.
Definition: oImageSpace.cc:984
This is the mother class of image-based transformation class.
Definition: vDeformation.hh:65
#define DEF_CARD_MOT
void InstantiateImageForDeformation(oImageSpace *ap_Image)
If deformation is enabled, ask the Image Space to Instantiate the temporary backward image for deform...
int CheckParameters()
This function is used to check parameters after the latter have been all set using Set functions...
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the image dimensions in use.
Definition: vDeformation.hh:90
void InitImageForDeformation(oImageSpace *ap_Image)
If deformation is enabled, ask the Image Space to initialize the temporary backward image for deforma...
~oDeformationManager()
Destructor of oDeformationManager. Free memory from all allocated tabs.
std::map< string, maker_deformation > mp_listOfDeformations
#define DEF_IPAT_MOT
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.
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...
Definition: oImageSpace.hh:61
int GetNbTimeFrames()
Get the number of time frames.
#define EXIT_DEBUG
Definition: gVariables.hh:97
int TestDeformationOnImage(FLTNB *ap_inputImage, FLTNB *ap_outputImage, int a_direction, int a_defIdx)
Apply deformation specified by arguments on provided input image, for testing purposes.
virtual int ReadAndCheckOptionsList(const string &a_listOptions)=0
This function is used to read parameters from a string. It is pure virtual so must be implemented b...
oDeformationManager()
Constructor of oDeformationManager. Simply set all data members to default values.
#define Cout(MESSAGE)
void InstantiateRefImagesForDeformation()
Allocate memory for the buffer sensitivity image required for image-based deformation. This function is called from the Deformation Manager.
Definition: oImageSpace.cc:872
vDeformation * mp_Deformation
void DeallocateImageForDeformation(oImageSpace *ap_Image)
If deformation is enabled, ask the Image Space to free memory of the temporary backward image for def...
int GetCurrentRespImage(int a_th)
call the eponym function from the oDynamicDataManager object
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) ...
Declaration of class sAddonManager.
int GetCurrentTimeFrame(int a_th)
call the eponym function from the oDynamicDataManager object