for person in range(0, len(dirs1)):
for root, dirs, files in os.walk(os.path.join(path, dirs1[person])):
dcmfiles = [_ for _ in files if _.endswith('.dcm')]
for dcmfile in dcmfiles:
dcm_image = pydicom.read_file(os.path.join(root, dcmfile))
img = dcm_image.pixel_array
img2 = dcm_image.ImagePosition # Error in this line
为了:
(0020, 0032) Image Position (Patient) DS: ['-166.000000', '-171.699997', '-207.500000']
我的问题是我想要“图像位置(患者)”结构作为一个数组或它的一个元素(如'-207.500000')。当我运行代码时,会出现这个错误:给的 img2 = dcm_image.ImagePosition
行AttributeError: 'FileDataset' object has no attribute 'ImagePosition'