Skip to content

Commit

Permalink
Fix writing data with vr=xs, fixes #1567
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Dec 5, 2023
1 parent 10f5832 commit f15f2a2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/dicom/dicomWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,13 @@ export class DicomWriter {
const atValue = [dec1, dec2];
byteOffset = writer.writeUint16Array(byteOffset, atValue);
}
} else if (element.vr === 'xs') {
// TODO would be better to use pixelRepresentation in if
if (value instanceof Int16Array) {
byteOffset = writer.writeInt16Array(byteOffset, value);
} else {
byteOffset = writer.writeUint16Array(byteOffset, value);
}
} else {
logger.warn('Unknown VR: ' + element.vr);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/dicom/synthetic-data_explicit.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
},
{
"name": "lee-08",
"description": "Little Endian Explicit test data with mulitple VRs.",
"description": "Little Endian Explicit test data with multiple VRs.",
"tags": {
"TransferSyntaxUID": "1.2.840.10008.1.2.1",
"Modality": "MR",
Expand All @@ -313,6 +313,7 @@
"BitsAllocated": 16,
"BitsStored": 12,
"HighBit": 11,
"SmallestImagePixelValue": 0,
"PrivateSQ": {
"value": [
{
Expand Down
3 changes: 2 additions & 1 deletion tests/dicom/synthetic-data_explicit_big-endian.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
},
{
"name": "beb-08",
"description": "Big Endian Explicit test data with mulitple VRs.",
"description": "Big Endian Explicit test data with multiple VRs.",
"tags": {
"TransferSyntaxUID": "1.2.840.10008.1.2.2",
"Modality": "MR",
Expand All @@ -313,6 +313,7 @@
"BitsAllocated": 16,
"BitsStored": 12,
"HighBit": 11,
"SmallestImagePixelValue": 0,
"PrivateSQ": {
"value": [
{
Expand Down
3 changes: 2 additions & 1 deletion tests/dicom/synthetic-data_implicit.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
},
{
"name": "lei-08",
"description": "Little Endian Implicit test data with mulitple VRs.",
"description": "Little Endian Implicit test data with multiple VRs.",
"tags": {
"TransferSyntaxUID": "1.2.840.10008.1.2",
"Modality": "MR",
Expand All @@ -313,6 +313,7 @@
"BitsAllocated": 16,
"BitsStored": 12,
"HighBit": 11,
"SmallestImagePixelValue": 0,
"PrivateSQ": {
"value": [
{
Expand Down

0 comments on commit f15f2a2

Please sign in to comment.