From c78d045fc13c9568c49f1a9de597b78c29e77dd6 Mon Sep 17 00:00:00 2001 From: Craig Berry Date: Mon, 12 Aug 2024 08:25:03 -0400 Subject: [PATCH 1/3] Treat OD value representation as explicit, and expect 2 empty byte padding when reading vr from data element --- src/ValueRepresentation.js | 2 +- 1 file changed, 1 insertion(+), 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 { From 0d97410c7298c99205406467f87a707479c3d41b Mon Sep 17 00:00:00 2001 From: Craig Berry Date: Mon, 12 Aug 2024 08:25:20 -0400 Subject: [PATCH 2/3] Add unit test based on external file with OD --- test/OD-single-word-example.dcm | Bin 0 -> 470 bytes test/data.test.js | 16 ++++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 test/OD-single-word-example.dcm diff --git a/test/OD-single-word-example.dcm b/test/OD-single-word-example.dcm new file mode 100644 index 0000000000000000000000000000000000000000..73c81cb72755f95793ff667fd88ba172ec192ec1 GIT binary patch literal 470 zcmc(b!AgTc41}j^!T(f>6%l;}U9!n$H+vK9!9vS_DE||*1usG$(ML0@7q2}zmm&E` z7zX%Xtv7GG;1Q { + test('Treat OD as explicit VR with correct length', () => { + const file = fs.readFileSync(`test/OD-single-word-example.dcm`); + 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 From ec823b81c16135c1b6a5991e81e7beb82e3480c8 Mon Sep 17 00:00:00 2001 From: Craig Berry Date: Mon, 12 Aug 2024 17:52:20 -0400 Subject: [PATCH 3/3] Bring in test OD file from data repo --- test/OD-single-word-example.dcm | Bin 470 -> 0 bytes test/data.test.js | 10 ++++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) delete mode 100644 test/OD-single-word-example.dcm diff --git a/test/OD-single-word-example.dcm b/test/OD-single-word-example.dcm deleted file mode 100644 index 73c81cb72755f95793ff667fd88ba172ec192ec1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 470 zcmc(b!AgTc41}j^!T(f>6%l;}U9!n$H+vK9!9vS_DE||*1usG$(ML0@7q2}zmm&E` z7zX%Xtv7GG;1Q { - test('Treat OD as explicit VR with correct length', () => { - const file = fs.readFileSync(`test/OD-single-word-example.dcm`); + 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