Skip to content

Conversation

@luissantosHCIT
Copy link

Fixes #454.

Although, I did not find any bugs with dcmjs, some of the tooling in the library could be better exposed for consumption in other projects. I focus on exposing the DICOM buffer decoding here given an initial SpecificCharacterSet. If translation is not necessary, a few convenience methods are provided to set the correct encoder or decoder on demand.

This is a code cleanup / reorganization kind of PR.

Jest tests passed.
I did not add any new tests since there is coverage from the current tests and the one class I added is trivial.

@netlify
Copy link

netlify bot commented Aug 19, 2025

Deploy Preview for dcmjs2 ready!

Name Link
🔨 Latest commit 50327d2
🔍 Latest deploy log https://app.netlify.com/projects/dcmjs2/deploys/68a4873833dd5100087c47e8
😎 Deploy Preview https://deploy-preview-455--dcmjs2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@luissantosHCIT
Copy link
Author

@pieper I went ahead and did some cleanup based on your comments in #454. In terms of the other issue (#373), I do not do anything here other than change the location of the logic in question which I partially move lower in the abstraction hierarchy. However, if I get some time in the near future and no one has addressed it, I might take a stab. I think that the reasonable approach is to find the specific character set at the level of the tree in the header and use that for that level only. That can get a bit complex than I have time at the moment and I will need to consult the standard for other potential cases.

@pieper pieper requested a review from wayfarer3130 August 19, 2025 19:39
@pieper
Copy link
Collaborator

pieper commented Aug 19, 2025

From a quick look I think the PR looks good 👍

I'd like another set of eyes on it though, so hopefully @wayfarer3130 can take a look too.

@luissantosHCIT
Copy link
Author

@wayfarer3130 checking in if there is anything you think I should improve on in this PR. No rush, I know you have been very helpful in other PRs and very busy. I am just helping keep this PR in people's minds in case there is a chance to merge. Thank you!

"1.2.840.10008.5.1.4.1.1.77.1.5.4": "OphthalmicTomographyImage"
};

DicomMetaDictionary.encodingMapping = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you drop this externally as it's own file? There should also be an addEncoding method to externally add them.
just import the encoding mapping and assign to the dicom meta dictionary rather than increasing the overall contents of this file.


DicomMetaDictionary.defaultEncoding = "latin1";

DicomMetaDictionary.encapsulatedSyntaxes = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this. I would suggest having several categories, and use a Set for this many values. The types:
Encapsulated
Video
Uncompressed

if (!vr.isBinary() && singleVRs.indexOf(vr.type) == -1) {
if (
!vr.isBinary() &&
ValueRepresentation.singleVRs.indexOf(vr.type) === -1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ValueRepresentation.singleVRs.has(vr.type)
with a set or map.

* Facilitates the conversion of binary buffers from a DICOM encoding scheme to
* a web supported string encoding scheme and vice versa.
*/
class DicomBufferCODEC {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be it's own file.
Also, the encoder/decoder should be identical because there are cases that both reading and writing occur on a single dicom buffer.
Would like to see a small unit test on this.
The default for both should actually be latin1 until the specific character set gets written.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong decoding from ISO 2022 IR 100 to ISO IR 192 (UTF-8)?

3 participants