No available image handler could decode this transfer syntax JPEG Lossless when read DICOM and ploting using matplotlib

后端 未结 3 690
旧巷少年郎
旧巷少年郎 2021-01-16 07:11

When i use pydicom in python3.6, there are some problem:

import pydicom
import matplotlib.pyplot as plt
import os
import pylab

filePath = \"/Users/zhuangrui         


        
相关标签:
3条回答
  • 2021-01-16 07:45

    With pydicom, you need an appropriate image handler also installed to handle compressed image types.

    For JPEG lossless, in theory the following should work: jpeg_ls, gdcm, or Pillow with jpeg plugin. All of these also require Numpy to be installed. See the discussion at https://github.com/pydicom/pydicom/issues/532.

    There is also a pull request in progress to add more descriptive error messages for what image handlers are needed for different images.

    0 讨论(0)
  • 2021-01-16 07:52

    Problem:

    I was trying to read medical images with .dcm extension. But was getting an error on Windows as well as on Ubuntu. I find a solution which will work on both the machined.

    The error I got on Ubuntu is: NotImplementedError: this transfer syntax JPEG 2000 Image Compression (Lossless Only), can not be read because Pillow lacks the jpeg 2000 decoder plugin

    (Note for Windows I was getting a different error but I am sure it's because of the same issue i.e. Pillow does not support JPEG 2000 format)

    Platforma Information:

    1. I am using: Python 3.6, Anaconda and Ubuntu, 15 GB RAM

    RAM is important:

    The solution I applied is the same as Ali explained above. But I want to add this installation may take time (depending on RAM you are using). On ubuntu where I am using 15 GB RAM on Cloud platform taken less time and on Windows on a local machine having 4 GB RAM taken a lot of time.

    Solution

    1. Anaconda is necessary. Why? Please check the official doc of pydicom (https://pydicom.github.io/pydicom/dev/getting_started.html) its mentioned "To install pydicom along with image handlers for compressed pixel data, we encourage you to use Miniconda or Anaconda" (Note for Windows I was getting a different error)

    2. If you are using Ubuntu directly open Terminal. If you are using Windows then on Anaconda Navigator go to Environment from here start terminal. Execute the following commands on it:

      pip install -U git+https://github.com/pydicom/pydicom.git

      conda install pydicom --channel conda-forge

      conda install -c conda-forge gdcm

    Cross Check:

    Now use .dcm file for which we got the Error. Try to use the following code in Python notebook

    filename = 'FileName.dcm'
    ds = pydicom.dcmread(filename)
    plt.imshow(ds.pixel_array, cmap=plt.cm.bone) 
    

    It should print the output. Also try this code:

    ds.pixel_array
    

    This will give you the array containing values.

    0 讨论(0)
  • 2021-01-16 08:03

    I've faced with the same problem, after doing some research on the suggested link above. I've managed to solve it by updating to the latest pydicom module "1.2.0" and installing gdcm. You can update the pydicom with pip install -U git+https://github.com/pydicom/pydicom.git

    You can find the latest gdcm here and this link explains the installation.


    I use anaconda and it's easier to install the gdcm package and solve the problem. If you use anaconda just type inside from your environment: conda install pydicom --channel conda-forge to get pydicom's latest and

    conda install -c conda-forge gdcm
    

    to get the gdcm. This resolves the problem. Hope these will help.

    0 讨论(0)
提交回复
热议问题