18 #ifndef sitkImageRegistrationMethod_h
19 #define sitkImageRegistrationMethod_h
37 template <
typename TInternalComputationValueType>
38 class ObjectToObjectOptimizerBaseTemplate;
39 template <
typename TFixedImage,
40 typename TMovingImage,
41 typename TVirtualImage,
42 typename TInternalComputationValueType,
43 typename TMetricTraits>
44 class ImageToImageMetricv4;
46 template <
typename TFixedImageType,
typename TMovingImageType,
typename TVirtualImageType,
typename TCoordRep>
47 class DefaultImageToImageMetricTraitsv4;
49 template <
typename TMetric>
50 class RegistrationParameterScalesEstimator;
52 template <
unsigned int VDimension>
62 class BSplineTransform;
100 return std::string(
"ImageRegistrationMethod");
110 ToString()
const override;
119 return this->m_Interpolator;
121 SITK_RETURN_SELF_TYPE_HEADER
124 this->m_Interpolator = Interpolator;
145 #if !defined(SWIG) || defined(JAVASWIG) || defined(CSHARPSWIG)
147 SITK_RETURN_SELF_TYPE_HEADER
148 SetInitialTransform(
const Transform & transform);
150 SITK_RETURN_SELF_TYPE_HEADER
151 SetInitialTransform(
Transform & transform,
bool inPlace =
true);
155 return this->m_InitialTransform;
160 return this->m_InitialTransformInPlace;
182 const std::vector<unsigned int> & scaleFactors = std::vector<unsigned int>());
197 SITK_RETURN_SELF_TYPE_HEADER
200 this->m_MovingInitialTransform = transform;
206 return this->m_MovingInitialTransform;
220 SITK_RETURN_SELF_TYPE_HEADER
223 this->m_FixedInitialTransform = transform;
229 return this->m_FixedInitialTransform;
238 SITK_RETURN_SELF_TYPE_HEADER
239 SetVirtualDomain(
const std::vector<uint32_t> & virtualSize,
240 const std::vector<double> & virtualOrigin,
241 const std::vector<double> & virtualSpacing,
242 const std::vector<double> & virtualDirection);
243 SITK_RETURN_SELF_TYPE_HEADER
244 SetVirtualDomainFromImage(
const Image & virtualImage);
253 SITK_RETURN_SELF_TYPE_HEADER
254 SetMetricAsANTSNeighborhoodCorrelation(
unsigned int radius);
260 SITK_RETURN_SELF_TYPE_HEADER
261 SetMetricAsCorrelation();
267 SITK_RETURN_SELF_TYPE_HEADER
268 SetMetricAsDemons(
double intensityDifferenceThreshold = 0.001);
274 SITK_RETURN_SELF_TYPE_HEADER
275 SetMetricAsJointHistogramMutualInformation(
unsigned int numberOfHistogramBins = 20,
276 double varianceForJointPDFSmoothing = 1.5);
282 SITK_RETURN_SELF_TYPE_HEADER
283 SetMetricAsMeanSquares();
290 SITK_RETURN_SELF_TYPE_HEADER
291 SetMetricAsMattesMutualInformation(
unsigned int numberOfHistogramBins = 50);
305 SITK_RETURN_SELF_TYPE_HEADER
306 SetOptimizerAsConjugateGradientLineSearch(
double learningRate,
307 unsigned int numberOfIterations,
308 double convergenceMinimumValue = 1e-6,
309 unsigned int convergenceWindowSize = 10,
310 double lineSearchLowerLimit = 0,
311 double lineSearchUpperLimit = 5.0,
312 double lineSearchEpsilon = 0.01,
313 unsigned int lineSearchMaximumIterations = 20,
314 EstimateLearningRateType estimateLearningRate = Once,
315 double maximumStepSizeInPhysicalUnits = 0.0);
321 SITK_RETURN_SELF_TYPE_HEADER
322 SetOptimizerAsRegularStepGradientDescent(
double learningRate,
324 unsigned int numberOfIterations,
325 double relaxationFactor = 0.5,
326 double gradientMagnitudeTolerance = 1e-4,
327 EstimateLearningRateType estimateLearningRate = Never,
328 double maximumStepSizeInPhysicalUnits = 0.0);
334 SITK_RETURN_SELF_TYPE_HEADER
335 SetOptimizerAsGradientDescent(
double learningRate,
336 unsigned int numberOfIterations,
337 double convergenceMinimumValue = 1e-6,
338 unsigned int convergenceWindowSize = 10,
339 EstimateLearningRateType estimateLearningRate = Once,
340 double maximumStepSizeInPhysicalUnits = 0.0);
346 SITK_RETURN_SELF_TYPE_HEADER
347 SetOptimizerAsGradientDescentLineSearch(
double learningRate,
348 unsigned int numberOfIterations,
349 double convergenceMinimumValue = 1e-6,
350 unsigned int convergenceWindowSize = 10,
351 double lineSearchLowerLimit = 0,
352 double lineSearchUpperLimit = 5.0,
353 double lineSearchEpsilon = 0.01,
354 unsigned int lineSearchMaximumIterations = 20,
355 EstimateLearningRateType estimateLearningRate = Once,
356 double maximumStepSizeInPhysicalUnits = 0.0);
364 SITK_RETURN_SELF_TYPE_HEADER
365 SetOptimizerAsLBFGSB(
double gradientConvergenceTolerance = 1e-5,
366 unsigned int numberOfIterations = 500,
367 unsigned int maximumNumberOfCorrections = 5,
368 unsigned int maximumNumberOfFunctionEvaluations = 2000,
369 double costFunctionConvergenceFactor = 1e+7,
370 double lowerBound = std::numeric_limits<double>::min(),
371 double upperBound = std::numeric_limits<double>::max(),
386 SITK_RETURN_SELF_TYPE_HEADER
387 SetOptimizerAsLBFGS2(
double solutionAccuracy = 1e-5,
388 unsigned int numberOfIterations = 0,
389 unsigned int hessianApproximateAccuracy = 6,
390 unsigned int deltaConvergenceDistance = 0,
391 double deltaConvergenceTolerance = 1e-5,
392 unsigned int lineSearchMaximumEvaluations = 40,
393 double lineSearchMinimumStep = 1e-20,
394 double lineSearchMaximumStep = 1e20,
395 double lineSearchAccuracy = 1e-4);
414 SITK_RETURN_SELF_TYPE_HEADER
415 SetOptimizerAsExhaustive(
const std::vector<unsigned int> & numberOfSteps,
double stepLength = 1.0);
426 SITK_RETURN_SELF_TYPE_HEADER
427 SetOptimizerAsAmoeba(
double simplexDelta,
428 unsigned int numberOfIterations,
429 double parametersConvergenceTolerance = 1e-8,
430 double functionConvergenceTolerance = 1e-4,
431 bool withRestarts =
false);
444 SITK_RETURN_SELF_TYPE_HEADER
445 SetOptimizerWeights(
const std::vector<double> & weights);
447 GetOptimizerWeights()
const;
454 SITK_RETURN_SELF_TYPE_HEADER
455 SetOptimizerAsPowell(
unsigned int numberOfIterations = 100,
456 unsigned int maximumLineIterations = 100,
457 double stepLength = 1,
458 double stepTolerance = 1e-6,
459 double valueTolerance = 1e-6);
469 SITK_RETURN_SELF_TYPE_HEADER
470 SetOptimizerAsOnePlusOneEvolutionary(
unsigned int numberOfIterations = 100,
471 double epsilon = 1.5e-4,
472 double initialRadius = 1.01,
473 double growthFactor = -1.0,
474 double shrinkFactor = -1.0,
479 SITK_RETURN_SELF_TYPE_HEADER
480 SetOptimizerScales(
const std::vector<double> & scales);
488 SITK_RETURN_SELF_TYPE_HEADER
489 SetOptimizerScalesFromJacobian(
unsigned int centralRegionRadius = 5);
496 SITK_RETURN_SELF_TYPE_HEADER
497 SetOptimizerScalesFromIndexShift(
unsigned int centralRegionRadius = 5,
double smallParameterVariation = 0.01);
505 SITK_RETURN_SELF_TYPE_HEADER
506 SetOptimizerScalesFromPhysicalShift(
unsigned int centralRegionRadius = 5,
double smallParameterVariation = 0.01);
518 SITK_RETURN_SELF_TYPE_HEADER
519 SetMetricFixedMask(
const Image & binaryMask);
530 SITK_RETURN_SELF_TYPE_HEADER
531 SetMetricMovingMask(
const Image & binaryMask);
551 SITK_RETURN_SELF_TYPE_HEADER
552 SetMetricSamplingPercentage(
double percentage,
unsigned int seed =
sitkWallClock);
553 SITK_RETURN_SELF_TYPE_HEADER
554 SetMetricSamplingPercentagePerLevel(
const std::vector<double> & percentage,
unsigned int seed =
sitkWallClock);
558 const std::vector<double> &
559 GetMetricSamplingPercentagePerLevel()
const;
582 SITK_RETURN_SELF_TYPE_HEADER
583 SetMetricSamplingStrategy(MetricSamplingStrategyType strategy);
594 SITK_RETURN_SELF_TYPE_HEADER
595 SetMetricUseFixedImageGradientFilter(
bool);
596 SITK_RETURN_SELF_TYPE_HEADER
599 return this->SetMetricUseFixedImageGradientFilter(
true);
601 SITK_RETURN_SELF_TYPE_HEADER
604 return this->SetMetricUseFixedImageGradientFilter(
false);
619 SITK_RETURN_SELF_TYPE_HEADER
620 SetMetricUseMovingImageGradientFilter(
bool);
621 SITK_RETURN_SELF_TYPE_HEADER
624 return this->SetMetricUseMovingImageGradientFilter(
true);
626 SITK_RETURN_SELF_TYPE_HEADER
629 return this->SetMetricUseMovingImageGradientFilter(
false);
641 SITK_RETURN_SELF_TYPE_HEADER
642 SetShrinkFactorsPerLevel(
const std::vector<unsigned int> & shrinkFactors);
652 SITK_RETURN_SELF_TYPE_HEADER
653 SetSmoothingSigmasPerLevel(
const std::vector<double> & smoothingSigmas);
661 SITK_RETURN_SELF_TYPE_HEADER
662 SetSmoothingSigmasAreSpecifiedInPhysicalUnits(
bool arg);
663 SITK_RETURN_SELF_TYPE_HEADER
666 this->SetSmoothingSigmasAreSpecifiedInPhysicalUnits(
true);
669 SITK_RETURN_SELF_TYPE_HEADER
672 this->SetSmoothingSigmasAreSpecifiedInPhysicalUnits(
false);
680 Execute(
const Image & fixed,
const Image & moving);
693 MetricEvaluate(
const Image & fixed,
const Image & moving);
703 GetOptimizerIteration()
const;
705 GetOptimizerPosition()
const;
707 GetOptimizerLearningRate()
const;
709 GetOptimizerConvergenceValue()
const;
711 GetMetricValue()
const;
722 GetMetricNumberOfValidPoints()
const;
726 GetCurrentLevel()
const;
736 GetOptimizerScales()
const;
741 GetOptimizerStopConditionDescription()
const;
756 template <
class TImage>
758 ExecuteInternal(
const Image & fixed,
const Image & moving);
760 template <
class TImage>
762 EvaluateInternal(
const Image & fixed,
const Image & moving);
766 CreateOptimizer(
unsigned int numberOfTransformParameters);
768 template <
unsigned int VDimension>
770 CreateSpatialObjectMask(
const Image & mask);
772 template <
class TImageType>
780 template <
class TImageType>
791 template <
typename TMetric>
793 CreateScalesEstimator();
795 template <
typename TTransformAdaptorPo
inter,
typename TRegistrationMethod>
796 std::vector<TTransformAdaptorPointer>
797 CreateTransformParametersAdaptor(TRegistrationMethod * method);
802 OnActiveProcessDelete() noexcept override;
806 RemoveITKObserver(EventCommand & e) override;
809 std::function<
unsigned int()> m_pfGetOptimizerIteration;
810 std::function<std::vector<
double>()> m_pfGetOptimizerPosition;
811 std::function<
double()> m_pfGetOptimizerLearningRate;
812 std::function<
double()> m_pfGetOptimizerConvergenceValue;
813 std::function<
double()> m_pfGetMetricValue;
814 std::function<uint64_t()> m_pfGetMetricNumberOfValidPoints;
815 std::function<std::vector<
double>()> m_pfGetOptimizerScales;
816 std::function<std::
string()> m_pfGetOptimizerStopConditionDescription;
817 std::function<
void()> m_pfOptimizerStopRegistration;
820 std::function<
unsigned int()> m_pfGetCurrentLevel;
824 template <class TMemberFunctionPointer>
827 using ObjectType = typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType;
829 template <
typename TImageType>
830 TMemberFunctionPointer
833 return &ObjectType::template EvaluateInternal<TImageType>;
937 MattesMutualInformation
970 #endif // sitkImageRegistrationMethod_h