我是图像处理的新手,想知道如何使用 python 预处理 dicom 图像。我正在关注以下教程:python 中的 dicom我的数据中没有 SliceThickness 属性。我该如何计算?
这是我拥有的示例数据集:
这是我的代码:
import pydicom
import os
import numpy
from matplotlib import pyplot, cm
PathDicom = "xyz\images"
lstFilesDCM = [] # creating an empty list
for dirName, subdirList, fileList in os.walk(PathDicom):
for filename in fileList:
if ".dcm" in filename.lower(): # checking whether the file's DICOM
lstFilesDCM.append(os.path.join(dirName,filename))
RefDs = pydicom.read_file(lstFilesDCM[0])
ConstPixelDims = (int(RefDs.Rows), int(RefDs.Columns), len(lstFilesDCM)) #Load dimensions based on the number of rows, columns, and slices (along the Z axis)
ConstPixelSpacing = (float(RefDs.PixelSpacing[0]), float(RefDs.PixelSpacing[1]), float(RefDs.SliceThickness)) # Load spacing values (in mm)
这是我得到的错误:
'FileDataset' object has no attribute 'SliceThickness'
白衣染霜花
扬帆大鱼
相关分类