Open lnogueir opened 5 months ago
Thanks @lnogueir! I agree that we can attempt some enhanced fallback behavior, particularly if that's standard practice in other parsers. Our current fallback behavior for no transfer syntax found in the Metadata is to proceed with little endian implicit but it shouldn't be too difficult to try a couple different transfer syntaxes speculatively.
For missing metadata group length we do hav a flag for that, but can consider automatic fallback behavior: https://github.com/suyashkumar/dicom/blob/65259e55c2dd96a811e752aff2864ef16b903351/read.go#L184
I think originally the idea was the safest option is to force callers to be as explicit as possible about what loosened restrictions they may want in case there are any safety issues with fallback behavior or in case the fact the dicom is not compliant is something the user would want raised to them (in case that led to other concerns). That being said, recently I've been thinking it's more reasonable to just have more automatic fallbacks, at least ones that are "standard" in the industry for dicom non-compliance.
Going through these in a little more detail, and adding some more notes:
8192
but there aren't that many bytes left in the dicom. We treat this as an error, which seems reasonable imo but we can discuss more. The draft changes in #330 address 1 and 2.
For missing metadata group length we do hav a flag for that, but can consider automatic fallback behavior:
https://github.com/suyashkumar/dicom/blob/65259e55c2dd96a811e752aff2864ef16b903351/read.go#L184
I think originally the idea was the safest option is to force callers to be as explicit as possible about what loosened restrictions they may want in case there are any safety issues with fallback behavior or in case the fact the dicom is not compliant is something the user would want raised to them (in case that led to other concerns). That being said, recently I've been thinking it's more reasonable to just have more automatic fallbacks, at least ones that are "standard" in the industry for dicom non-compliance.
I agree. I think it's better to have these automatic fallbacks and just log warnings if non-compliant things are found. That's the behavior most libraries choose I believe.
Also, the changes in #331 address 6 (with SkipPixelData). They almost address 4 but some other changes are still needed for that.
Edited the original comment to update current status, link to PRs, etc.
I noticed that the following files (also from pydicom) do not error, but drop values:
The issue seems to be that they change the transfer syntax when writing the SQ dataset. The top level dataset is encoded with explicit little endian, but the dataset of the Referenced RT Plan Sequence is encoded with implicit little endian.
These were the pydicom issues that handled that: https://github.com/pydicom/pydicom/issues/1035, https://github.com/pydicom/pydicom/issues/1067
I was playing around with the pydicom test files and noticed that parsing (with
SkipProcessingPixelDataValue()
option enabled) the following files result in errors:These files were parseable by dcm4che.
For most of them, the issue is related to missing some or all meta tags. Ideally, if the meta tags aren't included, we should ignore and try parsing the first data element. And we can guess the transfer syntax by peeking the first tag and VR of the first element. We try [implicit LE, explicit BE, explicit LE], whichever one decodes a known tag and VR is likely the correct transfer syntax and we should use that for the rest of the dataset.