Medical Imaging Interaction Toolkit  2018.4.99-c4b6bb11
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  m_AdditionalTagsOfInterest = other.m_AdditionalTagsOfInterest;
49  m_TagLookupTableToPropertyFunctor = other.m_TagLookupTableToPropertyFunctor;
50  }
51  return *this;
52 }
53 
54 void
56 ::SetConfigurationLabel(const std::string& label)
57 {
58  m_ConfigLabel = label;
59  this->Modified();
60 }
61 
62 std::string
65 {
66  return m_ConfigLabel;
67 }
68 
69 void
71 ::SetConfigurationDescription(const std::string& desc)
72 {
73  m_ConfigDescription = desc;
74  this->Modified();
75 }
76 
77 std::string
80 {
81  return m_ConfigDescription;
82 }
83 
84 void
86 ::SetInputFiles( const StringList& filenames)
87 {
88  m_InputFilenames = filenames;
89  this->Modified();
90 }
91 
92 const mitk::StringList&
95 {
96  return m_InputFilenames;
97 }
98 
99 unsigned int
102 {
103  return m_Outputs.size();
104 }
105 
106 void
109 {
110  m_Outputs.clear();
111 }
112 
113 void
115 ::SetNumberOfOutputs(unsigned int numberOfOutputs)
116 {
117  m_Outputs.resize(numberOfOutputs);
118 }
119 
120 void
122 ::SetOutput(unsigned int index, const mitk::DICOMImageBlockDescriptor& output)
123 {
124  if (index < m_Outputs.size())
125  {
126  m_Outputs[index] = output;
127  }
128  else
129  {
130  std::stringstream ss;
131  ss << "Index " << index << " out of range (" << m_Outputs.size() << " indices reserved)";
132  throw std::invalid_argument( ss.str() );
133  }
134 }
135 
136 void
138 ::PrintConfiguration(std::ostream& os) const
139 {
140  os << "---- Configuration of " << this->GetNameOfClass() <<" " << (void*)this << " ----"<< std::endl;
141  this->InternalPrintConfiguration(os);
142  os << "---- End of configuration ----" << std::endl;
143 }
144 
145 
146 void
148 ::PrintOutputs(std::ostream& os, bool filenameDetails) const
149 {
150  os << "---- Outputs of DICOMFilereader " << (void*)this << " ----"<< std::endl;
151 
152  for (unsigned int o = 0; o < m_Outputs.size(); ++o)
153  {
154  os << "-- Output " << o << std::endl;
155  const DICOMImageBlockDescriptor& block = m_Outputs[o];
156  block.Print(os, filenameDetails);
157  }
158  os << "---- End of output list ----" << std::endl;
159 }
160 
161 
164 ::GetOutput(unsigned int index) const
165 {
166  if (index < m_Outputs.size())
167  {
168  return m_Outputs[index];
169  }
170  else
171  {
172  std::stringstream ss;
173  ss << "Index " << index << " out of range (" << m_Outputs.size() << " indices reserved)";
174  throw std::invalid_argument( ss.str() );
175  }
176 }
179 ::InternalGetOutput(unsigned int index)
180 {
181  if (index < m_Outputs.size())
182  {
183  return m_Outputs[index];
184  }
185  else
186  {
187  std::stringstream ss;
188  ss << "Index " << index << " out of range (" << m_Outputs.size() << " indices reserved)";
189  throw std::invalid_argument( ss.str() );
190  }
191 }
192 
193 bool
195 ::IsDICOM(const std::string& filename)
196 {
197  itk::GDCMImageIO::Pointer io = itk::GDCMImageIO::New();
198  return io->CanReadFile( filename.c_str() );
199 }
200 
201 
203 {
204  return m_AdditionalTagsOfInterest;
205 }
206 
207 
209  const AdditionalTagsMapType& tagList)
210 {
211  m_AdditionalTagsOfInterest = tagList;
212  this->Modified();
213 }
214 
215 
218 {
219  m_TagLookupTableToPropertyFunctor = functor;
220  this->Modified();
221 }
222 
225 {
226  return m_TagLookupTableToPropertyFunctor;
227 }
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...