ANIMA  4.0
animaPyramidalDenseSVFMatchingBridge.hxx
Go to the documentation of this file.
1 #pragma once
3 
4 #include <itkResampleImageFilter.h>
5 #include <itkMinimumMaximumImageFilter.h>
6 
8 #include <animaVelocityUtils.h>
10 
15 
17 
18 namespace anima
19 {
20 
21 template <unsigned int ImageDimension>
23 {
24  m_ReferenceImage = nullptr;
25  m_FloatingImage = nullptr;
26 
27  m_OutputTransform = BaseTransformType::New();
28  m_OutputTransform->SetIdentity();
29 
30  m_outputTransformFile = "";
31 
32  m_OutputImage = nullptr;
33 
34  m_ReferenceMinimalValue = 0.0;
35  m_FloatingMinimalValue = 0.0;
36 
37  m_BlockSize = 5;
38  m_BlockSpacing = 2;
39  m_StDevThreshold = 5;
40 
41  m_SymmetryType = Asymmetric;
42  m_Transform = Translation;
43  m_AffineDirection = 1;
44  m_Metric = SquaredCorrelation;
45  m_Optimizer = Bobyqa;
46 
47  m_MaximumIterations = 10;
48  m_MinimalTransformError = 0.01;
49  m_OptimizerMaximumIterations = 100;
50  m_SearchRadius = 2;
51  m_SearchAngleRadius = 5;
52  m_SearchScaleRadius = 0.1;
53  m_FinalRadius = 0.001;
54  m_StepSize = 1;
55  m_TranslateUpperBound = 50;
56  m_AngleUpperBound = 180;
57  m_ScaleUpperBound = 3;
58  m_Agregator = Baloo;
59  m_ExtrapolationSigma = 3;
60  m_ElasticSigma = 3;
61  m_OutlierSigma = 3;
62  m_MEstimateConvergenceThreshold = 0.01;
63  m_NeighborhoodApproximation = 2.5;
64  m_BCHCompositionOrder = 1;
65  m_ExponentiationOrder = 1;
66  m_NumberOfPyramidLevels = 3;
67  m_LastPyramidLevel = 0;
68  m_PercentageKept = 0.8;
69  this->SetNumberOfWorkUnits(itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads());
70 
71  m_Abort = false;
72  m_Verbose = true;
73 
74  m_callback = itk::CStyleCommand::New();
75  m_callback->SetClientData ((void *) this);
76  m_callback->SetCallback (ManageProgress);
77 }
78 
79 template <unsigned int ImageDimension>
81 {
82 }
83 
84 template <unsigned int ImageDimension>
85 void
87 {
88  m_Abort = true;
89 
90  if(m_bmreg)
91  m_bmreg->Abort();
92 }
93 
94 template <unsigned int ImageDimension>
95 void
97 {
98  m_Abort = false;
99 
100  // progress management
101  m_progressReporter = new itk::ProgressReporter(this, 0, GetNumberOfPyramidLevels()*m_MaximumIterations);
102  this->AddObserver(itk::ProgressEvent(), m_progressCallback);
103 
104  this->InvokeEvent(itk::StartEvent());
105 
106  // Compute minimal value of reference and Floating images
107  using MinMaxFilterType = itk::MinimumMaximumImageFilter <InputImageType>;
108  typename MinMaxFilterType::Pointer minMaxFilter = MinMaxFilterType::New();
109  minMaxFilter->SetInput(m_ReferenceImage);
110  if (this->GetNumberOfWorkUnits() != 0)
111  minMaxFilter->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits());
112  minMaxFilter->Update();
113 
114  m_ReferenceMinimalValue = minMaxFilter->GetMinimum();
115 
116  minMaxFilter = MinMaxFilterType::New();
117  minMaxFilter->SetInput(m_FloatingImage);
118  if (this->GetNumberOfWorkUnits() != 0)
119  minMaxFilter->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits());
120  minMaxFilter->Update();
121 
122  m_FloatingMinimalValue = minMaxFilter->GetMinimum();
123 
124  // Only CT images are below zero, little hack to set minimal values to either -1024 or 0
125  if (m_ReferenceMinimalValue < 0.0)
126  m_ReferenceMinimalValue = -1024;
127  else
128  m_ReferenceMinimalValue = 0.0;
129 
130  if (m_FloatingMinimalValue < 0.0)
131  m_FloatingMinimalValue = -1024;
132  else
133  m_FloatingMinimalValue = 0.0;
134 
135  this->SetupPyramids();
136 
137  // Iterate over pyramid levels
138  for (unsigned int i = 0;i < m_ReferencePyramid->GetNumberOfLevels();++i)
139  {
140  if (i + m_LastPyramidLevel >= m_ReferencePyramid->GetNumberOfLevels())
141  continue;
142 
143  typename InputImageType::Pointer refImage = m_ReferencePyramid->GetOutput(i);
144  refImage->DisconnectPipeline();
145 
146  typename InputImageType::Pointer floImage = m_FloatingPyramid->GetOutput(i);
147  floImage->DisconnectPipeline();
148 
149  typename MaskImageType::Pointer maskGenerationImage = ITK_NULLPTR;
150  if (m_BlockGenerationPyramid)
151  {
152  maskGenerationImage = m_BlockGenerationPyramid->GetOutput(i);
153  maskGenerationImage->DisconnectPipeline();
154  }
155 
156  // Update field to match the current resolution
157  if (m_OutputTransform->GetParametersAsVectorField() != NULL)
158  {
159  typedef itk::ResampleImageFilter<VelocityFieldType,VelocityFieldType> VectorResampleFilterType;
160  typedef typename VectorResampleFilterType::Pointer VectorResampleFilterPointer;
161 
162  AffineTransformPointer tmpIdentity = AffineTransformType::New();
163  tmpIdentity->SetIdentity();
164 
165  VectorResampleFilterPointer tmpResample = VectorResampleFilterType::New();
166  tmpResample->SetTransform(tmpIdentity);
167  tmpResample->SetInput(m_OutputTransform->GetParametersAsVectorField());
168 
169  tmpResample->SetSize(refImage->GetLargestPossibleRegion().GetSize());
170  tmpResample->SetOutputOrigin(refImage->GetOrigin());
171  tmpResample->SetOutputSpacing(refImage->GetSpacing());
172  tmpResample->SetOutputDirection(refImage->GetDirection());
173 
174  tmpResample->Update();
175 
176  VelocityFieldType *tmpOut = tmpResample->GetOutput();
177  m_OutputTransform->SetParametersAsVectorField(tmpOut);
178  tmpOut->DisconnectPipeline();
179  }
180 
181  if (m_Verbose)
182  {
183  std::cout << "Processing pyramid level " << i << std::endl;
184  std::cout << "Image size: " << refImage->GetLargestPossibleRegion().GetSize() << std::endl;
185  }
186 
187  double meanSpacing = 0;
188  for (unsigned int j = 0;j < ImageDimension;++j)
189  meanSpacing += refImage->GetSpacing()[j];
190  meanSpacing /= ImageDimension;
191 
192  // Init agregator mean shift parameters
193  BaseAgregatorType* agregPtr = NULL;
194 
195  if (m_Agregator == MSmoother)
196  {
198  agreg->SetExtrapolationSigma(m_ExtrapolationSigma * meanSpacing);
199  agreg->SetOutlierRejectionSigma(m_OutlierSigma);
200  agreg->SetOutputTransformType(BaseAgregatorType::SVF);
201 
202  if (this->GetNumberOfWorkUnits() != 0)
203  agreg->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits());
204 
205  agreg->SetGeometryInformation(refImage.GetPointer());
206 
207  agreg->SetNeighborhoodHalfSize((unsigned int)floor(m_ExtrapolationSigma * m_NeighborhoodApproximation));
208  agreg->SetDistanceBoundary(m_ExtrapolationSigma * meanSpacing * m_NeighborhoodApproximation);
209  agreg->SetMEstimateConvergenceThreshold(m_MEstimateConvergenceThreshold);
210 
211  agregPtr = agreg;
212  }
213  else
214  {
216  agreg->SetExtrapolationSigma(m_ExtrapolationSigma * meanSpacing);
217  agreg->SetOutlierRejectionSigma(m_OutlierSigma);
218  agreg->SetOutputTransformType(BaseAgregatorType::SVF);
219 
220  if (this->GetNumberOfWorkUnits() != 0)
221  agreg->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits());
222 
223  agreg->SetGeometryInformation(refImage.GetPointer());
224 
225  agregPtr = agreg;
226  }
227 
228  agregPtr->SetVerboseAgregation(m_Verbose);
229 
230  // Init matcher
231  typedef anima::AnatomicalBlockMatcher <InputImageType> BlockMatcherType;
232 
233  BlockMatcherType *mainMatcher = new BlockMatcherType;
234  BlockMatcherType *reverseMatcher = 0;
235  mainMatcher->SetBlockPercentageKept(GetPercentageKept());
236  mainMatcher->SetBlockSize(GetBlockSize());
237  mainMatcher->SetBlockSpacing(GetBlockSpacing());
238  mainMatcher->SetBlockVarianceThreshold(GetStDevThreshold() * GetStDevThreshold());
239  mainMatcher->SetBlockGenerationMask(maskGenerationImage);
240  mainMatcher->SetDefaultBackgroundValue(m_FloatingMinimalValue);
241 
242  switch (m_SymmetryType)
243  {
244  case Asymmetric:
245  {
246  typedef typename anima::AsymmetricBMRegistrationMethod <InputImageType> BlockMatchRegistrationType;
247  m_bmreg = BlockMatchRegistrationType::New();
248  break;
249  }
250 
251  case Symmetric:
252  {
253  typedef typename anima::SymmetricBMRegistrationMethod <InputImageType> BlockMatchRegistrationType;
254  typename BlockMatchRegistrationType::Pointer tmpReg = BlockMatchRegistrationType::New();
255 
256  reverseMatcher = new BlockMatcherType;
257  reverseMatcher->SetBlockPercentageKept(GetPercentageKept());
258  reverseMatcher->SetBlockSize(GetBlockSize());
259  reverseMatcher->SetBlockSpacing(GetBlockSpacing());
260  reverseMatcher->SetBlockVarianceThreshold(GetStDevThreshold() * GetStDevThreshold());
261  reverseMatcher->SetBlockGenerationMask(maskGenerationImage);
262  reverseMatcher->SetDefaultBackgroundValue(m_ReferenceMinimalValue);
263  reverseMatcher->SetVerbose(m_Verbose);
264 
265  tmpReg->SetReverseBlockMatcher(reverseMatcher);
266  m_bmreg = tmpReg;
267  break;
268  }
269 
270  case Kissing:
271  {
272  typedef typename anima::KissingSymmetricBMRegistrationMethod <InputImageType> BlockMatchRegistrationType;
273  typename BlockMatchRegistrationType::Pointer tmpReg = BlockMatchRegistrationType::New();
274  tmpReg->SetReferenceBackgroundValue(m_ReferenceMinimalValue);
275  tmpReg->SetFloatingBackgroundValue(m_FloatingMinimalValue);
276 
277  m_bmreg = tmpReg;
278  break;
279  }
280  }
281 
282  mainMatcher->SetVerbose(m_Verbose);
283  m_bmreg->SetBlockMatcher(mainMatcher);
284  m_bmreg->SetBCHCompositionOrder(m_BCHCompositionOrder);
285  m_bmreg->SetExponentiationOrder(m_ExponentiationOrder);
286 
287  if (m_progressCallback)
288  {
289  // we cannot connect directly bmreg to m_progressCallback
290  // we need to create a new progressReporter with more iterations (m_progressReporter),
291  // to listen to progress events from bmreg and to send new ones to m_progressCallback
292  m_bmreg->AddObserver(itk::ProgressEvent(), m_callback);
293  }
294 
295  m_bmreg->SetAgregator(agregPtr);
296 
297  if (this->GetNumberOfWorkUnits() != 0)
298  m_bmreg->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits());
299 
300  m_bmreg->SetFixedImage(refImage);
301  m_bmreg->SetMovingImage(floImage);
302 
303  m_bmreg->SetSVFElasticRegSigma(m_ElasticSigma * meanSpacing);
304 
305  typedef anima::ResampleImageFilter<InputImageType, InputImageType,
306  typename BaseAgregatorType::ScalarType> ResampleFilterType;
307 
308  typename ResampleFilterType::Pointer refResampler = ResampleFilterType::New();
309  refResampler->SetSize(floImage->GetLargestPossibleRegion().GetSize());
310  refResampler->SetOutputOrigin(floImage->GetOrigin());
311  refResampler->SetOutputSpacing(floImage->GetSpacing());
312  refResampler->SetOutputDirection(floImage->GetDirection());
313  refResampler->SetDefaultPixelValue(m_ReferenceMinimalValue);
314  refResampler->SetNumberOfWorkUnits(GetNumberOfWorkUnits());
315  m_bmreg->SetReferenceImageResampler(refResampler);
316 
317  typename ResampleFilterType::Pointer movingResampler = ResampleFilterType::New();
318  movingResampler->SetSize(refImage->GetLargestPossibleRegion().GetSize());
319  movingResampler->SetOutputOrigin(refImage->GetOrigin());
320  movingResampler->SetOutputSpacing(refImage->GetSpacing());
321  movingResampler->SetOutputDirection(refImage->GetDirection());
322  movingResampler->SetDefaultPixelValue(m_FloatingMinimalValue);
323  movingResampler->SetNumberOfWorkUnits(GetNumberOfWorkUnits());
324  m_bmreg->SetMovingImageResampler(movingResampler);
325 
326  switch (GetTransform())
327  {
328  case Translation:
329  mainMatcher->SetBlockTransformType(BlockMatcherType::Superclass::Translation);
330  if (reverseMatcher)
331  reverseMatcher->SetBlockTransformType(BlockMatcherType::Superclass::Translation);
332  break;
333 
334  case Rigid:
335  mainMatcher->SetBlockTransformType(BlockMatcherType::Superclass::Rigid);
336  if (reverseMatcher)
337  reverseMatcher->SetBlockTransformType(BlockMatcherType::Superclass::Rigid);
338  break;
339 
340  case Directional_Affine:
341  mainMatcher->SetBlockTransformType(BlockMatcherType::Superclass::Directional_Affine);
342  mainMatcher->SetAffineDirection(m_AffineDirection);
343  if (reverseMatcher)
344  {
345  reverseMatcher->SetBlockTransformType(BlockMatcherType::Superclass::Directional_Affine);
346  reverseMatcher->SetAffineDirection(m_AffineDirection);
347  }
348  break;
349 
350  case Affine:
351  default:
352  mainMatcher->SetBlockTransformType(BlockMatcherType::Superclass::Affine);
353  if (reverseMatcher)
354  reverseMatcher->SetBlockTransformType(BlockMatcherType::Superclass::Affine);
355  break;
356  }
357 
358  switch (GetOptimizer())
359  {
360  case Exhaustive:
361  mainMatcher->SetOptimizerType(BlockMatcherType::Exhaustive);
362  if (reverseMatcher)
363  reverseMatcher->SetOptimizerType(BlockMatcherType::Exhaustive);
364  break;
365 
366  case Bobyqa:
367  default:
368  mainMatcher->SetOptimizerType(BlockMatcherType::Bobyqa);
369  if (reverseMatcher)
370  reverseMatcher->SetOptimizerType(BlockMatcherType::Bobyqa);
371  break;
372  }
373 
374  switch (GetMetric())
375  {
376  case SquaredCorrelation:
377  mainMatcher->SetSimilarityType(BlockMatcherType::SquaredCorrelation);
378  if (reverseMatcher)
379  reverseMatcher->SetSimilarityType(BlockMatcherType::SquaredCorrelation);
380  break;
381  case Correlation:
382  mainMatcher->SetSimilarityType(BlockMatcherType::Correlation);
383  if (reverseMatcher)
384  reverseMatcher->SetSimilarityType(BlockMatcherType::Correlation);
385  break;
386  case MeanSquares:
387  default:
388  mainMatcher->SetSimilarityType(BlockMatcherType::MeanSquares);
389  if (reverseMatcher)
390  reverseMatcher->SetSimilarityType(BlockMatcherType::MeanSquares);
391  break;
392  }
393 
394  m_bmreg->SetMaximumIterations(m_MaximumIterations);
395  m_bmreg->SetMinimalTransformError(m_MinimalTransformError);
396  m_bmreg->SetInitialTransform(m_OutputTransform.GetPointer());
397 
398  mainMatcher->SetNumberOfWorkUnits(GetNumberOfWorkUnits());
399  mainMatcher->SetOptimizerMaximumIterations(GetOptimizerMaximumIterations());
400 
401  double sr = GetSearchRadius();
402  mainMatcher->SetSearchRadius(sr);
403 
404  double sar = GetSearchAngleRadius();
405  mainMatcher->SetSearchAngleRadius(sar);
406 
407  double scr = GetSearchScaleRadius();
408  mainMatcher->SetSearchScaleRadius(scr);
409 
410  double fr = GetFinalRadius();
411  mainMatcher->SetFinalRadius(fr);
412 
413  double ss = GetStepSize();
414  mainMatcher->SetStepSize(ss);
415 
416  double tub = GetTranslateUpperBound();
417  mainMatcher->SetTranslateMax(tub);
418 
419  double aub = GetAngleUpperBound();
420  mainMatcher->SetAngleMax(aub);
421 
422  double scub = GetScaleUpperBound();
423  mainMatcher->SetScaleMax(scub);
424 
425  if (reverseMatcher)
426  {
427  reverseMatcher->SetNumberOfWorkUnits(GetNumberOfWorkUnits());
428  reverseMatcher->SetOptimizerMaximumIterations(GetOptimizerMaximumIterations());
429 
430  reverseMatcher->SetSearchRadius(sr);
431  reverseMatcher->SetSearchAngleRadius(sar);
432  reverseMatcher->SetSearchScaleRadius(scr);
433  reverseMatcher->SetFinalRadius(fr);
434  reverseMatcher->SetStepSize(ss);
435  reverseMatcher->SetTranslateMax(tub);
436  reverseMatcher->SetAngleMax(aub);
437  reverseMatcher->SetScaleMax(scub);
438  }
439 
440  m_bmreg->SetVerboseProgression(m_Verbose);
441 
442  try
443  {
444  m_bmreg->Update();
445  }
446  catch( itk::ExceptionObject & err )
447  {
448  std::cout << "ExceptionObject caught !" << err << std::endl;
449  exit(-1);
450  }
451 
452  const BaseTransformType *resTrsf = dynamic_cast <const BaseTransformType *> (m_bmreg->GetOutput()->Get());
453  m_OutputTransform->SetParametersAsVectorField(resTrsf->GetParametersAsVectorField());
454 
455  delete mainMatcher;
456  if (reverseMatcher)
457  delete reverseMatcher;
458  if (agregPtr)
459  delete agregPtr;
460  }
461 
462  if (m_Abort)
463  std::cout << "Process aborted" << std::endl;
464 
465  this->InvokeEvent(itk::EndEvent());
466 
467  if (m_SymmetryType == Kissing)
468  {
469  VelocityFieldType *finalTrsfField = const_cast <VelocityFieldType *> (m_OutputTransform->GetParametersAsVectorField());
470  typedef itk::MultiplyImageFilter <VelocityFieldType,itk::Image <double,ImageDimension>, VelocityFieldType> MultiplyFilterType;
471 
472  typename MultiplyFilterType::Pointer fieldMultiplier = MultiplyFilterType::New();
473  fieldMultiplier->SetInput(finalTrsfField);
474  fieldMultiplier->SetConstant(2.0);
475  fieldMultiplier->SetNumberOfWorkUnits(GetNumberOfWorkUnits());
476  fieldMultiplier->InPlaceOn();
477 
478  fieldMultiplier->Update();
479 
480  VelocityFieldType *outputField = fieldMultiplier->GetOutput();
481  m_OutputTransform->SetParametersAsVectorField(fieldMultiplier->GetOutput());
482  outputField->DisconnectPipeline();
483  }
484 
485  DisplacementFieldTransformPointer outputDispTrsf = DisplacementFieldTransformType::New();
486  anima::GetSVFExponential(m_OutputTransform.GetPointer(), outputDispTrsf.GetPointer(), m_ExponentiationOrder, GetNumberOfWorkUnits(), false);
487 
488  typedef typename anima::ResampleImageFilter<InputImageType, InputImageType,
489  typename BaseAgregatorType::ScalarType> ResampleFilterType;
490  typename ResampleFilterType::Pointer tmpResample = ResampleFilterType::New();
491  tmpResample->SetTransform(outputDispTrsf);
492  tmpResample->SetInput(m_FloatingImage);
493 
494  tmpResample->SetSize(m_ReferenceImage->GetLargestPossibleRegion().GetSize());
495  tmpResample->SetOutputOrigin(m_ReferenceImage->GetOrigin());
496  tmpResample->SetOutputSpacing(m_ReferenceImage->GetSpacing());
497  tmpResample->SetOutputDirection(m_ReferenceImage->GetDirection());
498  tmpResample->SetDefaultPixelValue(m_FloatingMinimalValue);
499  tmpResample->Update();
500 
501  m_OutputImage = tmpResample->GetOutput();
502  m_OutputImage->DisconnectPipeline();
503 }
504 
505 template <unsigned int ImageDimension>
508 {
509  DisplacementFieldTransformPointer outputDispTrsf = DisplacementFieldTransformType::New();
510 
511  anima::GetSVFExponential(m_OutputTransform.GetPointer(), outputDispTrsf.GetPointer(), m_ExponentiationOrder, this->GetNumberOfWorkUnits(), false);
512 
513  return outputDispTrsf;
514 }
515 
516 template <unsigned int ImageDimension>
517 void
519 {
520  if (m_progressReporter)
521  m_progressReporter->CompletedPixel();
522 }
523 
524 template <unsigned int ImageDimension>
525 void PyramidalDenseSVFMatchingBridge<ImageDimension>::ManageProgress (itk::Object* caller, const itk::EventObject& event, void* clientData)
526 {
527  PyramidalDenseSVFMatchingBridge * source = reinterpret_cast<PyramidalDenseSVFMatchingBridge *> (clientData);
528  itk::ProcessObject *processObject = (itk::ProcessObject *) caller;
529 
530  if (source && processObject)
531  source->EmitProgress(processObject->GetProgress() * 100);
532 }
533 
534 template <unsigned int ImageDimension>
535 void
537 {
538  std::cout << "Writing output image to: " << m_resultFile << std::endl;
539  anima::writeImage <InputImageType> (m_resultFile,m_OutputImage);
540 
541  if (m_outputTransformFile != "")
542  {
543  std::cout << "Writing output SVF to: " << m_outputTransformFile << std::endl;
544  anima::writeImage <VelocityFieldType> (m_outputTransformFile,
545  const_cast <VelocityFieldType *> (m_OutputTransform->GetParametersAsVectorField()));
546  }
547 }
548 
549 template <unsigned int ImageDimension>
550 void
552 {
553  // Create pyramid here, check images actually are of the same size.
554  m_ReferencePyramid = PyramidType::New();
555 
556  m_ReferencePyramid->SetInput(m_ReferenceImage);
557  m_ReferencePyramid->SetNumberOfLevels(m_NumberOfPyramidLevels);
558 
559  if (this->GetNumberOfWorkUnits() != 0)
560  m_ReferencePyramid->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits());
561 
562  typedef anima::ResampleImageFilter<InputImageType, InputImageType,
563  typename BaseAgregatorType::ScalarType> ResampleFilterType;
564 
565  typename ResampleFilterType::Pointer refResampler = ResampleFilterType::New();
566  refResampler->SetDefaultPixelValue(m_ReferenceMinimalValue);
567  m_ReferencePyramid->SetImageResampler(refResampler);
568 
569  m_ReferencePyramid->Update();
570 
571  // Create pyramid for Floating image
572  m_FloatingPyramid = PyramidType::New();
573 
574  m_FloatingPyramid->SetInput(m_FloatingImage);
575  m_FloatingPyramid->SetNumberOfLevels(m_NumberOfPyramidLevels);
576 
577  if (this->GetNumberOfWorkUnits() != 0)
578  m_FloatingPyramid->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits());
579 
580  typename ResampleFilterType::Pointer floResampler = ResampleFilterType::New();
581  floResampler->SetDefaultPixelValue(m_FloatingMinimalValue);
582  m_FloatingPyramid->SetImageResampler(floResampler);
583 
584  m_FloatingPyramid->Update();
585 
586  m_BlockGenerationPyramid = 0;
587  if (m_BlockGenerationMask)
588  {
589  typedef anima::ResampleImageFilter<MaskImageType, MaskImageType,
590  typename BaseAgregatorType::ScalarType> MaskResampleFilterType;
591 
592  typename MaskResampleFilterType::Pointer maskResampler = MaskResampleFilterType::New();
593 
594  m_BlockGenerationPyramid = MaskPyramidType::New();
595  m_BlockGenerationPyramid->SetImageResampler(maskResampler);
596  m_BlockGenerationPyramid->SetInput(m_BlockGenerationMask);
597  m_BlockGenerationPyramid->SetNumberOfLevels(GetNumberOfPyramidLevels());
598  m_BlockGenerationPyramid->SetNumberOfWorkUnits(GetNumberOfWorkUnits());
599  m_BlockGenerationPyramid->Update();
600  }
601 }
602 
603 } // end of namespace
itk::Image< unsigned char, ImageDimension > MaskImageType
void SetGeometryInformation(const TInputImageType *geomImage)
static void ManageProgress(itk::Object *caller, const itk::EventObject &event, void *clientData)
void SetGeometryInformation(const TInputImageType *geomImage)
void SetOutputTransformType(TRANSFORM_TYPE name)
DisplacementFieldTransformType::Pointer DisplacementFieldTransformPointer
void SetBlockPercentageKept(double val)
void GetSVFExponential(itk::StationaryVelocityFieldTransform< ScalarType, NDimensions > *baseTrsf, rpi::DisplacementFieldTransform< ScalarType, NDimensions > *resultTransform, unsigned int exponentiationOrder, unsigned int numThreads, bool invert)
DisplacementFieldTransformPointer GetOutputDisplacementFieldTransform()
MEstimateAgregatorType::BaseOutputTransformType BaseTransformType