Medical Imaging Interaction Toolkit  2025.12.02
Medical Imaging Interaction Toolkit
mitkDICOMFileReader.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 mitkDICOMFileReader_h
14 #define mitkDICOMFileReader_h
15 
16 #include "itkObjectFactory.h"
17 #include "mitkCommon.h"
18 
19 #include "MitkDICOMExports.h"
20 
21 #include "mitkDICOMTagCache.h"
22 
24 
25 #include <unordered_map>
26 
27 namespace mitk
28 {
29 // TODO Philips3D!
30 // TODO https://phabricator.mitk.org/T11572 ?
31 
55 class MITKDICOM_EXPORT DICOMFileReader : public itk::Object
56 {
57 public:
59 
61  static bool IsDICOM( const std::string& filename );
63  virtual bool CanHandleFile( const std::string& filename ) = 0;
64 
66  void SetInputFiles( const StringList& filenames );
68  const StringList& GetInputFiles() const;
69 
71  virtual void AnalyzeInputFiles() = 0;
72 
74  unsigned int GetNumberOfOutputs() const;
76  const DICOMImageBlockDescriptor& GetOutput( unsigned int index ) const;
77 
78  // void AllocateOutputImages(); TODO for later implementation of slice-by-slice loading
79 
82  virtual bool LoadImages() = 0;
83 
84  virtual DICOMTagPathList GetTagsOfInterest() const = 0;
85 
87  virtual void SetTagCache( const DICOMTagCache::Pointer& ) = 0;
88 
90  void SetConfigurationLabel( const std::string& );
92  std::string GetConfigurationLabel() const;
94  void SetConfigurationDescription( const std::string& );
96  std::string GetConfigurationDescription() const;
97 
99  void PrintConfiguration( std::ostream& os ) const;
101  void PrintOutputs( std::ostream& os, bool filenameDetails = false ) const;
102 
103  virtual bool operator==( const DICOMFileReader& other ) const = 0;
104 
121 
134 
135 protected:
137  ~DICOMFileReader() override;
138 
141 
142  void ClearOutputs();
143  void SetNumberOfOutputs( unsigned int numberOfOutputs );
144  void SetOutput( unsigned int index, const DICOMImageBlockDescriptor& output );
145 
148 
150  virtual void InternalPrintConfiguration( std::ostream& os ) const = 0;
151 
153 
155 
156 
157 private:
158  StringList m_InputFilenames;
159  std::vector<DICOMImageBlockDescriptor> m_Outputs;
160 
161  std::string m_ConfigLabel;
162  std::string m_ConfigDescription;
163 
164  AdditionalTagsMapType m_AdditionalTagsOfInterest;
166 };
167 }
168 
169 #endif
#define MITKDICOM_EXPORT
Interface for DICOM readers that produce mitk::Images.
void SetNumberOfOutputs(unsigned int numberOfOutputs)
DICOMImageBlockDescriptor & InternalGetOutput(unsigned int index)
non-const access to the DICOMImageBlockDescriptor
mitk::DICOMImageBlockDescriptor::TagLookupTableToPropertyFunctor GetTagLookupTableToPropertyFunctor() const
void SetOutput(unsigned int index, const DICOMImageBlockDescriptor &output)
void PrintOutputs(std::ostream &os, bool filenameDetails=false) const
Print output description to given stream, for human reader.
virtual void SetAdditionalTagsOfInterest(const AdditionalTagsMapType &tagList)
Set a list of DICOMTagPaths that specify all DICOM-Tags that will be copied into the property of the ...
virtual void SetTagCache(const DICOMTagCache::Pointer &)=0
A way to provide external knowledge about files and tag values is appreciated.
unsigned int GetNumberOfOutputs() const
Number of outputs, only meaningful after calling AnalyzeInputFiles()
void SetConfigurationLabel(const std::string &)
Short label/name to describe this reader.
~DICOMFileReader() override
const DICOMImageBlockDescriptor & GetOutput(unsigned int index) const
Individual outputs, only meaningful after calling AnalyzeInputFiles().
virtual AdditionalTagsMapType GetAdditionalTagsOfInterest() const
virtual void AnalyzeInputFiles()=0
Analyze input files.
virtual bool CanHandleFile(const std::string &filename)=0
Indicate whether this reader can handle given file.
const StringList & GetInputFiles() const
This input files.
void PrintConfiguration(std::ostream &os) const
Print configuration description to given stream, for human reader.
mitkClassMacroItkParent(DICOMFileReader, itk::Object)
void SetConfigurationDescription(const std::string &)
One-sentence description of the reader's loading "strategy".
DICOMFileReader(const DICOMFileReader &other)
static bool IsDICOM(const std::string &filename)
Test whether a file is DICOM at all.
DICOMImageBlockDescriptor::AdditionalTagsMapType AdditionalTagsMapType
DICOMFileReader & operator=(const DICOMFileReader &other)
virtual bool LoadImages()=0
std::string GetConfigurationLabel() const
Short label/name to describe this reader.
virtual bool operator==(const DICOMFileReader &other) const =0
virtual void SetTagLookupTableToPropertyFunctor(mitk::DICOMImageBlockDescriptor::TagLookupTableToPropertyFunctor functor)
Set a functor that defines how the slice-specific tag-values are stored in a Property.
void SetInputFiles(const StringList &filenames)
This input files.
std::string GetConfigurationDescription() const
One-sentence description of the reader's loading "strategy".
virtual DICOMTagPathList GetTagsOfInterest() const =0
virtual void InternalPrintConfiguration(std::ostream &os) const =0
Configuration description for human reader, to be implemented by sub-classes.
Output descriptor for DICOMFileReader.
std::map< DICOMTagPath, std::string > AdditionalTagsMapType
std::function< mitk::BaseProperty::Pointer(const DICOMCachedValueLookupTable &) > TagLookupTableToPropertyFunctor
Find image slices visible on a given plane.
std::vector< std::string > StringList
std::vector< DICOMTagPath > DICOMTagPathList