Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
mitk::ItkImageIO Class Reference

#include <mitkItkImageIO.h>

Inheritance diagram for mitk::ItkImageIO:
Collaboration diagram for mitk::ItkImageIO:

Public Member Functions

 ItkImageIO (itk::ImageIOBase::Pointer imageIO)
 
 ItkImageIO (const CustomMimeType &mimeType, itk::ImageIOBase::Pointer imageIO, int rank)
 
ConfidenceLevel GetReaderConfidenceLevel () const override
 
void Write () override
 Write the base data to the specified location or output stream. More...
 
ConfidenceLevel GetWriterConfidenceLevel () const override
 
std::vector< itk::SmartPointer< BaseData > > Read () override
 Reads a path or stream and creates a list of BaseData objects. More...
 
DataStorage::SetOfObjects::Pointer Read (mitk::DataStorage &ds) override
 
- Public Member Functions inherited from mitk::AbstractFileIO
Options GetReaderOptions () const
 
us::Any GetReaderOption (const std::string &name) const
 
void SetReaderOptions (const Options &options)
 
void SetReaderOption (const std::string &name, const us::Any &value)
 
Options GetWriterOptions () const
 
us::Any GetWriterOption (const std::string &name) const
 
void SetWriterOptions (const Options &options)
 
void SetWriterOption (const std::string &name, const us::Any &value)
 
std::pair< us::ServiceRegistration< IFileReader >, us::ServiceRegistration< IFileWriter > > RegisterService (us::ModuleContext *context=us::GetModuleContext())
 
- Public Member Functions inherited from mitk::AbstractFileIOReader
ConfidenceLevel GetConfidenceLevel () const override
 The confidence level of the reader or writer implementation. More...
 
- Public Member Functions inherited from mitk::AbstractFileReader
void SetInput (const std::string &location) override
 Set the input location. More...
 
void SetInput (const std::string &location, std::istream *is) override
 Set an input stream to read from. More...
 
std::string GetInputLocation () const override
 Get the current input location. More...
 
std::istream * GetInputStream () const override
 Get the input stream. More...
 
MimeType GetRegisteredMimeType () const
 
std::vector< itk::SmartPointer< BaseData > > Read () override
 Reads a path or stream and creates a list of BaseData objects. More...
 
DataStorage::SetOfObjects::Pointer Read (mitk::DataStorage &ds) override
 Reads the specified file or input stream, loading its contents into the provided DataStorage. More...
 
ConfidenceLevel GetConfidenceLevel () const override
 The confidence level of the reader or writer implementation. More...
 
Options GetOptions () const override
 returns a list of the supported options More...
 
us::Any GetOption (const std::string &name) const override
 
void SetOptions (const Options &options) override
 
void SetOption (const std::string &name, const us::Any &value) override
 
void AddProgressCallback (const ProgressCallback &callback) override
 
void RemoveProgressCallback (const ProgressCallback &callback) override
 
us::ServiceRegistration< IFileReaderRegisterService (us::ModuleContext *context=us::GetModuleContext())
 
void UnregisterService ()
 
std::vector< std::string > GetReadFiles () override
 
void SetProperties (const PropertyList *properties) override
 Optionally provide base data properties as a source of meta data. More...
 
- Public Member Functions inherited from mitk::IFileReader
 ~IFileReader () override
 
virtual ~IFileReader ()
 
- Public Member Functions inherited from mitk::IFileIO
virtual ~IFileIO ()
 
- Public Member Functions inherited from mitk::AbstractFileIOWriter
ConfidenceLevel GetConfidenceLevel () const override
 The confidence level of the reader or writer implementation. More...
 
- Public Member Functions inherited from mitk::AbstractFileWriter
void SetInput (const BaseData *data) override
 Set the input data for writing. More...
 
const BaseDataGetInput () const override
 Get the input data set via SetInput(). More...
 
void SetOutputLocation (const std::string &location) override
 Set the output location. More...
 
std::string GetOutputLocation () const override
 Get the current output location. More...
 
void SetOutputStream (const std::string &location, std::ostream *os) override
 Set an output stream for writing. More...
 
