18#ifndef itkAdvancedImageToImageMetric_h
19#define itkAdvancedImageToImageMetric_h
21#include "itkImageToImageMetric.h"
24#include "itkGradientImageFilter.h"
25#include "itkBSplineInterpolateImageFunction.h"
29#include "itkFixedArray.h"
32#include "itkImageMaskSpatialObject.h"
83template <
typename TFixedImage,
typename TMovingImage>
91 using Superclass = ImageToImageMetric<TFixedImage, TMovingImage>;
103 using typename Superclass::CoordinateRepresentationType;
104 using typename Superclass::MovingImageType;
105 using typename Superclass::MovingImagePixelType;
107 using typename Superclass::MovingImageConstPointer;
108 using typename Superclass::FixedImageType;
110 using typename Superclass::FixedImageConstPointer;
111 using typename Superclass::FixedImageRegionType;
112 using typename Superclass::TransformType;
113 using typename Superclass::TransformPointer;
114 using typename Superclass::InputPointType;
115 using typename Superclass::OutputPointType;
116 using typename Superclass::TransformParametersType;
117 using typename Superclass::TransformJacobianType;
118 using typename Superclass::InterpolatorType;
119 using typename Superclass::InterpolatorPointer;
120 using typename Superclass::RealType;
121 using typename Superclass::GradientPixelType;
122 using typename Superclass::GradientImageType;
123 using typename Superclass::GradientImagePointer;
133 using typename Superclass::MeasureType;
134 using typename Superclass::DerivativeType;
136 using typename Superclass::ParametersType;
180 Superclass::SetFixedImageMask(arg);
187 Superclass::SetMovingImageMask(arg);
190 const FixedImageMaskType *
193 const auto *
const mask = Superclass::GetFixedImageMask();
198 const MovingImageMaskType *
201 const auto *
const mask = Superclass::GetMovingImageMask();
210 this->Superclass::SetTransform(arg);
220 AdvancedTransformType *
227 const AdvancedTransformType *
245 itkGetConstMacro(UseImageSampler,
bool);
250 itkSetMacro(RequiredRatioOfValidSamples,
double);
251 itkGetConstMacro(RequiredRatioOfValidSamples,
double);
266 itkSetMacro(MovingLimitRangeRatio,
double);
267 itkGetConstMacro(MovingLimitRangeRatio,
double);
268 itkSetMacro(FixedLimitRangeRatio,
double);
269 itkGetConstMacro(FixedLimitRangeRatio,
double);
273 itkGetConstMacro(UseFixedImageLimiter,
bool);
274 itkGetConstMacro(UseMovingImageLimiter,
bool);
283 itkSetMacro(UseMovingImageDerivativeScales,
bool);
284 itkGetConstMacro(UseMovingImageDerivativeScales,
bool);
286 itkSetMacro(ScaleGradientWithRespectToMovingImageOrientation,
bool);
287 itkGetConstMacro(ScaleGradientWithRespectToMovingImageOrientation,
bool);
304 itkSetMacro(UseMetricSingleThreaded,
bool);
305 itkGetConstReferenceMacro(UseMetricSingleThreaded,
bool);
306 itkBooleanMacro(UseMetricSingleThreaded);
310 itkSetMacro(UseMultiThread,
bool);
311 itkGetConstReferenceMacro(UseMultiThread,
bool);
312 itkBooleanMacro(UseMultiThread);
337 PrintSelf(std::ostream & os, Indent indent)
const override;
351 BSplineInterpolateImageFunction<MovingImageType, CoordinateRepresentationType, double>;
354 BSplineInterpolateImageFunction<MovingImageType, CoordinateRepresentationType, float>;
402 static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
420 static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
428 static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
465 GetValueAndDerivativePerThreadStruct,
466 PaddedGetValueAndDerivativePerThreadStruct);
468 PaddedGetValueAndDerivativePerThreadStruct,
469 AlignedGetValueAndDerivativePerThreadStruct);
489 itkSetMacro(UseImageSampler,
bool);
513 RealType & movingImageValue,
523 RealType & movingImageValue,
525 const ThreadIdType threadId)
const
537 DerivativeType & imageJacobian)
const;
564 TransformJacobianType & jacobian,
578 itkSetMacro(UseFixedImageLimiter,
bool);
579 itkSetMacro(UseMovingImageLimiter,
bool);
588 itkExceptionMacro(
"Intentionally left unimplemented!");
594 itkExceptionMacro(
"Intentionally left unimplemented!");
600 itkExceptionMacro(
"Intentionally left unimplemented!");
606 itkExceptionMacro(
"Intentionally left unimplemented!");
609 Statistics::MersenneTwisterRandomVariateGenerator &
616 Statistics::MersenneTwisterRandomVariateGenerator &
623 using Superclass::SetTransform;
626 template <
typename... TOptionalThreadId>
629 RealType & movingImageValue,
631 const TOptionalThreadId... optionalThreadId)
const;
655 using Superclass::TransformPoint;
667#ifndef ITK_MANUAL_INSTANTIATION
668# include "itkAdvancedImageToImageMetric.hxx"
An extension of the ITK ImageToImageMetric. It is the intended base class for all elastix metrics.
MovingImagePixelType m_MovingImageTrueMin
MovingImageDerivativeScalesType m_MovingImageDerivativeScales
itkStaticConstMacro(MovingImageDimension, unsigned int, TMovingImage::ImageDimension)
MovingImageLimiterOutputType m_MovingImageMaxLimit
virtual void AfterThreadedGetValue(MeasureType &) const
virtual bool IsInsideMovingMask(const MovingImagePointType &point) const
static constexpr DummyMask m_FixedImageMask
virtual void ThreadedGetValueAndDerivative(ThreadIdType) const
const MovingImageMaskType * GetMovingImageMask() const override
typename BSplineOrder1TransformType::Pointer BSplineOrder1TransformPointer
void Initialize() override
typename TransformType::OutputPointType MovingImagePointType
typename ImageSamplerType::OutputVectorContainerPointer ImageSampleContainerPointer
void PrintSelf(std::ostream &os, Indent indent) const override
ITK_DISALLOW_COPY_AND_MOVE(AdvancedImageToImageMetric)
bool m_TransformIsBSpline
ThreadIdType m_GetValueAndDerivativePerThreadVariablesSize
typename MovingImageType::RegionType MovingImageRegionType
typename AdvancedTransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
bool m_UseFixedImageLimiter
virtual bool EvaluateMovingImageValueAndDerivative(const MovingImagePointType &mappedPoint, RealType &movingImageValue, MovingImageDerivativeType *gradient) const
MovingImageLimiterPointer m_MovingImageLimiter
void CheckForAdvancedTransform()
FixedArray< double, Self::MovingImageDimension > MovingImageDerivativeScalesType
AdvancedTransformType::Pointer m_AdvancedTransform
typename FixedImageType::PixelType FixedImagePixelType
AdvancedLinearInterpolateImageFunction< MovingImageType, CoordinateRepresentationType > LinearInterpolatorType
BSplineInterpolateImageFunction< MovingImageType, CoordinateRepresentationType, float > BSplineInterpolatorFloatType
bool m_UseMetricSingleThreaded
typename DerivativeType::ValueType DerivativeValueType
bool m_UseMovingImageDerivativeScales
AdvancedBSplineDeformableTransform< ScalarType, FixedImageDimension, 3 > BSplineOrder3TransformType
FixedImagePixelType m_FixedImageTrueMin
typename FixedImageLimiterType::Pointer FixedImageLimiterPointer
double m_MovingLimitRangeRatio
virtual void InitializeImageSampler()
void SetFixedImageMask(const typename Superclass::FixedImageMaskType *) final
typename FixedImageIndexType::IndexValueType FixedImageIndexValueType
typename MovingImageType::IndexType MovingImageIndexType
virtual void SetTransform(AdvancedTransformType *arg)
void LaunchGetValueAndDerivativeThreaderCallback() const
Statistics::MersenneTwisterRandomVariateGenerator & GetRandomVariateGenerator()
typename ImageSamplerType::OutputVectorContainerType ImageSampleContainerType
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION GetValueAndDerivativeThreaderCallback(void *arg)
typename MovingImageType::Pointer MovingImagePointer
BSplineInterpolatorFloatPointer m_BSplineInterpolatorFloat
ImageMaskSpatialObject< Self::FixedImageDimension > FixedImageMaskType
bool FastEvaluateMovingImageValueAndDerivative(const MovingImagePointType &mappedPoint, RealType &movingImageValue, MovingImageDerivativeType *gradient, const ThreadIdType threadId) const
void SetFixedImageMask(typename Superclass::FixedImageMaskType *) final
typename BSplineOrder3TransformType::Pointer BSplineOrder3TransformPointer
void LaunchGetValueThreaderCallback() const
virtual void InitializeThreadingParameters() const
~AdvancedImageToImageMetric() override=default
typename FixedImageType::Pointer FixedImagePointer
ImageSamplerPointer m_ImageSampler
typename ReducedBSplineInterpolatorType::Pointer ReducedBSplineInterpolatorPointer
virtual void BeforeThreadedGetValueAndDerivative(const TransformParametersType ¶meters) const
typename BSplineOrder2TransformType::Pointer BSplineOrder2TransformPointer
bool m_UseMovingImageLimiter
bool m_ScaleGradientWithRespectToMovingImageOrientation
void SetRandomVariateGenerator(Statistics::MersenneTwisterRandomVariateGenerator &randomVariateGenerator)
AdvancedTransform< ScalarType, FixedImageDimension, MovingImageDimension > AdvancedTransformType
typename FixedImageType::IndexType FixedImageIndexType
BSplineInterpolatorPointer m_BSplineInterpolator
SmartPointer< MovingImageMaskType > MovingImageMaskPointer
virtual void ThreadedGetValue(ThreadIdType) const
MovingImageLimiterOutputType m_MovingImageMinLimit
double m_FixedLimitRangeRatio
Statistics::MersenneTwisterRandomVariateGenerator & GetMutableRandomVariateGenerator() const
elx::DefaultConstruct< Statistics::MersenneTwisterRandomVariateGenerator > m_DefaultRandomVariateGenerator
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedGetValueAndDerivativePerThreadStruct, AlignedGetValueAndDerivativePerThreadStruct)
AdvancedBSplineDeformableTransform< ScalarType, FixedImageDimension, 1 > BSplineOrder1TransformType
LimiterFunctionBase< RealType, FixedImageDimension > FixedImageLimiterType
AdvancedImageToImageMetric()
typename BSplineInterpolatorType::Pointer BSplineInterpolatorPointer
bool EvaluateMovingImageValueAndDerivativeWithOptionalThreadId(const MovingImagePointType &mappedPoint, RealType &movingImageValue, MovingImageDerivativeType *gradient, const TOptionalThreadId... optionalThreadId) const
ImageSamplerBase< FixedImageType > ImageSamplerType
FixedImageLimiterPointer m_FixedImageLimiter
FixedImageLimiterOutputType m_FixedImageMinLimit
MultiThreaderBase::WorkUnitInfo ThreadInfoType
typename BSplineInterpolatorType::CovariantVectorType MovingImageDerivativeType
void CheckForBSplineTransform() const
virtual void AfterThreadedGetValueAndDerivative(MeasureType &, DerivativeType &) const
ReducedBSplineInterpolatorPointer m_ReducedBSplineInterpolator
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION AccumulateDerivativesThreaderCallback(void *arg)
FixedImagePixelType m_FixedImageTrueMax
virtual void SetMovingImageMask(const MovingImageMaskType *const arg)
virtual void EvaluateTransformJacobianInnerProduct(const TransformJacobianType &jacobian, const MovingImageDerivativeType &movingImageDerivative, DerivativeType &imageJacobian) const
std::unique_ptr< AlignedGetValueAndDerivativePerThreadStruct[]> m_GetValueAndDerivativePerThreadVariables
FixedImageLimiterOutputType m_FixedImageMaxLimit
SmartPointer< const Self > ConstPointer
LimiterFunctionBase< RealType, MovingImageDimension > MovingImageLimiterType
const FixedImageMaskType * GetFixedImageMask() const override
MovingImagePointType TransformPoint(const FixedImagePointType &fixedImagePoint) const
typename MovingImageLimiterType::OutputType MovingImageLimiterOutputType
void CheckNumberOfSamples() const
ImageSamplerType * GetImageSampler() const
typename TransformType::InputPointType FixedImagePointType
const AdvancedTransformType * GetTransform() const override
itkOverrideGetNameOfClassMacro(AdvancedImageToImageMetric)
double m_RequiredRatioOfValidSamples
void SetMovingImageMask(const typename Superclass::MovingImageMaskType *) final
typename FixedImageLimiterType::OutputType FixedImageLimiterOutputType
void InitializeLimiters()
SmartPointer< FixedImageMaskType > FixedImageMaskPointer
itkStaticConstMacro(FixedImageDimension, unsigned int, TFixedImage::ImageDimension)
void SetMovingImageMask(typename Superclass::MovingImageMaskType *) final
typename BSplineInterpolatorFloatType::Pointer BSplineInterpolatorFloatPointer
BSplineInterpolateImageFunction< MovingImageType, CoordinateRepresentationType, double > BSplineInterpolatorType
AdvancedTransformType * GetTransform() override
ReducedDimensionBSplineInterpolateImageFunction< MovingImageType, CoordinateRepresentationType, double > ReducedBSplineInterpolatorType
typename TransformType::ScalarType ScalarType
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION GetValueThreaderCallback(void *arg)
virtual void SetFixedImageMask(const FixedImageMaskType *const arg)
SmartPointer< const FixedImageMaskType > FixedImageMaskConstPointer
Statistics::MersenneTwisterRandomVariateGenerator * m_RandomVariateGenerator
typename ImageSamplerType::Pointer ImageSamplerPointer
bool EvaluateTransformJacobian(const FixedImagePointType &fixedImagePoint, TransformJacobianType &jacobian, NonZeroJacobianIndicesType &nzji) const
typename InterpolatorType::ContinuousIndexType MovingImageContinuousIndexType
AdvancedCombinationTransform< ScalarType, FixedImageDimension > CombinationTransformType
typename AdvancedTransformType::NumberOfParametersType NumberOfParametersType
AdvancedBSplineDeformableTransform< ScalarType, FixedImageDimension, 2 > BSplineOrder2TransformType
static constexpr DummyMask m_MovingImageMask
SmartPointer< Self > Pointer
SmartPointer< const MovingImageMaskType > MovingImageMaskConstPointer
void CheckForBSplineInterpolator()
typename MovingImageLimiterType::Pointer MovingImageLimiterPointer
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, GetValueAndDerivativePerThreadStruct, PaddedGetValueAndDerivativePerThreadStruct)
MovingImagePixelType m_MovingImageTrueMax
ImageMaskSpatialObject< Self::MovingImageDimension > MovingImageMaskType
MultiThreaderParameterType m_ThreaderMetricParameters
typename LinearInterpolatorType::Pointer LinearInterpolatorPointer
LinearInterpolatorPointer m_LinearInterpolator
Linearly interpolate an image at specified positions.
SmartPointer< Self > Pointer
This class is a base class for any image sampler.
typename OutputVectorContainerType::Pointer OutputVectorContainerPointer
SmartPointer< Self > Pointer
VectorDataContainer< ImageSample< FixedImageType > > OutputVectorContainerType
Base class for all ITK limiter function objects.
SmartPointer< Self > Pointer
Evaluates the B-Spline interpolation of an image. Spline order may be from 0 to 5.
SmartPointer< Self > Pointer
DerivativeType st_Derivative
SizeValueType st_NumberOfPixelsCounted
DerivativeValueType st_NormalizationFactor
DerivativeValueType * st_DerivativePointer
AdvancedImageToImageMetric * st_Metric