18 #ifndef sitkImageRegistrationMethod_h
19 #define sitkImageRegistrationMethod_h
38 template <
typename TInternalComputationValueType>
39 class ObjectToObjectOptimizerBaseTemplate;
40 template <
typename TFixedImage,
41 typename TMovingImage,
42 typename TVirtualImage,
43 typename TInternalComputationValueType,
44 typename TMetricTraits>
45 class ImageToImageMetricv4;
47 template <
typename TFixedImageType,
typename TMovingImageType,
typename TVirtualImageType,
typename TCoordRep>
48 class DefaultImageToImageMetricTraitsv4;
50 template <
typename TMetric>
51 class RegistrationParameterScalesEstimator;
53 template <
unsigned int VDimension>
63 class BSplineTransform;
101 return std::string(
"ImageRegistrationMethod");
111 ToString()
const override;
120 return this->m_Interpolator;
122 SITK_RETURN_SELF_TYPE_HEADER
125 this->m_Interpolator = Interpolator;
146 #if !defined(SWIG) || defined(JAVASWIG) || defined(CSHARPSWIG)
148 SITK_RETURN_SELF_TYPE_HEADER
149 SetInitialTransform(
const Transform & transform);
151 SITK_RETURN_SELF_TYPE_HEADER
152 SetInitialTransform(
Transform & transform,
bool inPlace =
true);
156 return this->m_InitialTransform;
161 return this->m_InitialTransformInPlace;
183 const std::vector<unsigned int> & scaleFactors = std::vector<unsigned int>());
198 SITK_RETURN_SELF_TYPE_HEADER
201 this->m_MovingInitialTransform = transform;
207 return this->m_MovingInitialTransform;
221 SITK_RETURN_SELF_TYPE_HEADER
224 this->m_FixedInitialTransform = transform;
230 return this->m_FixedInitialTransform;
239 SITK_RETURN_SELF_TYPE_HEADER
240 SetVirtualDomain(
const std::vector<uint32_t> & virtualSize,
241 const std::vector<double> & virtualOrigin,
242 const std::vector<double> & virtualSpacing,
243 const std::vector<double> & virtualDirection);
244 SITK_RETURN_SELF_TYPE_HEADER
245 SetVirtualDomainFromImage(
const Image & virtualImage);
254 SITK_RETURN_SELF_TYPE_HEADER
255 SetMetricAsANTSNeighborhoodCorrelation(
unsigned int radius);
261 SITK_RETURN_SELF_TYPE_HEADER
262 SetMetricAsCorrelation();
268 SITK_RETURN_SELF_TYPE_HEADER
269 SetMetricAsDemons(
double intensityDifferenceThreshold = 0.001);
275 SITK_RETURN_SELF_TYPE_HEADER
276 SetMetricAsJointHistogramMutualInformation(
unsigned int numberOfHistogramBins = 20,
277 double varianceForJointPDFSmoothing = 1.5);
283 SITK_RETURN_SELF_TYPE_HEADER
284 SetMetricAsMeanSquares();
291 SITK_RETURN_SELF_TYPE_HEADER
292 SetMetricAsMattesMutualInformation(
unsigned int numberOfHistogramBins = 50);
306 SITK_RETURN_SELF_TYPE_HEADER
307 SetOptimizerAsConjugateGradientLineSearch(
double learningRate,
308 unsigned int numberOfIterations,
309 double convergenceMinimumValue = 1e-6,
310 unsigned int convergenceWindowSize = 10,
311 double lineSearchLowerLimit = 0,
312 double lineSearchUpperLimit = 5.0,
313 double lineSearchEpsilon = 0.01,
314 unsigned int lineSearchMaximumIterations = 20,
315 EstimateLearningRateType estimateLearningRate = Once,
316 double maximumStepSizeInPhysicalUnits = 0.0);
322 SITK_RETURN_SELF_TYPE_HEADER
323 SetOptimizerAsRegularStepGradientDescent(
double learningRate,
325 unsigned int numberOfIterations,
326 double relaxationFactor = 0.5,
327 double gradientMagnitudeTolerance = 1e-4,
328 EstimateLearningRateType estimateLearningRate = Never,
329 double maximumStepSizeInPhysicalUnits = 0.0);
335 SITK_RETURN_SELF_TYPE_HEADER
336 SetOptimizerAsGradientDescent(
double learningRate,
337 unsigned int numberOfIterations,
338 double convergenceMinimumValue = 1e-6,
339 unsigned int convergenceWindowSize = 10,
340 EstimateLearningRateType estimateLearningRate = Once,
341 double maximumStepSizeInPhysicalUnits = 0.0);
347 SITK_RETURN_SELF_TYPE_HEADER
348 SetOptimizerAsGradientDescentLineSearch(
double learningRate,
349 unsigned int numberOfIterations,
350 double convergenceMinimumValue = 1e-6,
351 unsigned int convergenceWindowSize = 10,
352 double lineSearchLowerLimit = 0,
353 double lineSearchUpperLimit = 5.0,
354 double lineSearchEpsilon = 0.01,
355 unsigned int lineSearchMaximumIterations = 20,
356 EstimateLearningRateType estimateLearningRate = Once,
357 double maximumStepSizeInPhysicalUnits = 0.0);
365 SITK_RETURN_SELF_TYPE_HEADER
366 SetOptimizerAsLBFGSB(
double gradientConvergenceTolerance = 1e-5,
367 unsigned int numberOfIterations = 500,
368 unsigned int maximumNumberOfCorrections = 5,
369 unsigned int maximumNumberOfFunctionEvaluations = 2000,
370 double costFunctionConvergenceFactor = 1e+7,
371 double lowerBound = std::numeric_limits<double>::min(),
372 double upperBound = std::numeric_limits<double>::max(),
387 SITK_RETURN_SELF_TYPE_HEADER
388 SetOptimizerAsLBFGS2(
double solutionAccuracy = 1e-5,
389 unsigned int numberOfIterations = 0,
390 unsigned int hessianApproximateAccuracy = 6,
391 unsigned int deltaConvergenceDistance = 0,
392 double deltaConvergenceTolerance = 1e-5,
393 unsigned int lineSearchMaximumEvaluations = 40,
394 double lineSearchMinimumStep = 1e-20,
395 double lineSearchMaximumStep = 1e20,
396 double lineSearchAccuracy = 1e-4);
415 SITK_RETURN_SELF_TYPE_HEADER
416 SetOptimizerAsExhaustive(
const std::vector<unsigned int> & numberOfSteps,
double stepLength = 1.0);
427 SITK_RETURN_SELF_TYPE_HEADER
428 SetOptimizerAsAmoeba(
double simplexDelta,
429 unsigned int numberOfIterations,
430 double parametersConvergenceTolerance = 1e-8,
431 double functionConvergenceTolerance = 1e-4,
432 bool withRestarts =
false);
445 SITK_RETURN_SELF_TYPE_HEADER
446 SetOptimizerWeights(
const std::vector<double> & weights);
448 GetOptimizerWeights()
const;
455 SITK_RETURN_SELF_TYPE_HEADER
456 SetOptimizerAsPowell(
unsigned int numberOfIterations = 100,
457 unsigned int maximumLineIterations = 100,
458 double stepLength = 1,
459 double stepTolerance = 1e-6,
460 double valueTolerance = 1e-6);
470 SITK_RETURN_SELF_TYPE_HEADER
471 SetOptimizerAsOnePlusOneEvolutionary(
unsigned int numberOfIterations = 100,
472 double epsilon = 1.5e-4,
473 double initialRadius = 1.01,
474 double growthFactor = -1.0,
475 double shrinkFactor = -1.0,
480 SITK_RETURN_SELF_TYPE_HEADER
481 SetOptimizerScales(
const std::vector<double> & scales);
489 SITK_RETURN_SELF_TYPE_HEADER
490 SetOptimizerScalesFromJacobian(
unsigned int centralRegionRadius = 5);
497 SITK_RETURN_SELF_TYPE_HEADER
498 SetOptimizerScalesFromIndexShift(
unsigned int centralRegionRadius = 5,
double smallParameterVariation = 0.01);
506 SITK_RETURN_SELF_TYPE_HEADER
507 SetOptimizerScalesFromPhysicalShift(
unsigned int centralRegionRadius = 5,
double smallParameterVariation = 0.01);
519 SITK_RETURN_SELF_TYPE_HEADER
520 SetMetricFixedMask(
const Image & binaryMask);
531 SITK_RETURN_SELF_TYPE_HEADER
532 SetMetricMovingMask(
const Image & binaryMask);
552 SITK_RETURN_SELF_TYPE_HEADER
553 SetMetricSamplingPercentage(
double percentage,
unsigned int seed =
sitkWallClock);
554 SITK_RETURN_SELF_TYPE_HEADER
555 SetMetricSamplingPercentagePerLevel(
const std::vector<double> & percentage,
unsigned int seed =
sitkWallClock);
559 const std::vector<double> &
560 GetMetricSamplingPercentagePerLevel()
const;
583 SITK_RETURN_SELF_TYPE_HEADER
584 SetMetricSamplingStrategy(MetricSamplingStrategyType strategy);
595 SITK_RETURN_SELF_TYPE_HEADER
596 SetMetricUseFixedImageGradientFilter(
bool);
597 SITK_RETURN_SELF_TYPE_HEADER
600 return this->SetMetricUseFixedImageGradientFilter(
true);
602 SITK_RETURN_SELF_TYPE_HEADER
605 return this->SetMetricUseFixedImageGradientFilter(
false);
620 SITK_RETURN_SELF_TYPE_HEADER
621 SetMetricUseMovingImageGradientFilter(
bool);
622 SITK_RETURN_SELF_TYPE_HEADER
625 return this->SetMetricUseMovingImageGradientFilter(
true);
627 SITK_RETURN_SELF_TYPE_HEADER
630 return this->SetMetricUseMovingImageGradientFilter(
false);
642 SITK_RETURN_SELF_TYPE_HEADER
643 SetShrinkFactorsPerLevel(
const std::vector<unsigned int> & shrinkFactors);
653 SITK_RETURN_SELF_TYPE_HEADER
654 SetSmoothingSigmasPerLevel(
const std::vector<double> & smoothingSigmas);
662 SITK_RETURN_SELF_TYPE_HEADER
663 SetSmoothingSigmasAreSpecifiedInPhysicalUnits(
bool arg);
664 SITK_RETURN_SELF_TYPE_HEADER
667 this->SetSmoothingSigmasAreSpecifiedInPhysicalUnits(
true);
670 SITK_RETURN_SELF_TYPE_HEADER
673 this->SetSmoothingSigmasAreSpecifiedInPhysicalUnits(
false);
681 Execute(
const Image & fixed,
const Image & moving);
694 MetricEvaluate(
const Image & fixed,
const Image & moving);
704 GetOptimizerIteration()
const;
706 GetOptimizerPosition()
const;
708 GetOptimizerLearningRate()
const;
710 GetOptimizerConvergenceValue()
const;
712 GetMetricValue()
const;
723 GetMetricNumberOfValidPoints()
const;
727 GetCurrentLevel()
const;
737 GetOptimizerScales()
const;
742 GetOptimizerStopConditionDescription()
const;
757 template <
class TImage>
759 ExecuteInternal(
const Image & fixed,
const Image & moving);
761 template <
class TImage>
763 EvaluateInternal(
const Image & fixed,
const Image & moving);
767 CreateOptimizer(
unsigned int numberOfTransformParameters);
769 template <
unsigned int VDimension>
771 CreateSpatialObjectMask(
const Image & mask);
773 template <
class TImageType>
781 template <
class TImageType>
792 template <
typename TMetric>
794 CreateScalesEstimator();
796 template <
typename TTransformAdaptorPo
inter,
typename TRegistrationMethod>
797 std::vector<TTransformAdaptorPointer>
798 CreateTransformParametersAdaptor(TRegistrationMethod * method);
803 OnActiveProcessDelete() noexcept override;
807 RemoveITKObserver(EventCommand & e) override;
810 std::function<
unsigned int()> m_pfGetOptimizerIteration;
811 std::function<std::vector<
double>()> m_pfGetOptimizerPosition;
812 std::function<
double()> m_pfGetOptimizerLearningRate;
813 std::function<
double()> m_pfGetOptimizerConvergenceValue;
814 std::function<
double()> m_pfGetMetricValue;
815 std::function<uint64_t()> m_pfGetMetricNumberOfValidPoints;
816 std::function<std::vector<
double>()> m_pfGetOptimizerScales;
817 std::function<std::
string()> m_pfGetOptimizerStopConditionDescription;
818 std::function<
void()> m_pfOptimizerStopRegistration;
821 std::function<
unsigned int()> m_pfGetCurrentLevel;
825 template <class TMemberFunctionPointer>
828 using ObjectType = typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType;
830 template <
typename TImageType>
831 TMemberFunctionPointer
834 return &ObjectType::template EvaluateInternal<TImageType>;
938 MattesMutualInformation
971 #endif // sitkImageRegistrationMethod_h