将3D DICOM卷读入Python会显示“ sitk :: ERROR:系列文件中不支持3维”

时间:2019-12-13 18:14:26

标签: python dicom simpleitk

我在CentOS 7的Anaconda Spyder的Python 3.7.3上使用SimpleITK。我还安装了Aliza,并试图将样本卷/usr/share/aliza/datasets/DICOM/00_MR/PS_0.dcm读入Python用numpy处理它。但是下面的Python代码。

import SimpleITK as sitk

reader = sitk.ImageSeriesReader()
dicom_names = reader.GetGDCMSeriesFileNames( inputSeriesName )
reader.SetFileNames(dicom_names)
image = reader.Execute()

产生

Traceback (most recent call last):

  File "<ipython-input-38-8c1737986203>", line 1, in <module>
    image = reader.Execute()

  File "/home/peter/anaconda3/lib/python3.7/site-packages/SimpleITK/SimpleITK.py", line 8473, in Execute
    return _SimpleITK.ImageSeriesReader_Execute(self)

RuntimeError: Exception thrown in SimpleITK ImageSeriesReader_Execute: ../../Code/IO/src/sitkImageSeriesReader.cxx:163:
sitk::ERROR: The file in the series have unsupported 3 dimensions.

我可以读取一系列2D图像,这些图像可以堆叠成一个体积,但并非所有DICOM体积都以这种方式出现

1 个答案:

答案 0 :(得分:1)

我猜想,当您使用ImageSeriesReader类时,SimpleITK需要一系列2d图像。由于您没有一系列图像,而只有一个3d图像,因此请尝试使用ReadImage函数,如下所示:

import SimpleITK as sitk
image = sitk.ReadImage('/usr/share/aliza/datasets/DICOM/00_MR/PS_0.dcm' )