std::ostream * GetOutputStream () const override
 Get the output stream. More...
 
ConfidenceLevel GetConfidenceLevel () const override
 The confidence level of the reader or writer implementation. More...
 
MimeType GetRegisteredMimeType () const
 
Options GetOptions () const override
 returns a list of the supported options More...
 
us::Any GetOption (const std::string &name) const override
 
void SetOptions (const Options &options) override
 
void SetOption (const std::string &name, const us::Any &value) override
 
void AddProgressCallback (const ProgressCallback &callback) override
 
void RemoveProgressCallback (const ProgressCallback &callback) override
 
us::ServiceRegistration< IFileWriterRegisterService (us::ModuleContext *context=us::GetModuleContext())
 
void UnregisterService ()
 
- Public Member Functions inherited from mitk::IFileWriter
 ~IFileWriter () override
 

Static Public Member Functions

static PropertyList::Pointer ExtractMetaDataAsPropertyList (const itk::MetaDataDictionary &dictionary, const std::string &mimeTypeName, const std::vector< std::string > &defaultMetaDataKeys)
 
static Image::Pointer LoadRawMitkImageFromImageIO (itk::ImageIOBase *imageIO, const std::string &path)
 
static void PreparImageIOToWriteImage (itk::ImageIOBase *imageIO, const Image *image)
 
static void SavePropertyListAsMetaData (itk::MetaDataDictionary &dictionary, const PropertyList *properties, const std::string &mimeTypeName)
 
- Static Public Member Functions inherited from mitk::IFileIO
static std::string PROP_DESCRIPTION ()
 Service property name for a description. More...
 
static std::string PROP_MIMETYPE ()
 Service property name for the mime-type associated with this file writer. More...
 
- Static Public Member Functions inherited from mitk::IFileWriter
static std::string PROP_BASEDATA_TYPE ()
 Service property name for the supported mitk::BaseData sub-class. More...
 

Protected Member Functions

virtual std::vector< std::string > FixUpImageIOExtensions (const std::string &imageIOName)
 
virtual void FixUpCustomMimeTypeName (const std::string &imageIOName, CustomMimeType &customMimeType)
 
virtual void InitializeDefaultMetaDataKeys ()
 
std::vector< itk::SmartPointer< BaseData > > DoRead () override
 
- Protected Member Functions inherited from mitk::AbstractFileIO
 AbstractFileIO (const AbstractFileIO &other)
 
 AbstractFileIO (const std::string &baseDataType)
 
 AbstractFileIO (const std::string &baseDataType, const CustomMimeType &mimeType, const std::string &description)
 
void SetMimeType (const CustomMimeType &mimeType)
 
const CustomMimeTypeGetMimeType () const
 
void SetReaderDescription (const std::string &description)
 
std::string GetReaderDescription () const
 
void SetWriterDescription (const std::string &description)
 
std::string GetWriterDescription () const
 
void SetDefaultReaderOptions (const Options &defaultOptions)
 
Options GetDefaultReaderOptions () const
 
void SetDefaultWriterOptions (const Options &defaultOptions)
 
Options GetDefaultWriterOptions () const
 
void SetReaderRanking (int ranking)
 Set the service ranking for this file reader. More...
 
int GetReaderRanking () const
 
void SetWriterRanking (int ranking)
 
int GetWriterRanking () const
 
- Protected Member Functions inherited from mitk::AbstractFileIOReader
 AbstractFileIOReader ()
 
 AbstractFileIOReader (const CustomMimeType &mimeType, const std::string &description)
 
- Protected Member Functions inherited from mitk::AbstractFileReader
 AbstractFileReader ()
 
 ~AbstractFileReader () override
 
 AbstractFileReader (const AbstractFileReader &other)
 
 AbstractFileReader (const CustomMimeType &mimeType, const std::string &description)
 
virtual us::ServiceProperties GetServiceProperties () const
 
virtual us::ServiceRegistration< CustomMimeTypeRegisterMimeType (us::ModuleContext *context)
 
void SetMimeType (const CustomMimeType &mimeType)
 
