go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
elxElastixTemplate.h
Go to the documentation of this file.
1 /*======================================================================
2 
3  This file is part of the elastix software.
4 
5  Copyright (c) University Medical Center Utrecht. All rights reserved.
6  See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
7  details.
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 above copyright notices for more information.
12 
13 ======================================================================*/
14 
15 #ifndef __elxElastixTemplate_h
16 #define __elxElastixTemplate_h
17 
18 #include "elxElastixBase.h"
19 #include "itkObject.h"
20 
21 #include "itkObjectFactory.h"
22 #include "itkCommand.h"
23 #include "itkImage.h"
24 #include "itkImageFileReader.h"
25 #include "itkImageToImageMetric.h"
26 
27 #include "elxRegistrationBase.h"
30 #include "elxInterpolatorBase.h"
31 #include "elxImageSamplerBase.h"
32 #include "elxMetricBase.h"
33 #include "elxOptimizerBase.h"
34 #include "elxResamplerBase.h"
36 #include "elxTransformBase.h"
37 
38 #include "elxTimer.h"
39 
40 #include <sstream>
41 #include <fstream>
42 
57 #define elxGetBaseMacro(_name,_elxbasetype) \
58  virtual _elxbasetype * GetElx##_name##Base (void) const \
59  { \
60  return this->GetElx##_name##Base( 0 );\
61  }\
62  _elxbasetype * GetElx##_name##Base ( unsigned int idx ) const \
63  { \
64  if ( idx < this->GetNumberOf##_name##s() ) \
65  { \
66  return dynamic_cast<_elxbasetype *>( \
67  this->Get##_name##Container()->ElementAt(idx).GetPointer() );\
68  } \
69  return 0; \
70  }
71 //end elxGetBaseMacro
72 
73 
74 namespace elastix
75 {
76 using namespace itk;
77 
111 template <class TFixedImage, class TMovingImage>
112  class ElastixTemplate : public Object, public ElastixBase
113 {
114 public:
115 
118  typedef Object Superclass1;
120  typedef SmartPointer<Self> Pointer;
121  typedef SmartPointer<const Self> ConstPointer;
122 
124  itkNewMacro( Self );
125 
127  itkTypeMacro( ElastixTemplate, Object );
128 
132  typedef Superclass2::ObjectType ObjectType; //for the components
133  typedef Superclass2::DataObjectType DataObjectType; //for the images
142 
144  typedef TFixedImage FixedImageType;
145  typedef TMovingImage MovingImageType;
146  typedef typename FixedImageType::Pointer FixedImagePointer;
147  typedef typename MovingImageType::Pointer MovingImagePointer;
148 
150  itkStaticConstMacro( Dimension, unsigned int, FixedImageType::ImageDimension );
151  itkStaticConstMacro( FixedDimension, unsigned int, FixedImageType::ImageDimension );
152  itkStaticConstMacro( MovingDimension, unsigned int, MovingImageType::ImageDimension );
153 
155  typedef unsigned char MaskPixelType;
156  typedef Image<MaskPixelType, FixedDimension> FixedMaskType;
157  typedef Image<MaskPixelType, MovingDimension> MovingMaskType;
158  typedef typename FixedMaskType::Pointer FixedMaskPointer;
159  typedef typename MovingMaskType::Pointer MovingMaskPointer;
160 
162  typedef typename FixedImageType::DirectionType FixedImageDirectionType;
163 
165  typedef CostFunction::ParametersValueType CoordRepType; // double
166 
169 
171  typedef void (BaseComponentType::*PtrToMemberFunction)(void);
172  typedef int (BaseComponentType::*PtrToMemberFunction2)(void);
173 
175  typedef SimpleMemberCommand<Self> BeforeEachResolutionCommandType;
176  typedef SimpleMemberCommand<Self> AfterEachResolutionCommandType;
177  typedef SimpleMemberCommand<Self> AfterEachIterationCommandType;
178  typedef typename BeforeEachResolutionCommandType::Pointer BeforeEachResolutionCommandPointer;
179  typedef typename AfterEachResolutionCommandType::Pointer AfterEachResolutionCommandPointer;
180  typedef typename AfterEachIterationCommandType::Pointer AfterEachIterationCommandPointer;
181 
193 
197 
204 
208  elxGetBaseMacro( FixedImagePyramid, FixedImagePyramidBaseType );
209  elxGetBaseMacro( MovingImagePyramid, MovingImagePyramidBaseType );
210  elxGetBaseMacro( Interpolator, InterpolatorBaseType );
211  elxGetBaseMacro( ImageSampler, ImageSamplerBaseType );
212  elxGetBaseMacro( Metric, MetricBaseType );
213  elxGetBaseMacro( Optimizer, OptimizerBaseType );
214  elxGetBaseMacro( Registration, RegistrationBaseType );
215  elxGetBaseMacro( Resampler, ResamplerBaseType );
216  elxGetBaseMacro( ResampleInterpolator, ResampleInterpolatorBaseType );
217  elxGetBaseMacro( Transform, TransformBaseType );
218 
222  virtual FixedImageType * GetFixedImage( void ) const
223  {
224  return this->GetFixedImage( 0 );
225  }
226  virtual FixedImageType * GetFixedImage( unsigned int idx ) const;
227  virtual MovingImageType * GetMovingImage( void ) const
228  {
229  return this->GetMovingImage( 0 );
230  }
231  virtual MovingImageType * GetMovingImage( unsigned int idx ) const;
232 
236  virtual FixedMaskType * GetFixedMask( void ) const
237  {
238  return this->GetFixedMask( 0 );
239  }
240  virtual FixedMaskType * GetFixedMask( unsigned int idx ) const;
241  virtual MovingMaskType * GetMovingMask( void ) const
242  {
243  return this->GetMovingMask( 0 );
244  }
245  virtual MovingMaskType * GetMovingMask( unsigned int idx ) const;
246 
251  virtual int Run( void );
252  virtual int ApplyTransform( void );
253 
255  virtual int BeforeAll( void );
256  virtual int BeforeAllTransformix( void );
257  virtual void BeforeRegistration( void );
258  virtual void BeforeEachResolution( void );
259  virtual void AfterEachResolution( void );
260  virtual void AfterEachIteration( void );
261  virtual void AfterRegistration( void );
262 
264  itkGetConstMacro( IterationCounter, unsigned int );
265 
267  itkGetStringMacro( CurrentTransformParameterFileName );
268 
273  virtual bool GetOriginalFixedImageDirection( FixedImageDirectionType & direction ) const;
274 
275 protected:
276 
277  ElastixTemplate();
278  virtual ~ElastixTemplate(){};
279 
281  typedef typename Superclass2::MultipleImageLoader<FixedImageType> FixedImageLoaderType;
285 
290 
295 
298 
300  unsigned int m_IterationCounter;
301 
303  virtual void CreateTransformParameterFile( const std::string FileName,
304  const bool ToLog );
305 
307  virtual void OpenIterationInfoFile( void );
308  std::ofstream m_IterationInfoFile;
309 
323  void CallInEachComponent( PtrToMemberFunction func );
324  int CallInEachComponentInt( PtrToMemberFunction2 func );
325 
330  virtual void ConfigureComponents( Self * This );
331 
333  virtual void SetOriginalFixedImageDirection( const FixedImageDirectionType & arg );
334 
335 private:
336 
337  ElastixTemplate( const Self& ); // purposely not implemented
338  void operator=( const Self& ); // purposely not implemented
339 
340  }; // end class ElastixTemplate
341 
342 
343 } // end namespace elastix
344 
345 
346 #undef elxGetBaseMacro
347 
348 #ifndef ITK_MANUAL_INSTANTIATION
349 #include "elxElastixTemplate.hxx"
350 #endif
351 
352 #endif // end #ifndef __elxElastixTemplate_h
353 


Generated on 27-06-2013 for elastix by doxygen 1.8.3.1 elastix logo