28#ifndef elxElastixBase_h
29#define elxElastixBase_h
39#include <itkChangeInformationImageFilter.h>
40#include <itkDataObject.h>
41#include <itkImageFileReader.h>
43#include <itkTimeProbe.h>
44#include <itkVectorContainer.h>
55#define elxGetObjectMacro(_name, _type) \
56 _type * Get##_name() const { return m_##_name.GetPointer(); }
59#define elxSetObjectMacro(_name, _type) \
60 void Set##_name(_type * _arg) \
62 if (m_##_name != _arg) \
65 this->itk::Object::Modified(); \
71#define elxGetNumberOfMacro(_name) \
72 unsigned int GetNumberOf##_name##s() const \
74 if (m_##_name##Container != nullptr) \
76 return m_##_name##Container->Size(); \
422 template <
class TImage>
430 const std::string & imageDescription,
431 bool useDirectionCosines,
434 const auto imageContainer = DataObjectContainerType::New();
437 for (
const auto & fileName : *fileNameContainer)
439 const auto infoChanger = itk::ChangeInformationImageFilter<TImage>::New();
440 infoChanger->SetChangeDirection(!useDirectionCosines);
445 const auto image = itk::ReadImage<TImage>(fileName);
446 infoChanger->SetInput(image);
447 infoChanger->Update();
450 if (originalDirectionCosines !=
nullptr)
452 *originalDirectionCosines = image->GetDirection();
455 catch (itk::ExceptionObject & excp)
458 std::string err_str = excp.GetDescription();
459 err_str +=
"\nError occurred while reading the image described as " + imageDescription +
", with file name " +
461 excp.SetDescription(err_str);
467 imageContainer->push_back(infoChanger->GetOutput());
472 return imageContainer;
537#undef elxGetObjectMacro
538#undef elxSetObjectMacro
539#undef elxGetNumberOfMacro
The BaseComponent class is a class that all elastix components should inherit from.
itk::SmartPointer< Self > Pointer
A class that deals with user given parameters and command line arguments.
itk::SmartPointer< Self > Pointer
itk::SmartPointer< const Self > ConstPointer
~MultipleImageLoader()=default
MultipleImageLoader()=default
typename TImage::DirectionType DirectionType
static DataObjectContainerPointer GenerateImageContainer(const FileNameContainerType *const fileNameContainer, const std::string &imageDescription, bool useDirectionCosines, DirectionType *originalDirectionCosines=nullptr)
This class creates an interface for elastix.
elxSetObjectMacro(FixedImageContainer, DataObjectContainerType)
itk::TimeProbe m_ResolutionTimer
itk::TimeProbe m_IterationTimer
elxSetObjectMacro(MetricContainer, ObjectContainerType)
itk::VectorContainer< unsigned int, DataObjectPointer > DataObjectContainerType
ITK_DISALLOW_COPY_AND_MOVE(ElastixBase)
DataObjectContainerPointer m_FixedImageContainer
void AddTargetCellToIterationInfo(const char *const name)
elxGetObjectMacro(MovingImageFileNameContainer, FileNameContainerType)
elxGetObjectMacro(InitialTransform, itk::Object)
elxGetNumberOfMacro(Metric)
DataObjectContainerPointer m_MovingImageContainer
elxGetObjectMacro(FinalTransform, itk::Object)
ObjectContainerPointer m_RegistrationContainer
elxGetNumberOfMacro(MovingMaskFileName)
FileNameContainerPointer m_MovingMaskFileNameContainer
itk::DataObject::Pointer DataObjectPointer
static DataObjectContainerPointer GenerateDataObjectContainer(DataObjectPointer dataObject)
Configuration::Pointer m_Configuration
elxSetObjectMacro(ResultImageContainer, DataObjectContainerType)
elxSetObjectMacro(OptimizerContainer, ObjectContainerType)
elxSetObjectMacro(RegistrationContainer, ObjectContainerType)
itk::VectorContainer< unsigned int, std::string > FileNameContainerType
elxGetObjectMacro(FixedImagePyramidContainer, ObjectContainerType)
elxGetObjectMacro(FixedMaskFileNameContainer, FileNameContainerType)
itk::DataObject ResultImageType
ObjectContainerPointer m_OptimizerContainer
ObjectContainerPointer m_ResampleInterpolatorContainer
elxGetNumberOfMacro(Transform)
FileNameContainerPointer m_FixedImageFileNameContainer
elxGetNumberOfMacro(FixedImage)
elxSetObjectMacro(ResamplerContainer, ObjectContainerType)
std::vector< double > FlatDirectionCosinesType
elxGetObjectMacro(MovingImageContainer, DataObjectContainerType)
elxGetObjectMacro(TransformContainer, ObjectContainerType)
unsigned int m_IterationCounter
vcl_size_t GetNumberOfTransformConfigurations() const
elxGetNumberOfMacro(MovingMask)
bool m_UseDirectionCosines
itk::VectorContainer< unsigned int, ObjectPointer > ObjectContainerType
elxGetNumberOfMacro(MovingImage)
DataObjectContainerPointer m_FixedMaskContainer
elxSetObjectMacro(MovingImageContainer, DataObjectContainerType)
elxSetObjectMacro(Configuration, Configuration)
elxGetNumberOfMacro(FixedImagePyramid)
Configuration::ConstPointer GetTransformConfiguration(const vcl_size_t index) const
elxSetObjectMacro(MovingImagePyramidContainer, ObjectContainerType)
elxGetNumberOfMacro(FixedMaskFileName)
elxGetObjectMacro(OptimizerContainer, ObjectContainerType)
elxGetNumberOfMacro(FixedMask)
itk::Object::Pointer ObjectPointer
DataObjectContainerType::Pointer DataObjectContainerPointer
elxGetObjectMacro(ImageSamplerContainer, ObjectContainerType)
void SetOriginalFixedImageDirectionFlat(const FlatDirectionCosinesType &arg)
ObjectContainerPointer m_ResamplerContainer
void SetResultDeformationField(DataObjectPointer result_deformationfield)
elxGetObjectMacro(MovingMaskContainer, DataObjectContainerType)
elxGetObjectMacro(FixedImageContainer, DataObjectContainerType)
ObjectContainerPointer m_InterpolatorContainer
bool GetUseDirectionCosines() const
elxGetObjectMacro(ResampleInterpolatorContainer, ObjectContainerType)
elxSetObjectMacro(InitialTransform, itk::Object)
FlatDirectionCosinesType m_OriginalFixedImageDirection
elxGetObjectMacro(FixedImageFileNameContainer, FileNameContainerType)
elxSetObjectMacro(FixedImagePyramidContainer, ObjectContainerType)
DataObjectContainerPointer m_ResultImageContainer
elxSetObjectMacro(MovingMaskContainer, DataObjectContainerType)
elxGetNumberOfMacro(ResultImage)
elxGetNumberOfMacro(ResultDeformationField)
DataObjectContainerPointer m_MovingMaskContainer
elxGetNumberOfMacro(ResampleInterpolator)
elxGetObjectMacro(RegistrationContainer, ObjectContainerType)
elxSetObjectMacro(ResampleInterpolatorContainer, ObjectContainerType)
elxGetNumberOfMacro(Interpolator)
elxSetObjectMacro(FinalTransform, itk::Object)
const FlatDirectionCosinesType & GetOriginalFixedImageDirectionFlat() const
elxGetNumberOfMacro(MovingImageFileName)
elxSetObjectMacro(ImageSamplerContainer, ObjectContainerType)
void SetDBIndex(DBIndexType _arg)
std::string m_CurrentTransformParameterFileName
ResultDeformationFieldType * GetResultDeformationField(unsigned int idx=0) const
elxSetObjectMacro(MovingMaskFileNameContainer, FileNameContainerType)
ResultImageType * GetResultImage(const unsigned int idx=0) const
elxSetObjectMacro(MovingImageFileNameContainer, FileNameContainerType)
elxGetObjectMacro(InterpolatorContainer, ObjectContainerType)
ObjectContainerPointer m_FixedImagePyramidContainer
elxGetObjectMacro(MetricContainer, ObjectContainerType)
elxGetObjectMacro(Configuration, Configuration)
int BeforeAllBase() override
virtual int ApplyTransform(bool doReadTransform)=0
elxGetNumberOfMacro(Resampler)
elxSetObjectMacro(InterpolatorContainer, ObjectContainerType)
ObjectPointer m_InitialTransform
std::vector< Configuration::ConstPointer > m_TransformConfigurations
Configuration::ConstPointer GetPreviousTransformConfiguration(const Configuration &configuration) const
ObjectContainerPointer m_MovingImagePyramidContainer
elxGetObjectMacro(ResamplerContainer, ObjectContainerType)
elxSetObjectMacro(ResultDeformationFieldContainer, DataObjectContainerType)
elxSetObjectMacro(FixedMaskFileNameContainer, FileNameContainerType)
elxSetObjectMacro(FixedMaskContainer, DataObjectContainerType)
std::ofstream m_IterationInfoFile
elxGetNumberOfMacro(Optimizer)
itk::DataObject ResultDeformationFieldType
virtual void CreateTransformParameterMap()=0
ObjectContainerPointer m_TransformContainer
ObjectContainerPointer m_MetricContainer
IterationInfo m_IterationInfo
ObjectContainerPointer m_ImageSamplerContainer
ParameterMapType GetTransformParameterMap() const
elxGetNumberOfMacro(Registration)
elxSetObjectMacro(TransformContainer, ObjectContainerType)
elxSetObjectMacro(FixedImageFileNameContainer, FileNameContainerType)
elxGetNumberOfMacro(MovingImagePyramid)
int BeforeAllTransformixBase()
itk::ParameterMapInterface::ParameterMapType ParameterMapType
elxGetNumberOfMacro(ImageSampler)
void SetResultImage(DataObjectPointer result_image)
elxGetObjectMacro(ResultImageContainer, DataObjectContainerType)
elxGetObjectMacro(ResultDeformationFieldContainer, DataObjectContainerType)
~ElastixBase() override=default
elxGetObjectMacro(MovingMaskFileNameContainer, FileNameContainerType)
ObjectPointer m_FinalTransform
elxGetObjectMacro(MovingImagePyramidContainer, ObjectContainerType)
elxGetNumberOfMacro(FixedImageFileName)
FileNameContainerType::Pointer FileNameContainerPointer
void SetTransformConfigurations(const std::vector< Configuration::ConstPointer > &configurations)
ObjectContainerType::Pointer ObjectContainerPointer
elxGetObjectMacro(FixedMaskContainer, DataObjectContainerType)
FileNameContainerPointer m_FixedMaskFileNameContainer
ParameterMapType m_TransformParameterMap
FileNameContainerPointer m_MovingImageFileNameContainer
std::ostream & GetIterationInfoAt(const char *const name)
IterationInfo & GetIterationInfo()
DataObjectContainerPointer m_ResultDeformationFieldContainer
ComponentDatabase::Pointer ComponentDatabasePointer
void AddNewTargetCell(const char *const cellName)
ParameterFileParser::ParameterMapType ParameterMapType