SMILX  1.01
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
elastix::ElastixMain Class Reference

A class with all functionality to configure elastix. More...

#include <elxElastixMain.h>

Inheritance diagram for elastix::ElastixMain:

Public Types

typedef ElastixMain Self
 
typedef itk::Object Superclass
 
typedef itk::SmartPointer< SelfPointer
 
typedef itk::SmartPointer< const SelfConstPointer
 
typedef itk::Object ObjectType
 
typedef ObjectType::Pointer ObjectPointer
 
typedef itk::DataObject DataObjectType
 
typedef DataObjectType::Pointer DataObjectPointer
 
typedef ElastixBase ElastixBaseType
 
typedef ElastixBase::ConfigurationType ConfigurationType
 
typedef ConfigurationType::CommandLineArgumentMapType ArgumentMapType
 
typedef ConfigurationType::Pointer ConfigurationPointer
 
typedef ElastixBase::ObjectContainerType ObjectContainerType
 
typedef ElastixBase::DataObjectContainerType DataObjectContainerType
 
typedef ElastixBase::ObjectContainerPointer ObjectContainerPointer
 
typedef ElastixBase::DataObjectContainerPointer DataObjectContainerPointer
 
typedef ElastixBase::FlatDirectionCosinesType FlatDirectionCosinesType
 
typedef ComponentDatabase ComponentDatabaseType
 
typedef ComponentDatabaseType::Pointer ComponentDatabasePointer
 
typedef ComponentDatabaseType::PtrToCreator PtrToCreator
 
typedef ComponentDatabaseType::ComponentDescriptionType ComponentDescriptionType
 
typedef ComponentDatabaseType::PixelTypeDescriptionType PixelTypeDescriptionType
 
typedef ComponentDatabaseType::ImageDimensionType ImageDimensionType
 
typedef ComponentDatabaseType::IndexType DBIndexType
 
typedef ComponentLoader ComponentLoaderType
 
typedef ComponentLoaderType::Pointer ComponentLoaderPointer
 
typedef itk::ParameterMapInterface::ParameterMapType ParameterMapType
 

Public Member Functions

 itkNewMacro (Self)
 
 itkTypeMacro (ElastixMain, Object)
 
 itkSetMacro (FixedImagePixelType, PixelTypeDescriptionType)
 
 itkSetMacro (MovingImagePixelType, PixelTypeDescriptionType)
 
 itkSetMacro (FixedImageDimension, ImageDimensionType)
 
 itkSetMacro (MovingImageDimension, ImageDimensionType)
 
 itkGetMacro (FixedImagePixelType, PixelTypeDescriptionType)
 
 itkGetMacro (MovingImagePixelType, PixelTypeDescriptionType)
 
 itkGetMacro (FixedImageDimension, ImageDimensionType)
 
 itkGetMacro (MovingImageDimension, ImageDimensionType)
 
 itkSetObjectMacro (FixedImageContainer, DataObjectContainerType)
 
 itkSetObjectMacro (MovingImageContainer, DataObjectContainerType)
 
 itkGetObjectMacro (FixedImageContainer, DataObjectContainerType)
 
 itkGetObjectMacro (MovingImageContainer, DataObjectContainerType)
 
 itkSetObjectMacro (FixedMaskContainer, DataObjectContainerType)
 
 itkSetObjectMacro (MovingMaskContainer, DataObjectContainerType)
 
 itkGetObjectMacro (FixedMaskContainer, DataObjectContainerType)
 
 itkGetObjectMacro (MovingMaskContainer, DataObjectContainerType)
 
 itkSetObjectMacro (ResultImageContainer, DataObjectContainerType)
 
 itkGetObjectMacro (ResultImageContainer, DataObjectContainerType)
 
 itkSetObjectMacro (Configuration, ConfigurationType)
 
 itkGetObjectMacro (Configuration, ConfigurationType)
 
 itkGetObjectMacro (Elastix, ObjectType)
 
virtual ElastixBaseTypeGetElastixBase (void) const
 
 itkGetObjectMacro (FinalTransform, ObjectType)
 
 itkSetObjectMacro (InitialTransform, ObjectType)
 
 itkGetObjectMacro (InitialTransform, ObjectType)
 
