Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
mitk::MultiLabelIOHelper Class Reference

The MultiLabelIOHelper is a static helper class that supports serialization of mitk::LabelSetImage. More...

#include <mitkMultiLabelIOHelper.h>

Public Types

using LabelGroupMetaData = std::pair< std::string, LabelVector >
 

Static Public Member Functions

static bool SaveLabelSetImagePreset (const std::string &presetFilename, const mitk::LabelSetImage *inputImage)
 Saves the mitk::LabelSet configuration of inputImage to presetFilename. The preset is stored as "*.lsetp". More...
 
static bool LoadLabelSetImagePreset (const std::string &presetFilename, mitk::LabelSetImage *inputImage)
 Loads an existing preset for a mitk::LabelSetImage from presetFilename and applies it to inputImage. More...
 
static itk::SmartPointer< mitk::LabelLoadLabelFromXMLDocument (const tinyxml2::XMLElement *labelElem)
 Creates a mitk::Label from an XML element. More...
 
static tinyxml2::XMLElement * GetLabelAsXMLElement (tinyxml2::XMLDocument &doc, const Label *label)
 Creates an XML element from a mitk::Label. More...
 
static tinyxml2::XMLElement * PropertyToXMLElement (tinyxml2::XMLDocument &doc, const std::string &key, const BaseProperty *property)
 Since a mitk::Label is basically a mitk::PropertyList this function converts the label's properties into XML. More...
 
static bool PropertyFromXMLElement (std::string &key, itk::SmartPointer< mitk::BaseProperty > &prop, const tinyxml2::XMLElement *elem)
 Since a mitk::Label is basically a mitk::PropertyList this function converts an XML element into a property. More...
 
static int GetIntByKey (const itk::MetaDataDictionary &dic, const std::string &key)
 
static std::string GetStringByKey (const itk::MetaDataDictionary &dic, const std::string &key)
 
static nlohmann::json SerializeMultLabelGroupsToJSON (const mitk::LabelSetImage *inputImage)
 
static std::vector< LabelGroupMetaDataDeserializeMultiLabelGroupsFromJSON (const nlohmann::json &listOfLabelSets)
 
static nlohmann::json SerializeLabelToJSON (const Label *label)
 
static mitk::Label::Pointer DeserializeLabelFromJSON (const nlohmann::json &labelJson)
 

Detailed Description

The MultiLabelIOHelper is a static helper class that supports serialization of mitk::LabelSetImage.

This class provides static functions for converting mitk::Label into XML and also allows the serialization of mitk::LabelSet as presets

Definition at line 50 of file mitkMultiLabelIOHelper.h.

Member Typedef Documentation

◆ LabelGroupMetaData

using mitk::MultiLabelIOHelper::LabelGroupMetaData = std::pair < std::string, LabelVector>

Definition at line 116 of file mitkMultiLabelIOHelper.h.

Member Function Documentation

◆ DeserializeLabelFromJSON()

static mitk::Label::Pointer mitk::MultiLabelIOHelper::DeserializeLabelFromJSON ( const nlohmann::json labelJson)
static

◆ DeserializeMultiLabelGroupsFromJSON()

static std::vector<LabelGroupMetaData> mitk::MultiLabelIOHelper::DeserializeMultiLabelGroupsFromJSON ( const nlohmann::json listOfLabelSets)
static

◆ GetIntByKey()

static int mitk::MultiLabelIOHelper::GetIntByKey ( const itk::MetaDataDictionary &  dic,
const std::string &  key 
)
static

Helper that extracts the value of a key in a meta dictionary as int. If the key does not exist 0 is returned.

◆ GetLabelAsXMLElement()

static tinyxml2::XMLElement* mitk::MultiLabelIOHelper::GetLabelAsXMLElement ( tinyxml2::XMLDocument &  doc,
const Label label 
)
static

Creates an XML element from a mitk::Label.

Parameters
doc
labelthe mitk::Label from which the xml element will be created
Returns
the created XML element

◆ GetStringByKey()

static std::string mitk::MultiLabelIOHelper::GetStringByKey ( const itk::MetaDataDictionary &  dic,
const std::string &  key 
)
static

Helper that extracts the value of a key in a meta dictionary as string. If the key does not exist an empty string is returned.

◆ LoadLabelFromXMLDocument()

static itk::SmartPointer<mitk::Label> mitk::MultiLabelIOHelper::LoadLabelFromXMLDocument ( const tinyxml2::XMLElement *  labelElem)
static

Creates a mitk::Label from an XML element.

Parameters
labelElemthe xml element from which a mitk::Label will be created
Returns
the created mitk::Label

◆ LoadLabelSetImagePreset()

static bool mitk::MultiLabelIOHelper::LoadLabelSetImagePreset ( const std::string &  presetFilename,
mitk::LabelSetImage inputImage 
)
static

Loads an existing preset for a mitk::LabelSetImage from presetFilename and applies it to inputImage.

Parameters
presetFilenamethe filename of the preset including the filesystem path
inputImagethe image to which the loaded preset will be applied
Returns
true if the deserilization was successful and false otherwise

◆ PropertyFromXMLElement()

static bool mitk::MultiLabelIOHelper::PropertyFromXMLElement ( std::string &  key,
itk::SmartPointer< mitk::BaseProperty > &  prop,
const tinyxml2::XMLElement *  elem 
)
static

Since a mitk::Label is basically a mitk::PropertyList this function converts an XML element into a property.

Parameters
keythe property's key
propthe mitk::BaseProperty that will be created
elemthe XML elem from which the property will be created
Returns
true if the conversion was successful and false otherwise

◆ PropertyToXMLElement()

static tinyxml2::XMLElement* mitk::MultiLabelIOHelper::PropertyToXMLElement ( tinyxml2::XMLDocument &  doc,
const std::string &  key,
const BaseProperty property 
)
static

Since a mitk::Label is basically a mitk::PropertyList this function converts the label's properties into XML.

Parameters
doc
keythe property's key which will be used in the XML element
propertythe mitk::BaseProperty that should be converted
Returns
the created XML element

◆ SaveLabelSetImagePreset()

static bool mitk::MultiLabelIOHelper::SaveLabelSetImagePreset ( const std::string &  presetFilename,
const mitk::LabelSetImage inputImage 
)
static

Saves the mitk::LabelSet configuration of inputImage to presetFilename. The preset is stored as "*.lsetp".

Parameters
presetFilenamethe filename including the filesystem path
inputImagethe input image from which the preset should be generated
Returns
true if the serialization was successful and false otherwise

◆ SerializeLabelToJSON()

static nlohmann::json mitk::MultiLabelIOHelper::SerializeLabelToJSON ( const Label label)
static

◆ SerializeMultLabelGroupsToJSON()

static nlohmann::json mitk::MultiLabelIOHelper::SerializeMultLabelGroupsToJSON ( const mitk::LabelSetImage inputImage)
static

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