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
26namespace itk::simple
27{
28
69{
70public:
72
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
105
106
108 SITK_RETURN_SELF_TYPE_HEADER
110 SITK_RETURN_SELF_TYPE_HEADER
112
113
141 static std::vector<PathType>
143 const std::string & seriesID = "",
144 bool useSeriesDetails = false,
145 bool recursive = false,
146 bool loadSequences = false);
147
158 static std::vector<std::string>
159 GetGDCMSeriesIDs(const PathType & directory, bool useSeriesDetails = false);
160
161 SITK_RETURN_SELF_TYPE_HEADER
162 SetFileNames(const std::vector<PathType> & fileNames);
163 const std::vector<PathType> &
165
167 SITK_RETURN_SELF_TYPE_HEADER
168 SetSpacingWarningRelThreshold(double spacingWarningRelThreshold);
169 double
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
218protected:
219 template <class TImageType>
220 Image
222
223private:
224 // function pointer type
226
227 // friend to get access to executeInternal member
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
245};
246
272ReadImage(const std::vector<PathType> & fileNames,
273 PixelIDValueEnum outputPixelType = sitkUnknown,
274 const std::string & imageIO = "");
275} // namespace itk::simple
276
277#endif
std::string ToString() const override
Self & SetMetaDataDictionaryArrayUpdate(bool metaDataDictionaryArrayUpdate)
std::function< bool(int, const std::string &)> m_pfHasMetaDataKey
Image ExecuteInternal(itk::ImageIOBase *)
std::string GetName() const override
bool HasMetaDataKey(unsigned int slice, const std::string &key) const
Query a meta-data dictionary for the existence of a key.
std::vector< std::string > GetMetaDataKeys(unsigned int slice) const
Get the meta-data dictionary keys for a slice.
Image(Self::* MemberFunctionType)(itk::ImageIOBase *)
static std::vector< std::string > GetGDCMSeriesIDs(const PathType &directory, bool useSeriesDetails=false)
Get all the seriesIDs from a DICOM data set.
std::unique_ptr< detail::MemberFunctionFactory< MemberFunctionType > > m_MemberFactory
std::function< std::vector< std::string >(int)> m_pfGetMetaDataKeys
double GetSpacingWarningRelThreshold() const
const std::vector< PathType > & GetFileNames() const
std::string GetMetaData(unsigned int slice, const std::string &key) const
Get the value of a meta-data dictionary entry as a string.
std::function< std::string(int, const std::string &)> m_pfGetMetaData
Self & SetFileNames(const std::vector< PathType > &fileNames)
Self & SetSpacingWarningRelThreshold(double spacingWarningRelThreshold)
static std::vector< PathType > GetGDCMSeriesFileNames(const PathType &directory, const std::string &seriesID="", bool useSeriesDetails=false, bool recursive=false, bool loadSequences=false)
Generate a sequence of filenames from a directory with a DICOM data set and a series ID.
The Image class for SimpleITK.
Definition sitkImage.h:77
std::string PathType
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...
PixelIDValueEnum
Enumerated values of pixelIDs.
#define SITKIO_EXPORT
Definition sitkIO.h:33