go home Home | Main Page | Topics | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
Loading...
Searching...
No Matches
elastix::MainBase Class Referenceabstract

#include <elxMainBase.h>

Detailed Description

Common (abstract) base class of ElastixMain and TransformixMain.

Definition at line 44 of file elxMainBase.h.

Inheritance diagram for elastix::MainBase:

Public Types

using ArgumentMapType = Configuration::CommandLineArgumentMapType
using ComponentDatabasePointer = ComponentDatabase::Pointer
using ComponentDescriptionType = ComponentDatabase::ComponentDescriptionType
using ConstPointer = itk::SmartPointer<const Self>
using DataObjectContainerPointer = ElastixBase::DataObjectContainerPointer
using DataObjectContainerType = ElastixBase::DataObjectContainerType
using DataObjectPointer = itk::DataObject::Pointer
using DBIndexType = ComponentDatabase::IndexType
using FlatDirectionCosinesType = ElastixBase::FlatDirectionCosinesType
using ImageDimensionType = ComponentDatabase::ImageDimensionType
using ObjectContainerPointer = ElastixBase::ObjectContainerPointer
using ObjectContainerType = ElastixBase::ObjectContainerType
using ObjectPointer = itk::Object::Pointer
using ParameterMapType = itk::ParameterMapInterface::ParameterMapType
using PixelTypeDescriptionType = ComponentDatabase::PixelTypeDescriptionType
using Pointer = itk::SmartPointer<Self>
using PtrToCreator = ComponentDatabase::PtrToCreator
using Self = MainBase
using Superclass = itk::Object

Public Member Functions

virtual DBIndexType GetDBIndex () const
ElastixBaseGetElastixBase () const
virtual ImageDimensionType GetFixedImageDimension () const
virtual PixelTypeDescriptionType GetFixedImagePixelType () const
virtual ImageDimensionType GetMovingImageDimension () const
virtual PixelTypeDescriptionType GetMovingImagePixelType () const
 ITK_DISALLOW_COPY_AND_MOVE (MainBase)
 itkGetModifiableObjectMacro (Configuration, Configuration)
 itkGetModifiableObjectMacro (Elastix, itk::Object)
 itkGetModifiableObjectMacro (MovingImageContainer, DataObjectContainerType)
 itkGetModifiableObjectMacro (ResultDeformationFieldContainer, DataObjectContainerType)
 itkGetModifiableObjectMacro (ResultImageContainer, DataObjectContainerType)
 itkOverrideGetNameOfClassMacro (MainBase)
virtual int Run ()=0
virtual int Run (const ArgumentMapType &argmap)
virtual int Run (const ArgumentMapType &argmap, const ParameterMapType &inputMap)
virtual void SetConfiguration (Configuration *_arg)
virtual void SetFixedImageDimension (ImageDimensionType _arg)
virtual void SetFixedImagePixelType (PixelTypeDescriptionType _arg)
virtual void SetMaximumNumberOfThreads () const
virtual void SetMovingImageContainer (DataObjectContainerType *_arg)
virtual void SetMovingImageDimension (ImageDimensionType _arg)
virtual void SetMovingImagePixelType (PixelTypeDescriptionType _arg)
virtual void SetProcessPriority () const
virtual void SetResultDeformationFieldContainer (DataObjectContainerType *_arg)
virtual void SetResultImageContainer (DataObjectContainerType *_arg)

Static Public Member Functions

static const ComponentDatabaseGetComponentDatabase ()

Protected Member Functions

virtual ObjectPointer CreateComponent (const ComponentDescriptionType &name)
virtual ObjectContainerPointer CreateComponents (const ComponentDescriptionType &key, const ComponentDescriptionType &defaultComponentName, int &errorcode, bool mandatoryComponent=true)
virtual int InitDBIndex ()=0
 MainBase ()
 ~MainBase () override=0

Protected Attributes