virtual void SetOriginalFixedImageDirectionFlat (const FlatDirectionCosinesType &arg)
 
virtual const FlatDirectionCosinesType & GetOriginalFixedImageDirectionFlat (void) const
 
void SetElastixLevel (unsigned int level)
 
unsigned int GetElastixLevel (void)
 
void SetTotalNumberOfElastixLevels (unsigned int levels)
 
unsigned int GetTotalNumberOfElastixLevels (void)
 
 itkGetConstMacro (DBIndex, DBIndexType)
 
virtual void EnterCommandLineArguments (ArgumentMapType &argmap)
 
virtual void EnterCommandLineArguments (ArgumentMapType &argmap, ParameterMapType &inputMap)
 
virtual void EnterCommandLineArguments (ArgumentMapType &argmap, std::vector< ParameterMapType > &inputMaps)
 
virtual int Run (void)
 
virtual int Run (ArgumentMapType &argmap)
 
virtual int Run (ArgumentMapType &argmap, ParameterMapType &inputMap)
 
virtual void SetProcessPriority (void) const
 
virtual void SetMaximumNumberOfThreads (void) const
 
virtual ParameterMapType GetTransformParametersMap (void) const
 

Static Public Member Functions

static ComponentDatabase * GetComponentDatabase (void)
 
static void SetComponentDatabase (ComponentDatabase *arg)
 
static void UnloadComponents (void)
 

Protected Member Functions

 ElastixMain ()
 
virtual ~ElastixMain ()
 
virtual int LoadComponents (void)
 
virtual int InitDBIndex (void)
 
virtual ObjectPointer CreateComponent (const ComponentDescriptionType &name)
 
virtual ObjectContainerPointer CreateComponents (const ComponentDescriptionType &key, const ComponentDescriptionType &defaultComponentName, int &errorcode, bool mandatoryComponent=true)
 
void GetImageInformationFromFile (const std::string &filename, ImageDimensionType &imageDimension) const
 

Protected Attributes

ObjectPointer m_Elastix
 
ConfigurationPointer m_Configuration
 
std::vector< ConfigurationPointer > m_Configurations
 
PixelTypeDescriptionType m_FixedImagePixelType
 
ImageDimensionType m_FixedImageDimension
 
PixelTypeDescriptionType m_MovingImagePixelType
 
ImageDimensionType m_MovingImageDimension
 
DBIndexType m_DBIndex
 
DataObjectContainerPointer m_FixedImageContainer
 
DataObjectContainerPointer m_MovingImageContainer
 
DataObjectContainerPointer m_FixedMaskContainer
 
DataObjectContainerPointer m_MovingMaskContainer
 
DataObjectContainerPointer m_ResultImageContainer
 
ObjectPointer m_FinalTransform
 
ObjectPointer m_InitialTransform
 
ParameterMapType m_TransformParametersMap
 
FlatDirectionCosinesType m_OriginalFixedImageDirection
 

Static Protected Attributes

static ComponentDatabasePointer s_CDB = 0
 
static ComponentLoaderPointer s_ComponentLoader = 0
 

Detailed Description

A class with all functionality to configure elastix.

The ElastixMain initializes the MyConfiguration class with the parameters and commandline arguments. After this, the class loads and creates all components and sets them in ElastixTemplate.

FixedImageDimension: the dimension of the fixed image.
example: (FixedImageDimension 2)
MovingImageDimension: the dimension of the fixed image.
example: (MovingImageDimension 2)
FixedInternalImagePixelType: the pixel type of the internal fixed image representation. The fixed image is automatically converted to this type.
example: (FixedInternalImagePixelType "float")
Default/recommended: "float"
MovingInternalImagePixelType: the pixel type of the internal moving image representation. The moving image is automatically converted to this type.
example: (MovingInternalImagePixelType "float")
Default/recommended: "float"
FixedImageDimension: the dimension of the fixed image.
example: (FixedImageDimension 2)
MovingImageDimension: the dimension of the fixed image.
example: (MovingImageDimension 2)
FixedInternalImagePixelType: the pixel type of the internal fixed image representation. The fixed image is automatically converted to this type.
example: (FixedInternalImagePixelType "float")
Default/recommended: "float"
MovingInternalImagePixelType: the pixel type of the internal moving image representation. The moving image is automatically converted to this type.
example: (MovingInternalImagePixelType "float")
Default/recommended: "float"

