我正在打开样例dicom文件,但是我得到了这个错误:WinError 267目录名无效。
代码如下: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()