1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
|
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkDiffeomorphicDemonsRegistrationFilter.h
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkDiffeomorphicDemonsRegistrationFilter_h
#define __itkDiffeomorphicDemonsRegistrationFilter_h
#include "itkPDEDeformableRegistrationFilter.h"
#include "itkESMDemonsRegistrationFunction.h"
#include "itkMultiplyByConstantImageFilter.h"
#include "itkExponentialDeformationFieldImageFilter.h"
#include "itkWarpVectorImageFilter.h"
#include "itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunction.h"
#include "itkAddImageFilter.h"
namespace itk {
/** \class DiffeomorphicDemonsRegistrationFilter
* \brief Deformably register two images using a diffeomorphic demons algorithm.
*
* This class was contributed by Tom Vercauteren, INRIA & Mauna Kea Technologies,
* based on a variation of the DemonsRegistrationFilter. The basic modification
* is to use diffeomorphism exponentials.
*
* See T. Vercauteren, X. Pennec, A. Perchant and N. Ayache,
* "Non-parametric Diffeomorphic Image Registration with the Demons Algorithm",
* Proc. of MICCAI 2007.
*
* DiffeomorphicDemonsRegistrationFilter implements the demons deformable algorithm that
* register two images by computing the deformation field which will map a
* moving image onto a fixed image.
*
* A deformation field is represented as a image whose pixel type is some
* vector type with at least N elements, where N is the dimension of
* the fixed image. The vector type must support element access via operator
* []. It is assumed that the vector elements behave like floating point
* scalars.
*
* This class is templated over the fixed image type, moving image type
* and the deformation field type.
*
* The input fixed and moving images are set via methods SetFixedImage
* and SetMovingImage respectively. An initial deformation field maybe set via
* SetInitialDeformationField or SetInput. If no initial field is set,
* a zero field is used as the initial condition.
*
* The output deformation field can be obtained via methods GetOutput
* or GetDeformationField.
*
* This class make use of the finite difference solver hierarchy. Update
* for each iteration is computed in DemonsRegistrationFunction.
*
* \author Tom Vercauteren, INRIA & Mauna Kea Technologies
*
* \warning This filter assumes that the fixed image type, moving image type
* and deformation field type all have the same number of dimensions.
*
* This implementation was taken from the Insight Journal paper:
* http://hdl.handle.net/1926/510
*
* \sa DemonsRegistrationFilter
* \sa DemonsRegistrationFunction
* \ingroup DeformableImageRegistration MultiThreaded
*/
template<class TFixedImage, class TMovingImage, class TDeformationField>
class ITK_EXPORT DiffeomorphicDemonsRegistrationFilter :
public PDEDeformableRegistrationFilter< TFixedImage, TMovingImage,
TDeformationField>
{
public:
/** Standard class typedefs. */
typedef DiffeomorphicDemonsRegistrationFilter Self;
typedef PDEDeformableRegistrationFilter<
TFixedImage, TMovingImage,TDeformationField> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro( DiffeomorphicDemonsRegistrationFilter,
PDEDeformableRegistrationFilter );
/** FixedImage image type. */
typedef typename Superclass::FixedImageType FixedImageType;
typedef typename Superclass::FixedImagePointer FixedImagePointer;
/** MovingImage image type. */
typedef typename Superclass::MovingImageType MovingImageType;
typedef typename Superclass::MovingImagePointer MovingImagePointer;
/** Deformation field type. */
typedef typename Superclass::DeformationFieldType DeformationFieldType;
typedef typename Superclass::DeformationFieldPointer DeformationFieldPointer;
/** FiniteDifferenceFunction type. */
typedef typename
Superclass::FiniteDifferenceFunctionType FiniteDifferenceFunctionType;
/** Take timestep type from the FiniteDifferenceFunction. */
typedef typename
FiniteDifferenceFunctionType::TimeStepType TimeStepType;
/** DemonsRegistrationFilterFunction type. */
typedef ESMDemonsRegistrationFunction<
FixedImageType,
MovingImageType, DeformationFieldType> DemonsRegistrationFunctionType;
typedef typename
DemonsRegistrationFunctionType::GradientType GradientType;
/** Get the metric value. The metric value is the mean square difference
* in intensity between the fixed image and transforming moving image
* computed over the the overlapping region between the two images.
* This value is calculated for the current iteration */
virtual double GetMetric() const;
virtual const double &GetRMSChange() const;
virtual void SetUseGradientType( GradientType gtype );
virtual GradientType GetUseGradientType() const;
/** Use a first-order approximation of the exponential.
* This amounts to using an update rule of the type
* s <- s o (Id + u) instead of s <- s o exp(u) */
itkSetMacro( UseFirstOrderExp, bool );
itkGetConstMacro( UseFirstOrderExp, bool );
itkBooleanMacro( UseFirstOrderExp );
/** Set/Get the threshold below which the absolute difference of
* intensity yields a match. When the intensities match between a
* moving and fixed image pixel, the update vector (for that
* iteration) will be the zero vector. Default is 0.001. */
virtual void SetIntensityDifferenceThreshold(double);
virtual double GetIntensityDifferenceThreshold() const;
/** Set/Get the maximum length in terms of pixels of
* the vectors in the update buffer. */
virtual void SetMaximumUpdateStepLength(double);
virtual double GetMaximumUpdateStepLength() const;
protected:
DiffeomorphicDemonsRegistrationFilter();
~DiffeomorphicDemonsRegistrationFilter() {}
void PrintSelf(std::ostream& os, Indent indent) const;
/** Initialize the state of filter and equation before each iteration. */
virtual void InitializeIteration();
/** This method allocates storage in m_UpdateBuffer. It is called from
* FiniteDifferenceFilter::GenerateData(). */
virtual void AllocateUpdateBuffer();
/** Apply update. */
virtual void ApplyUpdate(TimeStepType dt);
private:
DiffeomorphicDemonsRegistrationFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
/** Downcast the DifferenceFunction using a dynamic_cast to ensure that it is of the correct type.
* this method will throw an exception if the function is not of the expected type. */
DemonsRegistrationFunctionType * DownCastDifferenceFunctionType();
const DemonsRegistrationFunctionType * DownCastDifferenceFunctionType() const;
/** Exp and composition typedefs */
typedef MultiplyByConstantImageFilter<
DeformationFieldType,
TimeStepType, DeformationFieldType > MultiplyByConstantType;
typedef ExponentialDeformationFieldImageFilter<
DeformationFieldType, DeformationFieldType > FieldExponentiatorType;
typedef WarpVectorImageFilter<
DeformationFieldType,
DeformationFieldType, DeformationFieldType> VectorWarperType;
typedef VectorLinearInterpolateNearestNeighborExtrapolateImageFunction<
DeformationFieldType, double> FieldInterpolatorType;
typedef AddImageFilter<
DeformationFieldType,
DeformationFieldType, DeformationFieldType> AdderType;
typedef typename MultiplyByConstantType::Pointer MultiplyByConstantPointer;
typedef typename FieldExponentiatorType::Pointer FieldExponentiatorPointer;
typedef typename VectorWarperType::Pointer VectorWarperPointer;
typedef typename FieldInterpolatorType::Pointer FieldInterpolatorPointer;
typedef typename FieldInterpolatorType::OutputType FieldInterpolatorOutputType;
typedef typename AdderType::Pointer AdderPointer;
MultiplyByConstantPointer m_Multiplier;
FieldExponentiatorPointer m_Exponentiator;
VectorWarperPointer m_Warper;
AdderPointer m_Adder;
bool m_UseFirstOrderExp;
};
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkDiffeomorphicDemonsRegistrationFilter.txx"
#endif
#endif
|