Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dicom image reading
#1
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)
print()

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)

plt.imshow(dataset.pixel_array)
plt.show()
The above code gives the following output and error
Output:
Image size.......: 496 x 512, 24887296 bytes Pixel spacing....: [0.011606, 0.003872]
Error:
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
Reply
#2
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.
Reply
#3
No need for apologies. This was just a friendly reminder.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Dicom Files spillai 2 1,984 Oct-12-2021, 06:00 PM
Last Post: menator01
  DICOM Structure Files jcozzi1 1 2,220 Jul-20-2019, 07:40 AM
Last Post: scidam
  Trying to invert DICOM image with Python 3.6 newmanf 1 5,650 Feb-28-2018, 08:49 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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