ITK  5.3.0
Insight Toolkit
itkSyNImageRegistrationMethod.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkSyNImageRegistrationMethod_h
19 #define itkSyNImageRegistrationMethod_h
20 
22 
25 
26 namespace itk
27 {
28 
66 template <typename TFixedImage,
67  typename TMovingImage,
68  typename TOutputTransform = DisplacementFieldTransform<double, TFixedImage::ImageDimension>,
69  typename TVirtualImage = TFixedImage,
70  typename TPointSet = PointSet<unsigned int, TFixedImage::ImageDimension>>
71 class ITK_TEMPLATE_EXPORT SyNImageRegistrationMethod
72  : public ImageRegistrationMethodv4<TFixedImage, TMovingImage, TOutputTransform, TVirtualImage, TPointSet>
73 {
74 public:
75  ITK_DISALLOW_COPY_AND_MOVE(SyNImageRegistrationMethod);
76 
82 
84  itkNewMacro(Self);
85 
87  static constexpr unsigned int ImageDimension = TFixedImage::ImageDimension;
88 
90  itkTypeMacro(SyNImageRegistrationMethod, SimpleImageRegistrationMethod);
91 
93  using FixedImageType = TFixedImage;
94  using FixedImagePointer = typename FixedImageType::Pointer;
95  using FixedImagesContainerType = typename Superclass::FixedImagesContainerType;
96  using MovingImageType = TMovingImage;
97  using MovingImagePointer = typename MovingImageType::Pointer;
98  using MovingImagesContainerType = typename Superclass::MovingImagesContainerType;
99 
100  using PointSetType = typename Superclass::PointSetType;
101  using PointSetPointer = typename PointSetType::Pointer;
102  using PointSetsContainerType = typename Superclass::PointSetsContainerType;
103 
105  using ImageMetricType = typename Superclass::ImageMetricType;
108 
110  using FixedImageMaskType = typename Superclass::FixedImageMaskType;
112  using FixedImageMasksContainerType = typename Superclass::FixedImageMasksContainerType;
113  using MovingImageMaskType = typename Superclass::MovingImageMaskType;
115  using MovingImageMasksContainerType = typename Superclass::MovingImageMasksContainerType;
116 
117  using VirtualImageType = typename Superclass::VirtualImageType;
118  using VirtualImageBaseType = typename Superclass::VirtualImageBaseType;
119  using VirtualImageBaseConstPointer = typename Superclass::VirtualImageBaseConstPointer;
120 
121  using MultiMetricType = typename Superclass::MultiMetricType;
122  using MetricType = typename Superclass::MetricType;
124  using PointSetMetricType = typename Superclass::PointSetMetricType;
125 
126  using InitialTransformType = typename Superclass::InitialTransformType;
127  using OutputTransformType = TOutputTransform;
128  using OutputTransformPointer = typename OutputTransformType::Pointer;
129  using RealType = typename OutputTransformType::ScalarType;
130  using DerivativeType = typename OutputTransformType::DerivativeType;
131  using DerivativeValueType = typename DerivativeType::ValueType;
132  using DisplacementFieldType = typename OutputTransformType::DisplacementFieldType;
133  using DisplacementFieldPointer = typename DisplacementFieldType::Pointer;
134  using DisplacementVectorType = typename DisplacementFieldType::PixelType;
135 
136  using CompositeTransformType = typename Superclass::CompositeTransformType;
138 
139  using DecoratedOutputTransformType = typename Superclass::DecoratedOutputTransformType;
141 
144 
146 
148  itkSetMacro(LearningRate, RealType);
149  itkGetConstMacro(LearningRate, RealType);
151 
153  itkSetMacro(NumberOfIterationsPerLevel, NumberOfIterationsArrayType);
154  itkGetConstMacro(NumberOfIterationsPerLevel, NumberOfIterationsArrayType);
156 
158  itkSetMacro(ConvergenceThreshold, RealType);
159  itkGetConstMacro(ConvergenceThreshold, RealType);
161 
163  itkSetMacro(ConvergenceWindowSize, unsigned int);
164  itkGetConstMacro(ConvergenceWindowSize, unsigned int);
166 
171  itkSetMacro(DownsampleImagesForMetricDerivatives, bool);
172  itkGetConstMacro(DownsampleImagesForMetricDerivatives, bool);
174 
178  itkSetMacro(AverageMidPointGradients, bool);
179  itkGetConstMacro(AverageMidPointGradients, bool);
181 
185  itkSetMacro(GaussianSmoothingVarianceForTheUpdateField, RealType);
186  itkGetConstReferenceMacro(GaussianSmoothingVarianceForTheUpdateField, RealType);
188 
192  itkSetMacro(GaussianSmoothingVarianceForTheTotalField, RealType);
193  itkGetConstReferenceMacro(GaussianSmoothingVarianceForTheTotalField, RealType);
195 
197  itkGetModifiableObjectMacro(FixedToMiddleTransform, OutputTransformType);
198  itkGetModifiableObjectMacro(MovingToMiddleTransform, OutputTransformType);
200 
202  itkSetObjectMacro(FixedToMiddleTransform, OutputTransformType);
203  itkSetObjectMacro(MovingToMiddleTransform, OutputTransformType);
205 
206 protected:
208  ~SyNImageRegistrationMethod() override = default;
209  void
210  PrintSelf(std::ostream & os, Indent indent) const override;
211 
213  void
214  GenerateData() override;
215 
219  virtual void
220  StartOptimization();
221 
226  void
227  InitializeRegistrationAtEachLevel(const SizeValueType) override;
228 
230  ComputeUpdateField(const FixedImagesContainerType,
232  const TransformBaseType *,
235  const TransformBaseType *,
238  MeasureType &);
240  ComputeMetricGradientField(const FixedImagesContainerType,
242  const TransformBaseType *,
245  const TransformBaseType *,
248  MeasureType &);
249 
251  ScaleUpdateField(const DisplacementFieldType *);
253  GaussianSmoothDisplacementField(const DisplacementFieldType *, const RealType);
255  InvertDisplacementField(const DisplacementFieldType *, const DisplacementFieldType * = nullptr);
256 
257  RealType m_LearningRate{ 0.25 };
258 
259  OutputTransformPointer m_MovingToMiddleTransform{ nullptr };
260  OutputTransformPointer m_FixedToMiddleTransform{ nullptr };
261 
262  RealType m_ConvergenceThreshold{ static_cast<RealType>(1.0e-6) };
263  unsigned int m_ConvergenceWindowSize{ 10 };
264 
266  bool m_DownsampleImagesForMetricDerivatives{ true };
267  bool m_AverageMidPointGradients{ false };
268 
269 private:
270  RealType m_GaussianSmoothingVarianceForTheUpdateField{ 3.0 };
271  RealType m_GaussianSmoothingVarianceForTheTotalField{ 0.5 };
272 };
273 } // end namespace itk
274 
275 #ifndef ITK_MANUAL_INSTANTIATION
276 # include "itkSyNImageRegistrationMethod.hxx"
277 #endif
278 
279 #endif
itk::ImageToImageMetricv4::MeasureType
typename Superclass::MeasureType MeasureType
Definition: itkImageToImageMetricv4.h:352
itk::ImageRegistrationMethodv4::MovingImageType
TMovingImage MovingImageType
Definition: itkImageRegistrationMethodv4.h:142
itkDisplacementFieldTransform.h
itk::CompositeTransform
This class contains a list of transforms and concatenates them by composition.
Definition: itkCompositeTransform.h:87
itk::ImageRegistrationMethodv4::PointSetsContainerType
std::vector< PointSetConstPointer > PointSetsContainerType
Definition: itkImageRegistrationMethodv4.h:149
itk::ImageRegistrationMethodv4::FixedImagePointer
typename FixedImageType::Pointer FixedImagePointer
Definition: itkImageRegistrationMethodv4.h:139
itk::ObjectToObjectMultiMetricv4
This class takes one ore more ObjectToObject metrics and assigns weights to their derivatives to comp...
Definition: itkObjectToObjectMultiMetricv4.h:96
itk::ImageBase
Base class for templated image classes.
Definition: itkImageBase.h:105
itk::ImageRegistrationMethodv4::PointSetType
TPointSet PointSetType
Definition: itkImageRegistrationMethodv4.h:147
itk::SyNImageRegistrationMethod::m_NumberOfIterationsPerLevel
NumberOfIterationsArrayType m_NumberOfIterationsPerLevel
Definition: itkSyNImageRegistrationMethod.h:265
itk::ImageRegistrationMethodv4::MovingImagesContainerType
std::vector< MovingImageConstPointer > MovingImagesContainerType
Definition: itkImageRegistrationMethodv4.h:145
itk::ImageRegistrationMethodv4::MetricPointer
typename MetricType::Pointer MetricPointer
Definition: itkImageRegistrationMethodv4.h:165
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::SyNImageRegistrationMethod::ImageMetricPointer
typename ImageMetricType::Pointer ImageMetricPointer
Definition: itkSyNImageRegistrationMethod.h:106
itkImageRegistrationMethodv4.h
itk::SyNImageRegistrationMethod::PointSetPointer
typename PointSetType::Pointer PointSetPointer
Definition: itkSyNImageRegistrationMethod.h:101
itk::SyNImageRegistrationMethod::DisplacementVectorType
typename DisplacementFieldType::PixelType DisplacementVectorType
Definition: itkSyNImageRegistrationMethod.h:134
itk::ImageRegistrationMethodv4::VirtualImageBaseConstPointer
typename VirtualImageBaseType::ConstPointer VirtualImageBaseConstPointer
Definition: itkImageRegistrationMethodv4.h:172
itk::DataObjectDecorator
Decorates any subclass of itkObject with a DataObject API.
Definition: itkDataObjectDecorator.h:66
itk::DisplacementFieldTransform
Provides local/dense/high-dimensionality transformation via a a displacement field.
Definition: itkDisplacementFieldTransform.h:86
itk::PointSetToPointSetMetricWithIndexv4
Computes similarity between two point sets.
Definition: itkPointSetToPointSetMetricWithIndexv4.h:72
itk::ImageRegistrationMethodv4::RealType
typename OutputTransformType::ScalarType RealType
Definition: itkImageRegistrationMethodv4.h:154
itk::ImageRegistrationMethodv4::MovingImageMasksContainerType
std::vector< MovingImageMaskConstPointer > MovingImageMasksContainerType
Definition: itkImageRegistrationMethodv4.h:183
itk::ImageRegistrationMethodv4::FixedImageMasksContainerType
std::vector< FixedImageMaskConstPointer > FixedImageMasksContainerType
Definition: itkImageRegistrationMethodv4.h:180
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::ImageRegistrationMethodv4::FixedImageType
TFixedImage FixedImageType
Definition: itkImageRegistrationMethodv4.h:138
itk::ImageRegistrationMethodv4::MovingImageMaskType
typename ImageMetricType::MovingImageMaskType MovingImageMaskType
Definition: itkImageRegistrationMethodv4.h:181
itk::SyNImageRegistrationMethod::MeasureType
typename ImageMetricType::MeasureType MeasureType
Definition: itkSyNImageRegistrationMethod.h:107
itk::ImageRegistrationMethodv4::MovingImagePointer
typename MovingImageType::Pointer MovingImagePointer
Definition: itkImageRegistrationMethodv4.h:143
itk::ObjectToObjectMetricBaseTemplate
Base class for all object-to-object similarity metrics added in ITKv4.
Definition: itkObjectToObjectMetricBase.h:90
itk::SyNImageRegistrationMethod::TransformBaseType
typename CompositeTransformType::TransformType TransformBaseType
Definition: itkSyNImageRegistrationMethod.h:137
itk::SyNImageRegistrationMethod::MovingMaskImageType
typename ImageMaskSpatialObjectType::ImageType MovingMaskImageType
Definition: itkSyNImageRegistrationMethod.h:114
itk::SyNImageRegistrationMethod::DisplacementFieldPointer
typename DisplacementFieldType::Pointer DisplacementFieldPointer
Definition: itkSyNImageRegistrationMethod.h:133
itk::ImageMaskSpatialObject
Implementation of an image mask as spatial object.
Definition: itkImageMaskSpatialObject.h:45
itk::SyNImageRegistrationMethod::DisplacementFieldTransformPointer
typename DisplacementFieldTransformType::Pointer DisplacementFieldTransformPointer
Definition: itkSyNImageRegistrationMethod.h:143
itk::ImageRegistrationMethodv4::FixedImagesContainerType
std::vector< FixedImageConstPointer > FixedImagesContainerType
Definition: itkImageRegistrationMethodv4.h:141
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ImageRegistrationMethodv4::FixedImageMaskType
typename ImageMetricType::FixedImageMaskType FixedImageMaskType
Definition: itkImageRegistrationMethodv4.h:178
itkImageMaskSpatialObject.h
itk::SyNImageRegistrationMethod::DisplacementFieldType
typename OutputTransformType::DisplacementFieldType DisplacementFieldType
Definition: itkSyNImageRegistrationMethod.h:132
itk::ImageRegistrationMethodv4
Interface method for the current registration framework.
Definition: itkImageRegistrationMethodv4.h:117
itk::CompositeTransform::TransformType
typename Superclass::TransformType TransformType
Definition: itkCompositeTransform.h:105
itk::ImageToImageMetricv4
Definition: itkImageToImageMetricv4.h:174
itk::ImageRegistrationMethodv4::OutputTransformPointer
typename OutputTransformType::Pointer OutputTransformPointer
Definition: itkImageRegistrationMethodv4.h:153
itk::Array< SizeValueType >
itk::Math::e
static constexpr double e
Definition: itkMath.h:54
itk::ImageRegistrationMethodv4::VirtualImageType
TVirtualImage VirtualImageType
Definition: itkImageRegistrationMethodv4.h:169
itk::SyNImageRegistrationMethod
Interface method for the performing greedy SyN image registration.
Definition: itkSyNImageRegistrationMethod.h:71
itk::Transform
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:83
itk::ImageRegistrationMethodv4::DecoratedOutputTransformPointer
typename DecoratedOutputTransformType::Pointer DecoratedOutputTransformPointer
Definition: itkImageRegistrationMethodv4.h:190
itk::ImageRegistrationMethodv4::OutputTransformType
TOutputTransform OutputTransformType
Definition: itkImageRegistrationMethodv4.h:152
itk::ImageRegistrationMethodv4::DerivativeValueType
typename DerivativeType::ValueType DerivativeValueType
Definition: itkImageRegistrationMethodv4.h:156
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::SyNImageRegistrationMethod::FixedMaskImageType
typename ImageMaskSpatialObjectType::ImageType FixedMaskImageType
Definition: itkSyNImageRegistrationMethod.h:111
itk::ImageMaskSpatialObject::ImageType
typename Superclass::ImageType ImageType
Definition: itkImageMaskSpatialObject.h:57
itk::ImageRegistrationMethodv4::DerivativeType
typename OutputTransformType::DerivativeType DerivativeType
Definition: itkImageRegistrationMethodv4.h:155