-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
Values with VRs constructed of character strings are padded with trailing NULL instead of spaces #80
Comments
Hi @selimyoussry, thank you for the detailed context. I think this proposed change makes sense to me, please feel free to submit a pull request to this repo! Contributions are very welcome. As for guidelines, I don't have any special requirements--I guess the main thing to keep in mind is that submitting a PR to this repo means you are okay licensing your patch under this repository's license (the standard MIT license). This is generally true of all of GitHub. If you're interested in contributing more to this repo in general, let me know and I'm happy to keep you in mind for future issues or feature development (I have a rewrite in progress at the s/1.0-rewrite branch, that cleans things up significantly and refactors the library a bit). |
Also, for VRs where leading and trailing spaces are considered insignificant, it may be worth trimming those by default when parsing as well--feel free to send a contribution for that as well, otherwise I'll open a separate issue to track that as well. Thank you! |
Also @suyashkumar , when you review my PR and it gets accepted and merged, can you please take care of the |
closed by #81 |
@selimyoussry apologies for the delay, but you should be able to use the v0.4.3 tag: https://github.com/suyashkumar/dicom/releases/tag/v0.4.3 |
Per http://dicom.nema.org/dicom/2013/output/chtml/part05/sect_6.2.html, paragraph 6.2 Value Representation (VR):
When parsing a DICOM file with
RequestAttributesSequence
(among other tags encoutering the same issue), withpydicom
, the trailing NULL byte is not removed bypydicom
, which is probably following the DICOM spec referenced above more closelydcm_file = pydicom.dcmread(...) print(dcm_file.RequestAttributesSequence[0]) Out[33]: (0040, 0007) Scheduled Procedure Step Descriptio LO: 'G2702\x00' (0040, 0009) Scheduled Procedure Step ID SH: 'G2702\x00' (0040, 1001) Requested Procedure ID SH: '918081'
For the record,
dcmdump
does not have the same issue and removes trailing NULL bytes.That being said, we are using your Go DICOM library to write some DICOM files, which are later consumed by Python users, with
pydicom
. I believe for "VRs constructed of character strings, except in the case of the VR UI", which would be "DT", "LO", "LT", "PN", "SH", "ST", "UT" per my read of http://dicom.nema.org/dicom/2013/output/chtml/part05/sect_6.2.html, that odd number of bytes should be padded by an empty space instead.I patched your code with this change and can confirm that
pydicom
then parses the values as expected, so does your library and so doesdcmdump
. See output belowHere is the diff
Here is the
make
(and thereforetest
) outputCan you please share guidelines to submit a PR for this? Or please feel free to simply open the PR yourself if you'd prefer not opening this repo to other contributors, and let me know. Happy to become a contributor though!
Best regards,
The text was updated successfully, but these errors were encountered: