Medical Imaging Interaction Toolkit  2026.06.00
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 
42  {
43  public:
46  using Pointer = std::shared_ptr<IOVolumeSplitReason>;
48  using ConstPointer = std::shared_ptr<const IOVolumeSplitReason>;
49 
53  enum class ReasonType
54  {
55  Unknown = 0,
56  ValueSplitDifference,
57  ValueSortDistance,
58  ImagePostionMissing,
59  OverlappingSlices,
60  GantryTiltDifference,
61  SliceDistanceInconsistency,
62  MissingSlices
63  };
64 
72  void AddReason(ReasonType type, const std::string& detail = "");
73 
79 
84  bool HasReasons() const;
85 
91  bool HasReason(ReasonType type) const;
92 
99  std::string GetReasonDetails(ReasonType type) const;
100 
112  Pointer ExtendReason(ConstPointer otherReason) const;
113 
121 
127  static Pointer FromJSON(const nlohmann::json& j);
128 
134  static std::string TypeToString(ReasonType reasonType);
135 
141  static IOVolumeSplitReason::ReasonType StringToType(const std::string& reasonStr);
142 
147  Pointer Clone() const;
148 
153  static Pointer New();
154 
155  protected:
157  using ReasonMapType = std::map<ReasonType, std::string>;
159  };
160 
161  template<typename BasicJsonType>
162  inline void to_json(BasicJsonType& j, const IOVolumeSplitReason::ReasonType& e)
163  {
164  static_assert(std::is_enum<IOVolumeSplitReason::ReasonType>::value,
165  "IOVolumeSplitReason::ReasonType"
166  " must be an enum!");
168  }
169 
170  template<typename BasicJsonType>
171  inline void from_json(const BasicJsonType& j, IOVolumeSplitReason::ReasonType& e)
172  {
173  static_assert(std::is_enum<IOVolumeSplitReason::ReasonType>::value,
174  "IOVolumeSplitReason::ReasonType"
175  " must be an enum!");
176  e = IOVolumeSplitReason::StringToType(j.template get<std::string>());
177  }
178 
179 
186 
193 
200 
201 }
202 
203 #endif
#define MITKCORE_EXPORT
Records the reasons why a DICOM volume was split during loading.
std::shared_ptr< IOVolumeSplitReason > Pointer
Shared pointer type.
Pointer ExtendReason(ConstPointer otherReason) const
Clone this instance and extend it with reasons from another instance.
Pointer Clone() const
Create a deep copy of this instance.
std::string GetReasonDetails(ReasonType type) const
Get the detail string for a specific reason type.
static std::string TypeToString(ReasonType reasonType)
Convert a ReasonType to its string representation.
bool HasReason(ReasonType type) const
Check whether a specific reason type has been recorded.
static nlohmann::json ToJSON(ConstPointer reason)
Serialize a split reason to JSON.
static IOVolumeSplitReason::ReasonType StringToType(const std::string &reasonStr)
Convert a string representation to a ReasonType.
ReasonType
Enumeration of possible reasons for splitting a DICOM volume.
static Pointer New()
Create a new, empty IOVolumeSplitReason instance.
std::map< ReasonType, std::string > ReasonMapType
Map storing reason types and their associated detail strings.
void RemoveReason(ReasonType type)
Remove a previously added split reason.
static Pointer FromJSON(const nlohmann::json &j)
Deserialize a split reason from JSON.
void AddReason(ReasonType type, const std::string &detail="")
Add a split reason with optional detail text.
bool HasReasons() const
Check whether any split reasons have been recorded.
std::shared_ptr< const IOVolumeSplitReason > ConstPointer
Shared pointer to const type.
nlohmann::json json
Find image slices visible on a given plane.
void from_json(const nlohmann::json &, GenericLookupTable< T > &)
Deserialize a GenericLookupTable from JSON.
void to_json(nlohmann::json &j, const GenericLookupTable< T > &t)
Serialize a GenericLookupTable to JSON.