> 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