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"
26
27namespace itk::simple
28{
29
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 void
95 SetMetaDataDictionaryArrayUpdate(bool metaDataDictionaryArrayUpdate)
96 {
97 this->m_MetaDataDictionaryArrayUpdate = metaDataDictionaryArrayUpdate;
98 }
99 bool
104
105
107 void
112 void
117
118
149 static std::vector<PathType>
151 const std::string & seriesID = "",
152 bool useSeriesDetails = false,
153 bool recursive = false,
154 bool loadSequences = false,
155 bool failOnAmbiguousOrdering = true);
156
167 static std::vector<std::string>
168 GetGDCMSeriesIDs(const PathType & directory, bool useSeriesDetails = false);
169
170 void
171 SetFileNames(const std::vector<PathType> & fileNames);
172 const std::vector<PathType> &
174
176 void
177 SetSpacingWarningRelThreshold(double spacingWarningRelThreshold);
178 double
180
186 void
187 SetForceOrthogonalDirection(bool forceOrthogonalDirection);
188 bool
190 void
192 void
194
199 void
200 SetReverseOrder(bool reverseOrder);
201 bool
203 void
205 void
207
208 Image
209 Execute() override;
210
225 std::vector<std::string>
226 GetMetaDataKeys(unsigned int slice) const
227 {
228 return this->m_pfGetMetaDataKeys(slice);
229 }
230
233 bool
234 HasMetaDataKey(unsigned int slice, const std::string & key) const
235 {
236 return this->m_pfHasMetaDataKey(slice, key);
237 }
238
247 std::string
248 GetMetaData(unsigned int slice, const std::string & key) const
249 {
250 return this->m_pfGetMetaData(slice, key);
251 }
252
253
254protected:
255 template <class TImageType>
256 Image
258
259private:
260 // function pointer type
262
263 // friend to get access to executeInternal member
267
268
269 std::function<std::vector<std::string>(int)> m_pfGetMetaDataKeys;
270 std::function<bool(int, const std::string &)> m_pfHasMetaDataKey;
271 std::function<std::string(int, const std::string &)> m_pfGetMetaData;
272
273 // Holder of a process object for active measurements
274 std::unique_ptr<itk::ProcessObject, ProcessObjectDeleter> m_Filter;
275
276
277 std::vector<PathType> m_FileNames;
278
280
282
284
285 bool m_ReverseOrder{ false };
286};
287
313ReadImage(const std::vector<PathType> & fileNames,
314 PixelIDValueEnum outputPixelType = sitkUnknown,
315 const std::string & imageIO = "");
316} // namespace itk::simple
317
318#endif
std::string ToString() const override
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.
bool GetForceOrthogonalDirection() const
std::function< std::vector< std::string >(int)> m_pfGetMetaDataKeys
void SetForceOrthogonalDirection(bool forceOrthogonalDirection)
void SetSpacingWarningRelThreshold(double spacingWarningRelThreshold)
double GetSpacingWarningRelThreshold() const
const std::vector< PathType > & GetFileNames() const
static const detail::MemberFunctionFactory< MemberFunctionType > & GetMemberFunctionFactory()
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
void SetFileNames(const std::vector< PathType > &fileNames)
void SetMetaDataDictionaryArrayUpdate(bool metaDataDictionaryArrayUpdate)
static std::vector< PathType > GetGDCMSeriesFileNames(const PathType &directory, const std::string &seriesID="", bool useSeriesDetails=false, bool recursive=false, bool loadSequences=false, bool failOnAmbiguousOrdering=true)
Generate a sequence of filenames from a directory with a DICOM data set and a series ID.
std::unique_ptr< itk::ProcessObject, ProcessObjectDeleter > m_Filter
void SetReverseOrder(bool reverseOrder)
The Image class for SimpleITK.
Definition sitkImage.h:77
A class used to instantiate and generate function object to templated member functions.
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