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 {
27  namespace simple {
28 
57  : public ImageReaderBase
58  {
59  public:
61 
62  ~ImageSeriesReader() override;
63 
65 
67  std::string ToString() const override;
68 
70  std::string GetName() const override { return std::string("ImageSeriesReader"); }
71 
72 
78  SITK_RETURN_SELF_TYPE_HEADER SetMetaDataDictionaryArrayUpdate ( bool metaDataDictionaryArrayUpdate )
79  { this->m_MetaDataDictionaryArrayUpdate = metaDataDictionaryArrayUpdate; return *this; }
80  bool GetMetaDataDictionaryArrayUpdate() { return this->m_MetaDataDictionaryArrayUpdate; }
81 
82 
84  SITK_RETURN_SELF_TYPE_HEADER MetaDataDictionaryArrayUpdateOn() { return this->SetMetaDataDictionaryArrayUpdate(true); }
85  SITK_RETURN_SELF_TYPE_HEADER MetaDataDictionaryArrayUpdateOff() { return this->SetMetaDataDictionaryArrayUpdate(false); }
86 
87 
111  static std::vector<std::string> GetGDCMSeriesFileNames( const std::string &directory,
112  const std::string &seriesID = "",
113  bool useSeriesDetails = false,
114  bool recursive = false,
115  bool loadSequences = false );
116 
122  static std::vector<std::string> GetGDCMSeriesIDs( const std::string &directory );
123 
124  SITK_RETURN_SELF_TYPE_HEADER SetFileNames ( const std::vector<std::string> &fileNames );
125  const std::vector<std::string> &GetFileNames() const;
126 
127  Image Execute() override;
128 
143  std::vector<std::string> GetMetaDataKeys( unsigned int slice ) const { return this->m_pfGetMetaDataKeys(slice); }
144 
147  bool HasMetaDataKey( unsigned int slice, const std::string &key ) const { return this->m_pfHasMetaDataKey(slice, key); }
148 
157  std::string GetMetaData( unsigned int slice, const std::string &key ) const { return this->m_pfGetMetaData(slice, key); }
158 
159 
160  protected:
161 
162  template <class TImageType> Image ExecuteInternal ( itk::ImageIOBase * );
163 
164  private:
165 
166  // function pointer type
167  typedef Image (Self::*MemberFunctionType)( itk::ImageIOBase * );
168 
169  // friend to get access to executeInternal member
170  friend struct detail::MemberFunctionAddressor<MemberFunctionType>;
171  std::unique_ptr<detail::MemberFunctionFactory<MemberFunctionType> > m_MemberFactory;
172 
173 
174  std::function<std::vector<std::string>(int)> m_pfGetMetaDataKeys;
175  std::function<bool(int, const std::string &)> m_pfHasMetaDataKey;
176  std::function<std::string(int, const std::string &)> m_pfGetMetaData;
177 
178  // Holder of process object for active measurements
180 
181 
182  std::vector<std::string> m_FileNames;
183 
185  };
186 
211  SITKIO_EXPORT Image ReadImage ( const std::vector<std::string> &fileNames,
212  PixelIDValueEnum outputPixelType=sitkUnknown,
213  const std::string &imageIO="");
214  }
215 }
216 
217 #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:175
itk::simple::ImageSeriesReader::GetMetaDataDictionaryArrayUpdate
bool GetMetaDataDictionaryArrayUpdate()
Definition: sitkImageSeriesReader.h:80
itk::simple::ImageSeriesReader::m_pfGetMetaData
std::function< std::string(int, const std::string &)> m_pfGetMetaData
Definition: sitkImageSeriesReader.h:176
itk::simple::detail::MemberFunctionAddressor
Definition: sitkDetail.h:32
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:143
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:157
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:147
SITKIO_EXPORT
#define SITKIO_EXPORT
Definition: sitkIO.h:33
sitkImage.h
itk::simple::PixelIDValueEnum
PixelIDValueEnum
Enumerated values of pixelIDs.
Definition: sitkPixelIDValues.h:93
sitkMemberFunctionFactory.h
itk::simple::ImageSeriesReader::m_pfGetMetaDataKeys
std::function< std::vector< std::string >int)> m_pfGetMetaDataKeys
Definition: sitkImageSeriesReader.h:174
sitkMacro.h
sitkImageReaderBase.h
itk::simple::ImageSeriesReader
Read series of image files into a SimpleITK image.
Definition: sitkImageSeriesReader.h:56
itk::simple::ImageSeriesReader::MetaDataDictionaryArrayUpdateOff
Self & MetaDataDictionaryArrayUpdateOff()
Definition: sitkImageSeriesReader.h:85
itk::simple::ReadImage
SITKIO_EXPORT Image ReadImage(const std::string &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::ImageSeriesReader::SetMetaDataDictionaryArrayUpdate
Self & SetMetaDataDictionaryArrayUpdate(bool metaDataDictionaryArrayUpdate)
Definition: sitkImageSeriesReader.h:78
itk::simple::ImageReaderBase
An abstract base class for image readers.
Definition: sitkImageReaderBase.h:39
itk::simple::ImageSeriesReader::m_MetaDataDictionaryArrayUpdate
bool m_MetaDataDictionaryArrayUpdate
Definition: sitkImageSeriesReader.h:184
itk::simple::ImageSeriesReader::m_MemberFactory
std::unique_ptr< detail::MemberFunctionFactory< MemberFunctionType > > m_MemberFactory
Definition: sitkImageSeriesReader.h:171
itk::simple::ImageSeriesReader::MetaDataDictionaryArrayUpdateOn
Self & MetaDataDictionaryArrayUpdateOn()
Definition: sitkImageSeriesReader.h:84
itk
itk::simple::ImageSeriesReader::m_Filter
itk::ProcessObject * m_Filter
Definition: sitkImageSeriesReader.h:179
itk::simple::ImageSeriesReader::m_FileNames
std::vector< std::string > m_FileNames
Definition: sitkImageSeriesReader.h:182
itk::ProcessObject
itk::simple::ProcessObject
Base class for SimpleITK classes based on ProcessObject.
Definition: sitkProcessObject.h:51
itk::simple::ImageSeriesReader::GetName
std::string GetName() const override
Definition: sitkImageSeriesReader.h:70
itk::simple::sitkUnknown
@ sitkUnknown
Definition: sitkPixelIDValues.h:94