18 #ifndef sitkImageRegistrationMethod_h
19 #define sitkImageRegistrationMethod_h
38 template<
typename TInternalComputationValueType>
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,
47 typename TMovingImageType,
48 typename TVirtualImageType,
50 class DefaultImageToImageMetricTraitsv4;
52 template<
typename TMetric>
class RegistrationParameterScalesEstimator;
54 template<
unsigned int VDimension>
class SpatialObject;
64 class BSplineTransform;
101 std::string
GetName()
const {
return std::string(
"ImageRegistrationMethod"); }
109 std::string ToString()
const;
116 {
return this->m_Interpolator; }
118 { this->m_Interpolator = Interpolator;
return *
this; }
137 #if !defined(SWIG) || defined(JAVASWIG) || defined(CSHARPSWIG)
139 SITK_RETURN_SELF_TYPE_HEADER SetInitialTransform (
const Transform &transform );
141 SITK_RETURN_SELF_TYPE_HEADER SetInitialTransform (
Transform &transform,
bool inPlace=
true );
143 {
return this->m_InitialTransform; }
145 {
return this->m_InitialTransformInPlace;}
165 const std::vector<unsigned int> &scaleFactors=std::vector<unsigned int>() );
181 { this->m_MovingInitialTransform = transform;
return *
this; }
183 {
return this->m_MovingInitialTransform; }
197 { this->m_FixedInitialTransform = transform;
return *
this; }
199 {
return this->m_FixedInitialTransform; }
207 SITK_RETURN_SELF_TYPE_HEADER SetVirtualDomain(
const std::vector<uint32_t> &virtualSize,
208 const std::vector<double> &virtualOrigin,
209 const std::vector<double> &virtualSpacing,
210 const std::vector<double> &virtualDirection );
211 SITK_RETURN_SELF_TYPE_HEADER SetVirtualDomainFromImage(
const Image &virtualImage );
220 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsANTSNeighborhoodCorrelation(
unsigned int radius );
226 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsCorrelation( );
232 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsDemons(
double intensityDifferenceThreshold = 0.001 );
238 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsJointHistogramMutualInformation(
unsigned int numberOfHistogramBins = 20,
239 double varianceForJointPDFSmoothing = 1.5);
245 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsMeanSquares( );
252 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsMattesMutualInformation(
unsigned int numberOfHistogramBins = 50 );
264 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsConjugateGradientLineSearch(
double learningRate,
265 unsigned int numberOfIterations,
266 double convergenceMinimumValue = 1e-6,
267 unsigned int convergenceWindowSize = 10,
268 double lineSearchLowerLimit = 0,
269 double lineSearchUpperLimit = 5.0,
270 double lineSearchEpsilon = 0.01,
271 unsigned int lineSearchMaximumIterations = 20,
272 EstimateLearningRateType estimateLearningRate = Once,
273 double maximumStepSizeInPhysicalUnits = 0.0 );
279 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsRegularStepGradientDescent(
double learningRate,
281 unsigned int numberOfIterations,
282 double relaxationFactor=0.5,
283 double gradientMagnitudeTolerance = 1e-4,
284 EstimateLearningRateType estimateLearningRate = Never,
285 double maximumStepSizeInPhysicalUnits = 0.0);
291 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsGradientDescent(
double learningRate,
292 unsigned int numberOfIterations,
293 double convergenceMinimumValue = 1e-6,
294 unsigned int convergenceWindowSize = 10,
295 EstimateLearningRateType estimateLearningRate = Once,
296 double maximumStepSizeInPhysicalUnits = 0.0);
302 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsGradientDescentLineSearch(
double learningRate,
303 unsigned int numberOfIterations,
304 double convergenceMinimumValue = 1e-6,
305 unsigned int convergenceWindowSize = 10,
306 double lineSearchLowerLimit = 0,
307 double lineSearchUpperLimit = 5.0,
308 double lineSearchEpsilon = 0.01,
309 unsigned int lineSearchMaximumIterations = 20,
310 EstimateLearningRateType estimateLearningRate = Once,
311 double maximumStepSizeInPhysicalUnits = 0.0 );
319 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsLBFGSB(
double gradientConvergenceTolerance = 1e-5,
320 unsigned int numberOfIterations = 500,
321 unsigned int maximumNumberOfCorrections = 5,
322 unsigned int maximumNumberOfFunctionEvaluations = 2000,
323 double costFunctionConvergenceFactor = 1e+7,
324 double lowerBound = std::numeric_limits<double>::min(),
325 double upperBound = std::numeric_limits<double>::max(),
326 bool trace =
false );
340 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsLBFGS2(
double solutionAccuracy = 1e-5,
341 unsigned int numberOfIterations = 0,
342 unsigned int hessianApproximateAccuracy = 6,
343 unsigned int deltaConvergenceDistance = 0,
344 double deltaConvergenceTolerance = 1e-5,
345 unsigned int lineSearchMaximumEvaluations = 40,
346 double lineSearchMinimumStep = 1e-20,
347 double lineSearchMaximumStep = 1e20,
348 double lineSearchAccuracy = 1e-4);
367 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsExhaustive(
const std::vector<unsigned int> &numberOfSteps,
368 double stepLength = 1.0 );
374 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsAmoeba(
double simplexDelta,
375 unsigned int numberOfIterations,
376 double parametersConvergenceTolerance=1e-8,
377 double functionConvergenceTolerance=1e-4,
378 bool withRestarts =
false );
391 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerWeights(
const std::vector<double> &weights);
392 std::vector<double> GetOptimizerWeights( )
const;
399 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsPowell(
unsigned int numberOfIterations = 100,
400 unsigned int maximumLineIterations = 100,
401 double stepLength = 1,
402 double stepTolerance = 1e-6,
403 double valueTolerance = 1e-6 );
413 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsOnePlusOneEvolutionary(
unsigned int numberOfIterations = 100,
414 double epsilon = 1.5e-4,
415 double initialRadius = 1.01,
416 double growthFactor = -1.0,
417 double shrinkFactor = -1.0,
423 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerScales(
const std::vector<double> &scales );
431 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerScalesFromJacobian(
unsigned int centralRegionRadius = 5 );
438 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerScalesFromIndexShift(
unsigned int centralRegionRadius = 5,
439 double smallParameterVariation = 0.01 );
447 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerScalesFromPhysicalShift(
unsigned int centralRegionRadius = 5,
448 double smallParameterVariation = 0.01 );
460 SITK_RETURN_SELF_TYPE_HEADER SetMetricFixedMask(
const Image &binaryMask );
471 SITK_RETURN_SELF_TYPE_HEADER SetMetricMovingMask(
const Image &binaryMask );
491 SITK_RETURN_SELF_TYPE_HEADER SetMetricSamplingPercentage(
double percentage,
unsigned int seed =
sitkWallClock);
492 SITK_RETURN_SELF_TYPE_HEADER SetMetricSamplingPercentagePerLevel(
const std::vector<double> &percentage,
unsigned int seed =
sitkWallClock);
496 const std::vector<double> &GetMetricSamplingPercentagePerLevel()
const;
508 SITK_RETURN_SELF_TYPE_HEADER SetMetricSamplingStrategy( MetricSamplingStrategyType strategy);
519 SITK_RETURN_SELF_TYPE_HEADER SetMetricUseFixedImageGradientFilter(
bool);
535 SITK_RETURN_SELF_TYPE_HEADER SetMetricUseMovingImageGradientFilter(
bool);
548 SITK_RETURN_SELF_TYPE_HEADER SetShrinkFactorsPerLevel(
const std::vector<unsigned int> &shrinkFactors );
558 SITK_RETURN_SELF_TYPE_HEADER SetSmoothingSigmasPerLevel(
const std::vector<double> &smoothingSigmas );
566 SITK_RETURN_SELF_TYPE_HEADER SetSmoothingSigmasAreSpecifiedInPhysicalUnits(
bool arg);
585 double MetricEvaluate(
const Image &fixed,
const Image & moving );
594 unsigned int GetOptimizerIteration()
const;
595 std::vector<double> GetOptimizerPosition()
const;
596 double GetOptimizerLearningRate()
const;
597 double GetOptimizerConvergenceValue()
const;
598 double GetMetricValue()
const;
608 uint64_t GetMetricNumberOfValidPoints()
const;
611 unsigned int GetCurrentLevel()
const;
620 std::vector<double> GetOptimizerScales()
const;
624 std::string GetOptimizerStopConditionDescription()
const;
628 template<
class TImage>
631 template<
class TImage>
632 double EvaluateInternal (
const Image &fixed,
const Image &moving );
637 template<
unsigned int VDimension>
640 template <
class TImageType>
648 template <
class TImageType>
655 >*,
const TImageType*,
const TImageType* );
657 template <
typename TMetric>
660 template <
typename TTransformAdaptorPo
inter,
typename TRegistrationMethod >
661 std::vector< TTransformAdaptorPointer >
662 CreateTransformParametersAdaptor(
663 TRegistrationMethod* method);
668 virtual
void RemoveITKObserver( EventCommand &e );
672 nsstd::function<
unsigned int()> m_pfGetOptimizerIteration;
673 nsstd::function<
std::vector<
double>()> m_pfGetOptimizerPosition;
674 nsstd::function<
double()> m_pfGetOptimizerLearningRate;
675 nsstd::function<
double()> m_pfGetOptimizerConvergenceValue;
676 nsstd::function<
double()> m_pfGetMetricValue;
677 nsstd::function<
uint64_t()> m_pfGetMetricNumberOfValidPoints;
678 nsstd::function<
std::vector<
double>()> m_pfGetOptimizerScales;
679 nsstd::function<
std::
string()> m_pfGetOptimizerStopConditionDescription;
682 nsstd::function<
unsigned int()> m_pfGetCurrentLevel;
686 template < class TMemberFunctionPointer >
689 typedef typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType
ObjectType;
691 template<
typename TImageType >
692 TMemberFunctionPointer operator() (
void )
const
694 return &ObjectType::template EvaluateInternal< TImageType >;
793 MattesMutualInformation
826 #endif // sitkImageRegistrationMethod_h
double m_MetricIntensityDifferenceThreshold
double m_OptimizerSolutionAccuracy
std::vector< unsigned int > m_OptimizerNumberOfSteps
unsigned int m_OptimizerSeed
double m_OptimizerShrinkFactor
std::vector< uint32_t > m_VirtualDomainSize
double m_OptimizerCostFunctionConvergenceFactor
double m_OptimizerEpsilon
Never run estimation, use provided value.
Transform m_MovingInitialTransform
double m_OptimizerGradientMagnitudeTolerance
double m_OptimizerUpperBound
double m_OptimizerValueTolerance
OptimizerScalesType m_OptimizerScalesType
std::vector< double > m_VirtualDomainOrigin
double m_OptimizerMaximumStepSizeInPhysicalUnits
Transform m_FixedInitialTransform
std::string GetName() const
unsigned int m_OptimizerMaximumLineIterations
double m_OptimizerGrowthFactor
std::string m_StopConditionDescription
Transform m_InitialTransform
double m_OptimizerStepLength
double m_OptimizerRelaxationFactor
double m_OptimizerLineSearchAccuracy
Self & SetFixedInitialTransform(const Transform &transform)
Set transform mapping to the fixed domain.
unsigned int m_OptimizerScalesCentralRegionRadius
bool m_SmoothingSigmasAreSpecifiedInPhysicalUnits
double m_OptimizerScalesSmallParameterVariation
std::vector< unsigned int > m_ShrinkFactorsPerLevel
Transform GetInitialTransform()
Set the initial transform and parameters to optimize.
bool m_MetricUseMovingImageGradientFilter
double m_OptimizerLineSearchMinimumStep
InterpolatorEnum m_Interpolator
itk::ObjectToObjectOptimizerBaseTemplate< double > * m_ActiveOptimizer
unsigned int m_OptimizerMaximumNumberOfFunctionEvaluations
#define SITKRegistration_EXPORT
std::vector< double > m_OptimizerScales
::detail::FunctionTraits< TMemberFunctionPointer >::ClassType ObjectType
Self & SetInterpolator(InterpolatorEnum Interpolator)
Set and get the interpolator to use.
std::vector< unsigned int > m_TransformBSplineScaleFactors
unsigned int m_OptimizerDeltaConvergenceDistance
double m_OptimizerParametersConvergenceTolerance
uint64_t m_NumberOfValidPoints
double m_OptimizerStepTolerance
unsigned int m_OptimizerHessianApproximationAccuracy
An interface method to the modular ITKv4 registration framework.
nsstd::auto_ptr< detail::MemberFunctionFactory< MemberFunctionType > > m_MemberFactory
std::vector< double > m_VirtualDomainDirection
double m_OptimizerLowerBound
unsigned int m_MetricNumberOfHistogramBins
double m_OptimizerLineSearchUpperLimit
Transform GetMovingInitialTransform() const
Set a fixed transform component towards moving domain.
An implementation of the Command design pattern for callback.
double m_OptimizerLearningRate
bool m_InitialTransformInPlace
unsigned int m_OptimizerMaximumNumberOfCorrections
bool m_MetricUseFixedImageGradientFilter
Image m_MetricFixedMaskImage
Self & SmoothingSigmasAreSpecifiedInPhysicalUnitsOff()
Enable the smoothing sigmas for each level in physical units (default) or in terms of voxels...
double m_OptimizerLineSearchMaximumStep
Self & MetricUseFixedImageGradientFilterOff()
Enable image gradient computation by a filter.
unsigned int m_OptimizerNumberOfIterations
Self & MetricUseMovingImageGradientFilterOff()
Enable image gradient computation by a filter.
MetricSamplingStrategyType m_MetricSamplingStrategy
OptimizerType m_OptimizerType
The Image class for SimpleITK.
MetricSamplingStrategyType
Self & MetricUseFixedImageGradientFilterOn()
Enable image gradient computation by a filter.
double m_OptimizerFunctionConvergenceTolerance
double m_OptimizerDeltaConvergenceTolerance
unsigned int m_OptimizerLineSearchMaximumEvaluations
double m_OptimizerSimplexDelta
Self & MetricUseMovingImageGradientFilterOn()
Enable image gradient computation by a filter.
double m_OptimizerMinimumStepLength
double m_OptimizerConvergenceMinimumValue
bool GetInitialTransformInPlace() const
Set the initial transform and parameters to optimize.
Self & SetMovingInitialTransform(const Transform &transform)
Set a fixed transform component towards moving domain.
Estimate learning once each level, ignore provided values.
Self & SmoothingSigmasAreSpecifiedInPhysicalUnitsOn()
Enable the smoothing sigmas for each level in physical units (default) or in terms of voxels...
std::vector< double > m_MetricSamplingPercentage
unsigned int m_OptimizerConvergenceWindowSize
Base class for SimpleITK classes based on ProcessObject.
std::vector< double > m_SmoothingSigmasPerLevel
double m_OptimizerInitialRadius
std::vector< double > m_OptimizerWeights
unsigned int m_MetricSamplingSeed
Transform GetFixedInitialTransform() const
Set transform mapping to the fixed domain.
class ITK_FORWARD_EXPORT Command
ImageRegistrationMethod Self
Image m_MetricMovingMaskImage
nsstd::auto_ptr< detail::MemberFunctionFactory< EvaluateMemberFunctionType > > m_EvaluateMemberFactory
unsigned int m_OptimizerLineSearchMaximumIterations
InterpolatorEnum GetInterpolator()
Set and get the interpolator to use.
unsigned int m_MetricRadius
double m_OptimizerGradientConvergenceTolerance
bool m_OptimizerWithRestarts
double m_OptimizerLineSearchLowerLimit
std::vector< double > m_VirtualDomainSpacing
EstimateLearningRateType m_OptimizerEstimateLearningRate
double m_OptimizerLineSearchEpsilon
double m_MetricVarianceForJointPDFSmoothing