Loading...
Searching...
No Matches
elastix::MetricBase< TElastix > Class Template Reference
Components » Metrics | Core » Component Base Classes

`#include <elxMetricBase.h>`

## Detailed Description

template<class TElastix>
class elastix::MetricBase< TElastix >

This class is the elastix base class for all Metrics.

This class contains the common functionality for all Metrics.

The parameters used in this class are:

Parameters

  ShowExactMetricValue: Flag that can set to "true" or "false". If "true" the metric computes the exact metric value (computed on all voxels rather than on the set of spatial samples) and shows it each iteration. Must be given for each resolution.
  example: (ShowExactMetricValue "true" "true" "false")
  Default is "false" for all resolutions.

  ExactMetricSampleGridSpacing: Set an integer downsampling rate for computing the "exact" metric. Only meaningful if set in combination with the ShowExactMetricValue set to "true". In some cases, it might be an overkill to really compute the exact metric with the ShowExactMetricValue. The metric computed on a downsampled image might already be accurate enough to draw conclusions about the rate of convergence for example. The downsampling rate must be given for each resolution, for each dimension.
  example: (ExactMetricSampleGridSpacing 1 1 2 2 )
  This example for a 2D registration of 2 resolutions sets the downsampling rate to 1 in the first resolution (so: use really all pixels), and to 2 in the second resolution. Default: 1 in each resolution and each dimension.

  CheckNumberOfSamples: Whether the metric checks if at least a certain fraction (default 1/4) of the samples map inside the moving image. Can be given for each resolution or for all resolutions at once.
  example: (CheckNumberOfSamples "false" "true" "false")
  The default is true. In general it is wise to set this to true, since it detects if the registration is going really bad.

  RequiredRatioOfValidSamples: Defines the fraction needed in CheckNumberOfSamples.
  example: (RequiredRatioOfValidSamples 0.1)
  The default is 0.25.

Definition at line 72 of file elxMetricBase.h.

Inheritance diagram for elastix::MetricBase< TElastix >:
[legend]

## Public Types

using | AdvancedMetricType = itk::AdvancedImageToImageMetric<FixedImageType, MovingImageType>
using | CoordinateRepresentationType = typename ITKBaseType::ParametersValueType
using | ElastixType
using | FixedImageType = typename ElastixType::FixedImageType
using | FixedPointSetType
using | FixedPointType = typename FixedImageType::PointType
using | FixedPointValueType = typename FixedPointType::ValueType
using | ImageSamplerBaseType = typename AdvancedMetricType::ImageSamplerType
using | ITKBaseType = itk::SingleValuedCostFunction
using | MeasureType = typename ITKBaseType::MeasureType
using | MovingImageDerivativeScalesType = typename AdvancedMetricType::MovingImageDerivativeScalesType
using | MovingImageType = typename ElastixType::MovingImageType
using | MovingPointSetType
using | MovingPointType = typename MovingImageType::PointType
using | MovingPointValueType = typename MovingPointType::ValueType
using | RegistrationType
using | Self = MetricBase
using | Superclass = BaseComponentSE<TElastix>
Public Types inherited from elastix::BaseComponentSE< TElastix >
using | ElastixType = TElastix
using | RegistrationType = typename ElastixType::RegistrationBaseType
using | Self = BaseComponentSE
using | Superclass = BaseComponent

## Public Member Functions

