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 #ifndef __elxElastixTemplate_h
15 #define __elxElastixTemplate_h
16 
17 #include "elxElastixBase.h"
18 #include "itkObject.h"
19 
20 #include "itkObjectFactory.h"
21 #include "itkCommand.h"
22 #include "itkImage.h"
23 #include "itkImageFileReader.h"
24 #include "itkImageToImageMetric.h"
25 
26 #include "elxRegistrationBase.h"
29 #include "elxInterpolatorBase.h"
30 #include "elxImageSamplerBase.h"
31 #include "elxMetricBase.h"
32 #include "elxOptimizerBase.h"
33 #include "elxResamplerBase.h"
35 #include "elxTransformBase.h"
36 
37 #include "elxTimer.h"
38 
39 #include <sstream>
40 #include <fstream>
41 
56 #define elxGetBaseMacro(_name,_elxbasetype) \
57  virtual _elxbasetype * GetElx##_name##Base (void) const \
58  { \
59  return this->GetElx##_name##Base( 0 );\
60  }\
61  _elxbasetype * GetElx##_name##Base ( unsigned int idx ) const \
62  { \
63  if ( idx < this->GetNumberOf##_name##s() ) \
64  { \
65  return dynamic_cast<_elxbasetype *>( \
66  this->Get##_name##Container()->ElementAt(idx).GetPointer() );\
67  } \
68  return 0; \
69  }
70 //end elxGetBaseMacro
71 
72 
73 namespace elastix
74 {
75 
109 template <class TFixedImage, class TMovingImage>
110 class ElastixTemplate : public itk::Object, public ElastixBase
111 {
112 public:
113 
116  typedef itk::Object Superclass1;
118  typedef itk::SmartPointer<Self> Pointer;
119  typedef itk::SmartPointer<const Self> ConstPointer;
120 
122  itkNewMacro( Self );
123 
125  itkTypeMacro( ElastixTemplate, itk::Object );
126 
130  typedef Superclass2::ObjectType ObjectType; //for the components
131  typedef Superclass2::DataObjectType DataObjectType; //for the images
140 
142  typedef TFixedImage FixedImageType;
143  typedef TMovingImage MovingImageType;
144  typedef typename FixedImageType::Pointer FixedImagePointer;
145  typedef typename MovingImageType::Pointer MovingImagePointer;
146 
148  itkStaticConstMacro( Dimension, unsigned int, FixedImageType::ImageDimension );
149  itkStaticConstMacro( FixedDimension, unsigned int, FixedImageType::ImageDimension );
150  itkStaticConstMacro( MovingDimension, unsigned int, MovingImageType::ImageDimension );
151 
153  typedef unsigned char MaskPixelType;
154  typedef itk::Image<MaskPixelType, FixedDimension> FixedMaskType;
155  typedef itk::Image<MaskPixelType, MovingDimension> MovingMaskType;
156  typedef typename FixedMaskType::Pointer FixedMaskPointer;
157  typedef typename MovingMaskType::Pointer MovingMaskPointer;
158 
160  typedef typename FixedImageType::DirectionType FixedImageDirectionType;
161 
163  typedef itk::CostFunction::ParametersValueType CoordRepType; // double
164 
167 
169  typedef void (BaseComponentType::*PtrToMemberFunction)(void);
171 
173  typedef itk::SimpleMemberCommand<Self> BeforeEachResolutionCommandType;
174  typedef itk::SimpleMemberCommand<Self> AfterEachResolutionCommandType;
175  typedef itk::SimpleMemberCommand<Self> AfterEachIterationCommandType;
176  typedef typename BeforeEachResolutionCommandType::Pointer BeforeEachResolutionCommandPointer;
177  typedef typename AfterEachResolutionCommandType::Pointer AfterEachResolutionCommandPointer;
178  typedef typename AfterEachIterationCommandType::Pointer AfterEachIterationCommandPointer;
179 
191 
195 
202 
206  elxGetBaseMacro( FixedImagePyramid, FixedImagePyramidBaseType );
207  elxGetBaseMacro( MovingImagePyramid, MovingImagePyramidBaseType );
208  elxGetBaseMacro( Interpolator, InterpolatorBaseType );
209  elxGetBaseMacro( ImageSampler, ImageSamplerBaseType );
210  elxGetBaseMacro( Metric, MetricBaseType );
211  elxGetBaseMacro( Optimizer, OptimizerBaseType );
212  elxGetBaseMacro( Registration, RegistrationBaseType );
213  elxGetBaseMacro( Resampler, ResamplerBaseType );
214  elxGetBaseMacro( ResampleInterpolator, ResampleInterpolatorBaseType );
215  elxGetBaseMacro( Transform, TransformBaseType );
216 
220  virtual FixedImageType * GetFixedImage( void ) const
221  {
222  return this->GetFixedImage( 0 );
223  }
224  virtual FixedImageType * GetFixedImage( unsigned int idx ) const;
225  virtual MovingImageType * GetMovingImage( void ) const
226  {
227  return this->GetMovingImage( 0 );
228  }
229  virtual MovingImageType * GetMovingImage( unsigned int idx ) const;
230 
234  virtual FixedMaskType * GetFixedMask( void ) const
235  {
236  return this->GetFixedMask( 0 );
237  }
238  virtual FixedMaskType * GetFixedMask( unsigned int idx ) const;
239  virtual MovingMaskType * GetMovingMask( void ) const
240  {
241  return this->GetMovingMask( 0 );
242  }
243  virtual MovingMaskType * GetMovingMask( unsigned int idx ) const;
244 
249  virtual int Run( void );
250  virtual int ApplyTransform( void );
251 
253  virtual int BeforeAll( void );
254  virtual int BeforeAllTransformix( void );
255  virtual void BeforeRegistration( void );
256  virtual void BeforeEachResolution( void );
257  virtual void AfterEachResolution( void );
258  virtual void AfterEachIteration( void );
259  virtual void AfterRegistration( void );
260 
262  itkGetConstMacro( IterationCounter, unsigned int );
263 
265  itkGetStringMacro( CurrentTransformParameterFileName );
266 
271  virtual bool GetOriginalFixedImageDirection( FixedImageDirectionType & direction ) const;
272 
273 protected:
274 
275  ElastixTemplate();
276  virtual ~ElastixTemplate(){};
277 
279  typedef typename Superclass2::MultipleImageLoader<FixedImageType> FixedImageLoaderType;
283 
288 
293 
296 
298  unsigned int m_IterationCounter;
299 
301  virtual void CreateTransformParameterFile( const std::string FileName,
302  const bool ToLog );
303 
305  virtual void OpenIterationInfoFile( void );
306  std::ofstream m_IterationInfoFile;
307 
323 
328  virtual void ConfigureComponents( Self * This );
329 
331  virtual void SetOriginalFixedImageDirection( const FixedImageDirectionType & arg );
332 
333 private:
334 
335  ElastixTemplate( const Self& ); // purposely not implemented
336  void operator=( const Self& ); // purposely not implemented
337 
338  }; // end class ElastixTemplate
339 
340 
341 } // end namespace elastix
342 
343 
344 #undef elxGetBaseMacro
345 
346 #ifndef ITK_MANUAL_INSTANTIATION
347 #include "elxElastixTemplate.hxx"
348 #endif
349 
350 #endif // end #ifndef __elxElastixTemplate_h
351 
virtual bool GetOriginalFixedImageDirection(FixedImageDirectionType &direction) const
FixedImagePyramidBase< Self > FixedImagePyramidBaseType
elx::TransformBase< Self > TransformBaseType
std::string m_CurrentTransformParameterFileName
DataObjectContainerType::Pointer DataObjectContainerPointer
virtual void BeforeEachResolution(void)
itk::VectorContainer< unsigned int, std::string > FileNameContainerType
itk::SmartPointer< Self > Pointer
Definition: elxTimer.h:72
Superclass2::DataObjectContainerType DataObjectContainerType
itk::VectorContainer< unsigned int, DataObjectPointer > DataObjectContainerType
AfterEachIterationCommandType::Pointer AfterEachIterationCommandPointer
The main elastix class, which connects components and invokes the BeforeRegistration(), BeforeEachResolution(), etc. methods.
AfterEachResolutionCommandType::Pointer AfterEachResolutionCommandPointer
virtual void SetOriginalFixedImageDirection(const FixedImageDirectionType &arg)
itk::SmartPointer< Self > Pointer
void CallInEachComponent(PtrToMemberFunction func)
AfterEachIterationCommandPointer m_AfterEachIterationCommand
virtual void BeforeRegistration(void)
This class is the elastix base class for all Optimizers.
This class is the elastix base class for all ImageSamplers.
itk::DataObject DataObjectType
void(BaseComponentType::* PtrToMemberFunction)(void)
itk::Image< MaskPixelType, FixedDimension > FixedMaskType
This class is the elastix base class for all Registration schemes.
FixedImageType::Pointer FixedImagePointer
The BaseComponent class is a class that all elastix components should inherit from.
virtual void AfterEachResolution(void)
void operator=(const Self &)
TimerType::Pointer TimerPointer
A class to time the different parts of the registration.
Definition: elxTimer.h:66
MovingMaskType::Pointer MovingMaskPointer
OptimizerBase< Self > OptimizerBaseType
virtual void OpenIterationInfoFile(void)
Superclass2::DataObjectPointer DataObjectPointer
virtual void CreateTransformParameterFile(const std::string FileName, const bool ToLog)
MovingImagePyramidBase< Self > MovingImagePyramidBaseType
itk::CostFunction::ParametersValueType CoordRepType
InterpolatorBase< Self > InterpolatorBaseType
AfterEachResolutionCommandPointer m_AfterEachResolutionCommand
virtual void AfterEachIteration(void)
virtual MovingImageType * GetMovingImage(void) const
This class is the elastix base class for all FixedImagePyramids.
FileNameContainerType::Pointer FileNameContainerPointer
itk::SimpleMemberCommand< Self > BeforeEachResolutionCommandType
Superclass2::MultipleImageLoader< MovingMaskType > MovingMaskLoaderType
Superclass2::ObjectContainerPointer ObjectContainerPointer
MovingImageType::Pointer MovingImagePointer
itk::SimpleMemberCommand< Self > AfterEachResolutionCommandType
virtual FixedImageType * GetFixedImage(void) const
Superclass2::ConfigurationType ConfigurationType
virtual int ApplyTransform(void)
int(BaseComponentType::* PtrToMemberFunction2)(void)
Superclass2::ObjectContainerType ObjectContainerType
FixedMaskType::Pointer FixedMaskPointer
virtual void ConfigureComponents(Self *This)
RegistrationBase< Self > RegistrationBaseType
virtual void AfterRegistration(void)
virtual FixedMaskType * GetFixedMask(void) const
Superclass2::ObjectPointer ObjectPointer
Superclass2::MultipleImageLoader< MovingImageType > MovingImageLoaderType
Superclass2::FileNameContainerType FileNameContainerType
This class is the elastix base class for all ResampleInterpolators.
ObjectContainerType::Pointer ObjectContainerPointer
This class is the elastix base class for all MovingImagePyramids.
This class is the elastix base class for all Interpolators.
ResampleInterpolatorBase< Self > ResampleInterpolatorBaseType
BeforeEachResolutionCommandPointer m_BeforeEachResolutionCommand
A class that deals with user given parameters and command line arguments.
itk::VectorContainer< unsigned int, ObjectPointer > ObjectContainerType
BeforeEachResolutionCommandType::Pointer BeforeEachResolutionCommandPointer
virtual int BeforeAllTransformix(void)
This class is the elastix base class for all Transforms.
Superclass2::MultipleImageLoader< FixedMaskType > FixedMaskLoaderType
DataObjectType::Pointer DataObjectPointer
virtual int Run(void)
virtual int BeforeAll(void)
ConfigurationType::Pointer ConfigurationPointer
Superclass2::DataObjectType DataObjectType
Superclass2::FileNameContainerPointer FileNameContainerPointer
Superclass2::ObjectType ObjectType
itkStaticConstMacro(Dimension, unsigned int, FixedImageType::ImageDimension)
Superclass2::ConfigurationPointer ConfigurationPointer
ResamplerBase< Self > ResamplerBaseType
itk::Image< MaskPixelType, MovingDimension > MovingMaskType
FixedImageType::DirectionType FixedImageDirectionType
ObjectType::Pointer ObjectPointer
itk::SmartPointer< const Self > ConstPointer
Superclass2::MultipleImageLoader< FixedImageType > FixedImageLoaderType
This class creates an interface for elastix.
int CallInEachComponentInt(PtrToMemberFunction2 func)
virtual MovingMaskType * GetMovingMask(void) const
elx::ImageSamplerBase< Self > ImageSamplerBaseType
elxGetBaseMacro(FixedImagePyramid, FixedImagePyramidBaseType)
itk::SimpleMemberCommand< Self > AfterEachIterationCommandType
This class is the elastix base class for all Metrics.
Definition: elxMetricBase.h:72
Superclass2::DataObjectContainerPointer DataObjectContainerPointer
MetricBase< Self > MetricBaseType


Generated on 04-01-2014 for elastix by doxygen 1.8.5 elastix logo