Medical Imaging Interaction Toolkit  2025.12.02
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 = "");
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 
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 
102 
103 }
104 
105 #endif
#define MITKCORE_EXPORT
std::shared_ptr< IOVolumeSplitReason > Pointer
Pointer ExtendReason(ConstPointer otherReason) const
std::string GetReasonDetails(ReasonType type) const
static std::string TypeToString(ReasonType reasonType)
bool HasReason(ReasonType type) const
static IOVolumeSplitReason::ReasonType StringToType(const std::string &reasonStr)
static Pointer New()
std::map< ReasonType, std::string > ReasonMapType
void RemoveReason(ReasonType type)
static Pointer FromJSON(const nlohmann::json &j)
void AddReason(ReasonType type, const std::string &detail="")
static nlohmann::json ToJSON(ConstPointer)
std::shared_ptr< const IOVolumeSplitReason > ConstPointer
nlohmann::json json
Find image slices visible on a given plane.
void to_json(nlohmann::json &j, const GenericLookupTable< T > &t)
void from_json(const nlohmann::json &, GenericLookupTable< T > &)