]> Creatis software - clitk.git/blob - registration/clitkSpatioTemporalMultiResolutionImageRegistrationMethod.h
Debug RTStruct conversion with empty struc
[clitk.git] / registration / clitkSpatioTemporalMultiResolutionImageRegistrationMethod.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
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
8
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.
12
13   It is distributed under dual licence
14
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"
21
22 #include "itkProcessObject.h"
23 #include "itkImageToImageMetric.h"
24 #include "itkSingleValuedNonLinearOptimizer.h"
25 #include "itkNumericTraits.h"
26 #include "itkDataObjectDecorator.h"
27
28 namespace clitk
29 {
30
31 template <typename TFixedImage, typename TMovingImage>
32 class ITK_EXPORT SpatioTemporalMultiResolutionImageRegistrationMethod : public itk::ProcessObject 
33 {
34 public:
35   /** Standard class typedefs. */
36   typedef SpatioTemporalMultiResolutionImageRegistrationMethod  Self;
37   typedef itk::ProcessObject                      Superclass;
38   typedef SmartPointer<Self>                      Pointer;
39   typedef SmartPointer<const Self>                ConstPointer;
40
41   /** Method for creation through the object factory. */
42   itkNewMacro(Self);
43   
44   /** Run-time type information (and related methods). */
45   itkTypeMacro(SpatioTemporalMultiResolutionImageRegistrationMethod, ProcessObject);
46
47   /**  Type of the Fixed image. */
48   typedef          TFixedImage                     FixedImageType;
49   typedef typename FixedImageType::ConstPointer    FixedImageConstPointer;
50   typedef typename FixedImageType::RegionType      FixedImageRegionType;
51
52   /**  Type of the Moving image. */
53   typedef          TMovingImage                    MovingImageType;
54   typedef typename MovingImageType::ConstPointer   MovingImageConstPointer;
55
56   /**  Type of the metric. */
57   typedef itk::ImageToImageMetric< FixedImageType,
58                               MovingImageType >    MetricType;
59   typedef typename MetricType::Pointer             MetricPointer;
60
61   /**  Type of the Transform . */
62   typedef typename MetricType::TransformType       TransformType;
63   typedef typename TransformType::Pointer          TransformPointer;
64
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;
70   
71   /**  Type of the Interpolator. */
72   typedef typename MetricType::InterpolatorType    InterpolatorType;
73   typedef typename InterpolatorType::Pointer       InterpolatorPointer;
74
75   /**  Type of the optimizer. */
76   typedef itk::SingleValuedNonLinearOptimizer           OptimizerType;
77
78   //JV replace with clitk Spatio Temporal Type
79   /** Type of the Fixed image multiresolution pyramid. */
80   typedef SpatioTemporalMultiResolutionPyramidImageFilter< FixedImageType,
81                                              FixedImageType >
82                                                    FixedImagePyramidType;
83   typedef typename FixedImagePyramidType::Pointer  FixedImagePyramidPointer;
84
85   /** Type of pyramid schedule type */
86   typedef typename FixedImagePyramidType::ScheduleType ScheduleType;
87
88   //JV replace with clitk Spatio Temporal Type
89   /** Type of the moving image multiresolution pyramid. */
90   typedef SpatioTemporalMultiResolutionPyramidImageFilter< MovingImageType,
91                                              MovingImageType >
92                                                    MovingImagePyramidType;
93   typedef typename MovingImagePyramidType::Pointer MovingImagePyramidPointer;
94
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;
98
99   /** Smart Pointer type to a DataObject. */
100   typedef typename itk::DataObject::Pointer DataObjectPointer;
101
102   /** Method that initiates the registration. */
103   void StartRegistration();
104
105   /** Method to stop the registration. */
106   void StopRegistration();
107
108   /** Set/Get the Fixed image. */
109   itkSetConstObjectMacro( FixedImage, FixedImageType );
110   itkGetConstObjectMacro( FixedImage, FixedImageType ); 
111
112   /** Set/Get the Moving image. */
113   itkSetConstObjectMacro( MovingImage, MovingImageType );
114   itkGetConstObjectMacro( MovingImage, MovingImageType );
115
116   /** Set/Get the Optimizer. */
117   itkSetObjectMacro( Optimizer,  OptimizerType );
118   itkGetObjectMacro( Optimizer,  OptimizerType );
119
120   /** Set/Get the Metric. */
121   itkSetObjectMacro( Metric, MetricType );
122   itkGetObjectMacro( Metric, MetricType );
123
124   /** Set/Get the Metric. */
125   itkSetMacro( FixedImageRegion, FixedImageRegionType );
126   itkGetConstReferenceMacro( FixedImageRegion, FixedImageRegionType );
127
128   /** Set/Get the Transfrom. */
129   itkSetObjectMacro( Transform, TransformType );
130   itkGetObjectMacro( Transform, TransformType );
131
132   /** Set/Get the Interpolator. */
133   itkSetObjectMacro( Interpolator, InterpolatorType );
134   itkGetObjectMacro( Interpolator, InterpolatorType );
135
136   /** Set/Get the Fixed image pyramid. */
137   itkSetObjectMacro( FixedImagePyramid, FixedImagePyramidType );
138   itkGetObjectMacro( FixedImagePyramid, FixedImagePyramidType ); 
139
140   /** Set/Get the Moving image pyramid. */
141   itkSetObjectMacro( MovingImagePyramid, MovingImagePyramidType );
142   itkGetObjectMacro( MovingImagePyramid, MovingImagePyramidType );
143
144   /** Set/Get the schedules . */
145   void SetSchedules( const ScheduleType & fixedSchedule,
146                     const ScheduleType & movingSchedule );
147   itkGetConstMacro( FixedImagePyramidSchedule, ScheduleType ); 
148   itkGetConstMacro( MovingImagePyramidSchedule, ScheduleType ); 
149
150   /** Set/Get the number of multi-resolution levels. */
151   void SetNumberOfLevels( unsigned long numberOfLevels );
152   itkGetMacro( NumberOfLevels, unsigned long );
153
154   /** Get the current resolution level being processed. */
155   itkGetMacro( CurrentLevel, unsigned long );
156
157   /** Set/Get the initial transformation parameters. */
158   itkSetMacro( InitialTransformParameters, ParametersType );
159   itkGetConstReferenceMacro( InitialTransformParameters, ParametersType );
160
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 );
166
167   /** Get the last transformation parameters visited by 
168    * the optimizer. */
169   itkGetConstReferenceMacro( LastTransformParameters, ParametersType );  
170
171   /** Returns the transform resulting from the registration process  */
172   const TransformOutputType * GetOutput() const;
173
174   /** Make a DataObject of the correct type to be used as the specified
175    * output. */
176   virtual DataObjectPointer MakeOutput(unsigned int idx);
177
178   /** Method to return the latest modified time of this object or
179    * any of its cached ivars */
180   unsigned long GetMTime() const;  
181   
182 protected:
183   SpatioTemporalMultiResolutionImageRegistrationMethod();
184   virtual ~SpatioTemporalMultiResolutionImageRegistrationMethod() {};
185   void PrintSelf(std::ostream& os, Indent indent) const;
186
187   /** Method invoked by the pipeline in order to trigger the computation of 
188    * the registration. */
189   void  GenerateData ();
190
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
194    */
195   void Initialize() throw (ExceptionObject);
196
197   /** Compute the size of the fixed region for each level of the pyramid. */
198   void PreparePyramids( void );
199
200   /** Set the current level to be processed */  
201   itkSetMacro( CurrentLevel, unsigned long );
202
203 private:
204   SpatioTemporalMultiResolutionImageRegistrationMethod(const Self&); //purposely not implemented
205   void operator=(const Self&); //purposely not implemented
206   
207   MetricPointer                    m_Metric;
208   OptimizerType::Pointer           m_Optimizer;
209
210   MovingImageConstPointer          m_MovingImage;
211   FixedImageConstPointer           m_FixedImage;
212
213   TransformPointer                 m_Transform;
214   InterpolatorPointer              m_Interpolator;
215
216   MovingImagePyramidPointer        m_MovingImagePyramid;
217   FixedImagePyramidPointer         m_FixedImagePyramid;
218
219   ParametersType                   m_InitialTransformParameters;
220   ParametersType                   m_InitialTransformParametersOfNextLevel;
221   ParametersType                   m_LastTransformParameters;
222
223   FixedImageRegionType               m_FixedImageRegion;
224   std::vector<FixedImageRegionType>  m_FixedImageRegionPyramid;
225
226   unsigned long                    m_NumberOfLevels;
227   unsigned long                    m_CurrentLevel;
228
229   bool                             m_Stop;
230
231   ScheduleType                     m_FixedImagePyramidSchedule;
232   ScheduleType                     m_MovingImagePyramidSchedule;
233
234   bool                             m_ScheduleSpecified;
235   bool                             m_NumberOfLevelsSpecified;
236   
237 };
238
239
240 } // end namespace clitk
241
242
243 #ifndef ITK_MANUAL_INSTANTIATION
244 #include "clitkSpatioTemporalMultiResolutionImageRegistrationMethod.txx"
245 #endif
246
247 #endif