Skip to content

Commit

Permalink
fix(naturalize): revert single element sequence (#223)
Browse files Browse the repository at this point in the history
Reverts dcmjs-org/dcmjs@9ca7465 to original behavior to avoid change in the api.

See discussion here for more details: dcmjs-org/dcmjs@74571a4
  • Loading branch information
pieper committed Oct 14, 2021
1 parent 5c0c6a8 commit 0743ed3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 2 additions & 5 deletions packages/adapters/src/DicomMetaDictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,8 @@ class DicomMetaDictionary {
}

if (naturalDataset[naturalName].length === 1) {
const sqZero = naturalDataset[naturalName][0];
naturalDataset[naturalName] = sqZero;
if (sqZero && typeof sqZero === "object") {
Object.assign(sqZero, [sqZero]);
}
naturalDataset[naturalName] =
naturalDataset[naturalName][0];
}
}
});
Expand Down
6 changes: 3 additions & 3 deletions packages/adapters/test/test_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ const tests = {
"IMG1332"
);

// tests that single element sequences have been converted
// from arrays to values.
// See discussion here for more details: https://github.com/dcmjs-org/dcmjs/commit/74571a4bd6c793af2a679a31cec7e197f93e28cc
const spacing = naturalSequence.SharedFunctionalGroupsSequence
.PixelMeasuresSequence.SpacingBetweenSlices;
const spacingIndexed = naturalSequence.SharedFunctionalGroupsSequence[0]
.PixelMeasuresSequence[0].SpacingBetweenSlices;
expect(spacing).to.equal(spacingIndexed);
expect(spacing).to.equal(0.12);

expect(naturalSequence.ProcedureCodeSequence).to.have.property(
Expand Down

0 comments on commit 0743ed3

Please sign in to comment.