Repository navigation
Add opt in force_read option for non-conformant DICOM files - #132
Open
pradeeppeddineni wants to merge 1 commit into
Open
pradeeppeddineni wants to merge 1 commit into
pradeeppeddineni wants to merge 1 commit into
Conversation
Some origin servers send instances without the preamble and DICM prefix, so pydicom raises InvalidDicomError. Add an optional force_read argument to DICOMwebClient (default False) and a set_force_read() method, and pass it on as force to pydicom.dcmread() for retrieved instances. Fixes ImagingDataCommons#89
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Fixes #89
This adds an optional force_read argument to DICOMwebClient (default False) and a set_force_read() method. When it's on, retrieved instances are read with pydicom.dcmread(..., force=True), so files from servers that leave out the preamble and DICM prefix can still be loaded. With the default nothing changes and those files still raise InvalidDicomError.
#96 by @ziqiangxu tried this before by always passing force=True. I went with what @pieper and @CPBridge asked for in that review, an opt in constructor argument plus a setter, same style as permissive_uid and set_chunk_size(). It covers both the multipart response and the single part application/dicom fallback so retrieve_instance, retrieve_series and retrieve_study all get it.
Tests are in tests/test_web.py. they strip the preamble from the test file and check it reads fine with force_read=True (multipart, single part and a series using set_force_read) and still raises by default. The forced ones fail on master and pass now. flake8 and mypy are clean and the full suite passes with pillow<13, on Pillow 13 test_file.py::test_retrieve_instance_frames_rendered fails on master too which #131 fixes.
I didn't add a CLI flag for it, happy to if you want one