dcmjs icon indicating copy to clipboard operation
dcmjs copied to clipboard

Null terminated strings are not read correctly

Open florianlink opened this issue 5 years ago • 5 comments
trafficstars

I know that the DICOM standard says that strings in PN, CS etc. should be padded with spaces. But I regularly get DICOM files that use a 0 char code for padding of the strings. This causes a Dicom Tag in dcmjs to have the trailing 0 char code at the end of the string.

I noticed code in ValueRepresentation.js PersonName that is uncommented, but I think this applies to most string VRs and should be handled by DCMJS.

For comparison, in DCMTK, I don't get these trailing 0 chars in the tag values.

florianlink avatar Jun 25 '20 13:06 florianlink

Thanks for reporting 👍

Can you provide an example file for testing? (ideally add it to https://github.com/dcmjs-org/data).

p.s. Hi Forian, hope you are well!

pieper avatar Jun 25 '20 14:06 pieper

As always, I can‘t easily share the data... will try to create one artificially...

P.S. thanks I‘m fine, working on client side dicom anonymization before uploading...

On Thu 25. Jun 2020 at 16:35, Steve Pieper [email protected] wrote:

Thanks for reporting 👍

Can you provide an example file for testing? (ideally add it to https://github.com/dcmjs-org/data).

p.s. Hi Forian, hope you are well!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dcmjs-org/dcmjs/issues/130#issuecomment-649588931, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKHPHE3KL7A3WHFWB6UFDTRYNOBVANCNFSM4OIMRIIA .

florianlink avatar Jun 25 '20 14:06 florianlink

Yes, a synthetic example would be fine.

@swederik and I are also working on deid scripts in javascript - it would be fun to coordinate if possible.

pieper avatar Jun 25 '20 15:06 pieper

I created an artificial DCM file, you can use it without restrictions (I don't know how to add it to the data repository) testZeroPaddedPatientName.zip

The PatientName of the file contains 0x00 padding instead of 0x20 (space) padding, which is not correct according to the DICOM standard, but nevertheless occurs in DICOM files out in the wild and is also parsed by DCMTK without problems.

I think this can happen on all VRs that allow/specify padding by 0x20, so DCMJS should strip all trailing zeros as well as all spaces.

florianlink avatar Jun 30 '20 13:06 florianlink

Thank you - I've added the data as a release asset https://github.com/dcmjs-org/data/releases

pieper avatar Jun 30 '20 20:06 pieper