From 117e3be2ddc5162f42b5276a05e91c4e1207b1ca Mon Sep 17 00:00:00 2001 From: Craig Berry <42152902+craigberry1@users.noreply.github.com> Date: Mon, 12 Aug 2024 18:07:53 -0400 Subject: [PATCH] Other double as explicit value representation (#399) * Treat OD value representation as explicit, and expect 2 empty byte padding when reading vr from data element * Add unit test based on external file with OD * Bring in test OD file from data repo --------- Co-authored-by: Craig Berry --- src/ValueRepresentation.js | 2 +- test/data.test.js | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/ValueRepresentation.js b/src/ValueRepresentation.js index 5b365f0c..7115aa85 100644 --- a/src/ValueRepresentation.js +++ b/src/ValueRepresentation.js @@ -68,7 +68,7 @@ function toWindows(inputArray, size) { let DicomMessage, Tag; var binaryVRs = ["FL", "FD", "SL", "SS", "UL", "US", "AT"], - explicitVRs = ["OB", "OW", "OF", "SQ", "UC", "UR", "UT", "UN"], + explicitVRs = ["OB", "OW", "OF", "SQ", "UC", "UR", "UT", "UN", "OD"], singleVRs = ["SQ", "OF", "OW", "OB", "UN"]; class ValueRepresentation { diff --git a/test/data.test.js b/test/data.test.js index c598d181..d1e62aad 100644 --- a/test/data.test.js +++ b/test/data.test.js @@ -1154,3 +1154,25 @@ it.each([ expect(value).toBe(expected); } ); + +describe('test OtherDouble ValueRepresentation', () => { + it('Treat OD as explicit VR with correct length', async () => { + const url = + "https://github.com/dcmjs-org/data/releases/download/od-encoding-data/OD-single-word-example.dcm"; + const dcmPath = await getTestDataset( + url, + "OD-single-word-example" + ); + const file = fs.readFileSync(dcmPath); + const data = dcmjs.data.DicomMessage.readFile(new Uint8Array(file).buffer); + + // expect OD VR data element (VolumetricCurveUpDirections) to be read with expected value + expect(data.dict['00701A07']).toBeTruthy(); + const odBuffer = data.dict['00701A07'].Value[0] + expect(new Uint8Array(odBuffer)).toEqual(new Uint8Array([0, 0, 0, 0, 0, 0, 0, 64])) + + // expect arbitrary tag (BlendingInputNumber, US VR) after OD VR to be read without issue + expect(data.dict['00701B02']).toBeTruthy(); + expect(data.dict['00701B02'].Value[0]).toBe(1); + }) +}); \ No newline at end of file