Skip to content

Commit 117e3be

Browse files
craigberry1Craig Berry
andauthored
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 <[email protected]>
1 parent a4c5312 commit 117e3be

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/ValueRepresentation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function toWindows(inputArray, size) {
6868
let DicomMessage, Tag;
6969

7070
var binaryVRs = ["FL", "FD", "SL", "SS", "UL", "US", "AT"],
71-
explicitVRs = ["OB", "OW", "OF", "SQ", "UC", "UR", "UT", "UN"],
71+
explicitVRs = ["OB", "OW", "OF", "SQ", "UC", "UR", "UT", "UN", "OD"],
7272
singleVRs = ["SQ", "OF", "OW", "OB", "UN"];
7373

7474
class ValueRepresentation {

test/data.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,3 +1154,25 @@ it.each([
11541154
expect(value).toBe(expected);
11551155
}
11561156
);
1157+
1158+
describe('test OtherDouble ValueRepresentation', () => {
1159+
it('Treat OD as explicit VR with correct length', async () => {
1160+
const url =
1161+
"https://github.com/dcmjs-org/data/releases/download/od-encoding-data/OD-single-word-example.dcm";
1162+
const dcmPath = await getTestDataset(
1163+
url,
1164+
"OD-single-word-example"
1165+
);
1166+
const file = fs.readFileSync(dcmPath);
1167+
const data = dcmjs.data.DicomMessage.readFile(new Uint8Array(file).buffer);
1168+
1169+
// expect OD VR data element (VolumetricCurveUpDirections) to be read with expected value
1170+
expect(data.dict['00701A07']).toBeTruthy();
1171+
const odBuffer = data.dict['00701A07'].Value[0]
1172+
expect(new Uint8Array(odBuffer)).toEqual(new Uint8Array([0, 0, 0, 0, 0, 0, 0, 64]))
1173+
1174+
// expect arbitrary tag (BlendingInputNumber, US VR) after OD VR to be read without issue
1175+
expect(data.dict['00701B02']).toBeTruthy();
1176+
expect(data.dict['00701B02'].Value[0]).toBe(1);
1177+
})
1178+
});

0 commit comments

Comments
 (0)