Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
mitkMultiLabelIOHelper.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkMultiLabelIOHelper_h
14 #define mitkMultiLabelIOHelper_h
15 
16 #include <mitkLabelSet.h>
17 
18 #include <itkSmartPointer.h>
19 #include <nlohmann/json.hpp>
20 
21 #include <MitkMultilabelExports.h>
22 
23 namespace tinyxml2
24 {
25  class XMLDocument;
26  class XMLElement;
27 }
28 
29 namespace itk
30 {
31  class MetaDataDictionary;
32 }
33 
34 namespace mitk
35 {
36  class LabelSetImage;
37 
38  const constexpr char* const PROPERTY_NAME_TIMEGEOMETRY_TYPE = "org.mitk.timegeometry.type";
39  const constexpr char* const PROPERTY_NAME_TIMEGEOMETRY_TIMEPOINTS = "org.mitk.timegeometry.timepoints";
40  const constexpr char* const PROPERTY_KEY_TIMEGEOMETRY_TYPE = "org_mitk_timegeometry_type";
41  const constexpr char* const PROPERTY_KEY_TIMEGEOMETRY_TIMEPOINTS = "org_mitk_timegeometry_timepoints";
42  const constexpr char* const PROPERTY_KEY_UID = "org_mitk_uid";
43 
51  {
52  public:
60  static bool SaveLabelSetImagePreset(const std::string &presetFilename,
61  const mitk::LabelSetImage *inputImage);
62 
69  static bool LoadLabelSetImagePreset(const std::string &presetFilename,
70  mitk::LabelSetImage *inputImage);
71 
77  static itk::SmartPointer<mitk::Label> LoadLabelFromXMLDocument(const tinyxml2::XMLElement *labelElem);
78 
85  static tinyxml2::XMLElement *GetLabelAsXMLElement(tinyxml2::XMLDocument &doc, Label *label);
86 
95  static tinyxml2::XMLElement *PropertyToXMLElement(tinyxml2::XMLDocument& doc, const std::string &key, const BaseProperty *property);
96 
104  static bool PropertyFromXMLElement(std::string &key, itk::SmartPointer<mitk::BaseProperty> &prop, const tinyxml2::XMLElement *elem);
105 
108  static int GetIntByKey(const itk::MetaDataDictionary& dic, const std::string& key);
111  static std::string GetStringByKey(const itk::MetaDataDictionary& dic, const std::string& key);
112 
113 
114  static nlohmann::json SerializeMultLabelGroupsToJSON(const mitk::LabelSetImage* inputImage);
115 
116  static std::vector<LabelSet::Pointer> DeserializeMultiLabelGroupsFromJSON(const nlohmann::json& listOfLabelSets);
117 
118  static nlohmann::json SerializeLabelToJSON(const Label* label);
119 
120  static mitk::Label::Pointer DeserializeLabelFromJSON(const nlohmann::json& labelJson);
121 
122  private:
124  };
125 }
126 
127 #endif
MITKMULTILABEL_EXPORT
#define MITKMULTILABEL_EXPORT
Definition: MitkMultilabelExports.h:15
mitk::BaseProperty
Abstract base class for properties.
Definition: mitkBaseProperty.h:35
mitk::MultiLabelIOHelper
The MultiLabelIOHelper is a static helper class that supports serialization of mitk::LabelSetImage.
Definition: mitkMultiLabelIOHelper.h:50
mitk::PROPERTY_KEY_TIMEGEOMETRY_TIMEPOINTS
const constexpr char *const PROPERTY_KEY_TIMEGEOMETRY_TIMEPOINTS
Definition: mitkMultiLabelIOHelper.h:41
mitkLabelSet.h
itk::SmartPointer
Definition: mitkIFileReader.h:30
mitk::PROPERTY_KEY_TIMEGEOMETRY_TYPE
const constexpr char *const PROPERTY_KEY_TIMEGEOMETRY_TYPE
Definition: mitkMultiLabelIOHelper.h:40
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::Label
A data structure describing a label.
Definition: mitkLabel.h:28
mitk::PROPERTY_KEY_UID
const constexpr char *const PROPERTY_KEY_UID
Definition: mitkMultiLabelIOHelper.h:42
mitk::PROPERTY_NAME_TIMEGEOMETRY_TIMEPOINTS
const constexpr char *const PROPERTY_NAME_TIMEGEOMETRY_TIMEPOINTS
Definition: mitkMultiLabelIOHelper.h:39
itk
SET FUNCTIONS.
Definition: itkIntelligentBinaryClosingFilter.h:30
tinyxml2
Definition: mitkXMLSerializable.h:20
mitk::PROPERTY_NAME_TIMEGEOMETRY_TYPE
const constexpr char *const PROPERTY_NAME_TIMEGEOMETRY_TYPE
Definition: mitkMultiLabelIOHelper.h:38
mitk::LabelSetImage
LabelSetImage class for handling labels and layers in a segmentation session.
Definition: mitkLabelSetImage.h:29
MitkMultilabelExports.h