Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
mitkDICOMFileReader.cpp
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 #include "mitkDICOMFileReader.h"
14 
15 #include <itkGDCMImageIO.h>
16 
19 :itk::Object()
20 {
21 }
22 
25 {
26 }
27 
30 :itk::Object()
31 ,m_InputFilenames( other.m_InputFilenames )
32 ,m_Outputs( other.m_Outputs )
33 ,m_ConfigLabel( other.m_ConfigLabel )
34 ,m_ConfigDescription( other.m_ConfigDescription )
35 {
36 }
37 
41 {
42  if (this != &other)
43  {
44  m_InputFilenames = other.m_InputFilenames;
45  m_Outputs = other.m_Outputs;
46  m_ConfigLabel = other.m_ConfigLabel;
47  m_ConfigDescription = other.m_ConfigDescription;
48  }
49  return *this;
50 }
51 
52 void
54 ::SetConfigurationLabel(const std::string& label)
55 {
56  m_ConfigLabel = label;
57  this->Modified();
58 }
59 
60 std::string
63 {
64  return m_ConfigLabel;
65 }
66 
67 void
69 ::SetConfigurationDescription(const std::string& desc)
70 {
71  m_ConfigDescription = desc;
72  this->Modified();
73 }
74 
75 std::string
78 {
79  return m_ConfigDescription;
80 }
81 
82 void
84 ::SetInputFiles( const StringList& filenames)
85 {
86  m_InputFilenames = filenames;
87  this->Modified();
88 }
89 
90 const mitk::StringList&
93 {
94  return m_InputFilenames;
95 }
96 
97 unsigned int
100 {
101  return m_Outputs.size();
102 }
103 
104 void
107 {
108  m_Outputs.clear();
109 }
110 
111 void
113 ::SetNumberOfOutputs(unsigned int numberOfOutputs)
114 {
115  m_Outputs.resize(numberOfOutputs);
116 }
117 
118 void
120 ::SetOutput(unsigned int index, const mitk::DICOMImageBlockDescriptor& output)
121 {
122  if (index < m_Outputs.size())
123  {
124  m_Outputs[index] = output;
125  }
126  else
127  {
128  std::stringstream ss;
129  ss << "Index " << index << " out of range (" << m_Outputs.size() << " indices reserved)";
130  throw std::invalid_argument( ss.str() );
131  }
132 }
133 
134 void
136 ::PrintConfiguration(std::ostream& os) const
137 {
138  os << "---- Configuration of " << this->GetNameOfClass() <<" " << (void*)this << " ----"<< std::endl;
139  this->InternalPrintConfiguration(os);
140  os << "---- End of configuration ----" << std::endl;
141 }
142 
143 
144 void
146 ::PrintOutputs(std::ostream& os, bool filenameDetails) const
147 {
148  os << "---- Outputs of DICOMFilereader " << (void*)this << " ----"<< std::endl;
149 
150  for (unsigned int o = 0; o < m_Outputs.size(); ++o)
151  {
152  os << "-- Output " << o << std::endl;
153  const DICOMImageBlockDescriptor& block = m_Outputs[o];
154  block.Print(os, filenameDetails);
155  }
156  os << "---- End of output list ----" << std::endl;
157 }
158 
159 
162 ::GetOutput(unsigned int index) const
163 {
164  if (index < m_Outputs.size())
165  {
166  return m_Outputs[index];
167  }
168  else
169  {
170  std::stringstream ss;
171  ss << "Index " << index << " out of range (" << m_Outputs.size() << " indices reserved)";
172  throw std::invalid_argument( ss.str() );
173  }
174 }
177 ::InternalGetOutput(unsigned int index)
178 {
179  if (index < m_Outputs.size())
180  {
181  return m_Outputs[index];
182  }
183  else
184  {
185  std::stringstream ss;
186  ss << "Index " << index << " out of range (" << m_Outputs.size() << " indices reserved)";
187  throw std::invalid_argument( ss.str() );
188  }
189 }
190 
191 bool
193 ::IsDICOM(const std::string& filename)
194 {
195  itk::GDCMImageIO::Pointer io = itk::GDCMImageIO::New();
196  return io->CanReadFile( filename.c_str() );
197 }
198 
199 
201 {
202  return m_AdditionalTagsOfInterest;
203 }
204 
205 
207  const AdditionalTagsMapType& tagList)
208 {
209  m_AdditionalTagsOfInterest = tagList;
210  this->Modified();
211 }
212 
213 
216 {
217  m_TagLookupTableToPropertyFunctor = functor;
218  this->Modified();
219 }
220 
223 {
224  return m_TagLookupTableToPropertyFunctor;
225 }
mitk::DICOMImageBlockDescriptor::TagLookupTableToPropertyFunctor GetTagLookupTableToPropertyFunctor() const
void Print(std::ostream &os, bool filenameDetails) const
Print information about this image block to given stream.
void PrintConfiguration(std::ostream &os) const
Print configuration description to given stream, for human reader.
static bool IsDICOM(const std::string &filename)
Test whether a file is DICOM at all.
void SetConfigurationDescription(const std::string &)
One-sentence description of the reader&#39;s loading "strategy".
void SetNumberOfOutputs(unsigned int numberOfOutputs)
virtual AdditionalTagsMapType GetAdditionalTagsOfInterest() const
virtual void InternalPrintConfiguration(std::ostream &os) const =0
Configuration description for human reader, to be implemented by sub-classes.
void SetConfigurationLabel(const std::string &)
Short label/name to describe this reader.
void SetOutput(unsigned int index, const DICOMImageBlockDescriptor &output)
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.
const StringList & GetInputFiles() const
This input files.
std::function< mitk::BaseProperty::Pointer(const DICOMCachedValueLookupTable &) > TagLookupTableToPropertyFunctor
unsigned int GetNumberOfOutputs() const
Number of outputs, only meaningful after calling AnalyzeInputFiles()
std::string GetConfigurationDescription() const
One-sentence description of the reader&#39;s loading "strategy".
const DICOMImageBlockDescriptor & GetOutput(unsigned int index) const
Individual outputs, only meaningful after calling AnalyzeInputFiles().
DICOMImageBlockDescriptor & InternalGetOutput(unsigned int index)
non-const access to the DICOMImageBlockDescriptor
DICOMImageBlockDescriptor::AdditionalTagsMapType AdditionalTagsMapType
void PrintOutputs(std::ostream &os, bool filenameDetails=false) const
Print output description to given stream, for human reader.
Output descriptor for DICOMFileReader.
std::string GetConfigurationLabel() const
Short label/name to describe this reader.
std::vector< std::string > StringList
DICOMFileReader & operator=(const DICOMFileReader &other)
Interface for DICOM readers that produce mitk::Images.
virtual void SetAdditionalTagsOfInterest(const AdditionalTagsMapType &tagList)
Set a list of DICOMTagPaths that specifiy all DICOM-Tags that will be copied into the property of the...