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;
99 std::string
GetName()
const {
return std::string(
"ImageRegistrationMethod"); }
107 std::string ToString()
const;
114 {
return this->m_Interpolator; }
116 { this->m_Interpolator = Interpolator;
return *
this; }
135 #if !defined(SWIG) || defined(JAVASWIG) || defined(CSHARPSWIG)
137 SITK_RETURN_SELF_TYPE_HEADER SetInitialTransform (
const Transform &transform );
139 SITK_RETURN_SELF_TYPE_HEADER SetInitialTransform (
Transform &transform,
bool inPlace=
true );
141 {
return this->m_InitialTransform; }
143 {
return this->m_InitialTransformInPlace;}
160 { this->m_MovingInitialTransform = transform;
return *
this; }
162 {
return this->m_MovingInitialTransform; }
176 { this->m_FixedInitialTransform = transform;
return *
this; }
178 {
return this->m_FixedInitialTransform; }
186 SITK_RETURN_SELF_TYPE_HEADER SetVirtualDomain(
const std::vector<uint32_t> &virtualSize,
187 const std::vector<double> &virtualOrigin,
188 const std::vector<double> &virtualSpacing,
189 const std::vector<double> &virtualDirection );
190 SITK_RETURN_SELF_TYPE_HEADER SetVirtualDomainFromImage(
const Image &virtualImage );
199 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsANTSNeighborhoodCorrelation(
unsigned int radius );
205 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsCorrelation( );
211 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsDemons(
double intensityDifferenceThreshold = 0.001 );
217 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsJointHistogramMutualInformation(
unsigned int numberOfHistogramBins = 20,
218 double varianceForJointPDFSmoothing = 1.5);
224 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsMeanSquares( );
231 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsMattesMutualInformation(
unsigned int numberOfHistogramBins = 50 );
243 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsConjugateGradientLineSearch(
double learningRate,
244 unsigned int numberOfIterations,
245 double convergenceMinimumValue = 1e-6,
246 unsigned int convergenceWindowSize = 10,
247 double lineSearchLowerLimit = 0,
248 double lineSearchUpperLimit = 5.0,
249 double lineSearchEpsilon = 0.01,
250 unsigned int lineSearchMaximumIterations = 20,
251 EstimateLearningRateType estimateLearningRate = Once,
252 double maximumStepSizeInPhysicalUnits = 0.0 );
258 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsRegularStepGradientDescent(
double learningRate,
260 unsigned int numberOfIterations,
261 double relaxationFactor=0.5,
262 double gradientMagnitudeTolerance = 1e-4,
263 EstimateLearningRateType estimateLearningRate = Never,
264 double maximumStepSizeInPhysicalUnits = 0.0);
270 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsGradientDescent(
double learningRate,
271 unsigned int numberOfIterations,
272 double convergenceMinimumValue = 1e-6,
273 unsigned int convergenceWindowSize = 10,
274 EstimateLearningRateType estimateLearningRate = Once,
275 double maximumStepSizeInPhysicalUnits = 0.0);
281 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsGradientDescentLineSearch(
double learningRate,
282 unsigned int numberOfIterations,
283 double convergenceMinimumValue = 1e-6,
284 unsigned int convergenceWindowSize = 10,
285 double lineSearchLowerLimit = 0,
286 double lineSearchUpperLimit = 5.0,
287 double lineSearchEpsilon = 0.01,
288 unsigned int lineSearchMaximumIterations = 20,
289 EstimateLearningRateType estimateLearningRate = Once,
290 double maximumStepSizeInPhysicalUnits = 0.0 );
298 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsLBFGSB(
double gradientConvergenceTolerance = 1e-5,
299 unsigned int numberOfIterations = 500,
300 unsigned int maximumNumberOfCorrections = 5,
301 unsigned int maximumNumberOfFunctionEvaluations = 2000,
302 double costFunctionConvergenceFactor = 1e+7,
303 double lowerBound = std::numeric_limits<double>::min(),
304 double upperBound = std::numeric_limits<double>::max(),
305 bool trace =
false );
323 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsExhaustive(
const std::vector<unsigned int> &numberOfSteps,
324 double stepLength = 1.0 );
330 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsAmoeba(
double simplexDelta,
331 unsigned int numberOfIterations,
332 double parametersConvergenceTolerance=1e-8,
333 double functionConvergenceTolerance=1e-4,
334 bool withRestarts =
false );
347 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerWeights(
const std::vector<double> &weights);
348 std::vector<double> GetOptimizerWeights( )
const;
355 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsPowell(
unsigned int numberOfIterations = 100,
356 unsigned int maximumLineIterations = 100,
357 double stepLength = 1,
358 double stepTolerance = 1e-6,
359 double valueTolerance = 1e-6 );
369 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsOnePlusOneEvolutionary(
unsigned int numberOfIterations = 100,
370 double epsilon = 1.5e-4,
371 double initialRadius = 1.01,
372 double growthFactor = -1.0,
373 double shrinkFactor = -1.0,
379 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerScales(
const std::vector<double> &scales );
387 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerScalesFromJacobian(
unsigned int centralRegionRadius = 5 );
394 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerScalesFromIndexShift(
unsigned int centralRegionRadius = 5,
395 double smallParameterVariation = 0.01 );
403 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerScalesFromPhysicalShift(
unsigned int centralRegionRadius = 5,
404 double smallParameterVariation = 0.01 );
416 SITK_RETURN_SELF_TYPE_HEADER SetMetricFixedMask(
const Image &binaryMask );
427 SITK_RETURN_SELF_TYPE_HEADER SetMetricMovingMask(
const Image &binaryMask );
439 SITK_RETURN_SELF_TYPE_HEADER SetMetricSamplingPercentage(
double percentage,
unsigned int seed =
sitkWallClock);
440 SITK_RETURN_SELF_TYPE_HEADER SetMetricSamplingPercentagePerLevel(
const std::vector<double> &percentage,
unsigned int seed =
sitkWallClock);
453 SITK_RETURN_SELF_TYPE_HEADER SetMetricSamplingStrategy( MetricSamplingStrategyType strategy);
464 SITK_RETURN_SELF_TYPE_HEADER SetMetricUseFixedImageGradientFilter(
bool);
479 SITK_RETURN_SELF_TYPE_HEADER SetMetricUseMovingImageGradientFilter(
bool);
490 SITK_RETURN_SELF_TYPE_HEADER SetShrinkFactorsPerLevel(
const std::vector<unsigned int> &shrinkFactors );
497 SITK_RETURN_SELF_TYPE_HEADER SetSmoothingSigmasPerLevel(
const std::vector<double> &smoothingSigmas );
505 SITK_RETURN_SELF_TYPE_HEADER SetSmoothingSigmasAreSpecifiedInPhysicalUnits(
bool arg);
524 double MetricEvaluate(
const Image &fixed,
const Image & moving );
533 unsigned int GetOptimizerIteration()
const;
534 std::vector<double> GetOptimizerPosition()
const;
535 double GetOptimizerLearningRate()
const;
536 double GetOptimizerConvergenceValue()
const;
537 double GetMetricValue()
const;
540 unsigned int GetCurrentLevel()
const;
549 std::vector<double> GetOptimizerScales()
const;
553 std::string GetOptimizerStopConditionDescription()
const;
557 template<
class TImage>
560 template<
class TImage>
561 double EvaluateInternal (
const Image &fixed,
const Image &moving );
566 template<
unsigned int VDimension>
569 template <
class TImageType>
577 template <
class TImageType>
584 >*,
const TImageType*,
const TImageType* );
586 template <
typename TMetric>
589 template <
typename TTransformAdaptorPo
inter,
typename TRegistrationMethod >
590 std::vector< TTransformAdaptorPointer >
591 CreateTransformParametersAdaptor(
592 TRegistrationMethod* method);
595 virtual void OnActiveProcessDelete( ) throw();
597 virtual
void RemoveITKObserver( EventCommand &e );
601 nsstd::function<
unsigned int()> m_pfGetOptimizerIteration;
602 nsstd::function<
std::vector<
double>()> m_pfGetOptimizerPosition;
603 nsstd::function<
double()> m_pfGetOptimizerLearningRate;
604 nsstd::function<
double()> m_pfGetOptimizerConvergenceValue;
605 nsstd::function<
double()> m_pfGetMetricValue;
606 nsstd::function<
std::vector<
double>()> m_pfGetOptimizerScales;
607 nsstd::function<
std::
string()> m_pfGetOptimizerStopConditionDescription;
610 nsstd::function<
unsigned int()> m_pfGetCurrentLevel;
614 template < class TMemberFunctionPointer >
617 typedef typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType
ObjectType;
619 template<
typename TImageType >
620 TMemberFunctionPointer operator() (
void )
const
622 return &ObjectType::template EvaluateInternal< TImageType >;
652 OnePlusOneEvolutionary
709 MattesMutualInformation
741 #endif // sitkImageRegistrationMethod_h
double m_MetricIntensityDifferenceThreshold
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
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
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.
double m_OptimizerParametersConvergenceTolerance
double m_OptimizerStepTolerance
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...
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 main Image class for SimpleITK.
MetricSamplingStrategyType
Self & MetricUseFixedImageGradientFilterOn()
Enable image gradient computation by a filter.
double m_OptimizerFunctionConvergenceTolerance
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