13 #ifndef mitkMultiLabelIOHelper_h
14 #define mitkMultiLabelIOHelper_h
20 #include <itkSmartPointer.h>
21 #include <nlohmann/json.hpp>
33 class MetaDataDictionary;
109 static int GetIntByKey(
const itk::MetaDataDictionary& dic,
const std::string& key);
112 static std::string
GetStringByKey(
const itk::MetaDataDictionary& dic,
const std::string& key);
178 template<
typename TValueType>
181 if (labelJson.find(key) != labelJson.end())
185 value = labelJson[key].get<TValueType>();
190 MITK_ERROR <<
"Unable to read label information from json. Value has wrong type. Failed key: " << key <<
"; invalid value: " << labelJson[key].dump();
#define MITKMULTILABEL_EXPORT
Abstract base class for properties.
A data structure describing a label.
The MultiLabelIOHelper is a static helper class that supports serialization of mitk::MultiLabelSegmen...
static void RemoveMetaPropertiesFromLabel(Label *label)
Remove all meta properties from a label instance. Meta properties (indicated by a preceding "_" in th...
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)
static bool LoadMultiLabelSegmentationPreset(const std::string &presetFilename, mitk::MultiLabelSegmentation *inputSegmentation)
Loads an existing preset for a mitk::MultiLabelSegmentation from presetFilename and applies it to inp...
static int GetIntByKey(const itk::MetaDataDictionary &dic, const std::string &key)
static tinyxml2::XMLElement * GetLabelAsXMLElement(tinyxml2::XMLDocument &doc, const Label *label)
Creates an XML element from a mitk::Label.
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 i...
std::function< mitk::MultiLabelSegmentation::LabelValueType(const mitk::MultiLabelSegmentation *, mitk::MultiLabelSegmentation::LabelValueType)> LabelFileValueCallback
static bool SaveMultiLabelSegmentationPreset(const std::string &presetFilename, const mitk::MultiLabelSegmentation *inputSegmentation)
Saves the mitk::LabelSet configuration of inputSegmentation to presetFilename. The preset is stored a...
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 pr...
static std::vector< LabelGroupMetaData > DeserializeMultiLabelGroupsFromJSON(const nlohmann::json &listOfLabelGroups)
Deserialize meta data of multilabel groups from JSON format (v2)
static nlohmann::json SerializeLabelPropertyToJSON(const BaseProperty *property)
Serialize the property of a label to JSON.
static mitk::Label::Pointer DeserializeLabelFromJSON(const nlohmann::json &labelJson)
Deserialize a single label from JSON.
static itk::SmartPointer< mitk::Label > LoadLabelFromXMLDocument(const tinyxml2::XMLElement *labelElem)
Creates a mitk::Label from an XML element.
static nlohmann::json SerializeLabelToJSON(const Label *label)
Serialize a single label to JSON.
static std::string GetStringByKey(const itk::MetaDataDictionary &dic, const std::string &key)
static bool GetValueFromJson(const nlohmann::json &labelJson, const std::string &key, TValueType &value)
static LabelVector CloneLabelsWithoutMetaProperties(const LabelVector &labels)
Remove all meta properties from all label clones of the passed vector. Meta properties (indicated by ...
std::function< std::string(const mitk::MultiLabelSegmentation *, mitk::MultiLabelSegmentation::LabelValueType)> LabelFileNameCallback
std::function< std::string(const mitk::MultiLabelSegmentation *, mitk::MultiLabelSegmentation::GroupIndexType)> GroupFileNameCallback
MultiLabelSegmentation class for handling labels and layers in a segmentation session.
std::size_t GroupIndexType
mitk::Label::PixelType LabelValueType
Key-value list holding instances of BaseProperty.
Find image slices visible on a given plane.
constexpr const char *const PROPERTY_NAME_TIMEGEOMETRY_TYPE
constexpr const char *const PROPERTY_KEY_TIMEGEOMETRY_TYPE
std::vector< Label::Pointer > LabelVector
constexpr const char *const PROPERTY_KEY_TIMEGEOMETRY_TIMEPOINTS
constexpr const char *const PROPERTY_NAME_TIMEGEOMETRY_TIMEPOINTS
constexpr const char *const PROPERTY_KEY_UID