0

How can I display image without CT (contouring) with pydicom?

Currently it shows the image but it includes the contouring and I would like to show the root image and if it could, the contouring without the root image

and here is my code for references but i tested in console for search

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)

1 Answers1

0

I'd suggest you look at dicompyler for an example of how to display both images and contours. It is using wxPython for display, but you could translate the concepts to other graphical libraries if you need to. Or perhaps you could add a custom plug-in to dicompyler for your needs.

darcymason
  • 1,223
  • 6
  • 9