Skip to content

Commit

Permalink
Other double as explicit value representation (#399)
Browse files Browse the repository at this point in the history
* 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 <craig.berry@veeva.com>
  • Loading branch information
craigberry1 and Craig Berry authored Aug 12, 2024
1 parent a4c5312 commit 117e3be
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ValueRepresentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 22 additions & 0 deletions test/data.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
});

0 comments on commit 117e3be

Please sign in to comment.