Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dicom image reading
Hi all

I am trying to read a dicom image. The image has 49 frames. The PixelData has some bytes in the array. But the pixel_array is not working. Please guide me on how to display the multiple frames from .dcm image?
import matplotlib.pyplot as plt
import pydicom

dataset = pydicom.dcmread('bscan.dcm')
print("Storage type.....:", dataset.SOPClassUID)

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)

The above code gives the following output and error
Image size.......: 496 x 512, 24887296 bytes Pixel spacing....: [0.011606, 0.003872]
AttributeError: Unable to convert the pixel data as the following required elements are missing from the dataset: SamplesPerPixel
Thank you in advance for the help
Thank you for formatting my question on forum. I am using this forum for first time. I will ensure the same next time. I will check the entire error and edit it soon. Apologies.
No need for apologies. This was just a friendly reminder.

Possibly Related Threads…
Thread Author Replies Views Last Post
  DICOM Structure Files jcozzi1 1 912 Jul-20-2019, 07:40 AM
Last Post: scidam
  Trying to invert DICOM image with Python 3.6 newmanf 1 3,631 Feb-28-2018, 08:49 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020