DBIndexType m_DBIndex { 0 }
ObjectPointer m_Elastix { nullptr }
ImageDimensionType m_FixedImageDimension { 0 }
PixelTypeDescriptionType m_FixedImagePixelType {}
DataObjectContainerPointer m_MovingImageContainer { nullptr }
ImageDimensionType m_MovingImageDimension { 0 }
PixelTypeDescriptionType m_MovingImagePixelType {}
DataObjectContainerPointer m_ResultDeformationFieldContainer { nullptr }
DataObjectContainerPointer m_ResultImageContainer { nullptr }
std::vector< Configuration::ConstPointerm_TransformConfigurations {}

Static Private Member Functions

static ComponentDatabaseGetMutableComponentDatabase ()
static bool TryLoadComponentPlugin (const ComponentDescriptionType &componentName)

Private Attributes

Configuration::Pointer m_Configuration { Configuration::New() }

Member Typedef Documentation

◆ ArgumentMapType

elastix components.

Definition at line 65 of file elxMainBase.h.

◆ ComponentDatabasePointer

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 75 of file elxMainBase.h.

◆ ComponentDescriptionType

◆ ConstPointer

using elastix::MainBase::ConstPointer = itk::SmartPointer<const Self>

Definition at line 53 of file elxMainBase.h.

◆ DataObjectContainerPointer

◆ DataObjectContainerType

◆ DataObjectPointer

using elastix::MainBase::DataObjectPointer = itk::DataObject::Pointer

Definition at line 62 of file elxMainBase.h.

◆ DBIndexType

◆ FlatDirectionCosinesType

◆ ImageDimensionType

◆ ObjectContainerPointer

◆ ObjectContainerType

◆ ObjectPointer

using elastix::MainBase::ObjectPointer = itk::Object::Pointer

Typedef's. ITK base objects.

Definition at line 61 of file elxMainBase.h.

◆ ParameterMapType

Typedef that is used in the elastix dll version.

Definition at line 83 of file elxMainBase.h.

◆ PixelTypeDescriptionType

◆ Pointer

using elastix::MainBase::Pointer = itk::SmartPointer<Self>

Definition at line 52 of file elxMainBase.h.

◆ PtrToCreator

◆ Self

Standard itk.

Definition at line 50 of file elxMainBase.h.

◆ Superclass

using elastix::MainBase::Superclass = itk::Object

Definition at line 51 of file elxMainBase.h.

Constructor & Destructor Documentation

◆ MainBase()

elastix::MainBase::MainBase ( )
protected

◆ ~MainBase()

elastix::MainBase::~MainBase ( )
overrideprotectedpure virtual

Member Function Documentation

◆ CreateComponent()

virtual ObjectPointer elastix::MainBase::CreateComponent ( const ComponentDescriptionType & name)
protectedvirtual

Creates an elastix component by name. Make sure InitDBIndex has been called before invoking this function.

The input is a string identifying the component, for example: "MattesMutualInformation" or "Impact".

Component creation follows a two-step strategy:

1) Fast path — static components First, the function queries the already populated ComponentDatabase. This covers all components that are statically linked into elastix and is the normal, zero-overhead code path.

2) Lazy plugin path — optional components If the component is not found, elastix attempts to lazy-load a plugin that may provide it (for example, the IMPACT metric). When the plugin is successfully loaded, it registers its components into the database, and the lookup is retried exactly once.

This design allows elastix to:

  • run out of the box without heavy optional dependencies (e.g. LibTorch),
  • keep startup time minimal,
  • enable optional components only when they are actually requested.

If both attempts fail, an exception is thrown with a clear diagnostic message explaining which component could not be created.

◆ CreateComponents()

virtual ObjectContainerPointer elastix::MainBase::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 instantiations 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

◆ GetComponentDatabase()

const ComponentDatabase & elastix::MainBase::GetComponentDatabase ( )
static

Const accessor for the ComponentDatabase.

Most of elastix only needs read-only access to the database (querying creators). This overload preserves const-correctness while still sharing the same underlying singleton instance.

