|
Medical Imaging Interaction Toolkit
2025.12.02
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 | SaveMultiLabelSegmentationPreset (const std::string &presetFilename, const mitk::MultiLabelSegmentation *inputSegmentation) |
| Saves the mitk::LabelSet configuration of inputSegmentation to presetFilename. The preset is stored as "*.multilabel.json". More... | |
| static bool | LoadMultiLabelSegmentationPreset (const std::string &presetFilename, mitk::MultiLabelSegmentation *inputSegmentation) |
| Loads an existing preset for a mitk::MultiLabelSegmentation from presetFilename and applies it to inputSegmentation This functions supports the new format (.multilabel.json) and the legacy format (*.lpset) 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) |
| static void | RemoveMetaPropertiesFromLabel (Label *label) |
| Remove all meta properties from a label instance. Meta properties (indicated by a preceding "_" in the property name) are used to steer code logic e.g. in the case of label loading or suggestion handling. They are not to be used in concrete label instances. This method removes all meta properties form a label. More... | |
| static LabelVector | CloneLabelsWithoutMetaProperties (const LabelVector &labels) |
| Remove all meta properties from all label clones of the passed vector. Meta properties (indicated by a preceding "_" in the property name) are used to steer code logic e.g. in the case of label loading or suggestion handling. They are not to be used in concrete label instances. This method clones all passed labels and removes all meta properties form the clones. More... | |
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 130 of file mitkMultiLabelIOHelper.h.
| using mitk::MultiLabelIOHelper::LabelFileNameCallback = std::function<std::string(const mitk::MultiLabelSegmentation*, mitk::MultiLabelSegmentation::LabelValueType)> |
Definition at line 131 of file mitkMultiLabelIOHelper.h.
| using mitk::MultiLabelIOHelper::LabelFileValueCallback = std::function<mitk::MultiLabelSegmentation::LabelValueType(const mitk::MultiLabelSegmentation*, mitk::MultiLabelSegmentation::LabelValueType)> |
Definition at line 132 of file mitkMultiLabelIOHelper.h.
|
static |
Remove all meta properties from all label clones of the passed vector. Meta properties (indicated by a preceding "_" in the property name) are used to steer code logic e.g. in the case of label loading or suggestion handling. They are not to be used in concrete label instances. This method clones all passed labels and removes all meta properties form the clones.
| labels | Vector with all labels that should be cloned and cleaned. |
|
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 179 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 This functions supports the new format (.multilabel.json) and the legacy format (*.lpset)
| presetFilename | the filename of the preset including the file system 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 |
Remove all meta properties from a label instance. Meta properties (indicated by a preceding "_" in the property name) are used to steer code logic e.g. in the case of label loading or suggestion handling. They are not to be used in concrete label instances. This method removes all meta properties form a label.
| label | Pointer to the label instance that should be stripped of its labels. |
|
static |
Saves the mitk::LabelSet configuration of inputSegmentation to presetFilename. The preset is stored as "*.multilabel.json".
| presetFilename | the filename including the file system 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. |