Unable to correctly stream bytes from DICOM-WADO servers #3253
Unanswered
kchawla-pi
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
DICOM is a file format used by MRI scanners to store MRIs and metadata.
DICOM servers which serve DICOM images over HTTP are expected to adhere to the WADO Specification for DICOM retrieval.
When I use requests with requests-toolbelt's
MultipartDecoder
I can successfully retrieve DICOMs with a streaming response.When I use
httpx
's streaming method, the parts received are invalid DICOMs.Unfortunately, I could not find public access WADO server to help you test this, hopefully you can find one.
How do I fix this?
Here is the Python code to reproduce.
In the code, each
part_
should be bytes for a single DICOM file.This is the error:
force=True gives an incomplete file and metadata.
Problems
httpx
's async stream object. The MultipartDecoder() provided by requests-toolbelt works withrequests.Response()
object but not withhttpx.Response()
object. While each file is ultimately 50-100KB, the entire response is 1-2GB so reading the whole response content to use it with the requests' decoder is a slow process.async_wado()
, it seems I need to decode thepart_
which is in bytes, btu can't figure out how/with what to do it.Beta Was this translation helpful? Give feedback.
All reactions