Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkDICOMFileReader.h"
18 
19 #include <itkGDCMImageIO.h>
20 
23 :itk::Object()
24 {
25 }
26 
29 {
30 }
31 
34 :itk::Object()
35 ,m_InputFilenames( other.m_InputFilenames )
36 ,m_Outputs( other.m_Outputs )
37 ,m_ConfigLabel( other.m_ConfigLabel )
38 ,m_ConfigDescription( other.m_ConfigDescription )
39 {
40 }
41 
45 {
46  if (this != &other)
47  {
48  m_InputFilenames = other.m_InputFilenames;
49  m_Outputs = other.m_Outputs;
50  m_ConfigLabel = other.m_ConfigLabel;
51  m_ConfigDescription = other.m_ConfigDescription;
52  }
53  return *this;
54 }
55 
56 void
58 ::SetConfigurationLabel(const std::string& label)
59 {
60  m_ConfigLabel = label;
61  this->Modified();
62 }
63 
64 std::string
67 {
68  return m_ConfigLabel;
69 }
70 
71 void
73 ::SetConfigurationDescription(const std::string& desc)
74 {
75  m_ConfigDescription = desc;
76  this->Modified();
77 }
78 
79 std::string
82 {
83  return m_ConfigDescription;
84 }
85 
86 void
88 ::SetInputFiles( const StringList& filenames)
89 {
90  m_InputFilenames = filenames;
91  this->Modified();
92 }
93 
94 const mitk::StringList&
97 {
98  return m_InputFilenames;
99 }
100 
101 unsigned int
104 {
105  return m_Outputs.size();
106 }
107 
108 void
111 {
112  m_Outputs.clear();
113 }
114 
115 void
117 ::SetNumberOfOutputs(unsigned int numberOfOutputs)
118 {
119  m_Outputs.resize(numberOfOutputs);
120 }
121 
122 void
124 ::SetOutput(unsigned int index, const mitk::DICOMImageBlockDescriptor& output)
125 {
126  if (index < m_Outputs.size())
127  {
128  m_Outputs[index] = output;
129  }
130  else
131  {
132  std::stringstream ss;
133  ss << "Index " << index << " out of range (" << m_Outputs.size() << " indices reserved)";
134  throw std::invalid_argument( ss.str() );
135  }
136 }
137 
138 void
140 ::PrintConfiguration(std::ostream& os) const
141 {
142  os << "---- Configuration of " << this->GetNameOfClass() <<" " << (void*)this << " ----"<< std::endl;
143  this->InternalPrintConfiguration(os);
144  os << "---- End of configuration ----" << std::endl;
145 }
146 
147 
148 void
150 ::PrintOutputs(std::ostream& os, bool filenameDetails) const
151 {
152  os << "---- Outputs of DICOMFilereader " << (void*)this << " ----"<< std::endl;
153 
154  for (unsigned int o = 0; o < m_Outputs.size(); ++o)
155  {
156  os << "-- Output " << o << std::endl;
157  const DICOMImageBlockDescriptor& block = m_Outputs[o];
158  block.Print(os, filenameDetails);
159  }
160  os << "---- End of output list ----" << std::endl;
161 }
162 
163 
166 ::GetOutput(unsigned int index) const
167 {
168  if (index < m_Outputs.size())
169  {
170  return m_Outputs[index];
171  }
172  else
173  {
174  std::stringstream ss;
175  ss << "Index " << index << " out of range (" << m_Outputs.size() << " indices reserved)";
176  throw std::invalid_argument( ss.str() );
177  }
178 }
181 ::InternalGetOutput(unsigned int index)
182 {
183  if (index < m_Outputs.size())
184  {
185  return m_Outputs[index];
186  }
187  else
188  {
189  std::stringstream ss;
190  ss << "Index " << index << " out of range (" << m_Outputs.size() << " indices reserved)";
191  throw std::invalid_argument( ss.str() );
192  }
193 }
194 
195 bool
197 ::IsDICOM(const std::string& filename)
198 {
200  return io->CanReadFile( filename.c_str() );
201 }
202 
203 
205 {
206  return m_AdditionalTagsOfInterest;
207 }
208 
209 
211  const AdditionalTagsMapType& tagList)
212 {
213  m_AdditionalTagsOfInterest = tagList;
214  this->Modified();
215 }
216 
217 
220 {
221  m_TagLookupTableToPropertyFunctor = functor;
222  this->Modified();
223 }
224 
227 {
228  return m_TagLookupTableToPropertyFunctor;
229 }
itk::SmartPointer< Self > Pointer
const DICOMImageBlockDescriptor & GetOutput(unsigned int index) const
Individual outputs, only meaningful after calling AnalyzeInputFiles().
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's loading "strategy".
void SetNumberOfOutputs(unsigned int numberOfOutputs)
void SetConfigurationLabel(const std::string &)
Short label/name to describe this reader.
void PrintOutputs(std::ostream &os, bool filenameDetails=false) const
Print output description to given stream, for human reader.
virtual AdditionalTagsMapType GetAdditionalTagsOfInterest() const
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.
std::function< mitk::BaseProperty::Pointer(const DICOMCachedValueLookupTable &) > TagLookupTableToPropertyFunctor
mitk::DICOMImageBlockDescriptor::TagLookupTableToPropertyFunctor GetTagLookupTableToPropertyFunctor() const
static const std::string filename
DICOMImageBlockDescriptor & InternalGetOutput(unsigned int index)
non-const access to the DICOMImageBlockDescriptor
DICOMImageBlockDescriptor::AdditionalTagsMapType AdditionalTagsMapType
Output descriptor for DICOMFileReader.
std::vector< std::string > StringList
std::string GetConfigurationDescription() const
One-sentence description of the reader's loading "strategy".
std::string GetConfigurationLabel() const
Short label/name to describe this reader.
void Print(std::ostream &os, bool filenameDetails) const
Print information about this image block to given stream.
DICOMFileReader & operator=(const DICOMFileReader &other)
Interface for DICOM readers that produce mitk::Images.
unsigned int GetNumberOfOutputs() const
Number of outputs, only meaningful after calling AnalyzeInputFiles()
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...
const StringList & GetInputFiles() const
This input files.
void PrintConfiguration(std::ostream &os) const
Print configuration description to given stream, for human reader.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.