Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::DICOMReaderConfigurator Class Reference

Too-simple factory to create DICOMFileReaders. More...

#include <mitkDICOMReaderConfigurator.h>

Inheritance diagram for mitk::DICOMReaderConfigurator:
Collaboration diagram for mitk::DICOMReaderConfigurator:

Public Member Functions

 mitkClassMacroItkParent (DICOMReaderConfigurator, itk::LightObject)
 
DICOMFileReader::Pointer CreateFromConfigFile (const std::string &filename) const
 Create a DICOMFileReader from an XML configuration file. More...
 
DICOMFileReader::Pointer CreateFromUTF8ConfigString (const std::string &xmlContents) const
 Create a DICOMFileReader from an XML configuration string (UTF-8 encoded). More...
 
std::string CreateConfigStringFromReader (DICOMFileReader::ConstPointer reader) const
 Serialize a DICOMFileReader's configuration to an XML string. More...
 

Static Public Member Functions

static Pointer New ()
 
static std::string GetConfigStringFromModuleResource (const std::string &resourcePath)
 Retrieve a configuration string from a compiled-in module resource. More...
 

Protected Member Functions

 DICOMReaderConfigurator ()
 
 ~DICOMReaderConfigurator () override
 

Detailed Description

Too-simple factory to create DICOMFileReaders.

This class is able to instantiate and configure (where possible) DICOMFileReaders from XML descriptions.

Note
This is a bad factory example, because the factory is not extensible and needs to know all the specific readers. A flexible implementation should be provided in a future version.

In its current version, the XML input is meant to be structured like

<?xml version="1.0" standalone=no>
<DICOMFileReader
  label="Example Reader"
  description="Sort images by example tags"
  class="DICOMITKSeriesGDCMReader"
  fixTiltByShearing="true">
<Distinguishing>
 <Tag name="SeriesInstanceUID" group="0020" element="000e"/>
 <Tag name="SeriesNumber" group="0020" element="0011"/>
</Distinguishing>
<Sorting>
 <ImagePositionPatient/>
 <Tag name="SOPInstanceUID" group="0x0008" element="0x0018"/>
</Sorting>
</DICOMFileReader>

The root-tag <DICOMFileReader> names the class to be instantiated, currently this can be one of

Both classes bring simple configuration flags with them and a description of how images are sorted prior to loading.

Flag for DICOMITKSeriesGDCMReader:

fixTiltByShearing="true|false"

Determines whether a potential gantry tilt should be "fixed" by shearing the output image.

Flag for ThreeDnTDICOMSeriesReader:

group3DnT="true|false"

Determines whether images at the same spatial position should be interpreted as 3D+t images.

The tags <Distinguishing> and <Sorting> describe the basic loading strategy of both reader mentioned above: first images are divided into incompatible groups (<Distinguishing>), and afterwards the images within each group are sorted by means of DICOMSortCriterion, which most commonly mentions a tag.

Tag element and group are interpreted as the hexadecimal numbers found all around the DICOM standard. The numbers can be prepended by a "0x" if this is preferred by the programmer (but they are taken as hexadecimal in all cases).

About the future evolution of this class

This first version is hard coded for the current state of the implementation.

If things should evolve in a way that needs us to split off readers for "old" versions, time should be taken to refactor this class.

Basically, a serializer class should accompany each of the configurable classes. Such serializer classes should be registered and discovered via micro-services (to support extensions). A serializer should offer both methods to serialize a class and to desirialize it again.

A "version" attribute at the top-level tag should be used to distinguish versions.

Usually it should be enough to keep DE-serializers for all versions. Writers for the most recent version should be enough.

Definition at line 93 of file mitkDICOMReaderConfigurator.h.

Constructor & Destructor Documentation

◆ DICOMReaderConfigurator()

mitk::DICOMReaderConfigurator::DICOMReaderConfigurator ( )
protected

◆ ~DICOMReaderConfigurator()

mitk::DICOMReaderConfigurator::~DICOMReaderConfigurator ( )
overrideprotected

Member Function Documentation

◆ CreateConfigStringFromReader()

std::string mitk::DICOMReaderConfigurator::CreateConfigStringFromReader ( DICOMFileReader::ConstPointer  reader) const

Serialize a DICOMFileReader's configuration to an XML string.

Parameters
[in]readerThe reader whose configuration should be serialized.
Returns
An XML configuration string representing the reader's setup.

◆ CreateFromConfigFile()

DICOMFileReader::Pointer mitk::DICOMReaderConfigurator::CreateFromConfigFile ( const std::string &  filename) const

Create a DICOMFileReader from an XML configuration file.

Parameters
[in]filenameAbsolute path to the XML configuration file.
Returns
A smart pointer to the configured DICOMFileReader, or nullptr on failure.

◆ CreateFromUTF8ConfigString()

DICOMFileReader::Pointer mitk::DICOMReaderConfigurator::CreateFromUTF8ConfigString ( const std::string &  xmlContents) const

Create a DICOMFileReader from an XML configuration string (UTF-8 encoded).

Parameters
[in]xmlContentsThe XML configuration as a string.
Returns
A smart pointer to the configured DICOMFileReader, or nullptr on failure.

◆ GetConfigStringFromModuleResource()

static std::string mitk::DICOMReaderConfigurator::GetConfigStringFromModuleResource ( const std::string &  resourcePath)
static

Retrieve a configuration string from a compiled-in module resource.

Parameters
[in]resourcePathPath of the resource within the MitkDICOM module.
Returns
The configuration XML as a string, or an empty string if the resource cannot be resolved.

◆ mitkClassMacroItkParent()

mitk::DICOMReaderConfigurator::mitkClassMacroItkParent ( DICOMReaderConfigurator  ,
itk::LightObject   
)

◆ New()

static Pointer mitk::DICOMReaderConfigurator::New ( )
static

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