1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef __clitkSpatioTemporalMultiResolutionImageRegistrationMethod_h
19 #define __clitkSpatioTemporalMultiResolutionImageRegistrationMethod_h
20 #include "clitkSpatioTemporalMultiResolutionPyramidImageFilter.h"
22 #include "itkProcessObject.h"
23 #include "itkImageToImageMetric.h"
24 #include "itkSingleValuedNonLinearOptimizer.h"
25 #include "itkNumericTraits.h"
26 #include "itkDataObjectDecorator.h"
31 template <typename TFixedImage, typename TMovingImage>
32 class ITK_EXPORT SpatioTemporalMultiResolutionImageRegistrationMethod : public itk::ProcessObject
35 /** Standard class typedefs. */
36 typedef SpatioTemporalMultiResolutionImageRegistrationMethod Self;
37 typedef itk::ProcessObject Superclass;
38 typedef SmartPointer<Self> Pointer;
39 typedef SmartPointer<const Self> ConstPointer;
41 /** Method for creation through the object factory. */
44 /** Run-time type information (and related methods). */
45 itkTypeMacro(SpatioTemporalMultiResolutionImageRegistrationMethod, ProcessObject);
47 /** Type of the Fixed image. */
48 typedef TFixedImage FixedImageType;
49 typedef typename FixedImageType::ConstPointer FixedImageConstPointer;
50 typedef typename FixedImageType::RegionType FixedImageRegionType;
52 /** Type of the Moving image. */
53 typedef TMovingImage MovingImageType;
54 typedef typename MovingImageType::ConstPointer MovingImageConstPointer;
56 /** Type of the metric. */
57 typedef itk::ImageToImageMetric< FixedImageType,
58 MovingImageType > MetricType;
59 typedef typename MetricType::Pointer MetricPointer;
61 /** Type of the Transform . */
62 typedef typename MetricType::TransformType TransformType;
63 typedef typename TransformType::Pointer TransformPointer;
65 /** Type for the output: Using Decorator pattern for enabling
66 * the Transform to be passed in the data pipeline */
67 typedef itk::DataObjectDecorator< TransformType > TransformOutputType;
68 typedef typename TransformOutputType::Pointer TransformOutputPointer;
69 typedef typename TransformOutputType::ConstPointer TransformOutputConstPointer;
71 /** Type of the Interpolator. */
72 typedef typename MetricType::InterpolatorType InterpolatorType;
73 typedef typename InterpolatorType::Pointer InterpolatorPointer;
75 /** Type of the optimizer. */
76 typedef itk::SingleValuedNonLinearOptimizer OptimizerType;
78 //JV replace with clitk Spatio Temporal Type
79 /** Type of the Fixed image multiresolution pyramid. */
80 typedef SpatioTemporalMultiResolutionPyramidImageFilter< FixedImageType,
82 FixedImagePyramidType;
83 typedef typename FixedImagePyramidType::Pointer FixedImagePyramidPointer;
85 /** Type of pyramid schedule type */
86 typedef typename FixedImagePyramidType::ScheduleType ScheduleType;
88 //JV replace with clitk Spatio Temporal Type
89 /** Type of the moving image multiresolution pyramid. */
90 typedef SpatioTemporalMultiResolutionPyramidImageFilter< MovingImageType,
92 MovingImagePyramidType;
93 typedef typename MovingImagePyramidType::Pointer MovingImagePyramidPointer;
95 /** Type of the Transformation parameters This is the same type used to
96 * represent the search space of the optimization algorithm */
97 typedef typename MetricType::TransformParametersType ParametersType;
99 /** Smart Pointer type to a DataObject. */
100 typedef typename itk::DataObject::Pointer DataObjectPointer;
102 /** Method that initiates the registration. */
103 void StartRegistration();
105 /** Method to stop the registration. */
106 void StopRegistration();
108 /** Set/Get the Fixed image. */
109 itkSetConstObjectMacro( FixedImage, FixedImageType );
110 itkGetConstObjectMacro( FixedImage, FixedImageType );
112 /** Set/Get the Moving image. */
113 itkSetConstObjectMacro( MovingImage, MovingImageType );
114 itkGetConstObjectMacro( MovingImage, MovingImageType );
116 /** Set/Get the Optimizer. */
117 itkSetObjectMacro( Optimizer, OptimizerType );
118 itkGetObjectMacro( Optimizer, OptimizerType );
120 /** Set/Get the Metric. */
121 itkSetObjectMacro( Metric, MetricType );
122 itkGetObjectMacro( Metric, MetricType );
124 /** Set/Get the Metric. */
125 itkSetMacro( FixedImageRegion, FixedImageRegionType );
126 itkGetConstReferenceMacro( FixedImageRegion, FixedImageRegionType );
128 /** Set/Get the Transfrom. */
129 itkSetObjectMacro( Transform, TransformType );
130 itkGetObjectMacro( Transform, TransformType );
132 /** Set/Get the Interpolator. */
133 itkSetObjectMacro( Interpolator, InterpolatorType );
134 itkGetObjectMacro( Interpolator, InterpolatorType );
136 /** Set/Get the Fixed image pyramid. */
137 itkSetObjectMacro( FixedImagePyramid, FixedImagePyramidType );
138 itkGetObjectMacro( FixedImagePyramid, FixedImagePyramidType );
140 /** Set/Get the Moving image pyramid. */
141 itkSetObjectMacro( MovingImagePyramid, MovingImagePyramidType );
142 itkGetObjectMacro( MovingImagePyramid, MovingImagePyramidType );
144 /** Set/Get the schedules . */
145 void SetSchedules( const ScheduleType & fixedSchedule,
146 const ScheduleType & movingSchedule );
147 itkGetConstMacro( FixedImagePyramidSchedule, ScheduleType );
148 itkGetConstMacro( MovingImagePyramidSchedule, ScheduleType );
150 /** Set/Get the number of multi-resolution levels. */
151 void SetNumberOfLevels( unsigned long numberOfLevels );
152 itkGetMacro( NumberOfLevels, unsigned long );
154 /** Get the current resolution level being processed. */
155 itkGetMacro( CurrentLevel, unsigned long );
157 /** Set/Get the initial transformation parameters. */
158 itkSetMacro( InitialTransformParameters, ParametersType );
159 itkGetConstReferenceMacro( InitialTransformParameters, ParametersType );
161 /** Set/Get the initial transformation parameters of the next resolution
162 level to be processed. The default is the last set of parameters of
163 the last resolution level. */
164 itkSetMacro( InitialTransformParametersOfNextLevel, ParametersType );
165 itkGetConstReferenceMacro( InitialTransformParametersOfNextLevel, ParametersType );
167 /** Get the last transformation parameters visited by
169 itkGetConstReferenceMacro( LastTransformParameters, ParametersType );
171 /** Returns the transform resulting from the registration process */
172 const TransformOutputType * GetOutput() const;
174 /** Make a DataObject of the correct type to be used as the specified
176 virtual DataObjectPointer MakeOutput(unsigned int idx);
178 /** Method to return the latest modified time of this object or
179 * any of its cached ivars */
180 unsigned long GetMTime() const;
183 SpatioTemporalMultiResolutionImageRegistrationMethod();
184 virtual ~SpatioTemporalMultiResolutionImageRegistrationMethod() {};
185 void PrintSelf(std::ostream& os, Indent indent) const;
187 /** Method invoked by the pipeline in order to trigger the computation of
188 * the registration. */
189 void GenerateData ();
191 /** Initialize by setting the interconnects between the components.
192 This method is executed at every level of the pyramid with the
193 values corresponding to this resolution
195 void Initialize() throw (ExceptionObject);
197 /** Compute the size of the fixed region for each level of the pyramid. */
198 void PreparePyramids( void );
200 /** Set the current level to be processed */
201 itkSetMacro( CurrentLevel, unsigned long );
204 SpatioTemporalMultiResolutionImageRegistrationMethod(const Self&); //purposely not implemented
205 void operator=(const Self&); //purposely not implemented
207 MetricPointer m_Metric;
208 OptimizerType::Pointer m_Optimizer;
210 MovingImageConstPointer m_MovingImage;
211 FixedImageConstPointer m_FixedImage;
213 TransformPointer m_Transform;
214 InterpolatorPointer m_Interpolator;
216 MovingImagePyramidPointer m_MovingImagePyramid;
217 FixedImagePyramidPointer m_FixedImagePyramid;
219 ParametersType m_InitialTransformParameters;
220 ParametersType m_InitialTransformParametersOfNextLevel;
221 ParametersType m_LastTransformParameters;
223 FixedImageRegionType m_FixedImageRegion;
224 std::vector<FixedImageRegionType> m_FixedImageRegionPyramid;
226 unsigned long m_NumberOfLevels;
227 unsigned long m_CurrentLevel;
231 ScheduleType m_FixedImagePyramidSchedule;
232 ScheduleType m_MovingImagePyramidSchedule;
234 bool m_ScheduleSpecified;
235 bool m_NumberOfLevelsSpecified;
240 } // end namespace clitk
243 #ifndef ITK_MANUAL_INSTANTIATION
244 #include "clitkSpatioTemporalMultiResolutionImageRegistrationMethod.txx"