Definition at line 92 of file elxElastixMain.h.

Member Typedef Documentation

◆ ComponentDatabaseType

Typedefs for the database that holds pointers to New() functions. Those functions are used to instantiate components, such as the metric etc.

Definition at line 130 of file elxElastixMain.h.

◆ ComponentLoaderType

Typedef for class that populates a ComponentDatabase.

Definition at line 139 of file elxElastixMain.h.

◆ ElastixBaseType

elastix components.

Definition at line 117 of file elxElastixMain.h.

◆ ObjectType

typedef itk::Object elastix::ElastixMain::ObjectType

Typedef's. ITK base objects.

Definition at line 111 of file elxElastixMain.h.

◆ ParameterMapType

typedef itk::ParameterMapInterface::ParameterMapType elastix::ElastixMain::ParameterMapType

Typedef that is used in the elastix dll version.

Definition at line 143 of file elxElastixMain.h.

◆ Self

Standard itk.

Definition at line 97 of file elxElastixMain.h.

Constructor & Destructor Documentation

◆ ElastixMain()

elastix::ElastixMain::ElastixMain ( )
protected

********************* Constructor ****************************

Initialize the components.

Definition at line 122 of file elxElastixMain.cxx.

◆ ~ElastixMain()

elastix::ElastixMain::~ElastixMain ( )
protectedvirtual

********************** Destructor ****************************

Definition at line 163 of file elxElastixMain.cxx.

Member Function Documentation

◆ CreateComponent()

ElastixMain::ObjectPointer elastix::ElastixMain::CreateComponent ( const ComponentDescriptionType &  name)
protectedvirtual

Create a component. Make sure InitDBIndex has been called before. The input is a string, e.g. "MattesMutualInformation".

************************* CreateComponent ***************************

A pointer to the New() function.

Definition at line 747 of file elxElastixMain.cxx.

◆ CreateComponents()

ElastixMain::ObjectContainerPointer elastix::ElastixMain::CreateComponents ( const ComponentDescriptionType &  key,
const ComponentDescriptionType &  defaultComponentName,
int &  errorcode,
bool  mandatoryComponent = true 
)
protectedvirtual

Create components. Reads from the configuration object (using the provided key) the names of the components to create and store their instantations in the provided ObjectContainer. The errorcode remains what it was if no error occurred. Otherwise it's set to 1. The 'key' is the entry inspected in the parameter file A component named 'defaultComponentName' is used when the key is not found in the parameter file. If "" is used, no default is assumed, and an error is given when the component was not specified. If the flag mandatoryComponent is set to false, no error is given, because the component may not be needed anyway.

NB: this function should never be called with: ( !mandatoryComponent && defaultComponentName != "" ) == true

*********************** CreateComponents *****************************

Read the component name. If the user hasn't specified any component names, use the default, and give a warning.

If the default equals "" (so no default), the mandatoryComponent flag is true, and not component was given by the user, then elastix quits.

Try creating the specified component.

Check if more than one component name is given.

Definition at line 770 of file elxElastixMain.cxx.

◆ EnterCommandLineArguments() [1/3]

void elastix::ElastixMain::EnterCommandLineArguments ( ArgumentMapType &  argmap)
virtual

Enter the command line parameters, which were given by the user, if elastix.exe is used to do a registration. The Configuration object will be initialized in this way.

*************** EnterCommandLineParameters *******************

Initialize the configuration object with the command line parameters entered by the user.

Definition at line 175 of file elxElastixMain.cxx.

◆ EnterCommandLineArguments() [2/3]

void elastix::ElastixMain::EnterCommandLineArguments ( ArgumentMapType &  argmap,
ParameterMapType inputMap 
)
virtual

*************** EnterCommandLineArguments *******************

Initialize the configuration object with the command line parameters entered by the user.

Definition at line 197 of file elxElastixMain.cxx.

◆ EnterCommandLineArguments() [3/3]

void elastix::ElastixMain::EnterCommandLineArguments ( ArgumentMapType &  argmap,
std::vector< ParameterMapType > &  inputMaps 
)
virtual

