Pixel Data and ds.Pixel_array issue

419 views
Skip to first unread message

Les Wub

unread,
Feb 14, 2020, 3:29:19 PM2/14/20
to pydicom
I am trying import dicom CT images but I keep getting this error 

import pydicom 
import numpy 
import PIL

from pydicom import dcmread

ds = dcmread('image-000001.dcm')

#raw pixel data
##ds.PixelData

ds.pixel_array

NotImplementedError                       Traceback (most recent call last)
<ipython-input-13-6b49465640e8> in <module>
     10 ##ds.PixelData
     11 
---> 12 ds.pixel_array

~\Anaconda3\lib\site-packages\pydicom\dataset.py in pixel_array(self)
   1621             :class:`numpy.ndarray`.
   1622         """
-> 1623         self.convert_pixel_data()
   1624         return self._pixel_array
   1625 

~\Anaconda3\lib\site-packages\pydicom\dataset.py in convert_pixel_data(self, handler_name)
   1330             self._convert_pixel_data_using_handler(handler_name)
   1331         else:
-> 1332             self._convert_pixel_data_without_handler()
   1333 
   1334     def _convert_pixel_data_using_handler(self, name):

~\Anaconda3\lib\site-packages\pydicom\dataset.py in _convert_pixel_data_without_handler(self)
   1440             .format(", ".join([str(hh) for hh in available_handlers]))
   1441         )
-> 1442         raise last_exception
   1443 
   1444     def _do_pixel_data_conversion(self, handler):

~\Anaconda3\lib\site-packages\pydicom\dataset.py in _convert_pixel_data_without_handler(self)
   1420         for handler in available_handlers:
   1421             try:
-> 1422                 self._do_pixel_data_conversion(handler)
   1423                 return
   1424             except Exception as exc:

~\Anaconda3\lib\site-packages\pydicom\dataset.py in _do_pixel_data_conversion(self, handler)
   1447         # Use the handler to get a 1D numpy array of the pixel data
   1448         # Will raise an exception if no pixel data element
-> 1449         arr = handler.get_pixeldata(self)
   1450         self._pixel_array = reshape_pixel_array(self, arr)
   1451 

~\Anaconda3\lib\site-packages\pydicom\pixel_data_handlers\pillow_handler.py in get_pixeldata(ds)
    132                "Pillow lacks the jpeg 2000 decoder plugin"
    133                .format(transfer_syntax.name))
--> 134         raise NotImplementedError(msg)
    135 
    136     if transfer_syntax not in PillowSupportedTransferSyntaxes:

NotImplementedError: this transfer syntax JPEG 2000 Image Compression, can not be read because Pillow lacks the jpeg 2000 decoder plugin




Peter Brunnengräber

unread,
Feb 26, 2020, 9:44:38 AM2/26/20
to pydicom
Hello Les,
  So the error message here should be self-explanatory...  The pixel data is compressed with JPEG 2000 and that is not supported in the decoder for that method.  I would suggest the quickest path would be to use something like the dcmtk tools to covert it to LittleEndianExplicit before you attempt to load it.

-Cheers, Peter.


On Friday, February 14, 2020 at 3:29:19 PM UTC-5, Les Wub wrote:
I am trying import dicom CT images but I keep getting this error 

Les Wub

unread,
Feb 26, 2020, 2:16:16 PM2/26/20
to pydicom
Thank you I will try it and get back to it. I found out some dicom images use Big Endian from older hardware on CT scanners but the newer ones use Little Endian it should be a simple fix now 

- Les 

Peter Brunnengräber

unread,
Feb 26, 2020, 2:46:54 PM2/26/20
to pydicom
Hi Les,
  That is correct... and not just CT scanners, but many older (typically unix) systems running RISC CPUs (especially Sun based gear) would be.  I would recommend you look here> working_with_pixel_data
Reply all
Reply to author
Forward
0 new messages