Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkDICOMImageBlockDescriptor.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 mitkDICOMImageBlockDescriptor_h
14 #define mitkDICOMImageBlockDescriptor_h
15 
16 #include <mitkDICOMEnums.h>
18 #include <mitkDICOMTag.h>
19 #include <mitkDICOMTagCache.h>
21 
22 #include <mitkImage.h>
23 #include <mitkProperties.h>
24 #include <mitkWeakPointer.h>
25 #include <mitkIPropertyProvider.h>
26 
28 
29 #include <unordered_map>
30 
31 namespace mitk
32 {
33 
44  {
45  unsigned int TimePoint;
46  unsigned int SliceInTimePoint;
47  std::string Value;
48  };
49 
56  class DICOMCachedValueLookupTable : public GenericLookupTable< DICOMCachedValueInfo >
57  {
58  public:
61  const char *GetNameOfClass() const override
62  {
63  return "DICOMCachedValueLookupTable";
64  }
65 
67  Superclass& operator=(const Superclass& other) override { return Superclass::operator=(other); }
69  };
70 
94  {
95  public:
96 
99 
102 
108 
110  void SetImageFrameList(const DICOMImageFrameList& framelist);
113 
115  void SetMitkImage(Image::Pointer image);
117  Image::Pointer GetMitkImage() const;
118 
123 
125  void SetProperty(const std::string& key, BaseProperty* value);
127  BaseProperty* GetProperty(const std::string& key) const;
128 
130  std::string GetPropertyAsString(const std::string&) const;
131 
138 
140  void SetFlag(const std::string& key, bool value);
142  bool GetFlag(const std::string& key, bool defaultValue) const;
143 
145  void SetIntProperty(const std::string& key, int value);
147  int GetIntProperty(const std::string& key, int defaultValue) const;
148 
149  BaseProperty::ConstPointer GetConstProperty(const std::string &propertyKey,
150  const std::string &contextName = "",
151  bool fallBackOnDefaultContext = true) const override;
152 
153  std::vector<std::string> GetPropertyKeys(const std::string &contextName = "",
154  bool includeDefaultContext = false) const override;
155 
156  std::vector<std::string> GetPropertyContextNames() const override;
157 
158  private:
159 
160  // For future implementation: load slice-by-slice, mark this using these methods
161  void SetSliceIsLoaded(unsigned int index, bool isLoaded);
162  // For future implementation: load slice-by-slice, mark this using these methods
163  bool IsSliceLoaded(unsigned int index) const;
164  // For future implementation: load slice-by-slice, mark this using these methods
165  bool AllSlicesAreLoaded() const;
166 
167  public:
168 
171 
173  void GetDesiredMITKImagePixelSpacing(ScalarType& spacingXinMM, ScalarType& spacingYinMM) const;
174 
179 
181  void SetSOPClassUID(const std::string& uid);
183  std::string GetSOPClassUID() const;
185  std::string GetSOPClassUIDAsName() const;
186 
191  int GetNumberOfTimeSteps() const;
192 
198 
203  void SetTagCache(DICOMTagCache* privateCache);
204 
208  typedef std::map<DICOMTagPath, std::string> AdditionalTagsMapType;
221 
222  typedef std::function<mitk::BaseProperty::Pointer(const DICOMCachedValueLookupTable&) > TagLookupTableToPropertyFunctor;
223 
235 
236 
238  void Print(std::ostream& os, bool filenameDetails) const;
239 
240  private:
241 
242  // read values from tag cache
243  std::string GetPixelSpacing() const;
244  std::string GetImagerPixelSpacing() const;
245 
246  Image::Pointer FixupSpacing(Image* mitkImage);
247  Image::Pointer DescribeImageWithProperties(Image* mitkImage);
248  void UpdateImageDescribingProperties() const;
249 
250  static mitk::BaseProperty::Pointer GetPropertyForDICOMValues(const DICOMCachedValueLookupTable& cacheLookupTable);
251 
252  double stringtodouble(const std::string& str) const;
253  DICOMImageFrameList m_ImageFrameList;
254 
255  Image::Pointer m_MitkImage;
256  BoolList m_SliceIsLoaded;
257  ReaderImplementationLevel m_ReaderImplementationLevel;
258 
259  GantryTiltInformation m_TiltInformation;
260 
261  PropertyList::Pointer m_PropertyList;
262 
263  IOVolumeSplitReason::Pointer m_SplitReason;
264 
265  WeakPointer<DICOMTagCache> m_TagCache;
266 
267  mutable bool m_PropertiesOutOfDate;
268 
269  AdditionalTagsMapType m_AdditionalTagMap;
270  std::set<std::string> m_FoundAdditionalTags;
271 
272  TagLookupTableToPropertyFunctor m_PropertyFunctor;
273  };
274 
275 }
276 
277 #endif
#define MITKDICOM_EXPORT
Abstract base class for properties.
Lookup table mapping slice indices to cached DICOM tag value information.
const char * GetNameOfClass() const override
Return the class name as a string.
Superclass & operator=(const Superclass &other) override
GenericLookupTable< DICOMCachedValueInfo > Superclass
Output descriptor for DICOMFileReader.
std::vector< std::string > GetPropertyKeys(const std::string &contextName="", bool includeDefaultContext=false) const override
Query keys of existing properties.
Image::Pointer GetMitkImage() const
the 3D mitk::Image that is loaded from the DICOM files of a DICOMImageFrameList
void SetIntProperty(const std::string &key, int value)
Convenience function around SetProperty()
void SetSplitReason(IOVolumeSplitReason::Pointer reason)
bool GetFlag(const std::string &key, bool defaultValue) const
Convenience function around GetProperty()
void SetReaderImplementationLevel(const ReaderImplementationLevel &level)
Reader's capability to appropriately load this set of frames.
void Print(std::ostream &os, bool filenameDetails) const
Print information about this image block to given stream.
BaseProperty::ConstPointer GetConstProperty(const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) const override
Get property by its key.
std::map< DICOMTagPath, std::string > AdditionalTagsMapType
void SetTiltInformation(const GantryTiltInformation &info)
Describe the gantry tilt of the acquisition.
std::string GetSOPClassUID() const
SOP Class UID of this set of frames.
const DICOMImageFrameList & GetImageFrameList() const
List of frames that constitute the mitk::Image (DICOMImageFrames)
PixelSpacingInterpretation GetPixelSpacingInterpretation() const
Describe how the mitk::Image's pixel spacing should be interpreted.
IOVolumeSplitReason::Pointer GetSplitReason()
void SetFlag(const std::string &key, bool value)
Convenience function around SetProperty()
static DICOMTagList GetTagsOfInterest()
Return the list of DICOM tags that the descriptor internally uses.
std::string GetSOPClassUIDAsName() const
SOP Class as human readable name (e.g. "CT Image Storage")
void GetDesiredMITKImagePixelSpacing(ScalarType &spacingXinMM, ScalarType &spacingYinMM) const
Describe the correct x/y pixel spacing of the mitk::Image (which some readers might need to adjust af...
DICOMImageBlockDescriptor & operator=(const DICOMImageBlockDescriptor &other)
DICOMImageBlockDescriptor(const DICOMImageBlockDescriptor &other)
ReaderImplementationLevel GetReaderImplementationLevel() const
Reader's capability to appropriately load this set of frames.
int GetNumberOfFramesPerTimeStep() const
Return the number of frames that constitute one time step.
std::string GetPropertyAsString(const std::string &) const
Convenience function around GetProperty()
void SetProperty(const std::string &key, BaseProperty *value)
Key-value store describing aspects of the image to be loaded.
std::vector< std::string > GetPropertyContextNames() const override
Query names of existing contexts.
std::function< mitk::BaseProperty::Pointer(const DICOMCachedValueLookupTable &) > TagLookupTableToPropertyFunctor
void SetImageFrameList(const DICOMImageFrameList &framelist)
List of frames that constitute the mitk::Image (DICOMImageFrames)
BaseProperty * GetProperty(const std::string &key) const
Key-value store describing aspects of the image to be loaded.
const GantryTiltInformation GetTiltInformation() const
Describe the gantry tilt of the acquisition.
void SetSOPClassUID(const std::string &uid)
SOP Class UID of this set of frames.
void SetMitkImage(Image::Pointer image)
The 3D mitk::Image that is loaded from the DICOM files of a DICOMImageFrameList.
IOVolumeSplitReason::ConstPointer GetSplitReason() const
int GetNumberOfTimeSteps() const
Convenience method that returns the number of time steps.
int GetIntProperty(const std::string &key, int defaultValue) const
Convenience function around GetProperty()
void SetAdditionalTagsOfInterest(const AdditionalTagsMapType &tagMap)
Set a list of DICOMTagPaths that specify all DICOM-Tags that will be copied into the property of the ...
void SetTagLookupTableToPropertyFunctor(TagLookupTableToPropertyFunctor)
Set a functor that defines how the slice-specific tag-values are stored in a Property.
void SetTagCache(DICOMTagCache *privateCache)
Set the tag cache used for reading tag values during image description.
Abstract base class for caching DICOM tag values scanned from files.
Gantry tilt analysis result.
Template class for generating lookup-tables.
virtual Self & operator=(const Self &other)
Assignment operator.
std::shared_ptr< IOVolumeSplitReason > Pointer
Shared pointer type.
std::shared_ptr< const IOVolumeSplitReason > ConstPointer
Shared pointer to const type.
Interface implemented by classes that provide access to property information.
Image class for storing multi-dimensional medical image data.
Definition: mitkImage.h:76
A weak pointer that observes an itk::Object without preventing its deletion.
ReaderImplementationLevel
Describes how well the reader is tested for a certain file type (see mitk::DICOMFileReader).
PixelSpacingInterpretation
How the mitk::Image spacing should be interpreted (see mitk::DICOMFileReader).
Declares commonly used GenericProperty specializations for MITK.
Find image slices visible on a given plane.
std::vector< DICOMImageFrameInfo::Pointer > DICOMImageFrameList
std::vector< DICOMTag > DICOMTagList
A list of DICOMTag instances.
Definition: mitkDICOMTag.h:96
double ScalarType
Scalar type used throughout MITK for geometric computations.
std::vector< bool > BoolList
A list of boolean values, used e.g. for tracking per-slice loaded states.
Stores cached DICOM tag value information for a specific slice.
unsigned int TimePoint
The time point index this value belongs to.
unsigned int SliceInTimePoint
The slice index within the time point.
std::string Value
The cached tag value as a string.