I know I can view a dicom file using following code:
import dicom
from dicom.contrib.pydicom_PIL import show_PIL
f = "CT-MONO2-8-abdo.dcm"
ds = dicom.read_file(f, force=True)
show_PIL(ds)
However, how can I extract and view all frames from a multi-frame DICOM file? I tried using above code but got following error:
File "/home/auser/.local/lib/python3.5/site-packages/dicom/dataset.py", line 399, in _get_pixel_array
raise NotImplementedError("Pixel Data is compressed in a format pydicom does not yet handle. Cannot return array")
NotImplementedError: Pixel Data is compressed in a format pydicom does not yet handle. Cannot return array
I had tried with some multi-frame files located at http://www.barre.nom.fr/medical/samples/. The pixel size etc are available for these files.
How can I extract and/or view different frames of a multi-frame DICOM file?
Edit: Following command using gdcm works on Linux to convert these to uncompressed file:
$ gdcmconv --raw compressed.dcm uncompressed.dcm
(I used http://www.barre.nom.fr/medical/samples/files/US-PAL-8-10x-echo.gz file after extraction).
This is then read by python code above but that shows only first frame. How can I extract and view other frames?
pydicom supports reading pixel data. Refer this documentation.
About pixel_array
Document also explains about viewing images at http://pydicom.readthedocs.io/en/stable/viewing_images.html.
As explained in error message (and by @kritzel_sw in comment) the pydicom does not support the Transfer Syntax of source image yet. Change the Transfer Syntax using some other tool before attempting to extract the frames.
Another helpful blog of Rony http://dicomiseasy.blogspot.in/2012/08/chapter-12-pixel-data.html
Also check this Stack Overflow question; it is about old version but may be helpful.