*************** EnterCommandLineArguments *******************

Initialize the configuration object with the command line parameters entered by the user.

Copy last configuration object to m_Configuration.

Definition at line 218 of file elxElastixMain.cxx.

◆ GetComponentDatabase()

static ComponentDatabase* elastix::ElastixMain::GetComponentDatabase ( void  )
inlinestatic

Functions to get/set the ComponentDatabase.

Definition at line 270 of file elxElastixMain.h.

◆ GetElastixBase()

ElastixMain::ElastixBaseType * elastix::ElastixMain::GetElastixBase ( void  ) const
virtual

Convenience function that returns the elastix component as a pointer to an ElastixBaseType. Use only after having called run()!

************************* GetElastixBase ***************************

Convert ElastixAsObject to a pointer to an ElastixBaseType.

Definition at line 726 of file elxElastixMain.cxx.

◆ GetElastixLevel()

unsigned int elastix::ElastixMain::GetElastixLevel ( void  )

********************* GetElastixLevel ************************

Call GetElastixLevel from MyConfiguration.

Definition at line 634 of file elxElastixMain.cxx.

◆ GetImageInformationFromFile()

void elastix::ElastixMain::GetImageInformationFromFile ( const std::string &  filename,
ImageDimensionType &  imageDimension 
) const
protected

Helper function to obtain information from images on disk.

******************** GetImageInformationFromFile ********************

Dummy image type.

Create a testReader.

Generate all information.

Extract the required information.

Extra check. In principal, ITK the testreader should already have thrown an exception if it was not possible to create the ImageIO object

Definition at line 968 of file elxElastixMain.cxx.

◆ GetOriginalFixedImageDirectionFlat()

const ElastixMain::FlatDirectionCosinesType & elastix::ElastixMain::GetOriginalFixedImageDirectionFlat ( void  ) const
virtual

******************** GetOriginalFixedImageDirectionFlat ********************

Definition at line 946 of file elxElastixMain.cxx.

◆ GetTotalNumberOfElastixLevels()

unsigned int elastix::ElastixMain::GetTotalNumberOfElastixLevels ( void  )

********************* GetTotalNumberOfElastixLevels ************************

Call GetTotalNumberOfElastixLevels from MyConfiguration.

Definition at line 660 of file elxElastixMain.cxx.

◆ GetTransformParametersMap()

ElastixMain::ParameterMapType elastix::ElastixMain::GetTransformParametersMap ( void  ) const
virtual

GetTransformParametersMap

******************** GetTransformParametersMap ********************

Definition at line 957 of file elxElastixMain.cxx.

◆ InitDBIndex()

int elastix::ElastixMain::InitDBIndex ( void  )
protectedvirtual

InitDBIndex sets m_DBIndex by asking the ImageTypes from the Configuration object and obtaining the corresponding DB index from the ComponentDatabase.

************************** InitDBIndex ***********************

Checks if the configuration object has been initialized, determines the requested ImageTypes, and sets the m_DBIndex to the corresponding value (by asking the elx::ComponentDatabase).

Only do something when the configuration object wasn't initialized yet.

FixedImagePixelType.

Try to read it from the parameter file.

FixedImageDimension.

Read it from the fixed image header.

Try to read it from the parameter file. This only serves as a check; elastix versions prior to 4.6 read the dimension from the parameter file, but now we read it from the image header.

Check.

Just a sanity check, probably not needed.

MovingImagePixelType.

Try to read it from the parameter file.

MovingImageDimension.

Read it from the moving image header.

Try to read it from the parameter file. This only serves as a check; elastix versions prior to 4.6 read the dimension from the parameter file, but now we read it from the image header.

Check.

Just a sanity check, probably not needed.

Load the components.

Get the DBIndex from the ComponentDatabase.

Return an OK value.

Definition at line 433 of file elxElastixMain.cxx.

◆ itkGetConstMacro()

elastix::ElastixMain::itkGetConstMacro ( DBIndex  ,
DBIndexType   
)

Returns the Index that is used in elx::ComponentDatabase.

◆ itkGetObjectMacro() [1/2]

elastix::ElastixMain::itkGetObjectMacro ( Elastix  ,
ObjectType   
)

