Python 3.x dicom文件读取错误:';运行时错误:生成器引发停止迭代';

Python 3.x dicom文件读取错误:';运行时错误:生成器引发停止迭代';,python-3.x,pydicom,Python 3.x,Pydicom,下面是python代码 def load_scan(path): print(path) slices = [dicom.read_file(path + '/' + s) for s in os.listdir(path)] slices.sort(key = lambda x: int(x.InstanceNumber)) try: slice_thickness = np.abs(slices[0].ImagePositionPatient[2] - slices[1].Image

下面是python代码

def load_scan(path):
print(path)
slices = [dicom.read_file(path + '/' + s) for s in os.listdir(path)]
slices.sort(key = lambda x: int(x.InstanceNumber))
try:
    slice_thickness = np.abs(slices[0].ImagePositionPatient[2] - slices[1].ImagePositionPatient[2])
except:
    slice_thickness = np.abs(slices[0].SliceLocation - slices[1].SliceLocation)

for s in slices:
    s.SliceThickness = slice_thickness

return slices


patient = load_scan(filepath)
我从中下载了示例dicom文件


任何帮助都会很好。。。如何读取dicom文件,然后对其进行处理。

查找filereader.py的位置。您可以从回溯本身看到目录

raisestopIteration
替换为
return
,您就可以开始了


您的filereader.py目录如下所示:
/usr/local/lib/python3.7/site packages/dicom/filereader.py

这是一个python 3.7错误,可能
dicom
还不支持3.7