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 namespace elastix
73 {
74 
108 template< class TFixedImage, class TMovingImage >
109 class ElastixTemplate : public itk::Object, public ElastixBase
110 {
111 public:
112 
115  typedef itk::Object Superclass1;
117  typedef itk::SmartPointer< Self > Pointer;
118  typedef itk::SmartPointer< const Self > ConstPointer;
119 
121  itkNewMacro( Self );
122 
124  itkTypeMacro( ElastixTemplate, itk::Object );
125 
129  typedef Superclass2::ObjectType ObjectType; //for the components
130  typedef Superclass2::DataObjectType DataObjectType; //for the images
139 
141  typedef TFixedImage FixedImageType;
142  typedef TMovingImage MovingImageType;
143  typedef typename FixedImageType::Pointer FixedImagePointer;
144  typedef typename MovingImageType::Pointer MovingImagePointer;
145 
147  typedef itk::DataObject ResultImageType;
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 itk::Image< MaskPixelType, FixedDimension > FixedMaskType;
157  typedef itk::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 itk::CostFunction::ParametersValueType CoordRepType; // double
166 
169 
171  typedef void (BaseComponentType::* PtrToMemberFunction)( void );
173 
175  typedef itk::SimpleMemberCommand< Self > BeforeEachResolutionCommandType;
176  typedef itk::SimpleMemberCommand< Self > AfterEachResolutionCommandType;
177  typedef itk::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 
207 
211  elxGetBaseMacro( FixedImagePyramid, FixedImagePyramidBaseType );
212  elxGetBaseMacro( MovingImagePyramid, MovingImagePyramidBaseType );
213  elxGetBaseMacro( Interpolator, InterpolatorBaseType );
214  elxGetBaseMacro( ImageSampler, ImageSamplerBaseType );
215  elxGetBaseMacro( Metric, MetricBaseType );
216  elxGetBaseMacro( Optimizer, OptimizerBaseType );
217  elxGetBaseMacro( Registration, RegistrationBaseType );
218  elxGetBaseMacro( Resampler, ResamplerBaseType );
219  elxGetBaseMacro( ResampleInterpolator, ResampleInterpolatorBaseType );
220  elxGetBaseMacro( Transform, TransformBaseType );
221 
225  virtual FixedImageType * GetFixedImage( void ) const
226  {
227  return this->GetFixedImage( 0 );
228  }
229 
230 
231  virtual FixedImageType * GetFixedImage( unsigned int idx ) const;
232 
233  virtual MovingImageType * GetMovingImage( void ) const
234  {
235  return this->GetMovingImage( 0 );
236  }
237 
238 
239  virtual MovingImageType * GetMovingImage( unsigned int idx ) const;
240 
244  virtual FixedMaskType * GetFixedMask( void ) const
245  {
246  return this->GetFixedMask( 0 );
247  }
248 
249 
250  virtual FixedMaskType * GetFixedMask( unsigned int idx ) const;
251 
252  virtual MovingMaskType * GetMovingMask( void ) const
253  {
254  return this->GetMovingMask( 0 );
255  }
256 
257 
258  virtual MovingMaskType * GetMovingMask( unsigned int idx ) const;
259 
263  virtual ResultImageType * GetResultImage( void ) const
264  {
265  return this->GetResultImage( 0 );
266  }
267 
268 
269  virtual ResultImageType * GetResultImage( unsigned int idx ) const;
270 
271  virtual int SetResultImage( DataObjectPointer result_image );
272 
277  virtual int Run( void );
278 
279  virtual int ApplyTransform( void );
280 
282  virtual int BeforeAll( void );
283 
284  virtual int BeforeAllTransformix( void );
285 
286  virtual void BeforeRegistration( void );
287 
288  virtual void BeforeEachResolution( void );
289 
290  virtual void AfterEachResolution( void );
291 
292  virtual void AfterEachIteration( void );
293 
294  virtual void AfterRegistration( void );
295 
297  itkGetConstMacro( IterationCounter, unsigned int );
298 
300  itkGetStringMacro( CurrentTransformParameterFileName );
301 
303  virtual void SetConfigurations( std::vector< ConfigurationPointer > & configurations );
304 
306  virtual ConfigurationPointer GetConfiguration( const size_t index );
307 
309  {
310  return Superclass2::GetConfiguration();
311  }
312 
313 
318  virtual bool GetOriginalFixedImageDirection( FixedImageDirectionType & direction ) const;
319 
320 protected:
321 
322  ElastixTemplate();
323  virtual ~ElastixTemplate(){}
324 
330 
335 
340 
343 
345  std::vector< ConfigurationPointer > m_Configurations;
346 
348  unsigned int m_IterationCounter;
349 
351  virtual void CreateTransformParameterFile( const std::string FileName,
352  const bool ToLog );
353 
355  virtual void CreateTransformParametersMap( void );
356 
358  virtual ParameterMapType GetTransformParametersMap( void ) const;
359 
362 
364  virtual void OpenIterationInfoFile( void );
365 
366  std::ofstream m_IterationInfoFile;
367 
382 
384 
389  virtual void ConfigureComponents( Self * This );
390 
392  virtual void SetOriginalFixedImageDirection( const FixedImageDirectionType & arg );
393 
394 private:
395 
396  ElastixTemplate( const Self & ); // purposely not implemented
397  void operator=( const Self & ); // purposely not implemented
398 
399 };
400 
401 } // end namespace elastix
402 
403 #undef elxGetBaseMacro
404 
405 #ifndef ITK_MANUAL_INSTANTIATION
406 #include "elxElastixTemplate.hxx"
407 #endif
408 
409 #endif // end #ifndef __elxElastixTemplate_h
elx::ImageSamplerBase< Self > ImageSamplerBaseType
Superclass2::MultipleImageLoader< FixedMaskType > FixedMaskLoaderType
virtual ResultImageType * GetResultImage(void) const
virtual bool GetOriginalFixedImageDirection(FixedImageDirectionType &direction) const
std::string m_CurrentTransformParameterFileName
DataObjectContainerType::Pointer DataObjectContainerPointer
virtual void BeforeEachResolution(void)
Superclass2::MultipleImageLoader< MovingImageType > MovingImageLoaderType
itk::VectorContainer< unsigned int, std::string > FileNameContainerType
ResamplerBase< Self > ResamplerBaseType
virtual ConfigurationPointer GetConfiguration()
Superclass2::DataObjectContainerType 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)
std::vector< ConfigurationPointer > m_Configurations
void CallInEachComponent(PtrToMemberFunction func)
AfterEachIterationCommandPointer m_AfterEachIterationCommand
virtual void BeforeRegistration(void)
This class is the elastix base class for all Optimizers.
OptimizerBase< Self > OptimizerBaseType
itk::DataObject DataObjectType
RegistrationBase< Self > RegistrationBaseType
MovingImagePyramidBase< Self > MovingImagePyramidBaseType
virtual ParameterMapType GetTransformParametersMap(void) const
ResampleInterpolatorBase< Self > ResampleInterpolatorBaseType
This class is the elastix base class for all Registration schemes.
itk::SimpleMemberCommand< Self > AfterEachResolutionCommandType
FixedImageType::Pointer FixedImagePointer
The BaseComponent class is a class that all elastix components should inherit from.
itk::Image< MaskPixelType, MovingDimension > MovingMaskType
virtual void AfterEachResolution(void)
void operator=(const Self &)
elx::TransformBase< Self > TransformBaseType
TimerType::Pointer TimerPointer
itk::SmartPointer< Self > Pointer
Definition: elxTimer.h:73
itk::SmartPointer< const Self > ConstPointer
A class to time the different parts of the registration.
Definition: elxTimer.h:66
MovingMaskType::Pointer MovingMaskPointer
itk::VectorContainer< unsigned int, ObjectPointer > ObjectContainerType
ParameterFileParser::ParameterMapType ParameterMapType
MetricBase< Self > MetricBaseType
itk::SmartPointer< Self > Pointer
virtual void OpenIterationInfoFile(void)
Superclass2::DataObjectPointer DataObjectPointer
virtual void CreateTransformParameterFile(const std::string FileName, const bool ToLog)
This class is a base class for any image sampler.
itk::CostFunction::ParametersValueType CoordRepType
int(BaseComponentType::* PtrToMemberFunction2)(void)
Superclass2::MultipleImageLoader< MovingMaskType > MovingMaskLoaderType
AfterEachResolutionCommandPointer m_AfterEachResolutionCommand
itk::Image< MaskPixelType, FixedDimension > FixedMaskType
virtual void AfterEachIteration(void)
virtual MovingImageType * GetMovingImage(void) const
This class is the elastix base class for all FixedImagePyramids.
FileNameContainerType::Pointer FileNameContainerPointer
Superclass2::ObjectContainerPointer ObjectContainerPointer
MovingImageType::Pointer MovingImagePointer
virtual FixedImageType * GetFixedImage(void) const
Superclass2::ConfigurationType ConfigurationType
virtual int ApplyTransform(void)
Superclass2::ObjectContainerType ObjectContainerType
FixedMaskType::Pointer FixedMaskPointer
itk::ParameterMapInterface::ParameterMapType ParameterMapType
virtual int SetResultImage(DataObjectPointer result_image)
virtual void ConfigureComponents(Self *This)
virtual void SetConfigurations(std::vector< ConfigurationPointer > &configurations)
virtual void AfterRegistration(void)
virtual FixedMaskType * GetFixedMask(void) const
itk::SimpleMemberCommand< Self > AfterEachIterationCommandType
Superclass2::ObjectPointer ObjectPointer
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.
FixedImagePyramidBase< Self > FixedImagePyramidBaseType
Superclass2::MultipleImageLoader< FixedImageType > FixedImageLoaderType
BeforeEachResolutionCommandPointer m_BeforeEachResolutionCommand
A class that deals with user given parameters and command line arguments.
void(BaseComponentType::* PtrToMemberFunction)(void)
InterpolatorBase< Self > InterpolatorBaseType
itk::SimpleMemberCommand< Self > BeforeEachResolutionCommandType
BeforeEachResolutionCommandType::Pointer BeforeEachResolutionCommandPointer
virtual int BeforeAllTransformix(void)
This class is the elastix base class for all Transforms.
DataObjectType::Pointer DataObjectPointer
virtual int Run(void)
virtual int BeforeAll(void)
ConfigurationType::Pointer ConfigurationPointer
Superclass2::DataObjectType DataObjectType
Superclass2::FileNameContainerPointer FileNameContainerPointer
itk::ParameterMapInterface::ParameterMapType ParameterMapType
itk::VectorContainer< unsigned int, DataObjectPointer > DataObjectContainerType
Superclass2::ObjectType ObjectType
itkStaticConstMacro(Dimension, unsigned int, FixedImageType::ImageDimension)
Superclass2::ConfigurationPointer ConfigurationPointer
FixedImageType::DirectionType FixedImageDirectionType
ObjectType::Pointer ObjectPointer
virtual void CreateTransformParametersMap(void)
ParameterMapType m_TransformParametersMap
This class creates an interface for elastix.
int CallInEachComponentInt(PtrToMemberFunction2 func)
virtual MovingMaskType * GetMovingMask(void) const
elxGetBaseMacro(FixedImagePyramid, FixedImagePyramidBaseType)
This class is the elastix base class for all Metrics.
Definition: elxMetricBase.h:71
Superclass2::DataObjectContainerPointer DataObjectContainerPointer


Generated on 27-04-2014 for elastix by doxygen 1.8.6 elastix logo