Medical Imaging Interaction Toolkit  2024.06.99-f6a54466
Medical Imaging Interaction Toolkit
mitkIOVolumeSplitReason.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 mitkIOVolumeSplitReason_h
14 #define mitkIOVolumeSplitReason_h
15 
16 #include <memory>
17 #include <nlohmann/json.hpp>
18 #include <mitkCommon.h>
19 
20 #include "MitkCoreExports.h"
21 
22 namespace mitk
23 {
24 
26  {
27  public:
29  using Pointer = std::shared_ptr<IOVolumeSplitReason>;
30  using ConstPointer = std::shared_ptr<const IOVolumeSplitReason>;
31 
32  enum class ReasonType
33  {
34  Unknown = 0,
35  ValueSplitDifference, //*< split due to different values in splitting relevant dicom tags
36  ValueSortDistance, //*< split due value distance of sort criterion too large for relevant dicom tag(s)
37  ImagePostionMissing, //*< split because image position tag was missing in one of the compared files
38  OverlappingSlices, //*< split because at least two input files are overlapping in world coordinate space
39  GantryTiltDifference, //*< split because the gantry tilts of at least two input files were different
40  SliceDistanceInconsistency, //*< split because the distance between slices were inconsistent.
41  // This can either be evoked by volumes with heterogeneous z spacing or by missing slices.
42  // Details for this reason will contain the detected slice distance inconsistency
43  MissingSlices //*< Indicates that is a split was done due to missing slices. (It is a sub class of SliceDistanceInconsistency
44  // as all SliceDistanceInconsistency with a positive distance inconsistency greater then one times the slice
45  // thickness are deemed also missing slices as split reason. This sub class was introduced to make it easier
46  // for parsing applications to react on this important split reason.
47  // Details for this reason will contain the assumed/detected number of missing slices
48  };
49 
50  void AddReason(ReasonType type, const std::string& detail = "");
51  void RemoveReason(ReasonType type);
52 
53  bool HasReasons() const;
54  bool HasReason(ReasonType type) const;
55  std::string GetReasonDetails(ReasonType type) const;
56 
63  Pointer ExtendReason(ConstPointer otherReason) const;
64 
65  static nlohmann::json ToJSON(ConstPointer);
66  static Pointer FromJSON(const nlohmann::json& j);
67 
68  static std::string TypeToString(ReasonType reasonType);
69  static IOVolumeSplitReason::ReasonType StringToType(const std::string& reasonStr);
70 
71  Pointer Clone() const;
72  static Pointer New();
73 
74  protected:
75  using ReasonMapType = std::map<ReasonType, std::string>;
77  };
78 
79  template<typename BasicJsonType>
80  inline void to_json(BasicJsonType& j, const IOVolumeSplitReason::ReasonType& e)
81  {
82  static_assert(std::is_enum<IOVolumeSplitReason::ReasonType>::value,
83  "IOVolumeSplitReason::ReasonType"
84  " must be an enum!");
86  }
87 
88  template<typename BasicJsonType>
89  inline void from_json(const BasicJsonType& j, IOVolumeSplitReason::ReasonType& e)
90  {
91  static_assert(std::is_enum<IOVolumeSplitReason::ReasonType>::value,
92  "IOVolumeSplitReason::ReasonType"
93  " must be an enum!");
94  e = IOVolumeSplitReason::StringToType(j.template get<std::string>());
95  }
96 
97 
100 
101  MITKCORE_EXPORT void from_json(const nlohmann::json& j, IOVolumeSplitReason& reason);
102 
103 }
104 
105 #endif
mitk::IOVolumeSplitReason::ReasonType
ReasonType
Definition: mitkIOVolumeSplitReason.h:32
mitk::IOVolumeSplitReason::ConstPointer
std::shared_ptr< const IOVolumeSplitReason > ConstPointer
Definition: mitkIOVolumeSplitReason.h:30
mitk::to_json
void to_json(nlohmann::json &j, const GenericLookupTable< T > &t)
Definition: mitkGenericLookupTable.h:98
mitk::FromJSON
MITKCORE_EXPORT void FromJSON(const nlohmann::json &j, AffineTransform3D::Pointer transform)
Read transform from JSON array (16 elements, resp. 4x4 matrix).
mitk::from_json
void from_json(const nlohmann::json &, GenericLookupTable< T > &)
Definition: mitkGenericLookupTable.h:104
mitk::IOVolumeSplitReason::Pointer
std::shared_ptr< IOVolumeSplitReason > Pointer
Definition: mitkIOVolumeSplitReason.h:29
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::IOVolumeSplitReason::m_ReasonMap
ReasonMapType m_ReasonMap
Definition: mitkIOVolumeSplitReason.h:76
mitk::IOVolumeSplitReason::ReasonMapType
std::map< ReasonType, std::string > ReasonMapType
Definition: mitkIOVolumeSplitReason.h:75
json
nlohmann::json json
Definition: mitkModelTestFixture.h:29
MitkCoreExports.h
mitk::IOVolumeSplitReason::TypeToString
static std::string TypeToString(ReasonType reasonType)
mitkCommon.h
mitk::IOVolumeSplitReason
Definition: mitkIOVolumeSplitReason.h:25
mitk::IOVolumeSplitReason::StringToType
static IOVolumeSplitReason::ReasonType StringToType(const std::string &reasonStr)
mitk::ToJSON
MITKCORE_EXPORT void ToJSON(nlohmann::json &j, AffineTransform3D::ConstPointer transform)
Write transform (4x4 matrix) as JSON array with 16 elements.
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15