From 5ef7e29b761c586439a2c37e0ee871688c191a63 Mon Sep 17 00:00:00 2001 From: Miguel Chambel Date: Tue, 2 Nov 2021 06:07:23 +0000 Subject: [PATCH 1/3] prevent arraybuffers from being excluded of naturalized datasets --- src/DicomMetaDictionary.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DicomMetaDictionary.js b/src/DicomMetaDictionary.js index c6a9dd1e..663fd639 100644 --- a/src/DicomMetaDictionary.js +++ b/src/DicomMetaDictionary.js @@ -149,7 +149,8 @@ class DicomMetaDictionary { if ( sqZero && typeof sqZero === "object" && - !sqZero.length + !sqZero.length && + !(sqZero instanceof ArrayBuffer) ) { addAccessors(naturalDataset[naturalName], sqZero); } else { From c72a0a7ef0f0ac796dd73194f8dfa287757c0b38 Mon Sep 17 00:00:00 2001 From: Miguel Chambel Date: Wed, 3 Nov 2021 08:02:24 +0000 Subject: [PATCH 2/3] fix (naturalizeDataset): exclude arraybuffers from being added accessors. Since addAccessor's function iterates on object keys only, arraybuffers will be set to undefined causing errors --- src/DicomMetaDictionary.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DicomMetaDictionary.js b/src/DicomMetaDictionary.js index 663fd639..4bbdce61 100644 --- a/src/DicomMetaDictionary.js +++ b/src/DicomMetaDictionary.js @@ -146,6 +146,7 @@ class DicomMetaDictionary { if (naturalDataset[naturalName].length === 1) { const sqZero = naturalDataset[naturalName][0]; + //add accessor to object props, leave arrays and arraybuffers unchanged if ( sqZero && typeof sqZero === "object" && From 7ffd2ce9f1fd1a421e4ae76956e9991e31e20da4 Mon Sep 17 00:00:00 2001 From: Miguel Chambel Date: Thu, 4 Nov 2021 12:07:20 +0000 Subject: [PATCH 3/3] fix(naturalizeDataset): exclude arraybuffers from being added accessors. In the case of segmentation files, PixelData key of naturalized datasets should be an arraybuffer but if added accessors it will be an array with an arraybuffer inside, which breaks further processing added relevant test on test_oneslice_seg of data part --- test/test_data.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_data.js b/test/test_data.js index 29000352..4a75c18e 100644 --- a/test/test_data.js +++ b/test/test_data.js @@ -166,7 +166,7 @@ const tests = { .PixelMeasuresSequence.SpacingBetweenSlices; expect(spacing).to.equal(0.12); expect(Array.isArray(naturalSequence.SharedFunctionalGroupsSequence)).to.equal(true); - + expect(naturalSequence.ProcedureCodeSequence).to.have.property( "CodingSchemeDesignator", "L" @@ -269,6 +269,7 @@ const tests = { const dataset = DicomMetaDictionary.naturalizeDataset( dicomDict.dict ); + expect(dataset.PixelData instanceof ArrayBuffer).to.be.true; datasets.push(dataset); });