In [ ]:
# Read compressed dicom without success

In [28]:
import SimpleITK as sitk
from pathlib import Path
import pydicom

pydicom.__version__


Out[28]:
'1.3.0'

In [20]:
pth = r"G:/Můj disk/data/biomedical/pigs/transplantation/Tx19D/Tx019D.CT.ThrAbd2FAdult.7.101.2020.06.02.20.25.52.269.43011157.dcm"
pth = Path(pth)
pth.exists()
# sitk.ReadImage(str(pth))


Out[20]:
True

In [24]:
dataset = pydicom.dcmread(str(pth))
# dataset.pixel_array

In [27]:
dataset.pixel_array.to_bytes()


---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
~\Miniconda3\envs\lisa3qt5\lib\site-packages\pydicom\pixel_data_handlers\pillow_handler.py in get_pixeldata(dicom_dataset)
    196                 fio = io.BytesIO(pixel_data)
--> 197                 decompressed_image = Image.open(fio)
    198             except IOError as e:

~\Miniconda3\envs\lisa3qt5\lib\site-packages\PIL\Image.py in open(fp, mode)
   2817         warnings.warn(message)
-> 2818     raise IOError("cannot identify image file %r" % (filename if filename else fp))
   2819 

OSError: cannot identify image file <_io.BytesIO object at 0x000002F1052F7C50>

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-27-cc261e8b1d59> in <module>
----> 1 dataset.pixel_array.to_bytes()

~\Miniconda3\envs\lisa3qt5\lib\site-packages\pydicom\dataset.py in pixel_array(self)
   1360             The Pixel Data (7FE0,0010) as a NumPy ndarray.
   1361         """
-> 1362         self.convert_pixel_data()
   1363         return self._pixel_array
   1364 

~\Miniconda3\envs\lisa3qt5\lib\site-packages\pydicom\dataset.py in convert_pixel_data(self)
   1306         )
   1307 
-> 1308         raise last_exception
   1309 
   1310     def decompress(self):

~\Miniconda3\envs\lisa3qt5\lib\site-packages\pydicom\dataset.py in convert_pixel_data(self)
   1274             try:
   1275                 # Use the handler to get a 1D numpy array of the pixel data
-> 1276                 arr = handler.get_pixeldata(self)
   1277                 self._pixel_array = reshape_pixel_array(self, arr)
   1278 

~\Miniconda3\envs\lisa3qt5\lib\site-packages\pydicom\pixel_data_handlers\pillow_handler.py in get_pixeldata(dicom_dataset)
    197                 decompressed_image = Image.open(fio)
    198             except IOError as e:
--> 199                 raise NotImplementedError(e.strerror)
    200             UncompressedPixelData.extend(decompressed_image.tobytes())
    201     except Exception:

NotImplementedError: None