ITK  6.0.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  * https://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  itkOverrideGetNameOfClassMacro(SyNImageRegistrationMethod);
91 
93  using FixedImageType = TFixedImage;
95  using typename Superclass::FixedImagesContainerType;
96  using MovingImageType = TMovingImage;
98  using typename Superclass::MovingImagesContainerType;
99 
100  using typename Superclass::PointSetType;
102  using typename Superclass::PointSetsContainerType;
103 
105  using typename Superclass::ImageMetricType;
108 
110  using typename Superclass::FixedImageMaskType;
112  using typename Superclass::FixedImageMasksContainerType;
113  using typename Superclass::MovingImageMaskType;
115  using typename Superclass::MovingImageMasksContainerType;
116 
117  using VirtualImageType = typename Superclass::VirtualImageType;
118  using typename Superclass::VirtualImageBaseType;
119  using typename Superclass::VirtualImageBaseConstPointer;
120 
121  using typename Superclass::MultiMetricType;
122  using typename Superclass::MetricType;
124  using typename Superclass::PointSetMetricType;
125 
126  using typename Superclass::InitialTransformType;
127  using OutputTransformType = TOutputTransform;
129  using RealType = typename OutputTransformType::ScalarType;
130  using DerivativeType = typename OutputTransformType::DerivativeType;
131  using DerivativeValueType = typename DerivativeType::ValueType;
132  using DisplacementFieldType = typename OutputTransformType::DisplacementFieldType;
134  using DisplacementVectorType = typename DisplacementFieldType::PixelType;
135 
136  using typename Superclass::CompositeTransformType;
138 
139  using typename Superclass::DecoratedOutputTransformType;
141 
144 
146 
148  itkSetMacro(LearningRate, RealType);
149  itkGetConstMacro(LearningRate, RealType);
153  itkSetMacro(NumberOfIterationsPerLevel, NumberOfIterationsArrayType);
154  itkGetConstMacro(NumberOfIterationsPerLevel, NumberOfIterationsArrayType);
158  itkSetMacro(ConvergenceThreshold, RealType);
159  itkGetConstMacro(ConvergenceThreshold, RealType);
163  itkSetMacro(ConvergenceWindowSize, unsigned int);
164  itkGetConstMacro(ConvergenceWindowSize, unsigned int);
171  itkSetMacro(DownsampleImagesForMetricDerivatives, bool);
172  itkGetConstMacro(DownsampleImagesForMetricDerivatives, bool);
178  itkSetMacro(AverageMidPointGradients, bool);
179  itkGetConstMacro(AverageMidPointGradients, bool);
185  itkSetMacro(GaussianSmoothingVarianceForTheUpdateField, RealType);
186  itkGetConstReferenceMacro(GaussianSmoothingVarianceForTheUpdateField, RealType);
192  itkSetMacro(GaussianSmoothingVarianceForTheTotalField, RealType);
193  itkGetConstReferenceMacro(GaussianSmoothingVarianceForTheTotalField, RealType);
197  itkGetModifiableObjectMacro(FixedToMiddleTransform, OutputTransformType);
198  itkGetModifiableObjectMacro(MovingToMiddleTransform, OutputTransformType);
202  itkSetObjectMacro(FixedToMiddleTransform, OutputTransformType);
203  itkSetObjectMacro(MovingToMiddleTransform, OutputTransformType);
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 
265  NumberOfIterationsArrayType m_NumberOfIterationsPerLevel{};
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
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::ImageRegistrationMethodv4::MovingImageType
TMovingImage MovingImageType
Definition: itkImageRegistrationMethodv4.h:142
itkDisplacementFieldTransform.h
itk::ImageRegistrationMethodv4::PointSetsContainerType
std::vector< PointSetConstPointer > PointSetsContainerType
Definition: itkImageRegistrationMethodv4.h:149
itk::ImageRegistrationMethodv4::FixedImagePointer
typename FixedImageType::Pointer FixedImagePointer
Definition: itkImageRegistrationMethodv4.h:139
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::DisplacementFieldTransform
Provides local/dense/high-dimensionality transformation via a a displacement field.
Definition: itkDisplacementFieldTransform.h:87
itk::ImageRegistrationMethodv4::RealType
typename OutputTransformType::ScalarType RealType
Definition: itkImageRegistrationMethodv4.h:154
itk::SingleValuedCostFunctionv4Template::MeasureType
TInternalComputationValueType MeasureType
Definition: itkSingleValuedCostFunctionv4.h:67
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:55
itk::ImageRegistrationMethodv4::FixedImageType
TFixedImage FixedImageType
Definition: itkImageRegistrationMethodv4.h:138
itk::SyNImageRegistrationMethod::MeasureType
typename ImageMetricType::MeasureType MeasureType
Definition: itkSyNImageRegistrationMethod.h:107
itk::ImageRegistrationMethodv4::MovingImagePointer
typename MovingImageType::Pointer MovingImagePointer
Definition: itkImageRegistrationMethodv4.h:143
itk::SyNImageRegistrationMethod::TransformBaseType
typename CompositeTransformType::TransformType TransformBaseType
Definition: itkSyNImageRegistrationMethod.h:137
itk::SyNImageRegistrationMethod::MovingMaskImageType
typename ImageMaskSpatialObjectType::ImageType MovingMaskImageType
Definition: itkSyNImageRegistrationMethod.h:114
itk::CompositeTransform::TransformType
typename Superclass::TransformType TransformType
Definition: itkCompositeTransform.h:105
itk::SyNImageRegistrationMethod::DisplacementFieldPointer
typename DisplacementFieldType::Pointer DisplacementFieldPointer
Definition: itkSyNImageRegistrationMethod.h:133
itk::ImageMaskSpatialObject
Implementation of an image mask as spatial object.
Definition: itkImageMaskSpatialObject.h:47
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: itkAnatomicalOrientation.h:29
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::ImageRegistrationMethodv4::OutputTransformPointer
typename OutputTransformType::Pointer OutputTransformPointer
Definition: itkImageRegistrationMethodv4.h:153
itk::Array< SizeValueType >
itk::Math::e
static constexpr double e
Definition: itkMath.h:56
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
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::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:86
itk::SyNImageRegistrationMethod::FixedMaskImageType
typename ImageMaskSpatialObjectType::ImageType FixedMaskImageType
Definition: itkSyNImageRegistrationMethod.h:111
itk::ImageRegistrationMethodv4::DerivativeType
typename OutputTransformType::DerivativeType DerivativeType
Definition: itkImageRegistrationMethodv4.h:155