Repository navigation
fix: support the OL, OV and SV value representations - #653
Merged
Merged
Conversation
1.0 port of #632 (commit 5b215ca). The Vrs registry in packages/core had no OL class, so createByTypeString("OL") fell back to UN. Add OtherLongString, a BinaryRepresentation like OF and OD, register it in Vrs, and give OL the seed flags "length32 single byteStream" in constants/vrs.js. These are the flags of 0.x: a 32 bit length, a single value, and not in the read-side singleVRs list. The 0.x test test/other-long.test.js moves to test/issues/pr632-other-long.test.js. Six of its seven tests fail without the change; the _vrMap test already passes. Other changes for OL: - The #457 contract test pinned OL as a UN fallback; it now pins only OV and SV. - test/core/registries.test.js uses OV as its unknown VR for registerVr, because OL is now registered. - The texts that said OL has no class change: the vrs.js comment, the registerVr example, REG-I-5 in docs/specs/registries-implementation.md, the createByTypeString comment, and the absentValues comment. - The bundle-size ceilings move to 1.081 and 1.063 for the new class. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Maintainer decision Q2 of the review of the 1.0 port of #632: one line in docs/MIGRATION.md, and one bullet in beta-1-release-notes.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 24, 2026
…r-long-vr # Conflicts: # beta-1-release-notes.md
Maintainer request on #653. Before, OV and SV fell back to UN, so an element could not be written with its own VR. - OV: OtherVeryLongString, a BinaryRepresentation with raw bytes, like OL. Seed flags "length32 single byteStream", the same as OL; OB, OW and OF also have readSingle, but OL and OV do not, so the exported singleVRs list does not change (REG-I-4). - SV: Signed64BitVeryLong extends Unsigned64BitVeryLong, which now takes the type and the stream accessor (BigUint64 or BigInt64). SV reads a BigInt with readBigInt64 and writes with writeBigInt64, and coerces a Number or a numeric string with BigInt(), as UV does. Seed flags "binary length32", the same as UV. - BufferStream.readBigInt64/writeBigInt64 and SplitDataView.getBigInt64/setBigInt64 mirror the BigUint64 methods. - VALID_VRS, BULKDATA_VRS, BINARY_VRS and the schema rules already listed OV and SV. No other code special-cases UV. Tests: test/issues/vr-sv-ov.test.js (OV bytes; SV negative, the 64 bit limits and a Number input) fails before this change. The #457 test and the registerVr test of test/core/registries.test.js now use codes that are not DICOM VRs (ZZ, QQ, XX), and the #457 once-per-type test now expects exactly one warning. test/core/absentValues.test.js no longer filters the "Invalid vr type" warning. Docs: the JSDoc of UV, SV and OV cites PS3.5 Section 6.2, Table 6.2-1. REG-I-5, the docs/MIGRATION.md OL line and the beta 1 release notes bullet now cover OV and SV. The bundle-size ceilings move to 1.083 and 1.065. Co-Authored-By: Claude Opus 5.5 <[email protected]>
wayfarer3130
marked this pull request as ready for review
November 24, 2026 20:42
…r-long-vr # Conflicts: # test/bundle-size.test.js
DicomWebJsonWriter put the BigInt value of an SV or UV element in Value, and JSON.stringify threw. PS3.18 Table F.2.3-1 allows a Number or a String, so a safe integer is a Number and a larger value is a decimal string, as for DS and IS beyond 2^53. Also: rewrap a long JSDoc line, rename the #457 describe title, and raise the bundle ceilings to 1.086 and 1.067 after the merge of 1.0-beta (measured x1.0851 and x1.0666). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r-long-vr test/bundle-size.test.js: took the 1.0-beta side and set the ceilings by measurement after the merge: dcmjs.js 1.08615 -> 1.087, dcmjs.es.js 1.06767 -> 1.068. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r-long-vr Resolve the bundle-size ceilings against the merged build: dcmjs.js x1.08975 -> 1.09, dcmjs.es.js x1.07144 -> 1.072. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🎉 This PR is included in version 1.0.0-beta.19 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
wayfarer3130
added a commit
that referenced
this pull request
Nov 25, 2026
…OV, the same with every reader With the OL and OV VR classes of #653, DicomMessage, fromPart10 and AsyncDicomReader (normal and expectsRaw) give little endian words for an explicit OL or OV value and for a UN value whose dictionary VR is OV. Drop the stale "no OL VR class" sentence of the dataset comment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
wayfarer3130
added a commit
that referenced
this pull request
Nov 25, 2026
…p docs After #653, every key of WORD_WIDTHS has a built-in VR class, so the Vrs check in BinaryRepresentation.wordWidth had no effect. NAT-I-BIN-4 now says that a code not in WORD_WIDTHS, also one that registerVr adds, has a width of 1. NAT-U-BIN-7, MIGRATION.md and the AsyncDicomReader skill doc name OW, OF, OD, OL and OV for the swap and for the UN rule, and item 7 of the skill doc lists SV and UV. Tests: UN rows for OW (0028,1201) and OF (0066,0016), fromPart10Stream in the every-reader check, SV in LENGTH_32_VRS, and a corrected comment for (0066,0040). Co-Authored-By: Claude Opus 5.5 <[email protected]>
wayfarer3130
added a commit
that referenced
this pull request
Nov 25, 2026
…t of #622) (#663) * fix: byte order of binary value fields in Explicit VR Big Endian (port of #622) Explicit VR Big Endian stores the words of OW, OF and OD (and OL / OV) value fields most significant byte first. dcmjs 1.0 gave them to the caller, and wrote them, in the order of the caller's memory. - core: swapBytes / swappedCopy (utilities/byteSwap.js, exported); BinaryRepresentation.wordWidth; swap on read, swap a copy on write; ParsedUnknownValue re-reads in the right byte order; BufferStream.readUint16Array off-by-one. - legacy: AsyncDicomReader cuts fragments to whole words and swaps them, also on the bit-packed path; a UN "ox" pixel data uses the OW width. - The event-stream parser and StreamingPart10Writer go through core. - test/big-endian.test.js: independent encoder; every reader and the writer, plus the CT1_UNC big endian / little endian fixture pair. - bundle-size ceilings 1.085 / 1.068. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(async): swap Big Endian OW pixel data before it is cut into frames When a frame of OW pixel data is not a whole number of words (8-bit data stored as OW, odd samples per frame), a word spans two frames. The async reader cut the value into frames first and swapped each frame alone, so it mixed the bytes of the two frames. It now reads and swaps the whole value first and then cuts it into frames, as the 1-bit path already does. The big endian test now runs for Explicit VR Big Endian only, with one little endian write test as a control, and checks the odd frame case on DicomMessage, AsyncDicomReader, fromPart10 and fromPart10Stream. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: little endian binary values in memory for every transfer syntax; bundle-size ceilings Add NAT-U-BIN-7 and NAT-I-BIN-4 to the naturalized dataset spec, a MIGRATION.md note for callers that swapped the bytes themselves, and the raw byte order and maxFragmentSize rounding to the AsyncDicomReader doc. Set the bundle-size ceilings to the measured ratios (x1.08949, x1.07200). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(async): swap expectsRaw OW/OF/OD words to little endian in Big Endian AsyncDicomReader.readRawBinary now passes the word width of the VR to _emitSplitValues, so a listener that returns expectsRaw gets OW, OF, OL, OD and OV words as little endian, the same as on the other read paths. OB, UN and other VRs keep the byte order of the file. Use one VR list in NAT-U-BIN-7, MIGRATION.md and the AsyncDicomReader skill doc: OW, OF and OD, and OL and OV where the VR is supported. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(bundle-size): raise the ceilings to 1.091 and 1.073 after the merge of 1.0-beta dcmjs.js is 1,509,340 bytes (ratio 1.09022) and dcmjs.es.js is 1,456,286 bytes (ratio 1.07284) after the merge of #654, #656 and #647. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(VR): give a VR with no registered class a word width of 1 A UN element whose dictionary VR is OV (or OL) with no registered VR class, for example (7FE0,0001), now reads the same with DicomMessage, fromPart10 and AsyncDicomReader: BinaryRepresentation.wordWidth is 1 for a type that Vrs does not hold, so no reader swaps it. Docs: NAT-I-BIN-4 states this rule; NAT-U-BIN-7, MIGRATION.md and the AsyncDicomReader skill say that a UN element whose dictionary VR is OW, OF or OD reads as that VR and gets the swap. Fix the readRawBinary doc comment (fragments of maxFragmentSize, not 64KB chunks) and rewrap a long MIGRATION.md line. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(big-endian): read explicit OL and OV, and UN with dictionary VR OV, the same with every reader With the OL and OV VR classes of #653, DicomMessage, fromPart10 and AsyncDicomReader (normal and expectsRaw) give little endian words for an explicit OL or OV value and for a UN value whose dictionary VR is OV. Drop the stale "no OL VR class" sentence of the dataset comment. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(VR): drop the Vrs check from wordWidth; name OL and OV in the swap docs After #653, every key of WORD_WIDTHS has a built-in VR class, so the Vrs check in BinaryRepresentation.wordWidth had no effect. NAT-I-BIN-4 now says that a code not in WORD_WIDTHS, also one that registerVr adds, has a width of 1. NAT-U-BIN-7, MIGRATION.md and the AsyncDicomReader skill doc name OW, OF, OD, OL and OV for the swap and for the UN rule, and item 7 of the skill doc lists SV and UV. Tests: UN rows for OW (0028,1201) and OF (0066,0016), fromPart10Stream in the every-reader check, SV in LENGTH_32_VRS, and a corrected comment for (0066,0040). Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR is the 1.0 port of #632 (commit
5b215ca). It adds the OL (Other Long) VR. The maintainer also asked for the SV (Signed 64-bit Very Long) and OV (Other 64-bit Very Long) VRs in this PR. SV and OV are new code, not a port. Before this PR, the 1.0 reader and writer used UN for an OL element. A rewrite of Long Triangle Point Index List (0066,0041) then came back as UL numbers.Changes
packages/core/src/ValueRepresentation.js: the new classOtherLongString, the same as in 0.x. The class registers in theVrstable from feat(core): extensible registries for VRs, SOP classes and character sets; options-object streams #650.packages/core/src/constants/vrs.js: the seed gives OL the flagslength32 single byteStream. The exportedsingleVRslist does not change.packages/core/src/ValueRepresentation.js: the new classOtherVeryLongString(OV, raw bytes, the same as OL). The new classSigned64BitVeryLong(SV) reads and writes a signedBigInt. SV and UV share one class and one write conversion. ANumberor a numeric string converts withBigInt().BufferStreamandSplitDataView: newreadBigInt64/writeBigInt64andgetBigInt64/setBigInt64, the same as theBigUint64methods.constants/vrs.js: OV gets the flagslength32 single byteStream, the same as OL. SV getsbinary length32, the same as UV. The exportedsingleVRslist does not change.test/issues/issue457-vr-instances.test.jsandtest/core/registries.test.js: each standard VR now has a class. These tests now use codes that are not DICOM VRs (ZZ, QQ, XX).docs/specs/registries-implementation.md(REG-I-5) and two code comments no longer say that OL has no class.docs/MIGRATION.md: one line. Code that matchedvr === "UN"for an OL, OV, or SV tag must match the new VR.beta-1-release-notes.md: one bullet.packages/generator/src/eventStream/DicomWebJsonWriter.js: an SV or UV value in DICOM JSON is a Number when the value is a safe integer, and a decimal string otherwise. PS3.18 Table F.2.3-1 allows a Number or a String. Before, an SV element was UN withInlineBinary. The release notes anddocs/MIGRATION.mdrecord the change.test/bundle-size.test.js: the ceilings increase to 1.086 (dcmjs.js) and 1.067 (dcmjs.es.js), measured after the merge of1.0-beta(×1.0851 and ×1.0666).Review
An independent review compared the port with #632. The class is the same as in 0.x. The other VR lists of 1.x (
VALID_VRS,BULKDATA_VRS,BINARY_VRS) already had OL. The parser package and the legacy package need no change. The review found a conflict with #650, which merged into1.0-betabefore this PR. The branch is rebased onto1.0-beta, and the resolution follows the merge plan of the review.An independent review of the SV and OV commit found no blocker. SV and OV use the 32-bit length field, as PS3.5 requires. UV does not change. The review found one problem:
DicomWebJsonWriterwrote an SV value as aBigInt, andJSON.stringifycannot serialize aBigInt. The fix uses the option that the review recommended: a Number for a safe integer, and a string otherwise, the same rule as for DS and IS.Tests
The 0.x test
test/other-long.test.jsmoves totest/issues/pr632-other-long.test.js.1.0-betawithout the fix, 6 of the 7 tests fail. The test that writes OL through_vrMappasses with or without the fix.The API must do this:
vr: "OL", and the value is a binary value.registerVrstill adds an unknown VR.BigIntvalues, and aNumberinput. An OV element reads and writes its bytes. Both tests fail before the change.DicomWebJsonWritergives-2as a Number and-9223372036854775808as a string, andJSON.stringifysucceeds. The test fails before the fix withTypeError: Do not know how to serialize a BigInt.The user experience must have this:
🤖 Generated with Claude Code