NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
itkFFDGradientDescentOptimizer.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef itkFFDGradientDescentOptimizer_h
16 #define itkFFDGradientDescentOptimizer_h
17 
18 #include <NifTKConfigure.h>
22 #include <itkUCLBSplineTransform.h>
28 
29 namespace itk
30 {
31 
38 template <class TFixedImage, class TMovingImage, class TScalarType, class TDeformationScalar>
39 class ITK_EXPORT FFDGradientDescentOptimizer :
40  public LocalSimilarityMeasureGradientDescentOptimizer<TFixedImage, TMovingImage, TScalarType, TDeformationScalar>
41 {
42 public:
43 
48  typedef LocalSimilarityMeasureGradientDescentOptimizer<TFixedImage, TMovingImage,
49  TScalarType, TDeformationScalar> Superclass;
50  typedef SmartPointer<Self> Pointer;
51  typedef SmartPointer<const Self> ConstPointer;
52 
55 
57  itkStaticConstMacro(Dimension, unsigned int, TFixedImage::ImageDimension);
58 
60  typedef DeformableTransform<TFixedImage, TScalarType,
61  Dimension, TDeformationScalar> DeformableTransformType;
63  typedef UCLBSplineTransform<TFixedImage, TScalarType,
64  Dimension, TDeformationScalar> UCLBSplineTransformType;
65  typedef UCLBSplineTransformType* UCLBSplineTransformPointer;
66 
67  typedef TScalarType MeasureType;
72 
74  typedef GridImageType* GridImagePointer;
75 
76  typedef Vector< TDeformationScalar, itkGetStaticConstMacro(Dimension) > VectorPixelType;
78 
80  typedef RegistrationForceFilter<TFixedImage, TMovingImage,
81  TDeformationScalar> ForceFilterType;
82  typedef typename ForceFilterType::Pointer ForceFilterPointer;
84 
88 
92 
98 
102  typedef typename OutputImageType::Pointer OutputImagePointer;
103  typedef ImageRegionIterator<OutputImageType> OutputImageIteratorType;
105  typedef typename OutputImageType::SpacingType OutputImageSpacingType;
106 
108  itkSetObjectMacro( ForceFilter, ForceFilterType );
109  itkGetConstObjectMacro( ForceFilter, ForceFilterType );
110 
112  itkSetObjectMacro( SmoothFilter, SmoothFilterType );
113  itkGetConstObjectMacro( SmoothFilter, SmoothFilterType );
114 
116  itkSetObjectMacro( InterpolatorFilter, InterpolateFilterType );
117  itkGetConstObjectMacro( InterpolatorFilter, InterpolateFilterType );
118 
124  itkSetMacro(MinimumGradientVectorMagnitudeThreshold, TScalarType);
125  itkGetMacro(MinimumGradientVectorMagnitudeThreshold, TScalarType);
126 
128  itkSetMacro(ScaleForceVectorsByGradientImage, bool);
129  itkGetMacro(ScaleForceVectorsByGradientImage, bool);
130 
134  itkSetMacro(ScaleByComponents, bool);
135  itkGetMacro(ScaleByComponents, bool);
136 
139  itkSetMacro(SmoothGradientVectorsBeforeInterpolatingToControlPointLevel, bool);
140  itkGetMacro(SmoothGradientVectorsBeforeInterpolatingToControlPointLevel, bool);
141 
143  itkSetMacro(WriteForceImage, bool);
144  itkGetMacro(WriteForceImage, bool);
145 
147  itkSetMacro(ForceImageFileName, std::string);
148  itkGetMacro(ForceImageFileName, std::string);
149 
151  itkSetMacro(ForceImageFileExt, std::string);
152  itkGetMacro(ForceImageFileExt, std::string);
153 
154 protected:
155 
158  void PrintSelf(std::ostream& os, Indent indent) const;
159 
161  virtual double CalculateNextStep(int iterationNumber, double currentSimilarity, const ParametersType& current, ParametersType& next);
162 
164  virtual void GetGradient(int iterationNumber, const ParametersType& current, ParametersType& next);
165 
167  virtual bool LineAscent(int iterationNumber, int numberOfGridVoxels, const ParametersType& current, ParametersType& next);
168 
171  virtual void OptimizeNextStep(int iterationNumber, int numberOfGridVoxels, const ParametersType& current, ParametersType& next) {};
172 
174  ForceFilterPointer m_ForceFilter;
175 
177  SmoothFilterPointer m_SmoothFilter;
178 
180  InterpolateFilterPointer m_InterpolatorFilter;
181 
183  ScaleFieldPointer m_ScaleVectorFieldFilter;
184 
186  GradientFilterPointer m_GradientImageFilter;
187 
190 
191 private:
192 
193  FFDGradientDescentOptimizer(const Self&); //purposely not implemented
194  void operator=(const Self&); //purposely not implemented
195 
197  TScalarType m_MinimumGradientVectorMagnitudeThreshold;
198 
200  bool m_ScaleForceVectorsByGradientImage;
201 
203  bool m_ScaleByComponents;
204 
206  bool m_SmoothGradientVectorsBeforeInterpolatingToControlPointLevel;
207 
209  bool m_WriteForceImage;
210 
212  std::string m_ForceImageFileName;
213 
215  std::string m_ForceImageFileExt;
216 
217 };
218 
219 } // namespace itk.
220 
221 #ifndef ITK_MANUAL_INSTANTIATION
222 #include "itkFFDGradientDescentOptimizer.txx"
223 #endif
224 
225 #endif /*ITKFFDGRADIENTDESCENTOPTIMIZER_H_*/
226 
227 
228 
InterpolateFilterPointer m_InterpolatorFilter
Definition: itkFFDGradientDescentOptimizer.h:180
unsigned int m_CalculateNextStepCounter
Definition: itkFFDGradientDescentOptimizer.h:189
ScaleVectorFieldFilter< TDeformationScalar, Dimension > ScaleFieldType
Definition: itkFFDGradientDescentOptimizer.h:94
Implement a gradient descent optimization suitable for FFD and Fluid deformation. ...
Definition: itkLocalSimilarityMeasureGradientDescentOptimizer.h:33
OutputImageType::PixelType OutputImagePixelType
Definition: itkFFDGradientDescentOptimizer.h:101
ImageType::SizeType SizeType
Definition: niftkMakeLapUSProbeBasicModel.cxx:31
SmoothFilterType::Pointer SmoothFilterPointer
Definition: itkFFDGradientDescentOptimizer.h:87
Deformable transform using a BSpline representation.
Definition: itkUCLBSplineTransform.h:56
UCLBSplineTransformType::GridImageType GridImageType
Definition: itkFFDGradientDescentOptimizer.h:73
SmartPointer< Self > Pointer
Definition: itkBSplineSmoothVectorFieldFilter.h:45
Abstract base class to provide functionality for adding arbitrary constraints, and also arbitrary way...
Definition: itkImageToImageMetricWithConstraint.h:49
SmartPointer< Self > Pointer
Definition: itkScalarImageToNormalizedGradientVectorImageFilter.h:82
SmoothFilterPointer m_SmoothFilter
Definition: itkFFDGradientDescentOptimizer.h:177
ScaleFieldType::Pointer ScaleFieldPointer
Definition: itkFFDGradientDescentOptimizer.h:95
Superclass::DerivativeType DerivativeType
Definition: itkImageToImageMetricWithConstraint.h:70
virtual void OptimizeNextStep(int iterationNumber, int numberOfGridVoxels, const ParametersType &current, ParametersType &next)
Definition: itkFFDGradientDescentOptimizer.h:171
Base class for deformable transforms.
Definition: itkDeformableTransform.h:69
virtual ~FFDGradientDescentOptimizer()
Definition: itkFFDGradientDescentOptimizer.h:157
Definition: niftkITKAffineResampleImage.cxx:74
OutputImageType::SpacingType OutputImageSpacingType
Definition: itkFFDGradientDescentOptimizer.h:105
DeformableTransformType::Pointer DeformableTransformPointer
Definition: itkFFDGradientDescentOptimizer.h:62
ScalarImageToNormalizedGradientVectorImageFilter< TFixedImage, TDeformationScalar > GradientFilterType
Definition: itkFFDGradientDescentOptimizer.h:96
OutputImageType::Pointer OutputImagePointer
Definition: itkFFDGradientDescentOptimizer.h:102
GradientFilterType::Pointer GradientFilterPointer
Definition: itkFFDGradientDescentOptimizer.h:97
GridImageType * GridImagePointer
Definition: itkFFDGradientDescentOptimizer.h:74
RegistrationForceFilter< TFixedImage, TMovingImage, TDeformationScalar > ForceFilterType
Definition: itkFFDGradientDescentOptimizer.h:81
LocalSimilarityMeasureGradientDescentOptimizer< TFixedImage, TMovingImage, TScalarType, TDeformationScalar > Superclass
Definition: itkFFDGradientDescentOptimizer.h:49
This class takes two inputs, the first is a vector field, such as the output from a registration forc...
Definition: itkScaleVectorFieldFilter.h:39
UCLBSplineTransform< TFixedImage, TScalarType, Dimension, TDeformationScalar > UCLBSplineTransformType
Definition: itkFFDGradientDescentOptimizer.h:64
SmartPointer< Self > Pointer
Definition: itkDeformableTransform.h:76
ForceFilterType::OutputImageType ForceOutputImageType
Definition: itkFFDGradientDescentOptimizer.h:83
GradientFilterPointer m_GradientImageFilter
Definition: itkFFDGradientDescentOptimizer.h:186
Vector< TDeformationScalar, itkGetStaticConstMacro(Dimension) > VectorPixelType
Definition: itkFFDGradientDescentOptimizer.h:76
FFDGradientDescentOptimizer Self
Definition: itkFFDGradientDescentOptimizer.h:47
This class takes as input 2 input images, and outputs the registration force.
Definition: itkRegistrationForceFilter.h:39
float PixelType
Definition: niftkBreastDCEandADC.cxx:88
InterpolateFilterType::Pointer InterpolateFilterPointer
Definition: itkFFDGradientDescentOptimizer.h:91
InterpolateFilterType::OutputImageType OutputImageType
Definition: itkFFDGradientDescentOptimizer.h:100
SmartPointer< const Self > ConstPointer
Definition: itkImageToImageMetricWithConstraint.h:58
ImageToImageMetricWithConstraint< TFixedImage, TMovingImage > SimilarityMeasureType
Definition: itkFFDGradientDescentOptimizer.h:68
TScalarType MeasureType
Definition: itkFFDGradientDescentOptimizer.h:67
SimilarityMeasureType::DerivativeType DerivativeType
Definition: itkFFDGradientDescentOptimizer.h:71
ForceFilterType::Pointer ForceFilterPointer
Definition: itkFFDGradientDescentOptimizer.h:82
Superclass::ParametersType TransformParametersType
Definition: itkImageToImageMetricWithConstraint.h:71
SmartPointer< Self > Pointer
Definition: itkScaleVectorFieldFilter.h:51
Class that takes a vector field, and applies BSpline smoothing.
Definition: itkBSplineSmoothVectorFieldFilter.h:35
UCLBSplineTransformType * UCLBSplineTransformPointer
Definition: itkFFDGradientDescentOptimizer.h:65
Image< VectorPixelType, itkGetStaticConstMacro(Dimension) > VectorImageType
Definition: itkFFDGradientDescentOptimizer.h:77
SmartPointer< Self > Pointer
Definition: itkInterpolateVectorFieldFilter.h:50
ImageRegionIterator< OutputImageType > OutputImageIteratorType
Definition: itkFFDGradientDescentOptimizer.h:103
Simultaneous itk::Image and itk::Array (and hence vnl_vector) class.
const unsigned int Dimension
Definition: niftkBreastDCEandADC.cxx:89
DeformableTransform< TFixedImage, TScalarType, Dimension, TDeformationScalar > DeformableTransformType
Definition: itkFFDGradientDescentOptimizer.h:61
SimilarityMeasureType::TransformParametersType ParametersType
Definition: itkFFDGradientDescentOptimizer.h:70
BSplineSmoothVectorFieldFilter< TDeformationScalar, Dimension > SmoothFilterType
Definition: itkFFDGradientDescentOptimizer.h:86
SmartPointer< const Self > ConstPointer
Definition: itkFFDGradientDescentOptimizer.h:51
Class to perform FFD specific optimization.
Definition: itkFFDGradientDescentOptimizer.h:39
SmartPointer< Self > Pointer
Definition: itkFFDGradientDescentOptimizer.h:50
This class takes scalar image as input, and outputs a vector field of image gradient.
Definition: itkScalarImageToNormalizedGradientVectorImageFilter.h:67
OutputImageType::SizeType OutputImageSizeType
Definition: itkFFDGradientDescentOptimizer.h:104
SimilarityMeasureType::ConstPointer SimilarityMeasurePointer
Definition: itkFFDGradientDescentOptimizer.h:69
This class takes a vector field as input 1, and a vector field as input 2, and the output is a vector...
Definition: itkInterpolateVectorFieldFilter.h:38
InterpolateVectorFieldFilter< TDeformationScalar, Dimension > InterpolateFilterType
Definition: itkFFDGradientDescentOptimizer.h:90
GLsizei const GLcharARB ** string
Definition: glew.h:5194
ScaleFieldPointer m_ScaleVectorFieldFilter
Definition: itkFFDGradientDescentOptimizer.h:183