New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open JPEG Lossless image #532
Comments
This probably means that you do not have a package installed that can handle this syntax. |
Just installed pillow and gdcm (numpy already installed) but I didn't find a way to install CharPyLS on Mac. I tried without CharPyLS and it throws the same error. |
Hm, I just checked the code, and |
Thank you for your answer. I just checked and
I have this error: |
Sorry for the late answer - but I don't have a solution. Sounds like a problem with the version of |
There is also the option to install gdcm using conda-forge (see https://pydicom.github.io/pydicom/dev/getting_started.html) -this works at least under Linux and Windows. |
Hi @alexattia, hi @mrbean-bremen, the hint with gdcm via conda-forge works out for that file format/transfer syntax. CharPyLS/pillow can't read A little heads up regarding gdcm (on mac?): the conda-forge gdcm only works in an |
@glemaitre - do you know anything about this conda-forge problem? |
@dalcacer could you open a PR with a minimum example triggering the crash. |
Just in case, a little more information.
when the test are run. |
Could you upgrade pydicom from conda-forge with the new version 1.0.1 |
Could you give a small snippet of code to trigger that error |
First of all, thanks for the conda-forge release :) I could fork and link the recipe with the according changes. |
I have encountered the above error many times ( PyThreadState_Get: no current thread ) gdcm's python wrapper has always been difficult for me to use because this issue appears on some builds/os's but not others, or I will get a crash on exit (a "double free" of something). Other times, it works perfectly. Again, the issue is almost always that I missed some step of compiling/installing correctly. |
Looks like #513 is a similar issue. |
Update to 1.2.0, solved the problem. |
Hi @Liu0329 , I met the same problem, but could not solve this problem even I have already update to 1.2.0 dev0 |
@fredaTian, what supporting libraries do you have installed? (see, e.g. second comment in this issue) |
And what's your transfer syntax UID? from pydicom import dcmread
ds = dcmread('/path/to/file')
print(ds.file_meta.TransferSyntaxUID) |
And see the table here; https://pydicom.github.io/pydicom/dev/image_data_handlers.html |
I fixed the issue by updating pydicom to 1.2.0dev() then restarting my kernel. |
I found that GDCM installation was missing compiling/importing it's libs for python3. Made a little wrapper, hope it helps: https://github.com/HealthplusAI/python3-gdcm after just do |
@Luxas98, I think that could be helpful for users -- perhaps we could add a link to python3-gdcm to the pydicom documentation at the page I linked above. Otherwise, I think we can close this issue. While we can try to point people in the right direction with errors like the ones discussed above, generally this is beyond the scope of pydicom. There are so many possible variations in platform, install, compiling, etc. as has been noted above, that the user really has to take that on themselves if using these external libraries. And the pydicom google group can be used to reach a broader user base for possible help. |
I had a similar issue and after installing gdcm (CentOS) I am now getting 'utf-8' codec can't decode byte 0xa8 in position 24806: invalid start byte error I tried loading a few different DICOM images and seem to always get utf8 errors. |
Could you start a new issue and attach an anonymised version of an example file please? |
I also have the problem using pydicom 1.2.0 dev and cannot solve it. |
@fredaTian |
Transfer syntax: 1.2.840.10008.1.2.4.70 (JPEGLossless Non-hierarchical, first-order prediction), 1 frame, 2021 x 2021, 1 sample/pixel, 16/14 bit, with 3 LUTs, overlay and image icon. Pixel Data element starts at offset 616798, has BOT with length 4, value 0. Image data starts at offset 616830 and ends at 4700086 (length 4083257). JPG has SOF11 marker, format matches transfer syntax, 2021x2021, 1 channel, 16 bit precision on input sample. Dataset can be decompressed with DCMTK's dcmdjpeg. @Liu0329 I don't have any issues in a new conda virtualenv with python 3.7, numpy 1.15.2, gdcm 2.8.4 and pydicom 1.2 running on ubuntu 18.04. Could you post a minimal working example and your system/package versions? The following works for me: from pydicom import dcmread
ds = dcmread('path/to/dataset')
arr = ds.pixel_array Also, is it OK if we add your dataset as one of our testing datasets? |
OK--thanks
…On Fri, May 10, 2019 at 9:58 AM mrbean-bremen ***@***.***> wrote:
Ok, most likely Pillow cannot handle your image in this case.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#532 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABLWAON7EYNEAT6EOFZ35ULPUWERRANCNFSM4EL2OUGQ>
.
|
I guess I was mostly confused by the error message--would be better if it
could have said what was not implemented.
…On Fri, May 10, 2019 at 10:00 AM mrbean-bremen ***@***.***> wrote:
Here
<https://pydicom.github.io/pydicom/dev/image_data_handlers.html#supported-transfer-syntaxes>
is a table what it can handle.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#532 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABLWAOJHCWQKF2FOQP6ZJFTPUWEXHANCNFSM4EL2OUGQ>
.
|
Well, it should log that - something along the lines in the original description. |
@darcymason - can we close this issue? I think it gets confusing with all the problems with unsupported transfer syntaxes and problems with GDCM mixed. Maybe we shall add some troubleshooting guide that explains this kind of problems in a more prominent place... |
yes may close
…On Fri, May 10, 2019 at 1:31 PM mrbean-bremen ***@***.***> wrote:
@darcymason <https://github.com/darcymason> - can we close this issue? I
think it gets confusing with all the problems with unsupported transfer
syntaxes and problems with GDCM mixed. Maybe we shall add some
troubleshooting guide that explains this kind of problems in a more
prominent place...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#532 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABLWAOIKURJGUC6UMTAZLELPUW5PVANCNFSM4EL2OUGQ>
.
|
@amandagb please don't upload non-anonymised datasets. I would suggest starting a new issue with an anonymised version of the dataset |
@scaramallion The dataset was anonymized by Orthanc, I simply forced it to be a "real looking" name with the faker package. If you'd like, I can force the name to be Anonymous. All PHI for HIPPA and GDPR was removed. |
@amandagb my apologies then, all the patient related info (name, ID, birthdate) seemed like it was from a real identity. |
@scaramallion I just finished re-creating the dataset with an anonymous name as you requested but it seems maybe the refresh lost my previous post....can you retrieve it somehow or do I have to re-type the issue? I have a new txt dicom file (which should be basically the same but with the name "Anonymous JPEGfailure" |
@amandagb's original comment:I'm having this same issue when trying to read the pixel array from a dicom sequence with transfer syntax '1.2.840.10008.1.2.4.70' (JPEG Lossless, Non-Hierarchical, First-Order Prediction (Process 14 [Selection Value 1]) ) The behavior is a bit complicated. The files are hosted on an Orthanc server, and I typically retrieve the files via the request (shown below), convert the file content to a bytes object, then feed it into pydicom. When I then try to access the pixel_array from the pydicom dataset, the kernel just dies (see Example Code Block 1). Alternatively, if I go through Chrome, and make the same request to download the file (type http://169.254.100.100:8042/instances/efd2303d-bd5b83e5-5656f3c1-31ece5f7-db2dfbbf/file into Chrome and get the attached dicom file (which I've re-defined as a txt file per Git file attachment requirements) ), then execute Example Code Block 2, I can access the pixel_array without any issues. Any insight into why this might be happening? I'm running Windows 10 with an Anaconda3 64bit install. I've attached my python=3.6.8 Example Code Block 1 import pydicom
import io
import requests
dcmInstance = 'http://169.254.100.100:8042/instances/efd2303d-bd5b83e5-5656f3c1-31ece5f7-db2dfbbf/file'
dcmFile = requests.get(dcmInstance)
dcmBytes = io.BytesIO(dcmFile.content)
ds = pydicom.dcmread(dcmBytes)
# Running this line will then kill the kernel
testArr = ds.pixel_array Example Code Block 2 import pydicom
ds = pydicom.dcmread(r'C:\Users\Downloads\aaf20e6f-f35f-4fb4-a52a-d257d2ccf4bc.txt')
testArr = ds.pixel_array |
I have a feeling it has to do with how the request contents are encoded or something. I'm not sure I understand how to use pydicom's I actually save the request contents (the dcmBytes object) to an actual dicom file. If I then re-read the file, I can access the pixel_array without problems. Is there any chance that there's a race condition where we're trying to access |
generator = generate_pixel_data(ds.PixelData, getattr(ds, 'NumberOfFrames', 1))
encoded_frame = next(generator) # each frame is a JPEG image
As far as I can tell |
Do you have the GDCM library installed? I have been burned by images compressed with that codec and the explanation from pydicom is not so clear.
Brad
… On Jul 20, 2020, at 7:09 PM, Amanda Gaudreau-Balderrama ***@***.***> wrote:
I have a feeling it has to do with how the request contents are encoded or something. I'm not sure I understand how to use pydicom's pydicom.encaps.generate_pixel_data but when I run this command:
pydicom.encaps.generate_pixel_data(dcmBytes)
I don't have an issue. I don't understand how to use this to get the actual pixel data out, though...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
We'd love to improve the documentation if you'd like to explain where/how it's deficient |
SOrry. What I mean is that occasionally DICOM images are stored in a compressed format, and the only library I have found that decompressed them is GDCM. But the error message when I don’t have GDCM installed is what is shown below—not that a codec is missing.
… On Jul 20, 2020, at 7:23 PM, scaramallion ***@***.***> wrote:
I have been burned by images compressed with that codec and the explanation from pydicom is not so clear.
We'd love to improve the documentation if you'd like to explain where/how it's deficient
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Yes, gdcm is installed. |
It might be a long shot, but you should probably try with the most recent release (v2.0) as well. |
Other parts of the dataset are accessible, and with other transfer syntax it works with the byte objects. For some reason just these files seem to kill the kernel when I try to access pixel_data. I’m not sure how generalizable it is. I’ll to do some more investigation tonight and post anything I figure out. |
Hmm, GDCM 2.8.4 doesn't have the in-memory pixel data decoding, so it'll be using Side note: I really hate debugging GDCM issues, it's such a pain to install |
No, I just get a regular exception: >>> import gdcm
>>> gdcm.Version_GetVersion()
'2.8.4'
>>> from pydicom import __version__
>>> __version__
'1.3.0'
>>> from pydicom import dcmread
>>> from io import BytesIO
>>> with open('532b.dcm', 'rb') as f:
... bs = BytesIO(f.read())
...
>>> ds = dcmread(bs)
>>> arr = ds.pixel_array
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../pydicom/dataset.py", line 1362, in pixel_array
self.convert_pixel_data()
File ".../pydicom/dataset.py", line 1308, in convert_pixel_data
raise last_exception
File ".../pydicom/dataset.py", line 1276, in convert_pixel_data
arr = handler.get_pixeldata(self)
File ".../pydicom/pixel_data_handlers/gdcm_handler.py", line 210, in get_pixeldata
raise TypeError("GDCM could not read DICOM image")
TypeError: GDCM could not read DICOM image Although that's a bug all on its own... |
I ultimately decided to just code a work around. With the versions and files I mentioned, I still get the python kernel just dying without any indication of the problem. I looked into pydicom's |
@scaramallion, I finally got to the root of the issue. As you mentioned, the ds.filename is used in the gdcm_handler, lines 208 - 211. While your environment somehow gracefully handles the error, mine kills the kernel
It seems what's happening is that since As best I can tell, you can't use the ImageReader directly for a bytes object. Seems like you'd have to use a gdcm.Fragment (see this Stackoverflow post which gives C# code). Am I correct, then, in saying that for the gdcm supported syntaxes (basically all the JPEG ones), you can't pass in a Bytes object? |
@amandagb this should be fixed in |
@scaramallion I find it can be really helpful to make it easier for people to test these sorts of things to create a dev release on pypi. Not sure if that's something that is easy to do for pydicom... But it makes user testing super simple... |
@scaramallion let me see what I can do. Is the best way to just clone from github and add that reference to pydicom to my path? I'm accustomed to using conda to set up environments so I'm not too clear on how to test the |
|
Description
Hello,
I am trying to use pydicom to open images in a dicom directory.
But when I try to open an image, I have this error :
NotImplementedError: No available image handler could decode this transfer syntax JPEG Lossless, Non-Hierarchical, First-Order Prediction (Process 14 [Selection Value 1])
Steps/Code to Reproduce
I run this :
and it output the NotImplemented Error
Versions
I have tried with pydicom 1.0.
Do you have any idea how to solve this error or another package to open these images ?
Thank you very much in advance.
The text was updated successfully, but these errors were encountered: