Reading 3D DICOM volume into Python gives "sitk::ERROR: The file in the series have unsupported 3 dimensions"

Reading 3D DICOM volume into Python gives "sitk::ERROR: The file in the series have unsupported 3 dimensions"

我在 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 卷都是这样

我猜想当您使用 ImageSeriesReader class 时,SimpleITK 需要一系列二维图像。由于您没有一系列图像,而是单个 3d 图像,请尝试使用 ReadImage 函数,如下所示:

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