void | AfterEachIterationBase () override
void | BeforeEachResolutionBase () override
virtual ImageSamplerBaseType * | GetAdvancedMetricImageSampler () const
virtual bool | GetAdvancedMetricUseImageSampler () const
ITKBaseType * | GetAsITKBaseType ()
const ITKBaseType * | GetAsITKBaseType () const
virtual const char * | GetClassName () const
virtual MeasureType | GetCurrentExactMetricValue () const
virtual bool | GetShowExactMetricValue () const
| ITK_DISALLOW_COPY_AND_MOVE (MetricBase)
| itkStaticConstMacro (FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
| itkStaticConstMacro (MovingImageDimension, unsigned int, MovingImageType::ImageDimension)
virtual void | SelectNewSamples ()
virtual void | SetAdvancedMetricImageSampler (ImageSamplerBaseType *sampler)
Public Member Functions inherited from elastix::BaseComponentSE< TElastix >
void | AddTargetCellToIterationInfo (const char *const name)
const Configuration * | GetConfiguration () const
ElastixType * | GetElastix () const
auto & | GetIterationInfoAt (const char *const name)
RegistrationType * | GetRegistration () const
| ITK_DISALLOW_COPY_AND_MOVE (BaseComponentSE)
void | RemoveTargetCellFromIterationInfo (const char *const name)
void | SetConfiguration (const Configuration *_arg)
void | SetElastix (ElastixType *_arg)
Public Member Functions inherited from elastix::BaseComponent
virtual void | AfterEachIteration ()
virtual void | AfterEachResolution ()
virtual void | AfterEachResolutionBase ()
virtual void | AfterRegistration ()
virtual void | AfterRegistrationBase ()
virtual int | BeforeAll ()
virtual int | BeforeAllBase ()
virtual void | BeforeEachResolution ()
virtual void | BeforeRegistration ()
virtual void | BeforeRegistrationBase ()
virtual const char * | elxGetClassName () const
const char * | GetComponentLabel () const
| ITK_DISALLOW_COPY_AND_MOVE (BaseComponent)
| itkTypeMacroNoParent (BaseComponent)
void | SetComponentLabel (const char *label, unsigned int idx)

## Protected Types

using | ExactMetricImageSamplerPointer = typename ExactMetricImageSamplerType::Pointer
using | ExactMetricImageSamplerType = itk::ImageGridSampler<FixedImageType>
using | ExactMetricSampleGridSpacingType = typename ExactMetricImageSamplerType::SampleGridSpacingType
using | ParametersType = typename ITKBaseType::ParametersType

## Protected Member Functions

virtual MeasureType | GetExactValue (const ParametersType &parameters)
| MetricBase ()=default
| ~MetricBase () override=default
Protected Member Functions inherited from elastix::BaseComponentSE< TElastix >
| BaseComponentSE ()=default
| ~BaseComponentSE () override=default
Protected Member Functions inherited from elastix::BaseComponent
| BaseComponent ()=default
virtual | ~BaseComponent ()=default

## Protected Attributes

MeasureType | m_CurrentExactMetricValue { 0.0 }
unsigned int | m_ExactMetricEachXNumberOfIterations { 1 }
ExactMetricSampleGridSpacingType | m_ExactMetricSampleGridSpacing
ExactMetricImageSamplerPointer | m_ExactMetricSampler { nullptr }
bool | m_ShowExactMetricValue { false }
Protected Attributes inherited from elastix::BaseComponentSE< TElastix >
Configuration::ConstPointer | m_Configuration {}
itk::WeakPointer< TElastix > | m_Elastix {}
RegistrationType * | m_Registration {}

## Private Member Functions

| elxDeclarePureVirtualGetSelfMacro (ITKBaseType)

## Additional Inherited Members

Static Public Member Functions inherited from elastix::BaseComponent
template<typename TBaseComponent>
static auto | AsITKBaseType (TBaseComponent *const baseComponent) -> decltype(baseComponent->GetAsITKBaseType())
static void | InitializeElastixExecutable ()
static bool | IsElastixLibrary ()

## Member Typedef Documentation

## AdvancedMetricType

template<class TElastix>

using elastix::MetricBase< TElastix >::AdvancedMetricType = itk::AdvancedImageToImageMetric<FixedImageType, MovingImageType>

Definition at line 98 of file elxMetricBase.h.

## CoordinateRepresentationType

template<class TElastix>

using elastix::MetricBase< TElastix >::CoordinateRepresentationType = typename ITKBaseType::ParametersValueType

Typedefs for point sets.

Definition at line 107 of file elxMetricBase.h.

## ElastixType

template<class TElastix>

using elastix::BaseComponentSE< TElastix >::ElastixType

Elastix typedef.

Definition at line 57 of file elxBaseComponentSE.h.

## ExactMetricImageSamplerPointer

template<class TElastix>

using elastix::MetricBase< TElastix >::ExactMetricImageSamplerPointer = typename ExactMetricImageSamplerType::Pointer

protected

Definition at line 206 of file elxMetricBase.h.

## ExactMetricImageSamplerType

template<class TElastix>

using elastix::MetricBase< TElastix >::ExactMetricImageSamplerType = itk::ImageGridSampler<FixedImageType>

protected

The full sampler used by the GetExactValue method.

Definition at line 205 of file elxMetricBase.h.

## ExactMetricSampleGridSpacingType

template<class TElastix>

using elastix::MetricBase< TElastix >::ExactMetricSampleGridSpacingType = typename ExactMetricImageSamplerType::SampleGridSpacingType

protected

Definition at line 207 of file elxMetricBase.h.

## FixedImageType

template<class TElastix>

using elastix::MetricBase< TElastix >::FixedImageType = typename ElastixType::FixedImageType

Other typedef's.

Definition at line 89 of file elxMetricBase.h.

## FixedPointSetType

template<class TElastix>

using elastix::MetricBase< TElastix >::FixedPointSetType

Initial value:
itk::PointSet<CoordinateRepresentationType,
FixedImageDimension,
itk::DefaultStaticMeshTraits<CoordinateRepresentationType,
FixedImageDimension,
FixedImageDimension,
CoordinateRepresentationType,
CoordinateRepresentationType,
CoordinateRepresentationType>>
elastix::MetricBase::CoordinateRepresentationType
typename ITKBaseType::ParametersValueType CoordinateRepresentationType
Definition elxMetricBase.h:107

Definition at line 108 of file elxMetricBase.h.

## FixedPointType

template<class TElastix>

using elastix::MetricBase< TElastix >::FixedPointType = typename FixedImageType::PointType

Definition at line 90 of file elxMetricBase.h.

## FixedPointValueType

template<class TElastix>

using elastix::MetricBase< TElastix >::FixedPointValueType = typename FixedPointType::ValueType

Definition at line 91 of file elxMetricBase.h.

## ImageSamplerBaseType

template<class TElastix>

using elastix::MetricBase< TElastix >::ImageSamplerBaseType = typename AdvancedMetricType::ImageSamplerType

Typedefs for sampler support.

Definition at line 126 of file elxMetricBase.h.

## ITKBaseType

template<class TElastix>

using elastix::MetricBase< TElastix >::ITKBaseType = itk::SingleValuedCostFunction

ITKBaseType.

Definition at line 97 of file elxMetricBase.h.

## MeasureType

template<class TElastix>

using elastix::MetricBase< TElastix >::MeasureType = typename ITKBaseType::MeasureType

Return type of GetValue

Definition at line 129 of file elxMetricBase.h.

## MovingImageDerivativeScalesType

template<class TElastix>

using elastix::MetricBase< TElastix >::MovingImageDerivativeScalesType = typename AdvancedMetricType::MovingImageDerivativeScalesType

Definition at line 99 of file elxMetricBase.h.

## MovingImageType

template<class TElastix>

using elastix::MetricBase< TElastix >::MovingImageType = typename ElastixType::MovingImageType

Definition at line 92 of file elxMetricBase.h.

## MovingPointSetType

template<class TElastix>

using elastix::MetricBase< TElastix >::MovingPointSetType

Initial value:
itk::PointSet<CoordinateRepresentationType,
MovingImageDimension,
itk::DefaultStaticMeshTraits<CoordinateRepresentationType,
MovingImageDimension,
MovingImageDimension,
CoordinateRepresentationType,
CoordinateRepresentationType,
CoordinateRepresentationType>>

Definition at line 116 of file elxMetricBase.h.

## MovingPointType

template<class TElastix>

using elastix::MetricBase< TElastix >::MovingPointType = typename MovingImageType::PointType

Definition at line 93 of file elxMetricBase.h.

## MovingPointValueType

template<class TElastix>

using elastix::MetricBase< TElastix >::MovingPointValueType = typename MovingPointType::ValueType

Definition at line 94 of file elxMetricBase.h.

## ParametersType

template<class TElastix>

using elastix::MetricBase< TElastix >::ParametersType = typename ITKBaseType::ParametersType

protected

The parameters type.

Definition at line 202 of file elxMetricBase.h.

## RegistrationType

template<class TElastix>

using elastix::BaseComponentSE< TElastix >::RegistrationType

RegistrationType; NB: this is the elx::RegistrationBase not an itk::Object or something like that.

Definition at line 62 of file elxBaseComponentSE.h.

## Self

template<class TElastix>

using elastix::MetricBase< TElastix >::Self = MetricBase

Standard ITK stuff.

Definition at line 78 of file elxMetricBase.h.

## Superclass

template<class TElastix>

using elastix::MetricBase< TElastix >::Superclass = BaseComponentSE<TElastix>

Definition at line 79 of file elxMetricBase.h.

## Constructor & Destructor Documentation

## MetricBase()

template<class TElastix>

elastix::MetricBase< TElastix >::MetricBase | ( |  | ) |

protected default

The constructor.

## ~MetricBase()

template<class TElastix>

elastix::MetricBase< TElastix >::~MetricBase | ( |  | ) |

override protected default

The destructor.

## Member Function Documentation

## AfterEachIterationBase()

template<class TElastix>

void elastix::MetricBase< TElastix >::AfterEachIterationBase | ( |  | ) |

override virtual

Execute stuff after each iteration:

- Optionally compute the exact metric value and plot it to screen.

Reimplemented from elastix::BaseComponent.

## BeforeEachResolutionBase()

template<class TElastix>

void elastix::MetricBase< TElastix >::BeforeEachResolutionBase | ( |  | ) |

override virtual

Execute stuff before each resolution:

- Check if the exact metric value should be computed (to monitor the progress of the registration).

Reimplemented from elastix::BaseComponent.

## elxDeclarePureVirtualGetSelfMacro()

template<class TElastix>

elastix::MetricBase< TElastix >::elxDeclarePureVirtualGetSelfMacro | ( | ITKBaseType |  | ) |

private

## GetAdvancedMetricImageSampler()

template<class TElastix>

virtual ImageSamplerBaseType * elastix::MetricBase< TElastix >::GetAdvancedMetricImageSampler | ( |  | ) | const

virtual

Methods to get the image sampler. The image sampler is only used when the metric is of type AdvancedMetricType, and has UseImageSampler set to true. In other cases, the function returns 0.

## GetAdvancedMetricUseImageSampler()

template<class TElastix>

virtual bool elastix::MetricBase< TElastix >::GetAdvancedMetricUseImageSampler | ( |  | ) | const

virtual

Returns whether the metric uses a sampler. When the metric is not of AdvancedMetricType, the function returns false immediately.

## GetAsITKBaseType() [1/2]

template<class TElastix>

ITKBaseType * elastix::MetricBase< TElastix >::GetAsITKBaseType | ( |  | ) |

inline

Retrieves this object as ITKBaseType.

Definition at line 133 of file elxMetricBase.h.

## GetAsITKBaseType() [2/2]

template<class TElastix>

const ITKBaseType * elastix::MetricBase< TElastix >::GetAsITKBaseType | ( |  | ) | const

inline

Retrieves this object as ITKBaseType, to use in const functions.

Definition at line 141 of file elxMetricBase.h.

## GetClassName()

template<class TElastix>

virtual const char * elastix::MetricBase< TElastix >::GetClassName | ( |  | ) | const

virtual

Run-time type information (and related methods).

Reimplemented in elastix::AdvancedKappaStatisticMetric< TElastix >, elastix::AdvancedMattesMutualInformationMetric< TElastix >, elastix::AdvancedMeanSquaresMetric< TElastix >, elastix::AdvancedNormalizedCorrelationMetric< TElastix >, elastix::CorrespondingPointsEuclideanDistanceMetric< TElastix >, elastix::DisplacementMagnitudePenalty< TElastix >, elastix::DistancePreservingRigidityPenalty< TElastix >, elastix::GradientDifferenceMetric< TElastix >, elastix::KNNGraphAlphaMutualInformationMetric< TElastix >, elastix::MissingStructurePenalty< TElastix >, elastix::NormalizedGradientCorrelationMetric< TElastix >, elastix::NormalizedMutualInformationMetric< TElastix >, elastix::PatternIntensityMetric< TElastix >, elastix::PCAMetric2< TElastix >, elastix::PCAMetric< TElastix >, elastix::PolydataDummyPenalty< TElastix >, elastix::StatisticalShapePenalty< TElastix >, elastix::SumOfPairwiseCorrelationCoefficientsMetric< TElastix >, elastix::SumSquaredTissueVolumeDifferenceMetric< TElastix >, elastix::TransformBendingEnergyPenalty< TElastix >, elastix::TransformRigidityPenalty< TElastix >, and elastix::VarianceOverLastDimensionMetric< TElastix >.

## GetCurrentExactMetricValue()

template<class TElastix>

virtual MeasureType elastix::MetricBase< TElastix >::GetCurrentExactMetricValue | ( |  | ) | const

inline virtual

Get the last computed exact metric value

Definition at line 195 of file elxMetricBase.h.

## GetExactValue()

template<class TElastix>

virtual MeasureType elastix::MetricBase< TElastix >::GetExactValue | ( | const ParametersType & | parameters | ) |

protected virtual

Get the exact value. Mutual information computed over all points. It is meant in situations when you optimize using just a subset of pixels, but are interested in the exact value of the metric.

This method only works when the itkYourMetric inherits from the AdvancedMetricType. In other cases it returns 0. You may re-implement this method in the elxYourMetric, if you like.

## GetShowExactMetricValue()

template<class TElastix>

virtual bool elastix::MetricBase< TElastix >::GetShowExactMetricValue | ( |  | ) | const

inline virtual

Get if the exact metric value is computed

Definition at line 188 of file elxMetricBase.h.

## ITK_DISALLOW_COPY_AND_MOVE()

template<class TElastix>

elastix::MetricBase< TElastix >::ITK_DISALLOW_COPY_AND_MOVE | ( | MetricBase< TElastix > |  | ) |

## itkStaticConstMacro() [1/2]

template<class TElastix>

elastix::MetricBase< TElastix >::itkStaticConstMacro | ( | FixedImageDimension | ,
|  | unsigned int | ,
|  | FixedImageType::ImageDimension | )

Get the dimension of the fixed image.

## itkStaticConstMacro() [2/2]

template<class TElastix>

elastix::MetricBase< TElastix >::itkStaticConstMacro | ( | MovingImageDimension | ,
|  | unsigned int | ,
|  | MovingImageType::ImageDimension | )

Get the dimension of the moving image.

## SelectNewSamples()

template<class TElastix>

virtual void elastix::MetricBase< TElastix >::SelectNewSamples | ( |  | ) |

virtual

Force the metric to base its computation on a new subset of image samples. Not every metric may have implemented this.

Reimplemented in elastix::CorrespondingPointsEuclideanDistanceMetric< TElastix >, elastix::MissingStructurePenalty< TElastix >, elastix::PolydataDummyPenalty< TElastix >, elastix::StatisticalShapePenalty< TElastix >, and elastix::TransformRigidityPenalty< TElastix >.

## SetAdvancedMetricImageSampler()

template<class TElastix>

virtual void elastix::MetricBase< TElastix >::SetAdvancedMetricImageSampler | ( | ImageSamplerBaseType * | sampler | ) |

virtual

Method to set the image sampler. The image sampler is only used when the metric is of type AdvancedMetricType, and has UseImageSampler set to true. In other cases, the function does nothing.

## Field Documentation

## m_CurrentExactMetricValue

template<class TElastix>

MeasureType elastix::MetricBase< TElastix >::m_CurrentExactMetricValue { 0.0 }

protected

Definition at line 230 of file elxMetricBase.h.

## m_ExactMetricEachXNumberOfIterations

template<class TElastix>

unsigned int elastix::MetricBase< TElastix >::m_ExactMetricEachXNumberOfIterations { 1 }

protected

Definition at line 233 of file elxMetricBase.h.

## m_ExactMetricSampleGridSpacing

template<class TElastix>

ExactMetricSampleGridSpacingType elastix::MetricBase< TElastix >::m_ExactMetricSampleGridSpacing

protected

Initial value:
{ itk::MakeFilled<ExactMetricSampleGridSpacingType>(
1) }

Definition at line 231 of file elxMetricBase.h.

## m_ExactMetricSampler

template<class TElastix>

ExactMetricImageSamplerPointer elastix::MetricBase< TElastix >::m_ExactMetricSampler { nullptr }

protected

Definition at line 229 of file elxMetricBase.h.

## m_ShowExactMetricValue

template<class TElastix>

bool elastix::MetricBase< TElastix >::m_ShowExactMetricValue { false }

protected

Todo
  the method GetExactDerivative could as well be added here.

Definition at line 228 of file elxMetricBase.h.

Generated on 1768596610 for elastix by 1.15.0 |