go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
elastix::MetricBase< TElastix > Class Template Reference

#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 >:

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 ImageSamplerBaseTypeGetAdvancedMetricImageSampler () const
 
virtual bool GetAdvancedMetricUseImageSampler () const
 
ITKBaseTypeGetAsITKBaseType ()
 
const ITKBaseTypeGetAsITKBaseType () 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 ConfigurationGetConfiguration () const
 
ElastixTypeGetElastix () const
 
auto & GetIterationInfoAt (const char *const name)
 
RegistrationTypeGetRegistration () 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 {}
 
RegistrationTypem_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:
FixedImageDimension,
itk::DefaultStaticMeshTraits<CoordinateRepresentationType,
FixedImageDimension,
FixedImageDimension,
CoordinateRepresentationType>>
typename ITKBaseType::ParametersValueType CoordinateRepresentationType

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:
MovingImageDimension,
itk::DefaultStaticMeshTraits<CoordinateRepresentationType,
MovingImageDimension,
MovingImageDimension,
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 ( )
protecteddefault

The constructor.

◆ ~MetricBase()

template<class TElastix >
elastix::MetricBase< TElastix >::~MetricBase ( )
overrideprotecteddefault

The destructor.

Member Function Documentation

◆ AfterEachIterationBase()

template<class TElastix >
void elastix::MetricBase< TElastix >::AfterEachIterationBase ( )
overridevirtual

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 ( )
overridevirtual

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()

◆ GetCurrentExactMetricValue()

template<class TElastix >
virtual MeasureType elastix::MetricBase< TElastix >::GetCurrentExactMetricValue ( ) const
inlinevirtual

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)
protectedvirtual

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
inlinevirtual

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

◆ 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 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo