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
76namespace elastix
77{
78
113template< class TFixedImage, class TMovingImage >
114class ElastixTemplate : public itk::Object, public ElastixBase
115{
116public:
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
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 );
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
211
214
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
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 int Run( void ) override;
296
297 int ApplyTransform( void ) override;
298
300 int BeforeAll( void ) override;
301
302 virtual int BeforeAllTransformix( void );
303
304 void BeforeRegistration( void ) override;
305
306 void BeforeEachResolution( void ) override;
307
308 void AfterEachResolution( void ) override;
309
310 void AfterEachIteration( void ) override;
311
312 void AfterRegistration( void ) override;
313
315 itkGetConstMacro( IterationCounter, unsigned int );
316
318 itkGetStringMacro( CurrentTransformParameterFileName );
319
321 void SetConfigurations( std::vector< ConfigurationPointer > & configurations ) override;
322
324 virtual ConfigurationPointer GetConfiguration( const size_t index );
325
327 {
328 return Superclass2::GetConfiguration();
329 }
330
331
337
338protected:
339
341 ~ElastixTemplate() override{}
342
348
353
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 void CreateTransformParametersMap( void ) override;
374
377
380
382 virtual void OpenIterationInfoFile( void );
383
384 std::ofstream m_IterationInfoFile;
385
400
402
407 virtual void ConfigureComponents( Self * This );
408
411
412private:
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
The BaseComponent class is a class that all elastix components should inherit from.
A class that deals with user given parameters and command line arguments.
This class creates an interface for elastix.
itk::VectorContainer< unsigned int, ObjectPointer > ObjectContainerType
itk::DataObject DataObjectType
ConfigurationType::Pointer ConfigurationPointer
ObjectType::Pointer ObjectPointer
itk::VectorContainer< unsigned int, DataObjectPointer > DataObjectContainerType
DataObjectContainerType::Pointer DataObjectContainerPointer
FileNameContainerType::Pointer FileNameContainerPointer
DataObjectType::Pointer DataObjectPointer
ObjectContainerType::Pointer ObjectContainerPointer
itk::VectorContainer< unsigned int, std::string > FileNameContainerType
itk::ParameterMapInterface::ParameterMapType ParameterMapType
The main elastix class, which connects components and invokes the BeforeRegistration(),...
itk::SmartPointer< Self > Pointer
itkStaticConstMacro(MovingDimension, unsigned int, MovingImageType::ImageDimension)
int ApplyTransform(void) override
int CallInEachComponentInt(PtrToMemberFunction2 func)
virtual int BeforeAllTransformix(void)
elx::ImageSamplerBase< Self > ImageSamplerBaseType
AfterEachIterationCommandPointer m_AfterEachIterationCommand
virtual ResultDeformationFieldType * GetResultDeformationField(unsigned int idx) const
MetricBase< Self > MetricBaseType
ResampleInterpolatorBase< Self > ResampleInterpolatorBaseType
virtual ConfigurationPointer GetConfiguration(const vcl_size_t index)
void BeforeRegistration(void) override
std::vector< ConfigurationPointer > m_Configurations
Superclass2::FileNameContainerPointer FileNameContainerPointer
virtual ResultImageType * GetResultImage(void) const
elxGetBaseMacro(Optimizer, OptimizerBaseType)
ParameterMapType GetTransformParametersMap(void) const override
virtual bool GetOriginalFixedImageDirection(FixedImageDirectionType &direction) const
virtual void OpenIterationInfoFile(void)
itk::SimpleMemberCommand< Self > AfterEachResolutionCommandType
MovingImagePyramidBase< Self > MovingImagePyramidBaseType
itk::DataObject ResultDeformationFieldType
itk::Image< MaskPixelType, MovingDimension > MovingMaskType
void CreateTransformParametersMap(void) override
void BeforeEachResolution(void) override
virtual MovingMaskType * GetMovingMask(void) const
elxGetBaseMacro(Transform, TransformBaseType)
elxGetBaseMacro(Resampler, ResamplerBaseType)
void AfterRegistration(void) override
Superclass2::ObjectType ObjectType
void CallInEachComponent(PtrToMemberFunction func)
itk::SmartPointer< const Self > ConstPointer
elx::TransformBase< Self > TransformBaseType
BeforeEachResolutionCommandType::Pointer BeforeEachResolutionCommandPointer
elxGetBaseMacro(Metric, MetricBaseType)
FixedImagePyramidBase< Self > FixedImagePyramidBaseType
Superclass2::MultipleImageLoader< MovingImageType > MovingImageLoaderType
void AfterEachResolution(void) override
Superclass2::ObjectContainerType ObjectContainerType
Superclass2::DataObjectContainerPointer DataObjectContainerPointer
virtual int SetResultImage(DataObjectPointer result_image)
FixedImageType::Pointer FixedImagePointer
virtual MovingImageType * GetMovingImage(void) const
RegistrationBase< Self > RegistrationBaseType
FixedImageType::DirectionType FixedImageDirectionType
virtual void SetOriginalFixedImageDirection(const FixedImageDirectionType &arg)
virtual MovingMaskType * GetMovingMask(unsigned int idx) const
virtual FixedImageType * GetFixedImage(unsigned int idx) const
ElastixTemplate(const Self &)
elxGetBaseMacro(FixedImagePyramid, FixedImagePyramidBaseType)
InterpolatorBase< Self > InterpolatorBaseType
virtual ResultImageType * GetResultImage(unsigned int idx) const
FixedMaskType::Pointer FixedMaskPointer
OptimizerBase< Self > OptimizerBaseType
BeforeEachResolutionCommandPointer m_BeforeEachResolutionCommand
itkStaticConstMacro(FixedDimension, unsigned int, FixedImageType::ImageDimension)
Superclass2::ObjectContainerPointer ObjectContainerPointer
Superclass2::MultipleImageLoader< FixedMaskType > FixedMaskLoaderType
itkStaticConstMacro(Dimension, unsigned int, FixedImageType::ImageDimension)
Superclass2::MultipleImageLoader< FixedImageType > FixedImageLoaderType
virtual void CreateTransformParameterFile(const std::string FileName, const bool ToLog)
void(BaseComponentType::* PtrToMemberFunction)(void)
int BeforeAll(void) override
MovingImageType::Pointer MovingImagePointer
Superclass2::ConfigurationType ConfigurationType
int Run(void) override
Superclass2::ConfigurationPointer ConfigurationPointer
Superclass2::MultipleImageLoader< MovingMaskType > MovingMaskLoaderType
virtual MovingImageType * GetMovingImage(unsigned int idx) const
Superclass2::ObjectPointer ObjectPointer
void SetConfigurations(std::vector< ConfigurationPointer > &configurations) override
virtual FixedImageType * GetFixedImage(void) const
itk::Image< MaskPixelType, FixedDimension > FixedMaskType
int(BaseComponentType::* PtrToMemberFunction2)(void)
virtual void ConfigureComponents(Self *This)
ParameterMapType m_TransformParametersMap
elxGetBaseMacro(Registration, RegistrationBaseType)
itk::SimpleMemberCommand< Self > AfterEachIterationCommandType
elxGetBaseMacro(ResampleInterpolator, ResampleInterpolatorBaseType)
Superclass2::FileNameContainerType FileNameContainerType
virtual int SetResultDeformationField(DataObjectPointer result_deformationfield)
Superclass2::DataObjectContainerType DataObjectContainerType
ResamplerBase< Self > ResamplerBaseType
void operator=(const Self &)
itk::ParameterMapInterface::ParameterMapType ParameterMapType
Superclass2::DataObjectPointer DataObjectPointer
AfterEachIterationCommandType::Pointer AfterEachIterationCommandPointer
virtual FixedMaskType * GetFixedMask(unsigned int idx) const
elxGetBaseMacro(Interpolator, InterpolatorBaseType)
itk::CostFunction::ParametersValueType CoordRepType
virtual FixedMaskType * GetFixedMask(void) const
void AfterEachIteration(void) override
virtual ConfigurationPointer GetConfiguration()
AfterEachResolutionCommandType::Pointer AfterEachResolutionCommandPointer
AfterEachResolutionCommandPointer m_AfterEachResolutionCommand
virtual ResultDeformationFieldType * GetResultDeformationField(void) const
itk::SimpleMemberCommand< Self > BeforeEachResolutionCommandType
MovingMaskType::Pointer MovingMaskPointer
elxGetBaseMacro(ImageSampler, ImageSamplerBaseType)
Superclass2::DataObjectType DataObjectType
std::string m_CurrentTransformParameterFileName
elxGetBaseMacro(MovingImagePyramid, MovingImagePyramidBaseType)
This class is the elastix base class for all FixedImagePyramids.
This class is the elastix base class for all Interpolators.
This class is the elastix base class for all Metrics.
Definition: elxMetricBase.h:73
This class is the elastix base class for all MovingImagePyramids.
This class is the elastix base class for all Optimizers.
This class is the elastix base class for all Registration schemes.
This class is the elastix base class for all ResampleInterpolators.
This class is the elastix base class for all Transforms.
This class is a base class for any image sampler.
ParameterFileParser::ParameterMapType ParameterMapType


Generated on 1667476801 for elastix by doxygen 1.9.4 elastix logo