feat(parser): support transfer syntax inference when parsing small DICOM fragments (<100 bytes)#347
feat(parser): support transfer syntax inference when parsing small DICOM fragments (<100 bytes)#347mlibanori wants to merge 6 commits intosuyashkumar:mainfrom
Conversation
|
Thanks for the contribution! Out of curiosity, is there some reason why the auto-detection doesn't work? Lines 179 to 180 in 0fbaef5 Or is the idea to make this behavior more explicit? |
|
Thanks for the review! The main reason for this change is that certain DICOM commands, such as C-ECHO, can be smaller than 100 bytes. When this happens, the auto-detection logic fails with the error: Line 184 in 0fbaef5 Another possible fix would be to reduce p.reader.rawReader.Peek(100) to p.reader.rawReader.Peek(50), which would allow reading smaller PDU messages. Line 181 in 0fbaef5 However, since I'm not entirely sure why the current value is set to 100, I opted to add an option to bypass the transfer syntax detection restriction rather than directly changing the default behavior. |
|
Makes sense! First off, I think adding an option if needed is totally reasonable. Out of curiosity, I'd like to see if we can make it work without an option (if possible and not too complex). There's no real reason for the 100 byte explicit limit, other than the thought that at least one element would fit in there and that most dicoms would be at least 100bytes. Both assumptions may not hold true, as you point out in this case! We can probably make this work for dicoms < 100 bytes:
It may not read as nicely, but we could also try to use What do you think? If you're willing to help with this change, please go ahead! We'll likely want some tests to cover this case as well. (Also, I'm curious if your payloads pass the autodetection test)! |
|
Thank you for the review! I really appreciate the suggestion. Based on your feedback, I implemented the PeekAtMost(n) function, which ignores EOF errors and returns the maximum available buffer size. Lines 238 to 244 in 0c00440 I also developed a test using a buffer captured from a real DICOM communication, and the parsing was successfully completed. Lines 78 to 106 in 0c00440 If you have any concerns or think there’s a better approach, I’m happy to iterate further PS: I noticed that this project does not include the Command Set tags (group 0x0000). Is there a specific reason for this, or have they simply not been implemented yet? If you’re open to it, I’d be happy to submit a new pull request contributing to the generation of these tags as well. |
suyashkumar
left a comment
There was a problem hiding this comment.
Thanks! Overall looking on right track, just a few more comments!
Regarding Command Set tags, you're absolutely welcome to help get those added. We're using the innolitics json dump of the standard to do this, so you're welcome to look into where those exist in there (if at all): https://github.com/suyashkumar/dicom/blob/main/pkg/tag/generate_tag_definitions.py . Thanks for the contributions, and always open to contributions as always!
|
@suyashkumar, do you have any other revisions? |
suyashkumar
left a comment
There was a problem hiding this comment.
Thanks! Apologies for the delay. This is looking good, just added a few more suggestions below and one question. I think we're pretty much there!
74051bd to
f3f762f
Compare
Co-authored-by: Suyash Kumar <suyashkumar2003@gmail.com>
Co-authored-by: Suyash Kumar <suyashkumar2003@gmail.com>
|
all done! lets go? |
|
@suyashkumar Are any further changes needed? Can we proceed? |
This PR introduces the SkipTransferSyntaxDetection option in the DICOM parser. The primary motivation for this change is to enable compatibility between this project and go-netdicom, which requires parsing DICOM network messages without enforcing transfer syntax detection.