◆ GetDBIndex()

virtual DBIndexType elastix::MainBase::GetDBIndex ( ) const
virtual

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

◆ GetElastixBase()

ElastixBase & elastix::MainBase::GetElastixBase ( ) const

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

◆ GetFixedImageDimension()

virtual ImageDimensionType elastix::MainBase::GetFixedImageDimension ( ) const
virtual

◆ GetFixedImagePixelType()

virtual PixelTypeDescriptionType elastix::MainBase::GetFixedImagePixelType ( ) const
virtual

◆ GetMovingImageDimension()

virtual ImageDimensionType elastix::MainBase::GetMovingImageDimension ( ) const
virtual

◆ GetMovingImagePixelType()

virtual PixelTypeDescriptionType elastix::MainBase::GetMovingImagePixelType ( ) const
virtual

◆ GetMutableComponentDatabase()

ComponentDatabase & elastix::MainBase::GetMutableComponentDatabase ( )
staticprivate

****************** GetComponentDatabase *********

Returns the global ComponentDatabase instance.

This function provides mutable access to the database. It is required for the lazy plugin mechanism: when a plugin is loaded at runtime, it must be able to register new components into the database. That registration modifies the database, hence a non-const reference is needed.

The database itself is created exactly once using a C++11 "magic static". This guarantees:

  • thread-safe initialization,
  • a single shared ComponentDatabase for the whole process,
  • identical behavior to the previous static-initialization design.

At construction time, the ComponentLoader installs all statically linked components. Later, TryLoadComponentPlugin() may add more entries by calling into this same mutable instance.

◆ InitDBIndex()

virtual int elastix::MainBase::InitDBIndex ( )
protectedpure virtual

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

Implemented in elastix::ElastixMain, and elastix::TransformixMain.

◆ ITK_DISALLOW_COPY_AND_MOVE()

elastix::MainBase::ITK_DISALLOW_COPY_AND_MOVE ( MainBase )

◆ itkGetModifiableObjectMacro() [1/5]

elastix::MainBase::itkGetModifiableObjectMacro ( Configuration ,
Configuration  )

◆ itkGetModifiableObjectMacro() [2/5]

elastix::MainBase::itkGetModifiableObjectMacro ( Elastix ,
itk::Object  )

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

◆ itkGetModifiableObjectMacro() [3/5]

elastix::MainBase::itkGetModifiableObjectMacro ( MovingImageContainer ,
DataObjectContainerType  )

◆ itkGetModifiableObjectMacro() [4/5]

elastix::MainBase::itkGetModifiableObjectMacro ( ResultDeformationFieldContainer ,
DataObjectContainerType  )

◆ itkGetModifiableObjectMacro() [5/5]

elastix::MainBase::itkGetModifiableObjectMacro ( ResultImageContainer ,
DataObjectContainerType  )

◆ itkOverrideGetNameOfClassMacro()

elastix::MainBase::itkOverrideGetNameOfClassMacro ( MainBase )

Run-time type information (and related methods).

◆ Run() [1/3]

virtual int elastix::MainBase::Run ( )
pure virtual

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

Implemented in elastix::ElastixMain, and elastix::TransformixMain.

◆ Run() [2/3]

virtual int elastix::MainBase::Run ( const ArgumentMapType & argmap)
virtual

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

Reimplemented in elastix::ElastixMain, and elastix::TransformixMain.

◆ Run() [3/3]

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

◆ SetConfiguration()

virtual void elastix::MainBase::SetConfiguration ( Configuration * _arg)
virtual

Set/Get the configuration object.

◆ SetFixedImageDimension()

virtual void elastix::MainBase::SetFixedImageDimension ( ImageDimensionType _arg)
virtual

◆ SetFixedImagePixelType()

virtual void elastix::MainBase::SetFixedImagePixelType ( PixelTypeDescriptionType _arg)
virtual

Set/Get functions for the description of the image type.

◆ SetMaximumNumberOfThreads()

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

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

