SimpleITK  
sitkImageSeriesReader.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef sitkImageSeriesReader_h
19 #define sitkImageSeriesReader_h
20 
21 #include "sitkMacro.h"
22 #include "sitkImage.h"
23 #include "sitkImageReaderBase.h"
25 
26 namespace itk::simple
27 {
28 
69 {
70 public:
72 
73  ~ImageSeriesReader() override;
74 
76 
78  std::string
79  ToString() const override;
80 
82  std::string
83  GetName() const override
84  {
85  return std::string("ImageSeriesReader");
86  }
87 
88 
94  SITK_RETURN_SELF_TYPE_HEADER
95  SetMetaDataDictionaryArrayUpdate(bool metaDataDictionaryArrayUpdate)
96  {
97  this->m_MetaDataDictionaryArrayUpdate = metaDataDictionaryArrayUpdate;
98  return *this;
99  }
100  bool
102  {
103  return this->m_MetaDataDictionaryArrayUpdate;
104  }
105 
106 
108  SITK_RETURN_SELF_TYPE_HEADER
110  {
111  return this->SetMetaDataDictionaryArrayUpdate(true);
112  }
113  SITK_RETURN_SELF_TYPE_HEADER
115  {
116  return this->SetMetaDataDictionaryArrayUpdate(false);
117  }
118 
119 
147  static std::vector<PathType>
148  GetGDCMSeriesFileNames(const PathType & directory,
149  const std::string & seriesID = "",
150  bool useSeriesDetails = false,
151  bool recursive = false,
152  bool loadSequences = false);
153 
164  static std::vector<std::string>
165  GetGDCMSeriesIDs(const PathType & directory, bool useSeriesDetails = false);
166 
167  SITK_RETURN_SELF_TYPE_HEADER
168  SetFileNames(const std::vector<PathType> & fileNames);
169  const std::vector<PathType> &
170  GetFileNames() const;
171 
172  Image
173  Execute() override;
174 
189  std::vector<std::string>
190  GetMetaDataKeys(unsigned int slice) const
191  {
192  return this->m_pfGetMetaDataKeys(slice);
193  }
194 
197  bool
198  HasMetaDataKey(unsigned int slice, const std::string & key) const
199  {
200  return this->m_pfHasMetaDataKey(slice, key);
201  }
202 
211  std::string
212  GetMetaData(unsigned int slice, const std::string & key) const
213  {
214  return this->m_pfGetMetaData(slice, key);
215  }
216 
217 
218 protected:
219  template <class TImageType>
220  Image
221  ExecuteInternal(itk::ImageIOBase *);
222 
223 private:
224  // function pointer type
225  typedef Image (Self::*MemberFunctionType)(itk::ImageIOBase *);
226 
227  // friend to get access to executeInternal member
228  friend struct detail::MemberFunctionAddressor<MemberFunctionType>;
229  std::unique_ptr<detail::MemberFunctionFactory<MemberFunctionType>> m_MemberFactory;
230 
231 
232  std::function<std::vector<std::string>(int)> m_pfGetMetaDataKeys;
233  std::function<bool(int, const std::string &)> m_pfHasMetaDataKey;
234  std::function<std::string(int, const std::string &)> m_pfGetMetaData;
235 
236  // Holder of process object for active measurements
238 
239 
240  std::vector<PathType> m_FileNames;
241 
243 };
244 
270 ReadImage(const std::vector<PathType> & fileNames,
271  PixelIDValueEnum outputPixelType = sitkUnknown,
272  const std::string & imageIO = "");
273 } // namespace itk::simple
274 
275 #endif
itk::simple::Image
The Image class for SimpleITK.
Definition: sitkImage.h:76
itk::ImageIOBase
itk::simple::ImageSeriesReader::m_pfHasMetaDataKey
std::function< bool(int, const std::string &)> m_pfHasMetaDataKey
Definition: sitkImageSeriesReader.h:233
itk::simple::ImageSeriesReader::GetMetaDataDictionaryArrayUpdate
bool GetMetaDataDictionaryArrayUpdate()
Definition: sitkImageSeriesReader.h:101
itk::simple::ImageSeriesReader::m_pfGetMetaData
std::function< std::string(int, const std::string &)> m_pfGetMetaData
Definition: sitkImageSeriesReader.h:234
itk::simple::detail::MemberFunctionAddressor
Definition: sitkDetail.h:29
itk::simple::ImageSeriesReader::GetMetaDataKeys
std::vector< std::string > GetMetaDataKeys(unsigned int slice) const
Get the meta-data dictionary keys for a slice.
Definition: sitkImageSeriesReader.h:190
itk::simple::ImageSeriesReader::GetMetaData
std::string GetMetaData(unsigned int slice, const std::string &key) const
Get the value of a meta-data dictionary entry as a string.
Definition: sitkImageSeriesReader.h:212
itk::simple::ImageSeriesReader::HasMetaDataKey
bool HasMetaDataKey(unsigned int slice, const std::string &key) const
Query a meta-data dictionary for the existence of a key.
Definition: sitkImageSeriesReader.h:198
SITKIO_EXPORT
#define SITKIO_EXPORT
Definition: sitkIO.h:33
sitkImage.h
itk::simple::ImageSeriesReader::m_FileNames
std::vector< PathType > m_FileNames
Definition: sitkImageSeriesReader.h:240
itk::simple::ReadImage
SITKIO_EXPORT Image ReadImage(const PathType &filename, PixelIDValueEnum outputPixelType=sitkUnknown, const std::string &imageIO="")
ReadImage is a procedural interface to the ImageFileReader class which is convenient for most image r...
itk::simple::PixelIDValueEnum
PixelIDValueEnum
Enumerated values of pixelIDs.
Definition: sitkPixelIDValues.h:100
sitkMemberFunctionFactory.h
itk::simple::ImageSeriesReader::m_pfGetMetaDataKeys
std::function< std::vector< std::string >int)> m_pfGetMetaDataKeys
Definition: sitkImageSeriesReader.h:232
sitkMacro.h
sitkImageReaderBase.h
itk::simple::ImageSeriesReader
Read series of image files into a SimpleITK image.
Definition: sitkImageSeriesReader.h:68
itk::simple::ImageSeriesReader::MetaDataDictionaryArrayUpdateOff
Self & MetaDataDictionaryArrayUpdateOff()
Definition: sitkImageSeriesReader.h:114
itk::simple::ImageSeriesReader::SetMetaDataDictionaryArrayUpdate
Self & SetMetaDataDictionaryArrayUpdate(bool metaDataDictionaryArrayUpdate)
Definition: sitkImageSeriesReader.h:95
itk::simple::ImageReaderBase
An abstract base class for image readers.
Definition: sitkImageReaderBase.h:42
itk::simple::ImageSeriesReader::m_MetaDataDictionaryArrayUpdate
bool m_MetaDataDictionaryArrayUpdate
Definition: sitkImageSeriesReader.h:242
itk::simple::ImageSeriesReader::m_MemberFactory
std::unique_ptr< detail::MemberFunctionFactory< MemberFunctionType > > m_MemberFactory
Definition: sitkImageSeriesReader.h:229
itk::simple::ImageSeriesReader::MetaDataDictionaryArrayUpdateOn
Self & MetaDataDictionaryArrayUpdateOn()
Definition: sitkImageSeriesReader.h:109
itk::simple::ImageSeriesReader::m_Filter
itk::ProcessObject * m_Filter
Definition: sitkImageSeriesReader.h:237
itk::ProcessObject
itk::simple::ProcessObject
Base class for SimpleITK classes based on ProcessObject.
Definition: sitkProcessObject.h:54
itk::simple::ImageSeriesReader::GetName
std::string GetName() const override
Definition: sitkImageSeriesReader.h:83
itk::simple
Definition: sitkAdditionalProcedures.h:28
itk::simple::PathType
std::string PathType
Definition: sitkPathType.h:25
itk::simple::sitkUnknown
@ sitkUnknown
Definition: sitkPixelIDValues.h:102