Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkTemporoSpatialStringProperty.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 mitkTemporoSpatialStringProperty_h
14 #define mitkTemporoSpatialStringProperty_h
15 
16 #include <itkConfigure.h>
17 
18 #include <mitkBaseProperty.h>
19 #include <MitkCoreExports.h>
20 
21 #include <mitkTimeGeometry.h>
22 
23 #include <string>
24 
25 namespace mitk
26 {
39  {
40  public:
42  typedef ::itk::IndexValueType IndexValueType;
43 
45  typedef std::string ValueType;
46 
48 
49  itkFactorylessNewMacro(Self);
50 
51  itkCloneMacro(Self);
54 
61 
73  ValueType GetValue(const TimeStepType &timeStep,
74  const IndexValueType &zSlice,
75  bool allowCloseTime = false,
76  bool allowCloseSlice = false) const;
77 
85  ValueType GetValueBySlice(const IndexValueType &zSlice, bool allowClose = false) const;
86 
94  ValueType GetValueByTimeStep(const TimeStepType &timeStep, bool allowClose = false) const;
95 
100  bool HasValue() const;
101 
111  bool HasValue(const TimeStepType &timeStep,
112  const IndexValueType &zSlice,
113  bool allowCloseTime = false,
114  bool allowCloseSlice = false) const;
115 
123  bool HasValueBySlice(const IndexValueType &zSlice, bool allowClose = false) const;
124 
132  bool HasValueByTimeStep(const TimeStepType &timeStep, bool allowClose = false) const;
133 
140  std::vector<IndexValueType> GetAvailableSlices(const TimeStepType& timeStep) const;
141 
148  std::vector<TimeStepType> GetAvailableTimeSteps(const IndexValueType& slice) const;
149 
154  std::vector<TimeStepType> GetAvailableTimeSteps() const;
155 
163  std::vector<IndexValueType> GetAvailableSlices() const;
164 
174  void SetValue(const TimeStepType &timeStep, const IndexValueType &zSlice, const ValueType &value);
175 
184  void SetValue(const ValueType &value);
185 
190  std::string GetValueAsString() const override;
191 
201  bool IsUniform() const;
202 
212  bool ToJSON(nlohmann::json& j) const override;
213 
223  bool FromJSON(const nlohmann::json& j) override;
224 
225  using BaseProperty::operator=;
226 
227  protected:
228  typedef std::map<IndexValueType, std::string> SliceMapType;
229  typedef std::map<TimeStepType, SliceMapType> TimeMapType;
230 
232 
233  TemporoSpatialStringProperty(const char *string = nullptr);
234  TemporoSpatialStringProperty(const std::string &s);
235 
237 
238  std::pair<bool, ValueType> CheckValue(const TimeStepType &timeStep,
239  const IndexValueType &zSlice,
240  bool allowCloseTime = false,
241  bool allowCloseSlice = false) const;
242 
244 
245  private:
246  // purposely not implemented
248 
249  bool IsEqual(const BaseProperty &property) const override;
250  bool Assign(const BaseProperty &property) override;
251  };
252 
253  namespace PropertyPersistenceSerialization
254  {
257  }
258 
259  namespace PropertyPersistenceDeserialization
260  {
262  MITKCORE_EXPORT mitk::BaseProperty::Pointer deserializeJSONToTemporoSpatialStringProperty(const std::string &value);
263  }
264 
273 
274 
275 } // namespace mitk
276 
277 #endif
#define MITKCORE_EXPORT
Abstract base class for properties.
Property for storing string values resolved by time step and slice index.
bool HasValue() const
Check whether any values are stored.
TemporoSpatialStringProperty(const std::string &s)
TemporoSpatialStringProperty(const TemporoSpatialStringProperty &)
std::vector< IndexValueType > GetAvailableSlices(const TimeStepType &timeStep) const
Get all slice indices stored for the specified time step.
::itk::IndexValueType IndexValueType
Index type for slice indices.
std::string GetValueAsString() const override
Return the value at the first time step and slice as a string.
void SetValue(const ValueType &value)
Set a uniform value (stored at time step 0, slice 0).
std::map< IndexValueType, std::string > SliceMapType
std::vector< TimeStepType > GetAvailableTimeSteps(const IndexValueType &slice) const
Get all time steps that contain a value for the specified slice.
void SetValue(const TimeStepType &timeStep, const IndexValueType &zSlice, const ValueType &value)
Set a value for a specific time step and slice.
bool HasValueByTimeStep(const TimeStepType &timeStep, bool allowClose=false) const
Check whether a value exists for the given time step.
std::string ValueType
The type of the string value stored per time/slice entry.
ValueType GetValueBySlice(const IndexValueType &zSlice, bool allowClose=false) const
Get the value for a given slice (time step defaults to 0).
mitkClassMacro(TemporoSpatialStringProperty, BaseProperty)
mitkNewMacro1Param(TemporoSpatialStringProperty, const char *)
bool HasValue(const TimeStepType &timeStep, const IndexValueType &zSlice, bool allowCloseTime=false, bool allowCloseSlice=false) const
Check whether a value exists for the given time step and slice.
ValueType GetValue(const TimeStepType &timeStep, const IndexValueType &zSlice, bool allowCloseTime=false, bool allowCloseSlice=false) const
Get the value for a specific time step and slice.
ValueType GetValue() const
Get the value at the first time step and first slice.
bool IsUniform() const
Check whether all stored values are identical.
std::vector< TimeStepType > GetAvailableTimeSteps() const
Get all time steps stored in the property.
std::vector< IndexValueType > GetAvailableSlices() const
Get all unique slice indices across all time steps.
bool ToJSON(nlohmann::json &j) const override
Serialize the property to JSON.
bool FromJSON(const nlohmann::json &j) override
Deserialize the property from JSON.
mitkNewMacro1Param(TemporoSpatialStringProperty, const std::string &)
std::pair< bool, ValueType > CheckValue(const TimeStepType &timeStep, const IndexValueType &zSlice, bool allowCloseTime=false, bool allowCloseSlice=false) const
TemporoSpatialStringProperty(const char *string=nullptr)
bool HasValueBySlice(const IndexValueType &zSlice, bool allowClose=false) const
Check whether a value exists for the given slice.
ValueType GetValueByTimeStep(const TimeStepType &timeStep, bool allowClose=false) const
Get the value for a given time step (slice defaults to 0).
mitkCloneMacro(TemporoSpatialStringProperty)
std::map< TimeStepType, SliceMapType > TimeMapType
nlohmann::json json
MITKCORE_EXPORT mitk::BaseProperty::Pointer deserializeJSONToTemporoSpatialStringProperty(const std::string &value)
MITKCORE_EXPORT std::string serializeTemporoSpatialStringPropertyToJSON(const mitk::BaseProperty *prop)
Find image slices visible on a given plane.
std::size_t TimeStepType
Type for time step indices (non-negative integers starting from 0).
TemporoSpatialStringProperty::Pointer MITKCORE_EXPORT ExtractTimeStepFromTemporoSpatialStringProperty(const TemporoSpatialStringProperty *tsProperty, TimeStepType ts)