◆ SetMovingImageContainer()

virtual void elastix::MainBase::SetMovingImageContainer ( DataObjectContainerType * _arg)
virtual

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

◆ SetMovingImageDimension()

virtual void elastix::MainBase::SetMovingImageDimension ( ImageDimensionType _arg)
virtual

◆ SetMovingImagePixelType()

virtual void elastix::MainBase::SetMovingImagePixelType ( PixelTypeDescriptionType _arg)
virtual

◆ SetProcessPriority()

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

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

◆ SetResultDeformationFieldContainer()

virtual void elastix::MainBase::SetResultDeformationFieldContainer ( DataObjectContainerType * _arg)
virtual

◆ SetResultImageContainer()

virtual void elastix::MainBase::SetResultImageContainer ( DataObjectContainerType * _arg)
virtual

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).

◆ TryLoadComponentPlugin()

bool elastix::MainBase::TryLoadComponentPlugin ( const ComponentDescriptionType & componentName)
staticprivate

Tries to load a component as a runtime plugin and register it in the ComponentDatabase.

This function is called when a component cannot be created because it is not yet present in the ComponentDatabase. It attempts to dynamically load a shared library whose name is derived from componentName (e.g. libImpactMetric.so, ImpactMetric.dll, ...), locate the exported <PluginName>InstallComponent symbol inside that library, and call it.

The install function is expected to register one or more components into the provided ComponentDatabase. After a successful call, the caller can retry component creation using the same name.

The plugin is searched using the system dynamic loader mechanisms (RPATH/RUNPATH, LD_LIBRARY_PATH on Unix, PATH on Windows), exactly like a regular shared library.

Parameters
componentNameName of the component as used in the parameter file (e.g. "Impact").
Returns
true if a plugin was successfully loaded and installed, false otherwise.

Member Data Documentation

◆ m_Configuration

Configuration::Pointer elastix::MainBase::m_Configuration { Configuration::New() }
private

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

Definition at line 310 of file elxMainBase.h.

◆ m_DBIndex

DBIndexType elastix::MainBase::m_DBIndex { 0 }
protected

Definition at line 192 of file elxMainBase.h.

◆ m_Elastix

ObjectPointer elastix::MainBase::m_Elastix { nullptr }
protected

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

Definition at line 181 of file elxMainBase.h.

◆ m_FixedImageDimension

ImageDimensionType elastix::MainBase::m_FixedImageDimension { 0 }
protected

Definition at line 188 of file elxMainBase.h.

◆ m_FixedImagePixelType

PixelTypeDescriptionType elastix::MainBase::m_FixedImagePixelType {}
protected

Description of the ImageTypes.

Definition at line 187 of file elxMainBase.h.

◆ m_MovingImageContainer

DataObjectContainerPointer elastix::MainBase::m_MovingImageContainer { nullptr }
protected

The images and masks.

Definition at line 195 of file elxMainBase.h.

◆ m_MovingImageDimension

ImageDimensionType elastix::MainBase::m_MovingImageDimension { 0 }
protected

Definition at line 190 of file elxMainBase.h.

◆ m_MovingImagePixelType

PixelTypeDescriptionType elastix::MainBase::m_MovingImagePixelType {}
protected

Definition at line 189 of file elxMainBase.h.

◆ m_ResultDeformationFieldContainer

DataObjectContainerPointer elastix::MainBase::m_ResultDeformationFieldContainer { nullptr }
protected

Definition at line 197 of file elxMainBase.h.

◆ m_ResultImageContainer

DataObjectContainerPointer elastix::MainBase::m_ResultImageContainer { nullptr }
protected

Definition at line 196 of file elxMainBase.h.

◆ m_TransformConfigurations

std::vector<Configuration::ConstPointer> elastix::MainBase::m_TransformConfigurations {}
protected

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

Definition at line 184 of file elxMainBase.h.



Generated on 1774142652 for elastix by doxygen 1.15.0 elastix logo