ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkSyNImageRegistrationMethod.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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, typename TMovingImage, typename TOutputTransform =
67  DisplacementFieldTransform<double, TFixedImage::ImageDimension>,
68  typename TVirtualImage = TFixedImage,
69  typename TPointSet = PointSet<unsigned int, TFixedImage::ImageDimension> >
70 class ITK_TEMPLATE_EXPORT SyNImageRegistrationMethod
71 : public ImageRegistrationMethodv4<TFixedImage, TMovingImage, TOutputTransform, TVirtualImage, TPointSet>
72 {
73 public:
74  ITK_DISALLOW_COPY_AND_ASSIGN(SyNImageRegistrationMethod);
75 
78  using Superclass = ImageRegistrationMethodv4<TFixedImage, TMovingImage, TOutputTransform,
79  TVirtualImage, TPointSet>;
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 PrintSelf( std::ostream & os, Indent indent ) const override;
210 
212  void GenerateData() override;
213 
215  virtual void StartOptimization();
216 
221  void InitializeRegistrationAtEachLevel( const SizeValueType ) override;
222 
223  virtual DisplacementFieldPointer ComputeUpdateField( const FixedImagesContainerType, const PointSetsContainerType,
226  virtual DisplacementFieldPointer ComputeMetricGradientField( const FixedImagesContainerType,
230 
231  virtual DisplacementFieldPointer ScaleUpdateField( const DisplacementFieldType * );
232  virtual DisplacementFieldPointer GaussianSmoothDisplacementField( const DisplacementFieldType *, const RealType );
233  virtual DisplacementFieldPointer InvertDisplacementField( const DisplacementFieldType *, const DisplacementFieldType * = nullptr );
234 
235  RealType m_LearningRate{ 0.25 };
236 
237  OutputTransformPointer m_MovingToMiddleTransform{ nullptr };
238  OutputTransformPointer m_FixedToMiddleTransform{ nullptr };
239 
240  RealType m_ConvergenceThreshold{ static_cast<RealType>(1.0e-6) };
241  unsigned int m_ConvergenceWindowSize{ 10 };
242 
244  bool m_DownsampleImagesForMetricDerivatives{ true };
245  bool m_AverageMidPointGradients{ false };
246 
247 private:
248  RealType m_GaussianSmoothingVarianceForTheUpdateField{ 3.0 };
249  RealType m_GaussianSmoothingVarianceForTheTotalField{ 0.5 };
250 };
251 } // end namespace itk
252 
253 #ifndef ITK_MANUAL_INSTANTIATION
254 #include "itkSyNImageRegistrationMethod.hxx"
255 #endif
256 
257 #endif
typename Superclass::TransformType TransformType
Implementation of an image mask as spatial object.
Light weight base class for most itk classes.
std::vector< FixedImageMaskConstPointer > FixedImageMasksContainerType
typename ImageMetricType::Pointer ImageMetricPointer
typename OutputTransformType::DerivativeType DerivativeType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
Provides local/dense/high-dimensionaltiy transformation via a a displacement field.
This class takes one ore more ObjectToObject metrics and assigns weights to their derivatives to comp...
Computes similarity between two point sets.
std::vector< MovingImageConstPointer > MovingImagesContainerType
typename ImageMetricType::FixedImageMaskType FixedImageMaskType
NumberOfIterationsArrayType m_NumberOfIterationsPerLevel
typename VirtualImageBaseType::ConstPointer VirtualImageBaseConstPointer
typename PointSetType::Pointer PointSetPointer
Base class for all object-to-object similarlity metrics added in ITKv4.
typename DisplacementFieldType::PixelType DisplacementVectorType
typename MovingImageType::Pointer MovingImagePointer
typename Superclass::MeasureType MeasureType
typename ImageMaskSpatialObjectType::ImageType MovingMaskImageType
Interface method for the performing greedy SyN image registration.
std::vector< MovingImageMaskConstPointer > MovingImageMasksContainerType
std::vector< PointSetConstPointer > PointSetsContainerType
typename CompositeTransformType::TransformType TransformBaseType
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:83
typename ImageMetricType::MeasureType MeasureType
This class contains a list of transforms and concatenates them by composition.
typename DisplacementFieldTransformType::Pointer DisplacementFieldTransformPointer
Decorates any subclass of itkObject with a DataObject API.
typename DerivativeType::ValueType DerivativeValueType
typename DecoratedOutputTransformType::Pointer DecoratedOutputTransformPointer
std::vector< FixedImageConstPointer > FixedImagesContainerType
typename FixedImageType::Pointer FixedImagePointer
typename DisplacementFieldType::Pointer DisplacementFieldPointer
Base class for templated image classes.
Definition: itkImageBase.h:105
typename ImageMetricType::MovingImageMaskType MovingImageMaskType
typename ImageMaskSpatialObjectType::ImageType FixedMaskImageType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename OutputTransformType::ScalarType RealType
typename Superclass::ImageType ImageType
Interface method for the current registration framework.
typename OutputTransformType::DisplacementFieldType DisplacementFieldType
typename MetricType::Pointer MetricPointer
typename OutputTransformType::Pointer OutputTransformPointer