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");
144#if !defined(SWIG) || defined(JAVASWIG) || defined(CSHARPSWIG)
181 const std::vector<unsigned int> & scaleFactors = std::vector<unsigned int>());
237 const std::vector<double> & virtualOrigin,
238 const std::vector<double> & virtualSpacing,
239 const std::vector<double> & virtualDirection);
273 double varianceForJointPDFSmoothing = 1.5);
304 unsigned int numberOfIterations,
305 double convergenceMinimumValue = 1e-6,
306 unsigned int convergenceWindowSize = 10,
307 double lineSearchLowerLimit = 0,
308 double lineSearchUpperLimit = 5.0,
309 double lineSearchEpsilon = 0.01,
310 unsigned int lineSearchMaximumIterations = 20,
312 double maximumStepSizeInPhysicalUnits = 0.0);
321 unsigned int numberOfIterations,
322 double relaxationFactor = 0.5,
323 double gradientMagnitudeTolerance = 1e-4,
325 double maximumStepSizeInPhysicalUnits = 0.0);
333 unsigned int numberOfIterations,
334 double convergenceMinimumValue = 1e-6,
335 unsigned int convergenceWindowSize = 10,
337 double maximumStepSizeInPhysicalUnits = 0.0);
345 unsigned int numberOfIterations,
346 double convergenceMinimumValue = 1e-6,
347 unsigned int convergenceWindowSize = 10,
348 double lineSearchLowerLimit = 0,
349 double lineSearchUpperLimit = 5.0,
350 double lineSearchEpsilon = 0.01,
351 unsigned int lineSearchMaximumIterations = 20,
353 double maximumStepSizeInPhysicalUnits = 0.0);
363 unsigned int numberOfIterations = 500,
364 unsigned int maximumNumberOfCorrections = 5,
365 unsigned int maximumNumberOfFunctionEvaluations = 2000,
366 double costFunctionConvergenceFactor = 1e+7,
367 double lowerBound = std::numeric_limits<double>::min(),
368 double upperBound = std::numeric_limits<double>::max(),
385 unsigned int numberOfIterations = 0,
386 unsigned int hessianApproximateAccuracy = 6,
387 unsigned int deltaConvergenceDistance = 0,
388 double deltaConvergenceTolerance = 1e-5,
389 unsigned int lineSearchMaximumEvaluations = 40,
390 double lineSearchMinimumStep = 1e-20,
391 double lineSearchMaximumStep = 1e20,
392 double lineSearchAccuracy = 1e-4);
425 unsigned int numberOfIterations,
426 double parametersConvergenceTolerance = 1e-8,
427 double functionConvergenceTolerance = 1e-4,
428 bool withRestarts =
false);
453 unsigned int maximumLineIterations = 100,
454 double stepLength = 1,
455 double stepTolerance = 1e-6,
456 double valueTolerance = 1e-6);
468 double epsilon = 1.5e-4,
469 double initialRadius = 1.01,
470 double growthFactor = -1.0,
471 double shrinkFactor = -1.0,
555 const std::vector<double> &
751 template <
class TImage>
755 template <
class TImage>
763 template <
unsigned int VDimension>
767 template <
class TImageType>
775 template <
class TImageType>
786 template <
typename TMetric>
790 template <
typename TTransformAdaptorPo
inter,
typename TRegistrationMethod>
791 std::vector<TTransformAdaptorPointer>
819 template <class TMemberFunctionPointer>
822 using ObjectType = typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType;
824 template <
typename TImageType>
825 constexpr TMemberFunctionPointer
double EvaluateInternal(const Image &fixed, const Image &moving)
void SetOptimizerAsExhaustive(const std::vector< unsigned int > &numberOfSteps, double stepLength=1.0)
Set the optimizer to sample the metric at regular steps.
std::function< std::vector< double >()> m_pfGetOptimizerPosition
unsigned int m_OptimizerMaximumNumberOfCorrections
void SetMetricAsCorrelation()
Use negative normalized cross correlation image metric.
void SetMetricAsMeanSquares()
Use negative means squares image metric.
double m_OptimizerShrinkFactor
void SetOptimizerWeights(const std::vector< double > &weights)
A per parameter weighting array for the optimizer.
void SetMetricSamplingStrategy(MetricSamplingStrategyType strategy)
Set sampling strategy for sample generation.
Transform(ImageRegistrationMethod::* MemberFunctionType)(const Image &fixed, const Image &moving)
void MetricUseMovingImageGradientFilterOff()
Enable image gradient computation by a filter.
void SetInterpolator(InterpolatorEnum Interpolator)
Set and get the interpolator to use.
double(ImageRegistrationMethod::* EvaluateMemberFunctionType)(const Image &fixed, const Image &moving)
unsigned int m_OptimizerScalesCentralRegionRadius
std::vector< double > GetOptimizerScales() const
Get the OptimizerScales.
EstimateLearningRateType m_OptimizerEstimateLearningRate
unsigned int m_OptimizerLineSearchMaximumEvaluations
std::function< void()> m_pfOptimizerStopRegistration
std::vector< double > m_VirtualDomainSpacing
double m_OptimizerParametersConvergenceTolerance
void SetMetricUseMovingImageGradientFilter(bool)
Enable image gradient computation by a filter.
uint64_t GetMetricNumberOfValidPoints() const
double m_OptimizerInitialRadius
void SetMetricSamplingPercentagePerLevel(const std::vector< double > &percentage, unsigned int seed=sitkWallClock)
Set percentage of pixels sampled for metric evaluation.
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
double m_OptimizerSimplexDelta
void SetMetricUseFixedImageGradientFilter(bool)
Enable image gradient computation by a filter.
void 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.
itk::ImageToImageMetricv4< TImageType, TImageType, TImageType, double, itk::DefaultImageToImageMetricTraitsv4< TImageType, TImageType, TImageType, double > > * CreateMetric()
double m_OptimizerStepLength
bool GetInitialTransformInPlace() const
Set the initial transform and parameters to optimize.
OptimizerScalesType m_OptimizerScalesType
void SetVirtualDomainFromImage(const Image &virtualImage)
Set the virtual domain used for sampling.
Transform Execute(const Image &fixed, const Image &moving)
Optimize the configured registration problem.
std::vector< double > GetOptimizerPosition() const
void SetMetricAsJointHistogramMutualInformation(unsigned int numberOfHistogramBins=20, double varianceForJointPDFSmoothing=1.5)
Use mutual information between two images.
void SetOptimizerScalesFromJacobian(unsigned int centralRegionRadius=5)
Estimate scales from Jacobian norms.
unsigned int m_OptimizerSeed
void 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.
void SmoothingSigmasAreSpecifiedInPhysicalUnitsOn()
Enable the smoothing sigmas for each level in physical units (default) or in terms of voxels.
void 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.
void PreUpdate(itk::ProcessObject *p) override
std::vector< double > m_MetricSamplingPercentage
double m_OptimizerLineSearchAccuracy
bool m_OptimizerWithRestarts
InterpolatorEnum m_Interpolator
void MetricUseFixedImageGradientFilterOff()
Enable image gradient computation by a filter.
double m_OptimizerGradientMagnitudeTolerance
void MetricUseFixedImageGradientFilterOn()
Enable image gradient computation by a filter.
bool m_InitialTransformInPlace
double m_OptimizerConvergenceMinimumValue
void SetMetricAsMattesMutualInformation(unsigned int numberOfHistogramBins=50)
Use the mutual information between two images to be registered using the method of Mattes et al.
Transform GetFixedInitialTransform() const
Set transform mapping to the fixed domain.
double m_OptimizerGrowthFactor
itk::ObjectToObjectOptimizerBaseTemplate< double > * m_ActiveOptimizer
double m_OptimizerSolutionAccuracy
void 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.
double m_MetricIntensityDifferenceThreshold
void SetMetricFixedMask(const Image &binaryMask)
Set an image mask in order to restrict the sampled points for the metric.
double m_OptimizerLineSearchMinimumStep
double m_OptimizerLearningRate
double m_OptimizerCostFunctionConvergenceFactor
std::vector< double > m_VirtualDomainDirection
unsigned int m_OptimizerLineSearchMaximumIterations
std::string ToString() const override
Print the information about the object to a string.
void SetShrinkFactorsPerLevel(const std::vector< unsigned int > &shrinkFactors)
Set the isotropic shrink factors for each level.
double m_OptimizerGradientConvergenceTolerance
double m_OptimizerLineSearchEpsilon
void SetMetricSamplingPercentage(double percentage, unsigned int seed=sitkWallClock)
Set percentage of pixels sampled for metric evaluation.
@ 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
double m_OptimizerScalesSmallParameterVariation
std::string GetOptimizerStopConditionDescription() const
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
void SetMetricMovingMask(const Image &binaryMask)
Set an image mask in order to restrict the sampled points for the metric in the moving image space.
std::function< unsigned int()> m_pfGetOptimizerIteration
void 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 MetricUseMovingImageGradientFilterOn()
Enable image gradient computation by a filter.
MetricSamplingStrategyType
Sampling strategies for obtaining points.
Transform m_FixedInitialTransform
std::function< void(itk::TransformBase *outTransform)> m_pfUpdateWithBestValue
bool m_MetricUseFixedImageGradientFilter
itk::ObjectToObjectOptimizerBaseTemplate< double > * CreateOptimizer(unsigned int numberOfTransformParameters)
@ GradientDescentLineSearch
@ RegularStepGradientDescent
@ ConjugateGradientLineSearch
void 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.
void SetInitialTransform(Transform &transform, bool inPlace=true)
Set the initial transform and parameters to optimize.
ImageRegistrationMethod()
std::vector< double > m_SmoothingSigmasPerLevel
double m_OptimizerStepTolerance
unsigned int m_MetricNumberOfHistogramBins
double m_OptimizerLowerBound
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)
void 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.
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.
void 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::vector< unsigned int > m_TransformBSplineScaleFactors
double GetOptimizerConvergenceValue() const
ImageRegistrationMethod Self
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 *)
void SetSmoothingSigmasPerLevel(const std::vector< double > &smoothingSigmas)
Set the sigmas of Gaussian used for smoothing.
void 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.
unsigned int m_OptimizerMaximumLineIterations
void RemoveITKObserver(EventCommand &e) override
unsigned int m_OptimizerMaximumNumberOfFunctionEvaluations
InterpolatorEnum GetInterpolator()
Set and get the interpolator to use.
Image m_MetricFixedMaskImage
std::function< uint64_t()> m_pfGetMetricNumberOfValidPoints
unsigned int GetCurrentLevel() const
void SetOptimizerScalesFromIndexShift(unsigned int centralRegionRadius=5, double smallParameterVariation=0.01)
Estimate scales from maximum voxel shift in index space cause by parameter change.
void 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...
@ 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
void SetOptimizerScales(const std::vector< double > &scales)
Manually set per parameter weighting for the transform parameters.
void SetMetricAsDemons(double intensityDifferenceThreshold=0.001)
Use demons image metric.
std::function< double()> m_pfGetOptimizerLearningRate
std::function< unsigned int()> m_pfGetCurrentLevel
std::function< double()> m_pfGetOptimizerConvergenceValue
Transform m_InitialTransform
OptimizerType m_OptimizerType
unsigned int GetOptimizerIteration() const
void SetMovingInitialTransform(const Transform &transform)
Set a fixed transform component towards moving domain.
double GetMetricValue() const
double m_OptimizerLineSearchLowerLimit
void SetSmoothingSigmasAreSpecifiedInPhysicalUnits(bool arg)
Enable the smoothing sigmas for each level in physical units (default) or in terms of voxels.
std::function< std::string()> m_pfGetOptimizerStopConditionDescription
void SetInitialTransform(const Transform &transform)
Set the initial transform and parameters to optimize.
void SetInitialTransformAsBSpline(BSplineTransform &transform, bool inPlace=true, const std::vector< unsigned int > &scaleFactors=std::vector< unsigned int >())
Set an initial BSpline transform to optimize.
void SmoothingSigmasAreSpecifiedInPhysicalUnitsOff()
Enable the smoothing sigmas for each level in physical units (default) or in terms of voxels.
void 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.
Image m_MetricMovingMaskImage
std::function< double()> m_pfGetMetricValue
bool m_SmoothingSigmasAreSpecifiedInPhysicalUnits
std::vector< TTransformAdaptorPointer > CreateTransformParametersAdaptor(TRegistrationMethod *method)
unsigned int m_OptimizerNumberOfIterations
std::vector< double > m_OptimizerWeights
std::function< std::vector< double >()> m_pfGetOptimizerScales
std::vector< uint32_t > m_VirtualDomainSize
void SetMetricAsANTSNeighborhoodCorrelation(unsigned int radius)
Use normalized cross correlation using a small neighborhood for each voxel between two images,...
void SetFixedInitialTransform(const Transform &transform)
Set transform mapping to the fixed domain.
bool m_MetricUseMovingImageGradientFilter
Transform GetMovingInitialTransform() const
Set a fixed transform component towards moving domain.
The Image class for SimpleITK.
friend class itk::simple::Command
TransformBaseTemplate< double > TransformBase
#define SITKRegistration_EXPORT
typename ::detail::FunctionTraits< TMemberFunctionPointer >::ClassType ObjectType
constexpr TMemberFunctionPointer operator()() const