Medical Imaging Interaction Toolkit
2024.12.99-2f135637
Medical Imaging Interaction Toolkit
|
The MultiLabelIOHelper is a static helper class that supports serialization of mitk::MultiLabelSegmentation. More...
#include <mitkMultiLabelIOHelper.h>
Classes | |
struct | LabelGroupMetaData |
Structure to hold label group metadata including labels and group properties. More... | |
Public Types | |
using | GroupFileNameCallback = std::function< std::string(const mitk::MultiLabelSegmentation *, mitk::MultiLabelSegmentation::GroupIndexType)> |
using | LabelFileNameCallback = std::function< std::string(const mitk::MultiLabelSegmentation *, mitk::MultiLabelSegmentation::LabelValueType)> |
using | LabelFileValueCallback = std::function< mitk::MultiLabelSegmentation::LabelValueType(const mitk::MultiLabelSegmentation *, mitk::MultiLabelSegmentation::LabelValueType)> |
Static Public Member Functions | |
static bool | SaveLabelSetImagePreset (const std::string &presetFilename, const mitk::MultiLabelSegmentation *inputImage) |
Saves the mitk::LabelSet configuration of inputSegmentation to presetFilename. The preset is stored as "*.lsetp". More... | |
static bool | LoadLabelSetImagePreset (const std::string &presetFilename, mitk::MultiLabelSegmentation *inputImage) |
Loads an existing preset for a mitk::MultiLabelSegmentation from presetFilename and applies it to inputSegmentation. More... | |
static itk::SmartPointer< mitk::Label > | LoadLabelFromXMLDocument (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::MultiLabelSegmentation *inputSegmentation, GroupFileNameCallback groupFileNameCallback=nullptr, LabelFileNameCallback labelFileNameCallback=nullptr, LabelFileValueCallback labelFileValueCallback=nullptr) |
Serialize meta data all groups of the multilabel segmentation to JSON format (v2) More... | |
static std::vector< LabelGroupMetaData > | DeserializeMultiLabelGroupsFromJSON (const nlohmann::json &listOfLabelGroups) |
Deserialize meta data of multilabel groups from JSON format (v2) More... | |
static nlohmann::json | SerializeLabelToJSON (const Label *label) |
Serialize a single label to JSON. More... | |
static mitk::Label::Pointer | DeserializeLabelFromJSON (const nlohmann::json &labelJson) |
Deserialize a single label from JSON. More... | |
static nlohmann::json | SerializeLabelPropertyToJSON (const BaseProperty *property) |
Serialize the property of a label to JSON. More... | |
template<typename TValueType > | |
static bool | GetValueFromJson (const nlohmann::json &labelJson, const std::string &key, TValueType &value) |
The MultiLabelIOHelper is a static helper class that supports serialization of mitk::MultiLabelSegmentation.
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.
using mitk::MultiLabelIOHelper::GroupFileNameCallback = std::function<std::string(const mitk::MultiLabelSegmentation*, mitk::MultiLabelSegmentation::GroupIndexType)> |
Definition at line 129 of file mitkMultiLabelIOHelper.h.
using mitk::MultiLabelIOHelper::LabelFileNameCallback = std::function<std::string(const mitk::MultiLabelSegmentation*, mitk::MultiLabelSegmentation::LabelValueType)> |
Definition at line 130 of file mitkMultiLabelIOHelper.h.
using mitk::MultiLabelIOHelper::LabelFileValueCallback = std::function<mitk::MultiLabelSegmentation::LabelValueType(const mitk::MultiLabelSegmentation*, mitk::MultiLabelSegmentation::LabelValueType)> |
Definition at line 131 of file mitkMultiLabelIOHelper.h.
|
static |
Deserialize a single label from JSON.
labelJson | JSON representation of the label |
|
static |
Deserialize meta data of multilabel groups from JSON format (v2)
listOfLabelGroups | JSON representation of label groups |
|
static |
Helper that extracts the value of a key in a meta dictionary as int. If the key does not exist 0 is returned.
|
static |
Creates an XML element from a mitk::Label.
doc | |
label | the mitk::Label from which the xml element will be created |
|
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.
|
inlinestatic |
Definition at line 178 of file mitkMultiLabelIOHelper.h.
References MITK_ERROR.
|
static |
Creates a mitk::Label from an XML element.
labelElem | the xml element from which a mitk::Label will be created |
|
static |
Loads an existing preset for a mitk::MultiLabelSegmentation from presetFilename and applies it to inputSegmentation.
presetFilename | the filename of the preset including the filesystem path |
inputSegmentation | the image to which the loaded preset will be applied |
|
static |
Since a mitk::Label is basically a mitk::PropertyList this function converts an XML element into a property.
key | the property's key |
prop | the mitk::BaseProperty that will be created |
elem | the XML elem from which the property will be created |
|
static |
Since a mitk::Label is basically a mitk::PropertyList this function converts the label's properties into XML.
doc | |
key | the property's key which will be used in the XML element |
property | the mitk::BaseProperty that should be converted |
|
static |
Saves the mitk::LabelSet configuration of inputSegmentation to presetFilename. The preset is stored as "*.lsetp".
presetFilename | the filename including the filesystem path |
inputSegmentation | the input image from which the preset should be generated |
|
static |
Serialize the property of a label to JSON.
property | Pointer to the property that should be serialized |
|
static |
Serialize a single label to JSON.
label | the label to serialize |
|
static |
Serialize meta data all groups of the multilabel segmentation to JSON format (v2)
inputSegmentation | the multilabel segmentation to serialize |
groupFileNameCallback | Optional call back function. If provided the property "file" on group level based on the returned string will be set. |
labelFileNameCallback | Optional call back function. If provided the property "file" per label based on the returned string will be set. |
labelFileValueCallback | Optional call back function. If provided the property "file_value" per label will be set according to the returned value. |