ITK  4.13.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:
76  typedef ImageRegistrationMethodv4<TFixedImage, TMovingImage, TOutputTransform,
77  TVirtualImage, TPointSet> Superclass;
80 
82  itkNewMacro( Self );
83 
85  itkStaticConstMacro( ImageDimension, unsigned int, TFixedImage::ImageDimension );
86 
88  itkTypeMacro( SyNImageRegistrationMethod, SimpleImageRegistrationMethod );
89 
91  typedef TFixedImage FixedImageType;
92  typedef typename FixedImageType::Pointer FixedImagePointer;
93  typedef typename Superclass::FixedImagesContainerType FixedImagesContainerType;
94  typedef TMovingImage MovingImageType;
95  typedef typename MovingImageType::Pointer MovingImagePointer;
96  typedef typename Superclass::MovingImagesContainerType MovingImagesContainerType;
97 
98  typedef typename Superclass::PointSetType PointSetType;
99  typedef typename PointSetType::Pointer PointSetPointer;
100  typedef typename Superclass::PointSetsContainerType PointSetsContainerType;
101 
103  typedef typename Superclass::ImageMetricType ImageMetricType;
106 
108  typedef typename Superclass::FixedImageMaskType FixedImageMaskType;
110  typedef typename Superclass::FixedImageMasksContainerType FixedImageMasksContainerType;
111  typedef typename Superclass::MovingImageMaskType MovingImageMaskType;
113  typedef typename Superclass::MovingImageMasksContainerType MovingImageMasksContainerType;
114 
115  typedef typename Superclass::VirtualImageType VirtualImageType;
116  typedef typename Superclass::VirtualImageBaseType VirtualImageBaseType;
117  typedef typename Superclass::VirtualImageBaseConstPointer VirtualImageBaseConstPointer;
118 
119  typedef typename Superclass::MultiMetricType MultiMetricType;
120  typedef typename Superclass::MetricType MetricType;
122  typedef typename Superclass::PointSetMetricType PointSetMetricType;
123 
124  typedef typename Superclass::InitialTransformType InitialTransformType;
125  typedef TOutputTransform OutputTransformType;
126  typedef typename OutputTransformType::Pointer OutputTransformPointer;
127  typedef typename OutputTransformType::ScalarType RealType;
128  typedef typename OutputTransformType::DerivativeType DerivativeType;
129  typedef typename DerivativeType::ValueType DerivativeValueType;
130  typedef typename OutputTransformType::DisplacementFieldType DisplacementFieldType;
131  typedef typename DisplacementFieldType::Pointer DisplacementFieldPointer;
132  typedef typename DisplacementFieldType::PixelType DisplacementVectorType;
133 
134  typedef typename Superclass::CompositeTransformType CompositeTransformType;
136 
137  typedef typename Superclass::DecoratedOutputTransformType DecoratedOutputTransformType;
139 
142 
144 
146  itkSetMacro( LearningRate, RealType );
147  itkGetConstMacro( LearningRate, RealType );
149 
151  itkSetMacro( NumberOfIterationsPerLevel, NumberOfIterationsArrayType );
152  itkGetConstMacro( NumberOfIterationsPerLevel, NumberOfIterationsArrayType );
154 
156  itkSetMacro( ConvergenceThreshold, RealType );
157  itkGetConstMacro( ConvergenceThreshold, RealType );
159 
161  itkSetMacro( ConvergenceWindowSize, unsigned int );
162  itkGetConstMacro( ConvergenceWindowSize, unsigned int );
164 
169  itkSetMacro( DownsampleImagesForMetricDerivatives, bool );
170  itkGetConstMacro( DownsampleImagesForMetricDerivatives, bool );
172 
176  itkSetMacro( AverageMidPointGradients, bool );
177  itkGetConstMacro( AverageMidPointGradients, bool );
179 
184  itkSetMacro( GaussianSmoothingVarianceForTheUpdateField, RealType );
185  itkGetConstReferenceMacro( GaussianSmoothingVarianceForTheUpdateField, RealType );
187 
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  virtual ~SyNImageRegistrationMethod() ITK_OVERRIDE;
209  virtual void PrintSelf( std::ostream & os, Indent indent ) const ITK_OVERRIDE;
210 
212  virtual void GenerateData() ITK_OVERRIDE;
213 
215  virtual void StartOptimization();
216 
221  virtual void InitializeRegistrationAtEachLevel( const SizeValueType ) ITK_OVERRIDE;
222 
223  virtual DisplacementFieldPointer ComputeUpdateField( const FixedImagesContainerType, const PointSetsContainerType,
224  const TransformBaseType *, const MovingImagesContainerType, const PointSetsContainerType,
225  const TransformBaseType *, const FixedImageMasksContainerType, const MovingImageMasksContainerType, MeasureType & );
226  virtual DisplacementFieldPointer ComputeMetricGradientField( const FixedImagesContainerType,
227  const PointSetsContainerType, const TransformBaseType *, const MovingImagesContainerType,
228  const PointSetsContainerType, const TransformBaseType *, const FixedImageMasksContainerType,
229  const MovingImageMasksContainerType, MeasureType & );
230 
231  virtual DisplacementFieldPointer ScaleUpdateField( const DisplacementFieldType * );
232  virtual DisplacementFieldPointer GaussianSmoothDisplacementField( const DisplacementFieldType *, const RealType );
233  virtual DisplacementFieldPointer InvertDisplacementField( const DisplacementFieldType *, const DisplacementFieldType * = ITK_NULLPTR );
234 
235  RealType m_LearningRate;
236 
237  OutputTransformPointer m_MovingToMiddleTransform;
238  OutputTransformPointer m_FixedToMiddleTransform;
239 
240  RealType m_ConvergenceThreshold;
241  unsigned int m_ConvergenceWindowSize;
242 
243  NumberOfIterationsArrayType m_NumberOfIterationsPerLevel;
244  bool m_DownsampleImagesForMetricDerivatives;
245  bool m_AverageMidPointGradients;
246 
247 private:
248  ITK_DISALLOW_COPY_AND_ASSIGN(SyNImageRegistrationMethod);
249 
250  RealType m_GaussianSmoothingVarianceForTheUpdateField;
251  RealType m_GaussianSmoothingVarianceForTheTotalField;
252 };
253 } // end namespace itk
254 
255 #ifndef ITK_MANUAL_INSTANTIATION
256 #include "itkSyNImageRegistrationMethod.hxx"
257 #endif
258 
259 #endif
Superclass::MovingImageMasksContainerType MovingImageMasksContainerType
Implementation of an image mask as spatial object.
Superclass::PointSetMetricType PointSetMetricType
Light weight base class for most itk classes.
Superclass::MeasureType MeasureType
Superclass::MovingImageMaskType MovingImageMaskType
Superclass::FixedImageMasksContainerType FixedImageMasksContainerType
DisplacementFieldTransformType::Pointer DisplacementFieldTransformPointer
Provides local/dense/high-dimensionaltiy transformation via a a displacement field.
OutputTransformType::Pointer OutputTransformPointer
ImageMaskSpatialObjectType::ImageType FixedMaskImageType
Superclass::VirtualImageType VirtualImageType
Superclass::InitialTransformType InitialTransformType
Superclass::FixedImageMaskType FixedImageMaskType
DisplacementFieldTransform< RealType, ImageDimension > DisplacementFieldTransformType
unsigned long SizeValueType
Definition: itkIntTypes.h:143
DisplacementFieldType::PixelType DisplacementVectorType
std::vector< MovingImageMaskConstPointer > MovingImageMasksContainerType
Superclass::VirtualImageBaseConstPointer VirtualImageBaseConstPointer
ImageMaskSpatialObject< ImageDimension > ImageMaskSpatialObjectType
Interface method for the performing greedy SyN image registration.
Superclass::VirtualImageBaseType VirtualImageBaseType
Superclass::CompositeTransformType CompositeTransformType
std::vector< FixedImageMaskConstPointer > FixedImageMasksContainerType
Superclass::PointSetsContainerType PointSetsContainerType
Superclass::FixedImagesContainerType FixedImagesContainerType
Superclass::MovingImagesContainerType MovingImagesContainerType
ImageMaskSpatialObjectType::ImageType MovingMaskImageType
ImageRegistrationMethodv4< TFixedImage, TMovingImage, TOutputTransform, TVirtualImage, TPointSet > Superclass
DisplacementFieldType::Pointer DisplacementFieldPointer
OutputTransformType::DerivativeType DerivativeType
std::vector< MovingImagePointer > MovingImagesContainerType
CompositeTransformType::TransformType TransformBaseType
OutputTransformType::DisplacementFieldType DisplacementFieldType
Superclass::DecoratedOutputTransformType DecoratedOutputTransformType
OutputTransformType::ScalarType RealType
Superclass::TransformType TransformType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
std::vector< FixedImagePointer > FixedImagesContainerType
DecoratedOutputTransformType::Pointer DecoratedOutputTransformPointer
Interface method for the current registration framework.
OutputTransformType::ScalarType RealType
std::vector< PointSetConstPointer > PointSetsContainerType
OutputTransformType::Pointer OutputTransformPointer