Functions to get pointers to the elastix components. The components are returned as Object::Pointer. Before calling this functions, call run().

◆ itkGetObjectMacro() [2/2]

elastix::ElastixMain::itkGetObjectMacro ( FinalTransform  ,
ObjectType   
)

Get the final transform (the result of running elastix). You may pass this as an InitialTransform in an other instantiation of ElastixMain. Only valid after calling Run()!

◆ itkNewMacro()

elastix::ElastixMain::itkNewMacro ( Self  )

Method for creation through the object factory.

◆ itkSetMacro()

elastix::ElastixMain::itkSetMacro ( FixedImagePixelType  ,
PixelTypeDescriptionType   
)

Set/Get functions for the description of the imagetype.

◆ itkSetObjectMacro() [1/5]

elastix::ElastixMain::itkSetObjectMacro ( FixedImageContainer  ,
DataObjectContainerType   
)

Set/Get functions for the fixed and moving images (if these are not used, elastix tries to read them from disk, according to the command line parameters).

◆ itkSetObjectMacro() [2/5]

elastix::ElastixMain::itkSetObjectMacro ( FixedMaskContainer  ,
DataObjectContainerType   
)

Set/Get functions for the fixed and moving masks (if these are not used, elastix tries to read them from disk, according to the command line parameters).

◆ itkSetObjectMacro() [3/5]

elastix::ElastixMain::itkSetObjectMacro ( ResultImageContainer  ,
DataObjectContainerType   
)

Set/Get functions for the result images (if these are not used, elastix tries to read them from disk, according to the command line parameters).

◆ itkSetObjectMacro() [4/5]

elastix::ElastixMain::itkSetObjectMacro ( Configuration  ,
ConfigurationType   
)

Set/Get the configuration object.

◆ itkSetObjectMacro() [5/5]

elastix::ElastixMain::itkSetObjectMacro ( InitialTransform  ,
ObjectType   
)

Set/Get the initial transform the type is ObjectType, but the pointer should actually point to an itk::Transform type (or inherited from that one).

◆ itkTypeMacro()

elastix::ElastixMain::itkTypeMacro ( ElastixMain  ,
Object   
)

Run-time type information (and related methods).

◆ LoadComponents()

int elastix::ElastixMain::LoadComponents ( void  )
protectedvirtual

********************* LoadComponents **************************

Store the install function of each component in the component database.

Create a ComponentDatabase.

Create a ComponentLoader and set the database.

Get the current program.

Load the components.

Definition at line 676 of file elxElastixMain.cxx.

◆ Run() [1/3]

int elastix::ElastixMain::Run ( void  )
virtual

Start the registration run() without command line parameters; it assumes that EnterCommandLineParameters has been invoked already, or that m_Configuration is initialised in a different way.

**************************** Run *****************************

Assuming EnterCommandLineParameters has already been invoked. or that m_Configuration is initialised in another way.

Set process properties.

Initialize database.

Create the elastix component.

Key "Elastix", see elxComponentLoader::InstallSupportedImageTypes().

We just print the exception and let the program quit.

Set some information in the ElastixBase.

Populate the component containers. ImageSampler is not mandatory. No defaults are specified for ImageSampler, Metric, Transform and Optimizer.

Check if all component could be created.

Set the images and masks. If not set by the user, it is not a problem. ElastixTemplate will try to load them from disk.

Set the initial transform, if it happens to be there.

