Medical Imaging Interaction Toolkit  2025.12.02
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 
35  {
36  unsigned int TimePoint;
37  unsigned int SliceInTimePoint;
38  std::string Value;
39  };
40 
41  class DICOMCachedValueLookupTable : public GenericLookupTable< DICOMCachedValueInfo >
42  {
43  public:
46  const char *GetNameOfClass() const override
47  {
48  return "DICOMCachedValueLookupTable";
49  }
50 
52  Superclass& operator=(const Superclass& other) override { return Superclass::operator=(other); }
54  };
55 
79  {
80  public:
81 
84 
87 
89 
91  void SetImageFrameList(const DICOMImageFrameList& framelist);
94 
99 
104 
106  void SetProperty(const std::string& key, BaseProperty* value);
108  BaseProperty* GetProperty(const std::string& key) const;
109 
111  std::string GetPropertyAsString(const std::string&) const;
112 
119 
121  void SetFlag(const std::string& key, bool value);
123  bool GetFlag(const std::string& key, bool defaultValue) const;
124 
126  void SetIntProperty(const std::string& key, int value);
128  int GetIntProperty(const std::string& key, int defaultValue) const;
129 
130  BaseProperty::ConstPointer GetConstProperty(const std::string &propertyKey,
131  const std::string &contextName = "",
132  bool fallBackOnDefaultContext = true) const override;
133 
134  std::vector<std::string> GetPropertyKeys(const std::string &contextName = "",
135  bool includeDefaultContext = false) const override;
136 
137  std::vector<std::string> GetPropertyContextNames() const override;
138 
139  private:
140 
141  // For future implementation: load slice-by-slice, mark this using these methods
142  void SetSliceIsLoaded(unsigned int index, bool isLoaded);
143  // For future implementation: load slice-by-slice, mark this using these methods
144  bool IsSliceLoaded(unsigned int index) const;
145  // For future implementation: load slice-by-slice, mark this using these methods
146  bool AllSlicesAreLoaded() const;
147 
148  public:
149 
152 
154  void GetDesiredMITKImagePixelSpacing(ScalarType& spacingXinMM, ScalarType& spacingYinMM) const;
155 
160 
162  void SetSOPClassUID(const std::string& uid);
164  std::string GetSOPClassUID() const;
166  std::string GetSOPClassUIDAsName() const;
167 
169  int GetNumberOfTimeSteps() const;
172 
173  void SetTagCache(DICOMTagCache* privateCache);
174 
178  typedef std::map<DICOMTagPath, std::string> AdditionalTagsMapType;
191 
192  typedef std::function<mitk::BaseProperty::Pointer(const DICOMCachedValueLookupTable&) > TagLookupTableToPropertyFunctor;
193 
205 
206 
208  void Print(std::ostream& os, bool filenameDetails) const;
209 
210  private:
211 
212  // read values from tag cache
213  std::string GetPixelSpacing() const;
214  std::string GetImagerPixelSpacing() const;
215 
216  Image::Pointer FixupSpacing(Image* mitkImage);
217  Image::Pointer DescribeImageWithProperties(Image* mitkImage);
218  void UpdateImageDescribingProperties() const;
219 
220  static mitk::BaseProperty::Pointer GetPropertyForDICOMValues(const DICOMCachedValueLookupTable& cacheLookupTable);
221 
222  double stringtodouble(const std::string& str) const;
223  DICOMImageFrameList m_ImageFrameList;
224 
225  Image::Pointer m_MitkImage;
226  BoolList m_SliceIsLoaded;
227  ReaderImplementationLevel m_ReaderImplementationLevel;
228 
229  GantryTiltInformation m_TiltInformation;
230 
231  PropertyList::Pointer m_PropertyList;
232 
233  IOVolumeSplitReason::Pointer m_SplitReason;
234 
235  WeakPointer<DICOMTagCache> m_TagCache;
236 
237  mutable bool m_PropertiesOutOfDate;
238 
239  AdditionalTagsMapType m_AdditionalTagMap;
240  std::set<std::string> m_FoundAdditionalTags;
241 
242  TagLookupTableToPropertyFunctor m_PropertyFunctor;
243  };
244 
245 }
246 
247 #endif
#define MITKDICOM_EXPORT
Abstract base class for properties.
const char * GetNameOfClass() const override
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()
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.
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 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)
Gantry tilt analysis result.
Template class for generating lookup-tables.
std::shared_ptr< IOVolumeSplitReason > Pointer
std::shared_ptr< const IOVolumeSplitReason > ConstPointer
Image class for storing images.
Definition: mitkImage.h:70
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).
Find image slices visible on a given plane.
std::vector< DICOMImageFrameInfo::Pointer > DICOMImageFrameList
std::vector< DICOMTag > DICOMTagList
Definition: mitkDICOMTag.h:59
double ScalarType
std::vector< bool > BoolList