DICOM Multi-frame

379 views
Skip to first unread message

mat...@c2ctsis.com

unread,
May 18, 2009, 7:42:12 AM5/18/09
to pydicom
Hi folks!

I'm trying to extract frames from multi-frame dicom file and I'm
getting this:
(<type 'exceptions.NotImplementedError'>, NotImplementedError('Pixel
Data is compressed in a format pydicom does not yet handle. Cannot
return array',), <traceback object at 0x00EF4648>)

I'm using pydicom 0.9.2 :?

This is a piece of code:
....
dicomFile = dicom.ReadFile("test.dcm")
fileArray = dicomFile.PixelArray
first_frame = fileArray[0]
...

mat...@c2ctsis.com

unread,
May 18, 2009, 11:25:56 AM5/18/09
to pydicom
I've tried with pydicom 0.9.3 (SVN version) and I get same error

Darcy Mason

unread,
May 18, 2009, 9:21:01 PM5/18/09
to pydicom
> On 18 mayo, 13:42, "mat...@c2ctsis.com" <mat...@c2ctsis.com> wrote:
>
> > I'm trying to extract frames from multi-frame dicom file and I'm
> > getting this:
> > (<type 'exceptions.NotImplementedError'>, NotImplementedError('Pixel
> > Data is compressed in a format pydicom does not yet handle. Cannot
> > return array',), <traceback object at 0x00EF4648>)
> > ...
> > dicomFile = dicom.ReadFile("test.dcm")
> > fileArray = dicomFile.PixelArray
> > first_frame = fileArray[0]

PixelArray only handles certain transfer syntaxes, and to be safe,
throws NotImplementedError for those that haven't been coded and
tested.
Most likely this means the pixel data is JPEG compressed. pydicom can
pass along compressed pixel data (the PixelData attribute -- just a
string of bytes), but does not handle decompressing it (like
PixelArray would have to do to properly shape it).

Which transfer syntax do you have? (print dicomFile.TransferSyntaxUID
after reading the file). The PIL library can handle some JPEG formats
-- I looked into this once [1] and also did some preliminary work to
handle the "fragments" that the compressed files come in [2], but
never finished that work.

Probably the most realistic solution for now is to convert the files
to non-compressed formats using other tools, e.g. dcmdjpeg from dcmtk
[3], and then work on the converted files with pydicom.

Hope that helps,
-Darcy

[1] http://code.google.com/p/pydicom/issues/detail?id=16&can=1
[2] http://code.google.com/p/pydicom/source/browse/trunk/source/dicom/encaps.py
[3] http://support.dcmtk.org/docs/dcmdjpeg.html


Reply all
Reply to author
Forward
0 new messages