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  * Copyright UMC Utrecht and contributors
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __elxElastixTemplate_h
19 #define __elxElastixTemplate_h
20 
21 #include "elxElastixBase.h"
22 #include "itkObject.h"
23 
24 #include "itkObjectFactory.h"
25 #include "itkCommand.h"
26 #include "itkImage.h"
27 #include "itkImageFileReader.h"
28 #include "itkImageToImageMetric.h"
29 
30 #include "elxRegistrationBase.h"
33 #include "elxInterpolatorBase.h"
34 #include "elxImageSamplerBase.h"
35 #include "elxMetricBase.h"
36 #include "elxOptimizerBase.h"
37 #include "elxResamplerBase.h"
39 #include "elxTransformBase.h"
40 
41 #include "itkTimeProbe.h"
42 
43 #include <sstream>
44 #include <fstream>
45 
60 #define elxGetBaseMacro( _name, _elxbasetype ) \
61  virtual _elxbasetype * GetElx##_name##Base( void ) const \
62  { \
63  return this->GetElx##_name##Base( 0 ); \
64  } \
65  _elxbasetype * GetElx##_name##Base( unsigned int idx ) const \
66  { \
67  if( idx < this->GetNumberOf##_name##s() ) \
68  { \
69  return dynamic_cast< _elxbasetype * >( \
70  this->Get##_name##Container()->ElementAt( idx ).GetPointer() ); \
71  } \
72  return 0; \
73  }
74 //end elxGetBaseMacro
75 
76 namespace elastix
77 {
78 
112 template< class TFixedImage, class TMovingImage >
113 class ElastixTemplate : public itk::Object, public ElastixBase
114 {
115 public:
116 
119  typedef itk::Object Superclass1;
121  typedef itk::SmartPointer< Self > Pointer;
122  typedef itk::SmartPointer< const Self > ConstPointer;
123 
125  itkNewMacro( Self );
126 
128  itkTypeMacro( ElastixTemplate, itk::Object );
129 
133  typedef Superclass2::ObjectType ObjectType; //for the components
134  typedef Superclass2::DataObjectType DataObjectType; //for the images
143 
145  typedef TFixedImage FixedImageType;
146  typedef TMovingImage MovingImageType;
147  typedef typename FixedImageType::Pointer FixedImagePointer;
148  typedef typename MovingImageType::Pointer MovingImagePointer;
149 
151  typedef itk::DataObject ResultImageType;
152 
154  itkStaticConstMacro( Dimension, unsigned int, FixedImageType::ImageDimension );
155  itkStaticConstMacro( FixedDimension, unsigned int, FixedImageType::ImageDimension );
156  itkStaticConstMacro( MovingDimension, unsigned int, MovingImageType::ImageDimension );
157 
159  typedef unsigned char MaskPixelType;
160  typedef itk::Image< MaskPixelType, FixedDimension > FixedMaskType;
161  typedef itk::Image< MaskPixelType, MovingDimension > MovingMaskType;
162  typedef typename FixedMaskType::Pointer FixedMaskPointer;
163  typedef typename MovingMaskType::Pointer MovingMaskPointer;
164 
166  typedef typename FixedImageType::DirectionType FixedImageDirectionType;
167 
169  typedef itk::CostFunction::ParametersValueType CoordRepType; // double
170 
173 
175  typedef void (BaseComponentType::* PtrToMemberFunction)( void );
176  typedef int (BaseComponentType::* PtrToMemberFunction2)( void );
177 
179  typedef itk::SimpleMemberCommand< Self > BeforeEachResolutionCommandType;
180  typedef itk::SimpleMemberCommand< Self > AfterEachResolutionCommandType;
181  typedef itk::SimpleMemberCommand< Self > AfterEachIterationCommandType;
182  typedef typename BeforeEachResolutionCommandType::Pointer BeforeEachResolutionCommandPointer;
183  typedef typename AfterEachResolutionCommandType::Pointer AfterEachResolutionCommandPointer;
184  typedef typename AfterEachIterationCommandType::Pointer AfterEachIterationCommandPointer;
185 
197 
199  typedef itk::TimeProbe TimerType;
200 
205  typedef MovingImageType InputImageType;
206  typedef MovingImageType OutputImageType;
207 
210 
214  elxGetBaseMacro( FixedImagePyramid, FixedImagePyramidBaseType );
215  elxGetBaseMacro( MovingImagePyramid, MovingImagePyramidBaseType );
216  elxGetBaseMacro( Interpolator, InterpolatorBaseType );
217  elxGetBaseMacro( ImageSampler, ImageSamplerBaseType );
218  elxGetBaseMacro( Metric, MetricBaseType );
219  elxGetBaseMacro( Optimizer, OptimizerBaseType );
220  elxGetBaseMacro( Registration, RegistrationBaseType );
221  elxGetBaseMacro( Resampler, ResamplerBaseType );
222  elxGetBaseMacro( ResampleInterpolator, ResampleInterpolatorBaseType );
223  elxGetBaseMacro( Transform, TransformBaseType );
224 
228  virtual FixedImageType * GetFixedImage( void ) const
229  {
230  return this->GetFixedImage( 0 );
231  }
232 
233 
234  virtual FixedImageType * GetFixedImage( unsigned int idx ) const;
235 
236  virtual MovingImageType * GetMovingImage( void ) const
237  {
238  return this->GetMovingImage( 0 );
239  }
240 
241 
242  virtual MovingImageType * GetMovingImage( unsigned int idx ) const;
243 
247  virtual FixedMaskType * GetFixedMask( void ) const
248  {
249  return this->GetFixedMask( 0 );
250  }
251 
252 
253  virtual FixedMaskType * GetFixedMask( unsigned int idx ) const;
254 
255  virtual MovingMaskType * GetMovingMask( void ) const
256  {
257  return this->GetMovingMask( 0 );
258  }
259 
260 
261  virtual MovingMaskType * GetMovingMask( unsigned int idx ) const;
262 
266  virtual ResultImageType * GetResultImage( void ) const
267  {
268  return this->GetResultImage( 0 );
269  }
270 
271 
272  virtual ResultImageType * GetResultImage( unsigned int idx ) const;
273 
274  virtual int SetResultImage( DataObjectPointer result_image );
275 
280  virtual int Run( void );
281 
282  virtual int ApplyTransform( void );
283 
285  virtual int BeforeAll( void );
286 
287  virtual int BeforeAllTransformix( void );
288 
289  virtual void BeforeRegistration( void );
290 
291  virtual void BeforeEachResolution( void );
292 
293  virtual void AfterEachResolution( void );
294 
295  virtual void AfterEachIteration( void );
296 
297  virtual void AfterRegistration( void );
298 
300  itkGetConstMacro( IterationCounter, unsigned int );
301 
303  itkGetStringMacro( CurrentTransformParameterFileName );
304 
306  virtual void SetConfigurations( std::vector< ConfigurationPointer > & configurations );
307 
309  virtual ConfigurationPointer GetConfiguration( const size_t index );
310 
311  virtual ConfigurationPointer GetConfiguration()
312  {
313  return Superclass2::GetConfiguration();
314  }
315 
316 
321  virtual bool GetOriginalFixedImageDirection( FixedImageDirectionType & direction ) const;
322 
323 protected:
324 
325  ElastixTemplate();
326  virtual ~ElastixTemplate(){}
327 
333 
335  BeforeEachResolutionCommandPointer m_BeforeEachResolutionCommand;
336  AfterEachIterationCommandPointer m_AfterEachIterationCommand;
337  AfterEachResolutionCommandPointer m_AfterEachResolutionCommand;
338 
340  TimerType m_Timer0;
341  TimerType m_IterationTimer;
342  TimerType m_ResolutionTimer;
343 
346 
348  std::vector< ConfigurationPointer > m_Configurations;
349 
351  unsigned int m_IterationCounter;
352 
354  virtual void CreateTransformParameterFile( const std::string FileName,
355  const bool ToLog );
356 
358  virtual void CreateTransformParametersMap( void );
359 
361  virtual ParameterMapType GetTransformParametersMap( void ) const;
362 
364  ParameterMapType m_TransformParametersMap;
365 
367  virtual void OpenIterationInfoFile( void );
368 
369  std::ofstream m_IterationInfoFile;
370 
385 
387 
392  virtual void ConfigureComponents( Self * This );
393 
395  virtual void SetOriginalFixedImageDirection( const FixedImageDirectionType & arg );
396 
397 private:
398 
399  ElastixTemplate( const Self & ); // purposely not implemented
400  void operator=( const Self & ); // purposely not implemented
401 
402 };
403 
404 } // end namespace elastix
405 
406 #undef elxGetBaseMacro
407 
408 #ifndef ITK_MANUAL_INSTANTIATION
409 #include "elxElastixTemplate.hxx"
410 #endif
411 
412 #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)
void(BaseComponentType::* PtrToMemberFunction)(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
itk::SmartPointer< const Self > ConstPointer
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
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
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.
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
int(BaseComponentType::* PtrToMemberFunction2)(void)
elxGetBaseMacro(FixedImagePyramid, FixedImagePyramidBaseType)
This class is the elastix base class for all Metrics.
Definition: elxMetricBase.h:73
Superclass2::DataObjectContainerPointer DataObjectContainerPointer


Generated on 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo