SMILX  1.01
elxElastixMain.h
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 
15 #ifndef __elxElastixMain_h
16 #define __elxElastixMain_h
17 
18 #include "elxComponentDatabase.h"
19 #include "elxComponentLoader.h"
20 
21 #include "elxBaseComponent.h"
22 #include "elxElastixBase.h"
23 #include "itkObject.h"
24 
25 #include <iostream>
26 #include <fstream>
27 
28 #include "itkParameterMapInterface.h"
29 
30 namespace elastix
31 {
32 
38 
49 extern int xoutSetup( const char * logfilename, bool setupLogging, bool setupCout );
50 
92 class ElastixMain : public itk::Object
93 {
94 public:
95 
97  typedef ElastixMain Self;
98  typedef itk::Object Superclass;
99  typedef itk::SmartPointer< Self > Pointer;
100  typedef itk::SmartPointer< const Self > ConstPointer;
101 
103  itkNewMacro( Self );
104 
106  itkTypeMacro( ElastixMain, Object );
107 
111  typedef itk::Object ObjectType;
112  typedef ObjectType::Pointer ObjectPointer;
113  typedef itk::DataObject DataObjectType;
114  typedef DataObjectType::Pointer DataObjectPointer;
115 
117  typedef ElastixBase ElastixBaseType;
118  typedef ElastixBase::ConfigurationType ConfigurationType;
119  typedef ConfigurationType::CommandLineArgumentMapType ArgumentMapType;
120  typedef ConfigurationType::Pointer ConfigurationPointer;
121  typedef ElastixBase::ObjectContainerType ObjectContainerType;
122  typedef ElastixBase::DataObjectContainerType DataObjectContainerType;
123  typedef ElastixBase::ObjectContainerPointer ObjectContainerPointer;
124  typedef ElastixBase::DataObjectContainerPointer DataObjectContainerPointer;
125  typedef ElastixBase::FlatDirectionCosinesType FlatDirectionCosinesType;
126 
130  typedef ComponentDatabase ComponentDatabaseType;
131  typedef ComponentDatabaseType::Pointer ComponentDatabasePointer;
132  typedef ComponentDatabaseType::PtrToCreator PtrToCreator;
133  typedef ComponentDatabaseType::ComponentDescriptionType ComponentDescriptionType;
134  typedef ComponentDatabaseType::PixelTypeDescriptionType PixelTypeDescriptionType;
135  typedef ComponentDatabaseType::ImageDimensionType ImageDimensionType;
136  typedef ComponentDatabaseType::IndexType DBIndexType;
137 
140  typedef ComponentLoaderType::Pointer ComponentLoaderPointer;
141 
143  typedef itk::ParameterMapInterface::ParameterMapType ParameterMapType;
144 
146  itkSetMacro( FixedImagePixelType, PixelTypeDescriptionType );
147  itkSetMacro( MovingImagePixelType, PixelTypeDescriptionType );
148  itkSetMacro( FixedImageDimension, ImageDimensionType );
149  itkSetMacro( MovingImageDimension, ImageDimensionType );
150  itkGetMacro( FixedImagePixelType, PixelTypeDescriptionType );
151  itkGetMacro( MovingImagePixelType, PixelTypeDescriptionType );
152  itkGetMacro( FixedImageDimension, ImageDimensionType );
153  itkGetMacro( MovingImageDimension, ImageDimensionType );
154 
159  itkSetObjectMacro( FixedImageContainer, DataObjectContainerType );
160  itkSetObjectMacro( MovingImageContainer, DataObjectContainerType );
161  itkGetObjectMacro( FixedImageContainer, DataObjectContainerType );
162  itkGetObjectMacro( MovingImageContainer, DataObjectContainerType );
163 
168  itkSetObjectMacro( FixedMaskContainer, DataObjectContainerType );
169  itkSetObjectMacro( MovingMaskContainer, DataObjectContainerType );
170  itkGetObjectMacro( FixedMaskContainer, DataObjectContainerType );
171  itkGetObjectMacro( MovingMaskContainer, DataObjectContainerType );
172 
177  itkSetObjectMacro( ResultImageContainer, DataObjectContainerType );
178  itkGetObjectMacro( ResultImageContainer, DataObjectContainerType );
179 
181  itkSetObjectMacro( Configuration, ConfigurationType );
182  itkGetObjectMacro( Configuration, ConfigurationType );
183 
188  itkGetObjectMacro( Elastix, ObjectType );
189 
193  virtual ElastixBaseType * GetElastixBase( void ) const;
194 
200  itkGetObjectMacro( FinalTransform, ObjectType );
201 
206  itkSetObjectMacro( InitialTransform, ObjectType );
207  itkGetObjectMacro( InitialTransform, ObjectType );
208 
212  const FlatDirectionCosinesType & arg );
213 
214  virtual const FlatDirectionCosinesType & GetOriginalFixedImageDirectionFlat( void ) const;
215 
217  void SetElastixLevel( unsigned int level );
218 
219  unsigned int GetElastixLevel( void );
220 
222  void SetTotalNumberOfElastixLevels( unsigned int levels );
223 
224  unsigned int GetTotalNumberOfElastixLevels( void );
225 
227  itkGetConstMacro( DBIndex, DBIndexType );
228 
233  virtual void EnterCommandLineArguments( ArgumentMapType & argmap );
234 
235  virtual void EnterCommandLineArguments( ArgumentMapType & argmap,
236  ParameterMapType & inputMap );
237 
238  // Version used when elastix is used as a library.
239  virtual void EnterCommandLineArguments( ArgumentMapType & argmap,
240  std::vector< ParameterMapType > & inputMaps );
241 
247  virtual int Run( void );
248 
253  virtual int Run( ArgumentMapType & argmap );
254 
255  virtual int Run( ArgumentMapType & argmap, ParameterMapType & inputMap );
256 
261  virtual void SetProcessPriority( void ) const;
262 
267  virtual void SetMaximumNumberOfThreads( void ) const;
268 
270  static ComponentDatabase * GetComponentDatabase( void )
271  {
272  return s_CDB.GetPointer();
273  }
274 
275 
276  static void SetComponentDatabase( ComponentDatabase * arg )
277  {
278  if( s_CDB != arg )
279  {
280  s_CDB = arg;
281  }
282  }
283 
284 
286  virtual ParameterMapType GetTransformParametersMap( void ) const;
287 
288  static void UnloadComponents( void );
289 
290 protected:
291 
292  ElastixMain();
293  virtual ~ElastixMain();
294 
298  ObjectPointer m_Elastix;
299 
301  ConfigurationPointer m_Configuration;
302 
304  std::vector< ConfigurationPointer > m_Configurations;
305 
307  PixelTypeDescriptionType m_FixedImagePixelType;
308  ImageDimensionType m_FixedImageDimension;
309  PixelTypeDescriptionType m_MovingImagePixelType;
310  ImageDimensionType m_MovingImageDimension;
311 
312  DBIndexType m_DBIndex;
313 
315  DataObjectContainerPointer m_FixedImageContainer;
316  DataObjectContainerPointer m_MovingImageContainer;
317  DataObjectContainerPointer m_FixedMaskContainer;
318  DataObjectContainerPointer m_MovingMaskContainer;
319  DataObjectContainerPointer m_ResultImageContainer;
320 
322  ObjectPointer m_FinalTransform;
323 
325  ObjectPointer m_InitialTransform;
329  ParameterMapType m_TransformParametersMap;
330 
331  FlatDirectionCosinesType m_OriginalFixedImageDirection;
332 
333  static ComponentDatabasePointer s_CDB;
334  static ComponentLoaderPointer s_ComponentLoader;
335  virtual int LoadComponents( void );
336 
341  virtual int InitDBIndex( void );
342 
346  virtual ObjectPointer CreateComponent( const ComponentDescriptionType & name );
347 
363  virtual ObjectContainerPointer CreateComponents(
364  const ComponentDescriptionType & key,
365  const ComponentDescriptionType & defaultComponentName,
366  int & errorcode,
367  bool mandatoryComponent = true );
368 
370  void GetImageInformationFromFile( const std::string & filename,
371  ImageDimensionType & imageDimension ) const;
372 
373 private:
374 
375  ElastixMain( const Self & ); // purposely not implemented
376  void operator=( const Self & ); // purposely not implemented
377 
378 };
379 
380 } // end namespace elastix
381 
382 #endif // end #ifndef __elxElastixMain_h
virtual void EnterCommandLineArguments(ArgumentMapType &argmap)
itkSetMacro(FixedImagePixelType, PixelTypeDescriptionType)
static ComponentDatabase * GetComponentDatabase(void)
virtual int LoadComponents(void)
void GetImageInformationFromFile(const std::string &filename, ImageDimensionType &imageDimension) const
std::vector< ConfigurationPointer > m_Configurations
int xoutSetup(const char *logfilename, bool setupLogging, bool setupCout)
PixelTypeDescriptionType m_FixedImagePixelType
virtual int InitDBIndex(void)
ComponentDatabase ComponentDatabaseType
ObjectPointer m_InitialTransform
ElastixBase ElastixBaseType
ObjectPointer m_FinalTransform
virtual ParameterMapType GetTransformParametersMap(void) const
void SetTotalNumberOfElastixLevels(unsigned int levels)
ObjectPointer m_Elastix
virtual const FlatDirectionCosinesType & GetOriginalFixedImageDirectionFlat(void) const
virtual ObjectPointer CreateComponent(const ComponentDescriptionType &name)
Determines which components (metrics, transforms, etc.) are available.
ParameterMapType m_TransformParametersMap
virtual void SetProcessPriority(void) const
virtual void SetOriginalFixedImageDirectionFlat(const FlatDirectionCosinesType &arg)
ConfigurationPointer m_Configuration
itkGetConstMacro(DBIndex, DBIndexType)
DataObjectContainerPointer m_FixedImageContainer
static void UnloadComponents(void)
A class with all functionality to configure elastix.
virtual ObjectContainerPointer CreateComponents(const ComponentDescriptionType &key, const ComponentDescriptionType &defaultComponentName, int &errorcode, bool mandatoryComponent=true)
static ComponentDatabasePointer s_CDB
void SetElastixLevel(unsigned int level)
itk::ParameterMapInterface::ParameterMapType ParameterMapType
virtual int Run(void)
unsigned int GetTotalNumberOfElastixLevels(void)
unsigned int GetElastixLevel(void)
itkSetObjectMacro(FixedImageContainer, DataObjectContainerType)
virtual ElastixBaseType * GetElastixBase(void) const
virtual void SetMaximumNumberOfThreads(void) const
ComponentLoader ComponentLoaderType
itkTypeMacro(ElastixMain, Object)