0

如何使用 pydicom 显示没有 CT(轮廓)的图像?

目前它显示图像,但它包括轮廓,我想显示根图像,如果可以的话,没有根图像的轮廓

这是我的参考代码,但我在控制台中进行了搜索测试

import matplotlib.pyplot as plt
import pydicom
#from pydicom.data import get_testdata_files

PathDicom = "./Dicoms/"
lstFilesDCM = []  # create an empty list
Pattient = []  # create an empty list
for dirName, subdirList, fileList in os.walk(PathDicom):
    for filename in fileList:
        if ".dcm" in filename.lower():  # check whether the file's DICOM
            lstFilesDCM.append(os.path.join(dirName,filename))
            dataset = pydicom.dcmread(os.path.join(dirName,filename))
            print(__doc__)
#            filename = get_testdata_files(os.path.join(dirName,filename))[0]
#            dataset = pydicom.dcmread(filename)

            # Normal mode:
            print()
            print("Filename.........:", filename)
            print("Storage type.....:", dataset.SOPClassUID)
            print()

            pat_name = dataset.PatientName
            display_name = pat_name.family_name + ", " + pat_name.given_name
            print("Patient's name...:", display_name)
            print("Patient id.......:", dataset.PatientID)
            print("Study id.......:", dataset.StudyID)
            print("Modality.........:", dataset.Modality)
            print("Study Date.......:", dataset.StudyDate)
            print("Contour..........:", dataset.dir("contour"))
            #espesor de corte
            print("Slice Thickness..:", dataset.SliceThickness)

            if 'PixelData' in dataset:
                rows = int(dataset.Rows)
                cols = int(dataset.Columns)
                print("Image size.......: {rows:d} x {cols:d}, {size:d} bytes".format(
                    rows=rows, cols=cols, size=len(dataset.PixelData)))
                if 'PixelSpacing' in dataset:
                    print("Pixel spacing....:", dataset.PixelSpacing)

            # use .get() if not sure the item exists, and want a default value if missing
            print("Slice location...:", dataset.get('SliceLocation', "(missing)"))
            #plot the image with contouring
            plt.imshow(dataset.pixel_array, cmap=plt.cm.bone)
4

1 回答 1

0

我建议您查看dicompyler以获取有关如何同时显示图像和轮廓的示例。它使用 wxPython 进行显示,但如果需要,您可以将这些概念转换为其他图形库。或者,也许您可​​以根据需要将自定义插件添加到 dicompyler。

于 2018-04-24T11:59:13.680 回答