我不明白 sitk.ReadImage 是否可以读取图像列表?我没有找到一个示例来说明如何将图像列表输入到函数中。但在功能文档中它说:
ReadImage(**VectorString fileNames**, itk::simple::PixelIDValueEnum outputPixelType) -> Image
ReadImage(std::string const & filename, itk::simple::PixelIDValueEnum outputPixelType) -> Image
ReadImage is a procedural interface to the ImageSeriesReader class which is convenient for most image reading tasks.
Note that when reading a series of images that have meta-data
associated with them (e.g. a DICOM series) the resulting image will
have an empty meta-data dictionary. It is possible to programmatically
add a meta-data dictionary to the compounded image by reading in one
or more images from the series using the ImageFileReader class,
analyzing the meta-dictionary associated with each of those images and
creating one that is relevant for the compounded image.
因此,从文档看来,这是可能的。谁能给我一个简单的例子。
编辑:我尝试了以下方法:
sitk.ReadImage(['volume00001.mhd','volume00002.mhd'])
但这是我得到的错误:
RuntimeErrorTraceback (most recent call last)
<ipython-input-42-85abf82c3afa> in <module>()
1 files = [f for f in os.listdir('.') if 'mhd' in f]
2 print(sorted_files[1:25])
----> 3 sitk.ReadImage(['volume00001.mhd','volume00002.mhd'])
/gpfs/bbp.cscs.ch/home/amsalem/anaconda2/lib/python2.7/site-packages/SimpleITK/SimpleITK.pyc in ReadImage(*args)
8330
8331 """
-> 8332 return _SimpleITK.ReadImage(*args)
8333 class HashImageFilter(ProcessObject):
8334 """
RuntimeError: Exception thrown in SimpleITK ReadImage: /tmp/SimpleITK/Code/IO/src/sitkImageSeriesReader.cxx:145:
sitk::ERROR: The file in the series have unsupported 3 dimensions.
谢谢。