const CustomMimeTypeGetMimeType () const
 
void SetMimeTypePrefix (const std::string &prefix)
 
std::string GetMimeTypePrefix () const
 
void SetDescription (const std::string &description)
 
std::string GetDescription () const
 
void SetDefaultOptions (const Options &defaultOptions)
 
Options GetDefaultOptions () const
 
void SetRanking (int ranking)
 Set the service ranking for this file reader. More...
 
int GetRanking () const
 
std::string GetLocalFileName () const
 Get a local file name for reading. More...
 
virtual void SetDefaultDataNodeProperties (DataNode *node, const std::string &filePath)
 
const PropertyListGetProperties () const override
 
- Protected Member Functions inherited from mitk::AbstractFileIOWriter
 AbstractFileIOWriter (const std::string &baseDataType)
 
 AbstractFileIOWriter (const std::string &baseDataType, const CustomMimeType &mimeType, const std::string &description)
 
- Protected Member Functions inherited from mitk::AbstractFileWriter
 ~AbstractFileWriter () override
 
 AbstractFileWriter (const AbstractFileWriter &other)
 
 AbstractFileWriter (const std::string &baseDataType)
 
 AbstractFileWriter (const std::string &baseDataType, const CustomMimeType &mimeType, const std::string &description)
 
virtual us::ServiceProperties GetServiceProperties () const
 
virtual us::ServiceRegistration< CustomMimeTypeRegisterMimeType (us::ModuleContext *context)
 
void SetMimeType (const CustomMimeType &mimeType)
 
const CustomMimeTypeGetMimeType () const
 
void SetMimeTypePrefix (const std::string &prefix)
 
std::string GetMimeTypePrefix () const
 
void SetDescription (const std::string &description)
 Sets a human readable description of this writer. More...
 
std::string GetDescription () const
 
void SetDefaultOptions (const Options &defaultOptions)
 
Options GetDefaultOptions () const
 
void SetRanking (int ranking)
 Set the service ranking for this file writer. More...
 
int GetRanking () const
 
void SetBaseDataType (const std::string &baseDataType)
 Sets the name of the mitk::Basedata that this writer is able to handle. More...
 
virtual std::string GetBaseDataType () const
 
void ValidateOutputLocation () const
 

Additional Inherited Members

- Public Types inherited from mitk::IFileIO
enum  ConfidenceLevel { Unsupported, PartiallySupported, Supported }
 A confidence level describing the confidence of the reader or writer in handling the given data. More...
 
typedef std::map< std::string, us::AnyOptions
 Options for reading or writing data. More...
 
typedef mitk::MessageAbstractDelegate1< float > ProgressCallback
 
- Protected Attributes inherited from mitk::AbstractFileReader
std::vector< std::string > m_ReadFiles
 

Detailed Description

This class wraps ITK image IO objects as mitk::IFileReader and mitk::IFileWriter objects.

Instantiating this class with a given itk::ImageIOBase instance will register corresponding MITK reader/writer services for that ITK ImageIO object. For all ITK ImageIOs that support the serialization of MetaData (e.g. nrrd or mhd) the ItkImageIO ensures the serialization of Identification UID.

Definition at line 33 of file mitkItkImageIO.h.

Constructor & Destructor Documentation

◆ ItkImageIO() [1/2]

mitk::ItkImageIO::ItkImageIO ( itk::ImageIOBase::Pointer  imageIO)

◆ ItkImageIO() [2/2]

mitk::ItkImageIO::ItkImageIO ( const CustomMimeType mimeType,
itk::ImageIOBase::Pointer  imageIO,
int  rank 
)

Member Function Documentation

◆ DoRead()

std::vector<itk::SmartPointer<BaseData> > mitk::ItkImageIO::DoRead ( )
overrideprotectedvirtual

Method that should be implemented by derived classes and does the real loading. This method is called by Read(). This method must be implemented for each specific reader. Call GetInputStream() first and check for a non-null stream to read from. If the input stream is nullptr, use GetInputLocation() to read from a local file-system path.

