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 
113 template< class TFixedImage, class TMovingImage >
114 class ElastixTemplate : public itk::Object, public ElastixBase
115 {
116 public:
117 
120  typedef itk::Object Superclass1;
122  typedef itk::SmartPointer< Self > Pointer;
123  typedef itk::SmartPointer< const Self > ConstPointer;
124 
126  itkNewMacro( Self );
127 
129  itkTypeMacro( ElastixTemplate, itk::Object );
130 
134  typedef Superclass2::ObjectType ObjectType; //for the components
135  typedef Superclass2::DataObjectType DataObjectType; //for the images
144 
146  typedef TFixedImage FixedImageType;
147  typedef TMovingImage MovingImageType;
148  typedef typename FixedImageType::Pointer FixedImagePointer;
149  typedef typename MovingImageType::Pointer MovingImagePointer;
150 
152  typedef itk::DataObject ResultImageType;
153 
155  typedef itk::DataObject ResultDeformationFieldType;
156 
158  itkStaticConstMacro( Dimension, unsigned int, FixedImageType::ImageDimension );
159  itkStaticConstMacro( FixedDimension, unsigned int, FixedImageType::ImageDimension );
160  itkStaticConstMacro( MovingDimension, unsigned int, MovingImageType::ImageDimension );
161 
163  typedef unsigned char MaskPixelType;
164  typedef itk::Image< MaskPixelType, FixedDimension > FixedMaskType;
165  typedef itk::Image< MaskPixelType, MovingDimension > MovingMaskType;
166  typedef typename FixedMaskType::Pointer FixedMaskPointer;
167  typedef typename MovingMaskType::Pointer MovingMaskPointer;
168 
170  typedef typename FixedImageType::DirectionType FixedImageDirectionType;
171 
173  typedef itk::CostFunction::ParametersValueType CoordRepType; // double
174 
177 
179  typedef void (BaseComponentType::* PtrToMemberFunction)( void );
180  typedef int (BaseComponentType::* PtrToMemberFunction2)( void );
181 
183  typedef itk::SimpleMemberCommand< Self > BeforeEachResolutionCommandType;
184  typedef itk::SimpleMemberCommand< Self > AfterEachResolutionCommandType;
185  typedef itk::SimpleMemberCommand< Self > AfterEachIterationCommandType;
186  typedef typename BeforeEachResolutionCommandType::Pointer BeforeEachResolutionCommandPointer;
187  typedef typename AfterEachResolutionCommandType::Pointer AfterEachResolutionCommandPointer;
188  typedef typename AfterEachIterationCommandType::Pointer AfterEachIterationCommandPointer;
189 
201 
203  typedef itk::TimeProbe TimerType;
204 
209  typedef MovingImageType InputImageType;
210  typedef MovingImageType OutputImageType;
211 
214 
218  elxGetBaseMacro( FixedImagePyramid, FixedImagePyramidBaseType );
219  elxGetBaseMacro( MovingImagePyramid, MovingImagePyramidBaseType );
220  elxGetBaseMacro( Interpolator, InterpolatorBaseType );
221  elxGetBaseMacro( ImageSampler, ImageSamplerBaseType );
222  elxGetBaseMacro( Metric, MetricBaseType );
223  elxGetBaseMacro( Optimizer, OptimizerBaseType );
224  elxGetBaseMacro( Registration, RegistrationBaseType );
225  elxGetBaseMacro( Resampler, ResamplerBaseType );
226  elxGetBaseMacro( ResampleInterpolator, ResampleInterpolatorBaseType );
227  elxGetBaseMacro( Transform, TransformBaseType );
228 
232  virtual FixedImageType * GetFixedImage( void ) const
233  {
234  return this->GetFixedImage( 0 );
235  }
236 
237 
238  virtual FixedImageType * GetFixedImage( unsigned int idx ) const;
239 
240  virtual MovingImageType * GetMovingImage( void ) const
241  {
242  return this->GetMovingImage( 0 );
243  }
244 
245 
246  virtual MovingImageType * GetMovingImage( unsigned int idx ) const;
247 
251  virtual FixedMaskType * GetFixedMask( void ) const
252  {
253  return this->GetFixedMask( 0 );
254  }
255 
256 
257  virtual FixedMaskType * GetFixedMask( unsigned int idx ) const;
258 
259  virtual MovingMaskType * GetMovingMask( void ) const
260  {
261  return this->GetMovingMask( 0 );
262  }
263 
264 
265  virtual MovingMaskType * GetMovingMask( unsigned int idx ) const;
266 
270  virtual ResultImageType * GetResultImage( void ) const
271  {
272  return this->GetResultImage( 0 );
273  }
274 
275 
276  virtual ResultImageType * GetResultImage( unsigned int idx ) const;
277 
278  virtual int SetResultImage( DataObjectPointer result_image );
279 
280 
281  virtual ResultDeformationFieldType * GetResultDeformationField( void ) const
282  {
283  return this->GetResultDeformationField( 0 );
284  }
285 
286 
287  virtual ResultDeformationFieldType * GetResultDeformationField( unsigned int idx ) const;
288 
289  virtual int SetResultDeformationField( DataObjectPointer result_deformationfield );
290 
295  virtual int Run( void );
296 
297  virtual int ApplyTransform( void );
298 
300  virtual int BeforeAll( void );
301 
302  virtual int BeforeAllTransformix( void );
303 
304  virtual void BeforeRegistration( void );
305 
306  virtual void BeforeEachResolution( void );
307 
308  virtual void AfterEachResolution( void );
309 
310  virtual void AfterEachIteration( void );
311 
312  virtual void AfterRegistration( void );
313 
315  itkGetConstMacro( IterationCounter, unsigned int );
316 
318  itkGetStringMacro( CurrentTransformParameterFileName );
319 
321  virtual void SetConfigurations( std::vector< ConfigurationPointer > & configurations );
322 
324  virtual ConfigurationPointer GetConfiguration( const size_t index );
325 
326  virtual ConfigurationPointer GetConfiguration()
327  {
328  return Superclass2::GetConfiguration();
329  }
330 
331 
336  virtual bool GetOriginalFixedImageDirection( FixedImageDirectionType & direction ) const;
337 
338 protected:
339 
340  ElastixTemplate();
341  virtual ~ElastixTemplate(){}
342 
348 
350  BeforeEachResolutionCommandPointer m_BeforeEachResolutionCommand;
351  AfterEachIterationCommandPointer m_AfterEachIterationCommand;
352  AfterEachResolutionCommandPointer m_AfterEachResolutionCommand;
353 
355  TimerType m_Timer0;
356  TimerType m_IterationTimer;
357  TimerType m_ResolutionTimer;
358 
361 
363  std::vector< ConfigurationPointer > m_Configurations;
364 
366  unsigned int m_IterationCounter;
367 
369  virtual void CreateTransformParameterFile( const std::string FileName,
370  const bool ToLog );
371 
373  virtual void CreateTransformParametersMap( void );
374 
376  virtual ParameterMapType GetTransformParametersMap( void ) const;
377 
379  ParameterMapType m_TransformParametersMap;
380 
382  virtual void OpenIterationInfoFile( void );
383 
384  std::ofstream m_IterationInfoFile;
385 
400 
402 
407  virtual void ConfigureComponents( Self * This );
408 
410  virtual void SetOriginalFixedImageDirection( const FixedImageDirectionType & arg );
411 
412 private:
413 
414  ElastixTemplate( const Self & ); // purposely not implemented
415  void operator=( const Self & ); // purposely not implemented
416 
417 };
418 
419 } // end namespace elastix
420 
421 #undef elxGetBaseMacro
422 
423 #ifndef ITK_MANUAL_INSTANTIATION
424 #include "elxElastixTemplate.hxx"
425 #endif
426 
427 #endif // end #ifndef __elxElastixTemplate_h
elx::ImageSamplerBase< Self > ImageSamplerBaseType
Superclass2::MultipleImageLoader< FixedMaskType > FixedMaskLoaderType
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)
virtual FixedMaskType * GetFixedMask(void) const
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
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
virtual ResultImageType * GetResultImage(void) const
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
virtual FixedImageType * GetFixedImage(void) const
itk::Image< MaskPixelType, FixedDimension > FixedMaskType
virtual void AfterEachIteration(void)
virtual ParameterMapType GetTransformParametersMap(void) const
This class is the elastix base class for all FixedImagePyramids.
FileNameContainerType::Pointer FileNameContainerPointer
virtual MovingMaskType * GetMovingMask(void) const
Superclass2::ObjectContainerPointer ObjectContainerPointer
MovingImageType::Pointer MovingImagePointer
Superclass2::ConfigurationType ConfigurationType
virtual int ApplyTransform(void)
Superclass2::ObjectContainerType ObjectContainerType
FixedMaskType::Pointer FixedMaskPointer
virtual int SetResultImage(DataObjectPointer result_image)
itk::DataObject ResultDeformationFieldType
virtual void ConfigureComponents(Self *This)
virtual void SetConfigurations(std::vector< ConfigurationPointer > &configurations)
virtual void AfterRegistration(void)
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
virtual int SetResultDeformationField(DataObjectPointer result_deformationfield)
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
virtual ResultDeformationFieldType * GetResultDeformationField(void) const
virtual MovingImageType * GetMovingImage(void) const
itk::ParameterMapInterface::ParameterMapType ParameterMapType
itk::VectorContainer< unsigned int, DataObjectPointer > DataObjectContainerType
Superclass2::ObjectType ObjectType
itkStaticConstMacro(Dimension, unsigned int, FixedImageType::ImageDimension)
virtual bool GetOriginalFixedImageDirection(FixedImageDirectionType &direction) const
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)
int(BaseComponentType::* PtrToMemberFunction2)(void)
elxGetBaseMacro(FixedImagePyramid, FixedImagePyramidBaseType)
This class is the elastix base class for all Metrics.
Definition: elxMetricBase.h:72
Superclass2::DataObjectContainerPointer DataObjectContainerPointer


Generated on OURCE_DATE_EPOCH for elastix by doxygen 1.8.13 elastix logo