Set the original fixed image direction cosines (relevant in case the UseDirectionCosines parameter was set to false.

Run elastix!

We just print the itk::exception and let the program quit.

We just print the std::exception and let the program quit.

We don't know what happened and just print a general message.

Return the final transform.

Get the transformation parameter map

Store the images in ElastixMain.

Store the original fixed image direction cosines (relevant in case the UseDirectionCosines parameter was set to false.

Return a value.

Definition at line 250 of file elxElastixMain.cxx.

◆ Run() [2/3]

int elastix::ElastixMain::Run ( ArgumentMapType &  argmap)
virtual

Start the registration this version of 'run' first calls this->EnterCommandLineParameters(argc,argv) and then calls run().

**************************** Run *****************************

Definition at line 403 of file elxElastixMain.cxx.

◆ Run() [3/3]

int elastix::ElastixMain::Run ( ArgumentMapType &  argmap,
ParameterMapType inputMap 
)
virtual

**************************** Run *****************************

Definition at line 416 of file elxElastixMain.cxx.

◆ SetElastixLevel()

void elastix::ElastixMain::SetElastixLevel ( unsigned int  level)

Get and Set the elastix level.

********************* SetElastixLevel ************************

Call SetElastixLevel from MyConfiguration.

Definition at line 621 of file elxElastixMain.cxx.

◆ SetMaximumNumberOfThreads()

void elastix::ElastixMain::SetMaximumNumberOfThreads ( void  ) const
virtual

Set maximum number of threads, which is read from the command line arguments. Syntax: -threads <int>

*********************** SetMaximumNumberOfThreads *************************

Get the number of threads from the command line.

If supplied, set the maximum number of threads.

Definition at line 911 of file elxElastixMain.cxx.

◆ SetOriginalFixedImageDirectionFlat()

void elastix::ElastixMain::SetOriginalFixedImageDirectionFlat ( const FlatDirectionCosinesType &  arg)
virtual

Set/Get the original fixed image direction as a flat array (d11 d21 d31 d21 d22 etc )

******************** SetOriginalFixedImageDirectionFlat ********************

Definition at line 934 of file elxElastixMain.cxx.

◆ SetProcessPriority()

void elastix::ElastixMain::SetProcessPriority ( void  ) const
virtual

Set process priority, which is read from the command line arguments. Syntax: -priority <high, belownormal>

*********************** SetProcessPriority *************************

If wanted, set the priority of this process high or below normal.

Definition at line 862 of file elxElastixMain.cxx.

◆ SetTotalNumberOfElastixLevels()

void elastix::ElastixMain::SetTotalNumberOfElastixLevels ( unsigned int  levels)

Get and Set the total number of elastix levels.

********************* SetTotalNumberOfElastixLevels ************************

Call SetTotalNumberOfElastixLevels from MyConfiguration.

Definition at line 647 of file elxElastixMain.cxx.

◆ UnloadComponents()

void elastix::ElastixMain::UnloadComponents ( void  )
static

********************* UnloadComponents **************************

Definition at line 706 of file elxElastixMain.cxx.

Member Data Documentation

◆ m_Configuration

ConfigurationPointer elastix::ElastixMain::m_Configuration
protected

The configuration object, containing the parameters and command-line arguments.

Definition at line 301 of file elxElastixMain.h.

◆ m_Configurations

std::vector< ConfigurationPointer > elastix::ElastixMain::m_Configurations
protected

A vector of configuration objects, needed when transformix is used as library.

Definition at line 304 of file elxElastixMain.h.

◆ m_Elastix

ObjectPointer elastix::ElastixMain::m_Elastix
protected

A pointer to elastix as an itk::object. In run() this pointer will be assigned to an ElastixTemplate<>.

Definition at line 298 of file elxElastixMain.h.

◆ m_FinalTransform

ObjectPointer elastix::ElastixMain::m_FinalTransform
protected

A transform that is the result of registration.

Definition at line 322 of file elxElastixMain.h.

◆ m_FixedImageContainer

DataObjectContainerPointer elastix::ElastixMain::m_FixedImageContainer
protected

The images and masks.

Definition at line 315 of file elxElastixMain.h.

◆ m_FixedImagePixelType

PixelTypeDescriptionType elastix::ElastixMain::m_FixedImagePixelType
protected

Description of the ImageTypes.

Definition at line 307 of file elxElastixMain.h.

◆ m_InitialTransform

ObjectPointer elastix::ElastixMain::m_InitialTransform
protected

The initial transform.

Definition at line 325 of file elxElastixMain.h.

◆ m_TransformParametersMap

ParameterMapType elastix::ElastixMain::m_TransformParametersMap
protected

Transformation parameters map containing parameters that is the result of registration.

Definition at line 329 of file elxElastixMain.h.

◆ s_CDB

ElastixMain::ComponentDatabasePointer elastix::ElastixMain::s_CDB = 0
staticprotected

****************** Initialization of static members *********

Definition at line 333 of file elxElastixMain.h.


The documentation for this class was generated from the following files: