Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
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"
20 
21 #include "mitkImage.h"
22 #include "mitkProperties.h"
23 #include "mitkWeakPointer.h"
24 #include "mitkIPropertyProvider.h"
25 
27 
28 #include <unordered_map>
29 
30 namespace mitk
31 {
32 
34  {
35  unsigned int TimePoint;
36  unsigned int SliceInTimePoint;
37  std::string Value;
38  };
39 
40  class DICOMCachedValueLookupTable : public GenericLookupTable< DICOMCachedValueInfo >
41  {
42  public:
45  const char *GetNameOfClass() const override
46  {
47  return "DICOMCachedValueLookupTable";
48  }
49 
51  Superclass& operator=(const Superclass& other) override { return Superclass::operator=(other); }
53  };
54 
78  {
79  public:
80 
82  ~DICOMImageBlockDescriptor() override;
83 
86 
87  static DICOMTagList GetTagsOfInterest();
88 
90  void SetImageFrameList(const DICOMImageFrameList& framelist);
92  const DICOMImageFrameList& GetImageFrameList() const;
93 
95  void SetMitkImage(Image::Pointer image);
97  Image::Pointer GetMitkImage() const;
98 
100  ReaderImplementationLevel GetReaderImplementationLevel() const;
102  void SetReaderImplementationLevel(const ReaderImplementationLevel& level);
103 
105  void SetProperty(const std::string& key, BaseProperty* value);
107  BaseProperty* GetProperty(const std::string& key) const;
108 
110  std::string GetPropertyAsString(const std::string&) const;
111 
113  void SetFlag(const std::string& key, bool value);
115  bool GetFlag(const std::string& key, bool defaultValue) const;
116 
118  void SetIntProperty(const std::string& key, int value);
120  int GetIntProperty(const std::string& key, int defaultValue) const;
121 
122  BaseProperty::ConstPointer GetConstProperty(const std::string &propertyKey,
123  const std::string &contextName = "",
124  bool fallBackOnDefaultContext = true) const override;
125 
126  std::vector<std::string> GetPropertyKeys(const std::string &contextName = "",
127  bool includeDefaultContext = false) const override;
128 
129  std::vector<std::string> GetPropertyContextNames() const override;
130 
131  private:
132 
133  // For future implementation: load slice-by-slice, mark this using these methods
134  void SetSliceIsLoaded(unsigned int index, bool isLoaded);
135  // For future implementation: load slice-by-slice, mark this using these methods
136  bool IsSliceLoaded(unsigned int index) const;
137  // For future implementation: load slice-by-slice, mark this using these methods
138  bool AllSlicesAreLoaded() const;
139 
140  public:
141 
143  PixelSpacingInterpretation GetPixelSpacingInterpretation() const;
144 
146  void GetDesiredMITKImagePixelSpacing(ScalarType& spacingXinMM, ScalarType& spacingYinMM) const;
147 
149  void SetTiltInformation(const GantryTiltInformation& info);
151  const GantryTiltInformation GetTiltInformation() const;
152 
154  void SetSOPClassUID(const std::string& uid);
156  std::string GetSOPClassUID() const;
158  std::string GetSOPClassUIDAsName() const;
159 
161  int GetNumberOfTimeSteps() const;
163  int GetNumberOfFramesPerTimeStep() const;
164 
165  void SetTagCache(DICOMTagCache* privateCache);
166 
170  typedef std::map<DICOMTagPath, std::string> AdditionalTagsMapType;
182  void SetAdditionalTagsOfInterest(const AdditionalTagsMapType& tagMap);
183 
184  typedef std::function<mitk::BaseProperty::Pointer(const DICOMCachedValueLookupTable&) > TagLookupTableToPropertyFunctor;
185 
196  void SetTagLookupTableToPropertyFunctor(TagLookupTableToPropertyFunctor);
197 
198 
200  void Print(std::ostream& os, bool filenameDetails) const;
201 
202  private:
203 
204  // read values from tag cache
205  std::string GetPixelSpacing() const;
206  std::string GetImagerPixelSpacing() const;
207 
208  Image::Pointer FixupSpacing(Image* mitkImage);
209  Image::Pointer DescribeImageWithProperties(Image* mitkImage);
210  void UpdateImageDescribingProperties() const;
211 
212  static mitk::BaseProperty::Pointer GetPropertyForDICOMValues(const DICOMCachedValueLookupTable& cacheLookupTable);
213 
214  double stringtodouble(const std::string& str) const;
215  DICOMImageFrameList m_ImageFrameList;
216 
217  Image::Pointer m_MitkImage;
218  BoolList m_SliceIsLoaded;
219  ReaderImplementationLevel m_ReaderImplementationLevel;
220 
221  GantryTiltInformation m_TiltInformation;
222 
223  PropertyList::Pointer m_PropertyList;
224 
226 
227  mutable bool m_PropertiesOutOfDate;
228 
229  AdditionalTagsMapType m_AdditionalTagMap;
230  std::set<std::string> m_FoundAdditionalTags;
231 
232  TagLookupTableToPropertyFunctor m_PropertyFunctor;
233  };
234 
235 }
236 
237 #endif
double ScalarType
std::vector< DICOMTag > DICOMTagList
Definition: mitkDICOMTag.h:59
#define MITKDICOMREADER_EXPORT
const char * GetNameOfClass() const override
DataCollection - Class to facilitate loading/accessing structured data.
GenericLookupTable< DICOMCachedValueInfo > Superclass
std::map< DICOMTagPath, std::string > AdditionalTagsMapType
Template class for generating lookup-tables.
static void info(const char *fmt,...)
Definition: svm.cpp:86
std::function< mitk::BaseProperty::Pointer(const DICOMCachedValueLookupTable &) > TagLookupTableToPropertyFunctor
Superclass & operator=(const Superclass &other) override
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).
Abstract base class for properties.
std::vector< DICOMImageFrameInfo::Pointer > DICOMImageFrameList
Image class for storing images.
Definition: mitkImage.h:72
Output descriptor for DICOMFileReader.
mitk::Image::Pointer image
Gantry tilt analysis result.
std::vector< bool > BoolList