18#ifndef sitkImageRegistrationMethod_h
19#define sitkImageRegistrationMethod_h
37template <
typename TInternalComputationValueType>
39template <
typename TFixedImage,
40 typename TMovingImage,
41 typename TVirtualImage,
42 typename TInternalComputationValueType,
43 typename TMetricTraits>
46template <
typename TFixedImageType,
typename TMovingImageType,
typename TVirtualImageType,
typename TCoordRep>
49template <
typename TMetric>
52template <
unsigned int VDimension>
100 return std::string(
"ImageRegistrationMethod");
121 SITK_RETURN_SELF_TYPE_HEADER
145#if !defined(SWIG) || defined(JAVASWIG) || defined(CSHARPSWIG)
147 SITK_RETURN_SELF_TYPE_HEADER
150 SITK_RETURN_SELF_TYPE_HEADER
182 const std::vector<unsigned int> & scaleFactors = std::vector<unsigned int>());
197 SITK_RETURN_SELF_TYPE_HEADER
220 SITK_RETURN_SELF_TYPE_HEADER
238 SITK_RETURN_SELF_TYPE_HEADER
240 const std::vector<double> & virtualOrigin,
241 const std::vector<double> & virtualSpacing,
242 const std::vector<double> & virtualDirection);
243 SITK_RETURN_SELF_TYPE_HEADER
253 SITK_RETURN_SELF_TYPE_HEADER
260 SITK_RETURN_SELF_TYPE_HEADER
267 SITK_RETURN_SELF_TYPE_HEADER
274 SITK_RETURN_SELF_TYPE_HEADER
276 double varianceForJointPDFSmoothing = 1.5);
282 SITK_RETURN_SELF_TYPE_HEADER
290 SITK_RETURN_SELF_TYPE_HEADER
305 SITK_RETURN_SELF_TYPE_HEADER
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,
315 double maximumStepSizeInPhysicalUnits = 0.0);
321 SITK_RETURN_SELF_TYPE_HEADER
324 unsigned int numberOfIterations,
325 double relaxationFactor = 0.5,
326 double gradientMagnitudeTolerance = 1e-4,
328 double maximumStepSizeInPhysicalUnits = 0.0);
334 SITK_RETURN_SELF_TYPE_HEADER
336 unsigned int numberOfIterations,
337 double convergenceMinimumValue = 1e-6,
338 unsigned int convergenceWindowSize = 10,
340 double maximumStepSizeInPhysicalUnits = 0.0);
346 SITK_RETURN_SELF_TYPE_HEADER
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,
356 double maximumStepSizeInPhysicalUnits = 0.0);
364 SITK_RETURN_SELF_TYPE_HEADER
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
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
426 SITK_RETURN_SELF_TYPE_HEADER
428 unsigned int numberOfIterations,
429 double parametersConvergenceTolerance = 1e-8,
430 double functionConvergenceTolerance = 1e-4,
431 bool withRestarts =
false);
444 SITK_RETURN_SELF_TYPE_HEADER
454 SITK_RETURN_SELF_TYPE_HEADER
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
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
488 SITK_RETURN_SELF_TYPE_HEADER
496 SITK_RETURN_SELF_TYPE_HEADER
505 SITK_RETURN_SELF_TYPE_HEADER
518 SITK_RETURN_SELF_TYPE_HEADER
530 SITK_RETURN_SELF_TYPE_HEADER
551 SITK_RETURN_SELF_TYPE_HEADER
553 SITK_RETURN_SELF_TYPE_HEADER
558 const std::vector<double> &
582 SITK_RETURN_SELF_TYPE_HEADER
594 SITK_RETURN_SELF_TYPE_HEADER
596 SITK_RETURN_SELF_TYPE_HEADER
598 SITK_RETURN_SELF_TYPE_HEADER
613 SITK_RETURN_SELF_TYPE_HEADER
615 SITK_RETURN_SELF_TYPE_HEADER
617 SITK_RETURN_SELF_TYPE_HEADER
629 SITK_RETURN_SELF_TYPE_HEADER
640 SITK_RETURN_SELF_TYPE_HEADER
649 SITK_RETURN_SELF_TYPE_HEADER
651 SITK_RETURN_SELF_TYPE_HEADER
657 SITK_RETURN_SELF_TYPE_HEADER
744 template <
class TImage>
748 template <
class TImage>
756 template <
unsigned int VDimension>
760 template <
class TImageType>
768 template <
class TImageType>
779 template <
typename TMetric>
783 template <
typename TTransformAdaptorPo
inter,
typename TRegistrationMethod>
784 std::vector<TTransformAdaptorPointer>
812 template <class TMemberFunctionPointer>
815 using ObjectType = typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType;
817 template <
typename TImageType>
818 TMemberFunctionPointer
Self & SetInitialTransform(Transform &transform, bool inPlace=true)
Set the initial transform and parameters to optimize.
double EvaluateInternal(const Image &fixed, const Image &moving)
Self & SetMetricSamplingStrategy(MetricSamplingStrategyType strategy)
Set sampling strategy for sample generation.
std::function< std::vector< double >()> m_pfGetOptimizerPosition
Self & SetInterpolator(InterpolatorEnum Interpolator)
Set and get the interpolator to use.
unsigned int m_OptimizerMaximumNumberOfCorrections
Self & SetVirtualDomain(const std::vector< uint32_t > &virtualSize, const std::vector< double > &virtualOrigin, const std::vector< double > &virtualSpacing, const std::vector< double > &virtualDirection)
Set the virtual domain used for sampling.
Self & SetSmoothingSigmasAreSpecifiedInPhysicalUnits(bool arg)
Enable the smoothing sigmas for each level in physical units (default) or in terms of voxels.
double m_OptimizerShrinkFactor
Transform(ImageRegistrationMethod::* MemberFunctionType)(const Image &fixed, const Image &moving)
Self & SetMetricUseFixedImageGradientFilter(bool)
Enable image gradient computation by a filter.
double(ImageRegistrationMethod::* EvaluateMemberFunctionType)(const Image &fixed, const Image &moving)
unsigned int m_OptimizerScalesCentralRegionRadius
std::vector< double > GetOptimizerScales() const
Get the OptimizerScales.
EstimateLearningRateType m_OptimizerEstimateLearningRate
Self & SetMetricMovingMask(const Image &binaryMask)
Set an image mask in order to restrict the sampled points for the metric in the moving image space.
unsigned int m_OptimizerLineSearchMaximumEvaluations
std::function< void()> m_pfOptimizerStopRegistration
std::vector< double > m_VirtualDomainSpacing
double m_OptimizerParametersConvergenceTolerance
uint64_t GetMetricNumberOfValidPoints() const
Self & SetMetricAsDemons(double intensityDifferenceThreshold=0.001)
Use demons image metric.
double m_OptimizerInitialRadius
Transform m_MovingInitialTransform
double m_OptimizerEpsilon
itk::SpatialObject< VDimension > * CreateSpatialObjectMask(const Image &mask)
std::vector< unsigned int > m_OptimizerNumberOfSteps
const std::vector< double > & GetMetricSamplingPercentagePerLevel() const
Get the percentage of pixels used for metric evaluation.
double m_OptimizerMinimumStepLength
double m_OptimizerFunctionConvergenceTolerance
Self & MetricUseFixedImageGradientFilterOn()
Enable image gradient computation by a filter.
double m_OptimizerSimplexDelta
itk::ImageToImageMetricv4< TImageType, TImageType, TImageType, double, itk::DefaultImageToImageMetricTraitsv4< TImageType, TImageType, TImageType, double > > * CreateMetric()
double m_OptimizerStepLength
Self & SetOptimizerAsAmoeba(double simplexDelta, unsigned int numberOfIterations, double parametersConvergenceTolerance=1e-8, double functionConvergenceTolerance=1e-4, bool withRestarts=false)
Set optimizer to Nelder-Mead downhill simplex algorithm.
bool GetInitialTransformInPlace() const
Set the initial transform and parameters to optimize.
OptimizerScalesType m_OptimizerScalesType
Transform Execute(const Image &fixed, const Image &moving)
Optimize the configured registration problem.
std::vector< double > GetOptimizerPosition() const
Self & SetOptimizerWeights(const std::vector< double > &weights)
A per parameter weighting array for the optimizer.
Self & SetOptimizerAsExhaustive(const std::vector< unsigned int > &numberOfSteps, double stepLength=1.0)
Set the optimizer to sample the metric at regular steps.
unsigned int m_OptimizerSeed
Self & SetMetricAsMattesMutualInformation(unsigned int numberOfHistogramBins=50)
Use the mutual information between two images to be registered using the method of Mattes et al.
Self & SetOptimizerAsOnePlusOneEvolutionary(unsigned int numberOfIterations=100, double epsilon=1.5e-4, double initialRadius=1.01, double growthFactor=-1.0, double shrinkFactor=-1.0, unsigned int seed=sitkWallClock)
1+1 evolutionary optimizer strategy.
void PreUpdate(itk::ProcessObject *p) override
std::vector< double > m_MetricSamplingPercentage
Self & SetMetricSamplingPercentagePerLevel(const std::vector< double > &percentage, unsigned int seed=sitkWallClock)
Set percentage of pixels sampled for metric evaluation.
double m_OptimizerLineSearchAccuracy
bool m_OptimizerWithRestarts
InterpolatorEnum m_Interpolator
double m_OptimizerGradientMagnitudeTolerance
bool m_InitialTransformInPlace
Self & SetFixedInitialTransform(const Transform &transform)
Set transform mapping to the fixed domain.
double m_OptimizerConvergenceMinimumValue
Self & SetOptimizerAsRegularStepGradientDescent(double learningRate, double minStep, unsigned int numberOfIterations, double relaxationFactor=0.5, double gradientMagnitudeTolerance=1e-4, EstimateLearningRateType estimateLearningRate=Never, double maximumStepSizeInPhysicalUnits=0.0)
Regular Step Gradient descent optimizer.
Transform GetFixedInitialTransform() const
Set transform mapping to the fixed domain.
double m_OptimizerGrowthFactor
itk::ObjectToObjectOptimizerBaseTemplate< double > * m_ActiveOptimizer
double m_OptimizerSolutionAccuracy
double m_MetricIntensityDifferenceThreshold
Self & SetShrinkFactorsPerLevel(const std::vector< unsigned int > &shrinkFactors)
Set the isotropic shrink factors for each level.
double m_OptimizerLineSearchMinimumStep
Self & SmoothingSigmasAreSpecifiedInPhysicalUnitsOff()
Enable the smoothing sigmas for each level in physical units (default) or in terms of voxels.
double m_OptimizerLearningRate
double m_OptimizerCostFunctionConvergenceFactor
std::vector< double > m_VirtualDomainDirection
Self & SetMetricAsCorrelation()
Use negative normalized cross correlation image metric.
unsigned int m_OptimizerLineSearchMaximumIterations
std::string ToString() const override
Print the information about the object to a string.
Self & SetMetricUseMovingImageGradientFilter(bool)
Enable image gradient computation by a filter.
Self & SetSmoothingSigmasPerLevel(const std::vector< double > &smoothingSigmas)
Set the sigmas of Gaussian used for smoothing.
double m_OptimizerGradientConvergenceTolerance
double m_OptimizerLineSearchEpsilon
@ MattesMutualInformation
@ ANTSNeighborhoodCorrelation
@ JointHistogramMutualInformation
std::vector< double > m_VirtualDomainOrigin
double m_OptimizerLineSearchMaximumStep
std::vector< unsigned int > m_ShrinkFactorsPerLevel
Transform GetInitialTransform()
Set the initial transform and parameters to optimize.
unsigned int m_MetricRadius
double m_OptimizerDeltaConvergenceTolerance
~ImageRegistrationMethod() override
Self & SetOptimizerAsPowell(unsigned int numberOfIterations=100, unsigned int maximumLineIterations=100, double stepLength=1, double stepTolerance=1e-6, double valueTolerance=1e-6)
Powell optimization using Brent line search.
double m_OptimizerScalesSmallParameterVariation
Self & MetricUseMovingImageGradientFilterOff()
Enable image gradient computation by a filter.
std::string GetOptimizerStopConditionDescription() const
Self & SetMetricAsANTSNeighborhoodCorrelation(unsigned int radius)
Use normalized cross correlation using a small neighborhood for each voxel between two images,...
std::string m_StopConditionDescription
itk::RegistrationParameterScalesEstimator< TMetric > * CreateScalesEstimator()
double m_MetricVarianceForJointPDFSmoothing
unsigned int m_OptimizerConvergenceWindowSize
std::string GetName() const override
unsigned int m_MetricSamplingSeed
double m_OptimizerValueTolerance
MetricSamplingStrategyType m_MetricSamplingStrategy
std::function< unsigned int()> m_pfGetOptimizerIteration
MetricSamplingStrategyType
Sampling strategies for obtaining points.
Transform m_FixedInitialTransform
Self & SetMetricSamplingPercentage(double percentage, unsigned int seed=sitkWallClock)
Set percentage of pixels sampled for metric evaluation.
std::function< void(itk::TransformBase *outTransform)> m_pfUpdateWithBestValue
bool m_MetricUseFixedImageGradientFilter
itk::ObjectToObjectOptimizerBaseTemplate< double > * CreateOptimizer(unsigned int numberOfTransformParameters)
@ GradientDescentLineSearch
@ RegularStepGradientDescent
@ ConjugateGradientLineSearch
ImageRegistrationMethod()
std::vector< double > m_SmoothingSigmasPerLevel
double m_OptimizerStepTolerance
unsigned int m_MetricNumberOfHistogramBins
double m_OptimizerLowerBound
Self & SetVirtualDomainFromImage(const Image &virtualImage)
Set the virtual domain used for sampling.
void OnActiveProcessDelete() noexcept override
unsigned int m_OptimizerHessianApproximationAccuracy
uint64_t m_NumberOfValidPoints
std::vector< double > m_OptimizerScales
double m_OptimizerMaximumStepSizeInPhysicalUnits
Transform ExecuteInternal(const Image &fixed, const Image &moving)
unsigned long AddITKObserver(const itk::EventObject &, itk::Command *) override
double MetricEvaluate(const Image &fixed, const Image &moving)
Get the value of the metric given the state of the method.
Self & SetMovingInitialTransform(const Transform &transform)
Set a fixed transform component towards moving domain.
std::vector< unsigned int > m_TransformBSplineScaleFactors
double GetOptimizerConvergenceValue() const
ImageRegistrationMethod Self
Self & SmoothingSigmasAreSpecifiedInPhysicalUnitsOn()
Enable the smoothing sigmas for each level in physical units (default) or in terms of voxels.
double m_OptimizerRelaxationFactor
std::vector< double > GetOptimizerWeights() const
A per parameter weighting array for the optimizer.
void SetupMetric(itk::ImageToImageMetricv4< TImageType, TImageType, TImageType, double, itk::DefaultImageToImageMetricTraitsv4< TImageType, TImageType, TImageType, double > > *, const TImageType *, const TImageType *)
Self & SetOptimizerAsLBFGSB(double gradientConvergenceTolerance=1e-5, unsigned int numberOfIterations=500, unsigned int maximumNumberOfCorrections=5, unsigned int maximumNumberOfFunctionEvaluations=2000, double costFunctionConvergenceFactor=1e+7, double lowerBound=std::numeric_limits< double >::min(), double upperBound=std::numeric_limits< double >::max(), bool trace=false)
Limited memory Broyden Fletcher Goldfarb Shannon minimization with simple bounds.
unsigned int m_OptimizerMaximumLineIterations
void RemoveITKObserver(EventCommand &e) override
unsigned int m_OptimizerMaximumNumberOfFunctionEvaluations
Self & SetMetricAsMeanSquares()
Use negative means squares image metric.
InterpolatorEnum GetInterpolator()
Set and get the interpolator to use.
Image m_MetricFixedMaskImage
Self & SetOptimizerScalesFromPhysicalShift(unsigned int centralRegionRadius=5, double smallParameterVariation=0.01)
Estimating scales of transform parameters a step sizes, from the maximum voxel shift in physical spac...
std::function< uint64_t()> m_pfGetMetricNumberOfValidPoints
Self & MetricUseMovingImageGradientFilterOn()
Enable image gradient computation by a filter.
Self & SetMetricAsJointHistogramMutualInformation(unsigned int numberOfHistogramBins=20, double varianceForJointPDFSmoothing=1.5)
Use mutual information between two images.
unsigned int GetCurrentLevel() const
Self & SetMetricFixedMask(const Image &binaryMask)
Set an image mask in order to restrict the sampled points for the metric.
@ Once
Estimate learning once each level, ignore provided values.
@ EachIteration
Estimate learning rate at each iteration.
@ Never
Never run estimation, use provided value.
unsigned int m_OptimizerDeltaConvergenceDistance
double m_OptimizerLineSearchUpperLimit
double GetOptimizerLearningRate() const
double m_OptimizerUpperBound
std::function< double()> m_pfGetOptimizerLearningRate
std::function< unsigned int()> m_pfGetCurrentLevel
std::function< double()> m_pfGetOptimizerConvergenceValue
Self & SetOptimizerAsConjugateGradientLineSearch(double learningRate, unsigned int numberOfIterations, double convergenceMinimumValue=1e-6, unsigned int convergenceWindowSize=10, double lineSearchLowerLimit=0, double lineSearchUpperLimit=5.0, double lineSearchEpsilon=0.01, unsigned int lineSearchMaximumIterations=20, EstimateLearningRateType estimateLearningRate=Once, double maximumStepSizeInPhysicalUnits=0.0)
Conjugate gradient descent optimizer with a golden section line search for nonlinear optimization.
Transform m_InitialTransform
OptimizerType m_OptimizerType
unsigned int GetOptimizerIteration() const
double GetMetricValue() const
double m_OptimizerLineSearchLowerLimit
std::function< std::string()> m_pfGetOptimizerStopConditionDescription
Self & SetOptimizerAsGradientDescent(double learningRate, unsigned int numberOfIterations, double convergenceMinimumValue=1e-6, unsigned int convergenceWindowSize=10, EstimateLearningRateType estimateLearningRate=Once, double maximumStepSizeInPhysicalUnits=0.0)
Gradient descent optimizer.
std::unique_ptr< detail::MemberFunctionFactory< EvaluateMemberFunctionType > > m_EvaluateMemberFactory
void SetInitialTransformAsBSpline(BSplineTransform &transform, bool inPlace=true, const std::vector< unsigned int > &scaleFactors=std::vector< unsigned int >())
Set an initial BSpline transform to optimize.
Self & SetOptimizerScalesFromJacobian(unsigned int centralRegionRadius=5)
Estimate scales from Jacobian norms.
Image m_MetricMovingMaskImage
std::function< double()> m_pfGetMetricValue
bool m_SmoothingSigmasAreSpecifiedInPhysicalUnits
Self & SetOptimizerScalesFromIndexShift(unsigned int centralRegionRadius=5, double smallParameterVariation=0.01)
Estimate scales from maximum voxel shift in index space cause by parameter change.
std::vector< TTransformAdaptorPointer > CreateTransformParametersAdaptor(TRegistrationMethod *method)
unsigned int m_OptimizerNumberOfIterations
Self & SetOptimizerScales(const std::vector< double > &scales)
Manually set per parameter weighting for the transform parameters.
std::vector< double > m_OptimizerWeights
std::function< std::vector< double >()> m_pfGetOptimizerScales
std::vector< uint32_t > m_VirtualDomainSize
std::unique_ptr< detail::MemberFunctionFactory< MemberFunctionType > > m_MemberFactory
bool m_MetricUseMovingImageGradientFilter
Transform GetMovingInitialTransform() const
Set a fixed transform component towards moving domain.
Self & SetOptimizerAsLBFGS2(double solutionAccuracy=1e-5, unsigned int numberOfIterations=0, unsigned int hessianApproximateAccuracy=6, unsigned int deltaConvergenceDistance=0, double deltaConvergenceTolerance=1e-5, unsigned int lineSearchMaximumEvaluations=40, double lineSearchMinimumStep=1e-20, double lineSearchMaximumStep=1e20, double lineSearchAccuracy=1e-4)
Limited memory Broyden Fletcher Goldfarb Shannon minimization without bounds.
Self & SetInitialTransform(const Transform &transform)
Set the initial transform and parameters to optimize.
Self & MetricUseFixedImageGradientFilterOff()
Enable image gradient computation by a filter.
Self & SetOptimizerAsGradientDescentLineSearch(double learningRate, unsigned int numberOfIterations, double convergenceMinimumValue=1e-6, unsigned int convergenceWindowSize=10, double lineSearchLowerLimit=0, double lineSearchUpperLimit=5.0, double lineSearchEpsilon=0.01, unsigned int lineSearchMaximumIterations=20, EstimateLearningRateType estimateLearningRate=Once, double maximumStepSizeInPhysicalUnits=0.0)
Gradient descent optimizer with a golden section line search.
The Image class for SimpleITK.
friend class itk::simple::Command
TransformBaseTemplate< double > TransformBase
#define SITKRegistration_EXPORT
typename ::detail::FunctionTraits< TMemberFunctionPointer >::ClassType ObjectType
TMemberFunctionPointer operator()() const