Skip to main content
 首页 » 编程设计

python:[WinError 267] 目录名无效

2024年12月31日8wuhuacong

<分区>

我正在打开示例 dicom 文件,但出现此错误 [WinError 267] 目录名无效

我正在使用 anaconda,pydicom 1.1.0 a如果有人可以帮助我解决这个问题,或者甚至只是帮助我一般如何加载 DICOM 文件,我将不胜感激。

import numpy as np # linear algebra 
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) 
import pydicom 
import os 
import scipy.ndimage 
import matplotlib.pyplot as plt 
from skimage import measure, morphology 
from mpl_toolkits.mplot3d.art3d import Poly3DCollection 
 
# Some constants  
data_dir ="F:\\deep\\sample\\" 
patients = os.listdir(data_dir) 
 
for patient in patients[:1]: 
    path = data_dir + patient 
    slices = [dicom.read_file(path + '/' + s) for s in os.listdir(path)] 
    slices.sort(key = lambda x: int(x.ImagePositionPatient[2])) 
#the first slice 
plt.imshow(slices[0].pixel_array) 
plt.show()