Skip to content

add support for overriding 'isEncapsulated()' - #60

Open
keean wants to merge 1 commit into
cornerstonejs:masterfrom
keean:master
Open

add support for overriding 'isEncapsulated()'#60
keean wants to merge 1 commit into
cornerstonejs:masterfrom
keean:master

Conversation

@keean

@keean keean commented Feb 17, 2017

Copy link
Copy Markdown

This adds transferSyntax to ByteStream object, so that it can be used by isEncapsulated. The logic in readDicomElementExplicit is refactored so that isEncapsulated is used for the pixel-data, whereas the normal length criteria is used for UN and other element types.

MichaelLeeHobbs referenced this pull request in MichaelLeeHobbs/dicomParser Jul 23, 2026
…h encapsulation, charset decoding (#8)

* feat: CP-246 defined-length UN sequences, speculative fallback, defined-length encapsulation

Phase 2 backlog items 3 and 9. Defined-length sequence frames are now
speculative: a parse failure inside rolls back only that element to an
opaque value with a 'sequence-fallback' warning and parsing continues —
this is the safe form of CP-246 (cornerstonejs#141: UN + defined length parses as an
implicit sequence when vrLookup says SQ, binary fallback otherwise) and
also recovers the cornerstonejs#114-class peek-misdetection derailment instead of
erroring. TS-driven encapsulation detection (#59/#60): defined-length
pixel data in a compressed transfer syntax whose value starts with an
item tag is scanned as BOT+fragments (bounded scan, no delimiter
required), with opaque-value fallback. parse() derives the compressed-TS
flag from the transfer syntax UID.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DSSLWZvjSRByQP3KsghQcJ

* feat: charset-aware string decoding (SpecificCharacterSet, ISO 2022)

Phase 2 backlog item 4 (cornerstonejs#146). Ports the proven charset decoder from
@ubercode/dcmtk (single-byte ISO_IR sets, UTF-8, GB18030/GBK, Shift_JIS,
ISO 2022 escape walking for JP IR 13/87, KR IR 149, CN IR 58) with the
PS3.5 Annex H/I/J fixture suite, adapted to typed errors and a
Buffer-free build. parse() resolves (0008,0005) into a CharsetContext,
walks the dataset tree iteratively (items inherit, own 0008,0005
overrides), and string()/text() decode through it — decode-then-split, so
0x5C trail bytes in multi-byte encodings never corrupt multi-value
splitting. Unsupported charsets warn ('unsupported-charset') and decode
as Latin-1; charset {assume, fallback} options cover headerless/misfiled
data. UTF-8 mislabel detection helpers exported for consumers.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DSSLWZvjSRByQP3KsghQcJ

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants