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