If the reader cannot use streams directly, use GetLocalFileName() instead.

Returns
The created BaseData objects.
Exceptions
mitk::Exception
See also
GetLocalFileName()
IFileReader::Read()

Implements mitk::AbstractFileReader.

◆ ExtractMetaDataAsPropertyList()

static PropertyList::Pointer mitk::ItkImageIO::ExtractMetaDataAsPropertyList ( const itk::MetaDataDictionary &  dictionary,
const std::string &  mimeTypeName,
const std::vector< std::string > &  defaultMetaDataKeys 
)
static

Helper function that can be used to convert a MetaDataDictionary into a PropertyList for a certain mimeType. The function uses the Property serialization service for that.

Parameters
mimeTypeNameMime type that should be assumed for the meta data deserialization.
defaultMetaDataKeysVector of keys that should be assumed as defaults. For defaults no PropertyInfo will be registered at the PropertyPersistence service, as they are assumed to be handled anyways. For all other keys an info will be registered to ensure that they will be serialized again, even if unknown.
dictionaryReference to the meta data dictionary that contains the information that should be extracted.

◆ FixUpCustomMimeTypeName()

virtual void mitk::ItkImageIO::FixUpCustomMimeTypeName ( const std::string &  imageIOName,
CustomMimeType customMimeType 
)
protectedvirtual

◆ FixUpImageIOExtensions()

virtual std::vector<std::string> mitk::ItkImageIO::FixUpImageIOExtensions ( const std::string &  imageIOName)
protectedvirtual

◆ GetReaderConfidenceLevel()

ConfidenceLevel mitk::ItkImageIO::GetReaderConfidenceLevel ( ) const
overridevirtual

Reimplemented from mitk::AbstractFileIO.

◆ GetWriterConfidenceLevel()

ConfidenceLevel mitk::ItkImageIO::GetWriterConfidenceLevel ( ) const
overridevirtual

Reimplemented from mitk::AbstractFileIO.

◆ InitializeDefaultMetaDataKeys()

virtual void mitk::ItkImageIO::InitializeDefaultMetaDataKeys ( )
protectedvirtual

◆ LoadRawMitkImageFromImageIO()

static Image::Pointer mitk::ItkImageIO::LoadRawMitkImageFromImageIO ( itk::ImageIOBase *  imageIO,
const std::string &  path 
)
static

Helper function that van be used to extract a raw mitk image for the passed path using the also passed ImageIOBase instance. Raw means, that only the pixel data and geometry information is loaded. But e.g. no properties etc...

◆ PreparImageIOToWriteImage()

static void mitk::ItkImageIO::PreparImageIOToWriteImage ( itk::ImageIOBase *  imageIO,
const Image image 
)
static

Helper function that van be used to extract a raw mitk image for the passed path using the also passed ImageIOBase instance. Raw means, that only the pixel data and geometry information is loaded. But e.g. no properties etc...

◆ Read() [1/2]

std::vector<itk::SmartPointer<BaseData> > mitk::AbstractFileReader::Read
override

Reads a path or stream and creates a list of BaseData objects.

The default implementation of this method (1) calls DoRead() (Implement the specific reader operation there) and (2) it adds general meta information about the loading process.

◆ Read() [2/2]

DataStorage::SetOfObjects::Pointer mitk::AbstractFileReader::Read
override

◆ SavePropertyListAsMetaData()

static void mitk::ItkImageIO::SavePropertyListAsMetaData ( itk::MetaDataDictionary &  dictionary,
const PropertyList properties,
const std::string &  mimeTypeName 
)
static

◆ Write()

void mitk::ItkImageIO::Write ( )
overridevirtual

Write the base data to the specified location or output stream.

This method must be implemented for each specific writer. Call GetOutputStream() first and check for a non-null stream to write to. If the output stream is nullptr, use GetOutputLocation() to write to a local file-system path.

If the reader cannot use streams directly, use GetLocalFile() to retrieve a temporary local file name instead.

Exceptions
mitk::Exception
See also
GetLocalFile()
IFileWriter::Write()

Implements mitk::AbstractFileWriter.


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