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;
100 std::string
GetName()
const {
return std::string(
"ImageRegistrationMethod"); }
108 std::string ToString()
const;
115 {
return this->m_Interpolator; }
117 { this->m_Interpolator = Interpolator;
return *
this; }
136 #if !defined(SWIG) || defined(JAVASWIG) || defined(CSHARPSWIG)
138 SITK_RETURN_SELF_TYPE_HEADER SetInitialTransform (
const Transform &transform );
140 SITK_RETURN_SELF_TYPE_HEADER SetInitialTransform (
Transform &transform,
bool inPlace=
true );
142 {
return this->m_InitialTransform; }
144 {
return this->m_InitialTransformInPlace;}
161 { this->m_MovingInitialTransform = transform;
return *
this; }
163 {
return this->m_MovingInitialTransform; }
177 { this->m_FixedInitialTransform = transform;
return *
this; }
179 {
return this->m_FixedInitialTransform; }
187 SITK_RETURN_SELF_TYPE_HEADER SetVirtualDomain(
const std::vector<uint32_t> &virtualSize,
188 const std::vector<double> &virtualOrigin,
189 const std::vector<double> &virtualSpacing,
190 const std::vector<double> &virtualDirection );
191 SITK_RETURN_SELF_TYPE_HEADER SetVirtualDomainFromImage(
const Image &virtualImage );
200 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsANTSNeighborhoodCorrelation(
unsigned int radius );
206 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsCorrelation( );
212 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsDemons(
double intensityDifferenceThreshold = 0.001 );
218 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsJointHistogramMutualInformation(
unsigned int numberOfHistogramBins = 20,
219 double varianceForJointPDFSmoothing = 1.5);
225 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsMeanSquares( );
232 SITK_RETURN_SELF_TYPE_HEADER SetMetricAsMattesMutualInformation(
unsigned int numberOfHistogramBins = 50 );
244 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsConjugateGradientLineSearch(
double learningRate,
245 unsigned int numberOfIterations,
246 double convergenceMinimumValue = 1e-6,
247 unsigned int convergenceWindowSize = 10,
248 double lineSearchLowerLimit = 0,
249 double lineSearchUpperLimit = 5.0,
250 double lineSearchEpsilon = 0.01,
251 unsigned int lineSearchMaximumIterations = 20,
252 EstimateLearningRateType estimateLearningRate = Once,
253 double maximumStepSizeInPhysicalUnits = 0.0 );
259 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsRegularStepGradientDescent(
double learningRate,
261 unsigned int numberOfIterations,
262 double relaxationFactor=0.5,
263 double gradientMagnitudeTolerance = 1e-4,
264 EstimateLearningRateType estimateLearningRate = Never,
265 double maximumStepSizeInPhysicalUnits = 0.0);
271 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsGradientDescent(
double learningRate,
272 unsigned int numberOfIterations,
273 double convergenceMinimumValue = 1e-6,
274 unsigned int convergenceWindowSize = 10,
275 EstimateLearningRateType estimateLearningRate = Once,
276 double maximumStepSizeInPhysicalUnits = 0.0);
282 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsGradientDescentLineSearch(
double learningRate,
283 unsigned int numberOfIterations,
284 double convergenceMinimumValue = 1e-6,
285 unsigned int convergenceWindowSize = 10,
286 double lineSearchLowerLimit = 0,
287 double lineSearchUpperLimit = 5.0,
288 double lineSearchEpsilon = 0.01,
289 unsigned int lineSearchMaximumIterations = 20,
290 EstimateLearningRateType estimateLearningRate = Once,
291 double maximumStepSizeInPhysicalUnits = 0.0 );
299 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsLBFGSB(
double gradientConvergenceTolerance = 1e-5,
300 unsigned int numberOfIterations = 500,
301 unsigned int maximumNumberOfCorrections = 5,
302 unsigned int maximumNumberOfFunctionEvaluations = 2000,
303 double costFunctionConvergenceFactor = 1e+7,
304 double lowerBound = std::numeric_limits<double>::min(),
305 double upperBound = std::numeric_limits<double>::max(),
306 bool trace =
false );
320 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsLBFGS2(
double solutionAccuracy = 1e-5,
321 unsigned int numberOfIterations = 0,
322 unsigned int hessianApproximateAccuracy = 6,
323 unsigned int deltaConvergenceDistance = 0,
324 double deltaConvergenceTolerance = 1e-5,
325 unsigned int lineSearchMaximumEvaluations = 40,
326 double lineSearchMinimumStep = 1e-20,
327 double lineSearchMaximumStep = 1e20,
328 double lineSearchAccuracy = 1e-4);
347 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsExhaustive(
const std::vector<unsigned int> &numberOfSteps,
348 double stepLength = 1.0 );
354 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsAmoeba(
double simplexDelta,
355 unsigned int numberOfIterations,
356 double parametersConvergenceTolerance=1e-8,
357 double functionConvergenceTolerance=1e-4,
358 bool withRestarts =
false );
371 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerWeights(
const std::vector<double> &weights);
372 std::vector<double> GetOptimizerWeights( )
const;
379 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsPowell(
unsigned int numberOfIterations = 100,
380 unsigned int maximumLineIterations = 100,
381 double stepLength = 1,
382 double stepTolerance = 1e-6,
383 double valueTolerance = 1e-6 );
393 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerAsOnePlusOneEvolutionary(
unsigned int numberOfIterations = 100,
394 double epsilon = 1.5e-4,
395 double initialRadius = 1.01,
396 double growthFactor = -1.0,
397 double shrinkFactor = -1.0,
403 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerScales(
const std::vector<double> &scales );
411 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerScalesFromJacobian(
unsigned int centralRegionRadius = 5 );
418 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerScalesFromIndexShift(
unsigned int centralRegionRadius = 5,
419 double smallParameterVariation = 0.01 );
427 SITK_RETURN_SELF_TYPE_HEADER SetOptimizerScalesFromPhysicalShift(
unsigned int centralRegionRadius = 5,
428 double smallParameterVariation = 0.01 );
440 SITK_RETURN_SELF_TYPE_HEADER SetMetricFixedMask(
const Image &binaryMask );
451 SITK_RETURN_SELF_TYPE_HEADER SetMetricMovingMask(
const Image &binaryMask );
463 SITK_RETURN_SELF_TYPE_HEADER SetMetricSamplingPercentage(
double percentage,
unsigned int seed =
sitkWallClock);
464 SITK_RETURN_SELF_TYPE_HEADER SetMetricSamplingPercentagePerLevel(
const std::vector<double> &percentage,
unsigned int seed =
sitkWallClock);
477 SITK_RETURN_SELF_TYPE_HEADER SetMetricSamplingStrategy( MetricSamplingStrategyType strategy);
488 SITK_RETURN_SELF_TYPE_HEADER SetMetricUseFixedImageGradientFilter(
bool);
503 SITK_RETURN_SELF_TYPE_HEADER SetMetricUseMovingImageGradientFilter(
bool);
514 SITK_RETURN_SELF_TYPE_HEADER SetShrinkFactorsPerLevel(
const std::vector<unsigned int> &shrinkFactors );
521 SITK_RETURN_SELF_TYPE_HEADER SetSmoothingSigmasPerLevel(
const std::vector<double> &smoothingSigmas );
529 SITK_RETURN_SELF_TYPE_HEADER SetSmoothingSigmasAreSpecifiedInPhysicalUnits(
bool arg);
548 double MetricEvaluate(
const Image &fixed,
const Image & moving );
557 unsigned int GetOptimizerIteration()
const;
558 std::vector<double> GetOptimizerPosition()
const;
559 double GetOptimizerLearningRate()
const;
560 double GetOptimizerConvergenceValue()
const;
561 double GetMetricValue()
const;
564 unsigned int GetCurrentLevel()
const;
573 std::vector<double> GetOptimizerScales()
const;
577 std::string GetOptimizerStopConditionDescription()
const;
581 template<
class TImage>
584 template<
class TImage>
585 double EvaluateInternal (
const Image &fixed,
const Image &moving );
590 template<
unsigned int VDimension>
593 template <
class TImageType>
601 template <
class TImageType>
608 >*,
const TImageType*,
const TImageType* );
610 template <
typename TMetric>
613 template <
typename TTransformAdaptorPo
inter,
typename TRegistrationMethod >
614 std::vector< TTransformAdaptorPointer >
615 CreateTransformParametersAdaptor(
616 TRegistrationMethod* method);
621 virtual
void RemoveITKObserver( EventCommand &e );
625 nsstd::function<
unsigned int()> m_pfGetOptimizerIteration;
626 nsstd::function<std::vector<
double>()> m_pfGetOptimizerPosition;
627 nsstd::function<
double()> m_pfGetOptimizerLearningRate;
628 nsstd::function<
double()> m_pfGetOptimizerConvergenceValue;
629 nsstd::function<
double()> m_pfGetMetricValue;
630 nsstd::function<std::vector<
double>()> m_pfGetOptimizerScales;
631 nsstd::function<std::
string()> m_pfGetOptimizerStopConditionDescription;
634 nsstd::function<
unsigned int()> m_pfGetCurrentLevel;
638 template < class TMemberFunctionPointer >
641 typedef typename ::detail::FunctionTraits<TMemberFunctionPointer>::ClassType
ObjectType;
643 template<
typename TImageType >
644 TMemberFunctionPointer operator() (
void )
const
646 return &ObjectType::template EvaluateInternal< TImageType >;
744 MattesMutualInformation
776 #endif // sitkImageRegistrationMethod_h