I'm trying get all images in a multi-frame DICOM file. Right now I was successfully able to see and save a single image in a single-frame DICOM file, by using the pydicom
and matplotlib
libraries, like so:
filename = pydicom.data.data_manager.get_files(*base folder path*,*dicom filename*)[0]
ds = pydicom.dcmread(filename)
plt.imshow(ds.pixel_array, cmap=plt.cm.bone)
plt.show()
Now, I wanted to be able to see and save all images in a multi-frame DICOM image, but by using this snippet of code, it returns the following error:
TypeError: Invalid shape (150, 768, 1024, 3) for image data
I've searched a bit on the web, but couldn't seem to find anything to enlighten me. I wanted to know if someone has passed through this, and what's the best way to overcome it, and be able to get all images in a multi-frame DICOM file.
Note: The similar questions found on Stack Overflow are either outdated or do not comply with what I want.