Repository navigation
Conversation
❌ Deploy Preview for volview-dev failed.
|
This was referenced Nov 24, 2026
PaulHax
marked this pull request as ready for review
November 25, 2026 13:36
PaulHax
force-pushed
the
dicom-loading
branch
from
November 25, 2026 13:47
49e1b48 to
1434db7
Compare
PaulHax
force-pushed
the
dicom-loading
branch
from
November 25, 2026 21:22
bb8ad21 to
9f2aad4
Compare
This was referenced Nov 25, 2026
PaulHax
force-pushed
the
dicom-loading
branch
3 times, most recently
from
November 29, 2026 03:14
365d69f to
dabac4f
Compare
DICOM files and URLs share one metadata-first pipeline that loads volumes frame by frame, in place of the ITK DICOM pipeline. Collections are planned the same way for batch and incremental imports, splitting incompatible acquisitions and pixel geometries while keeping stable identities, reconstruction details and session provenance. The module lives in src/dicom, split into core and vtk, and eslint.config.js keeps both apart from the application. Core reads instances from byte sources (files, blobs and URLs with Range requests) with an AbortSignal, parses headers with dcmjs in workers, plans collections with a pure registry reducer and fills a Volume buffer it owns. A runtime holds the request pool and workers, and dispose() stops everything it started. The vtk part wraps the buffer in vtkImageData without copying and widens its scalar range as slices arrive. VolView keeps its stores and UI. An import plans and commits each series in one synchronous step, so a series that fails changes nothing. The slice in view loads first, then the rest coarse to fine. Uncompressed MONOCHROME2 and RGB frames are read by their own ranges and decoded without GDCM, which still decodes other instances whole in workers. JPIP, video, HTJ2K and JPEG XL syntaxes have no decoder. Volumes use Float32 buffers where the rescale allows, which vtk.js renders without converting. Whether a multi-frame ultrasound instance plays as a clip is decided from its header, and encapsulated frames are split without dicom-parser. A file without file meta information is read in the VR form its first element shows, with a notice. Enhanced frames that carry no position and no Spacing Between Slices take their slice spacing from Slice Thickness. A later import that regroups a volume into others removes it with a warning, along with the annotations and view settings made on it. A restored session reports a saved dataset that now loads as several volumes instead of binding it to one. The itk-dicom WebAssembly build and its npm scripts are removed, and dcmjs replaces the dicom-parser and fflate dependencies.
DICOM objects with no Rows element, such as reports, key objects and directories, hold no image to load. Like RT modality objects, they are skipped with a warning that names the file and its modality instead of failing the import. A DICOMweb series whose files partly fail still shows its volume and raises a single notice that counts the failures and lists each failed file's error. An HTTP failure names its status instead of reporting every non-200 response as a missing resource.
HTJ2K transfer syntaxes had no decoder. They now decode whole on up to decodeConcurrency OpenJPH workers (@cornerstonejs/codec-openjph), each started on first use. The samples are finished by the same code as native frames, so the HTJ2K decoder declines what native decoding declines, and an HTJ2K instance it declines fails to load. Color stored as YBR_RCT or YBR_ICT, which OpenJPH returns as RGB, loads as RGB. The GDCM, HTJ2K and metadata workers each run on a lane pool built from one shared implementation: one job per worker, the rest queued. A worker error rejects the running job and drops that worker, so the next job starts a fresh one.
MONOCHROME1 polarity belongs to display. GDCM rewrote the samples as their reflection across the stored range, which left the header window pointing at the wrong values. Native frames now decode uncompressed MONOCHROME1 instead of handing it to GDCM, and HTJ2K MONOCHROME1, which had no decoder, now loads. Both keep the stored values, and the GDCM decoder reflects GDCM's output back so every path agrees. MONOCHROME1 images open with the Inverted grayscale preset and inverted thumbnails.
A bare data set has no magic, so its first element decides once every other magic has failed. Such a file was readable only when named .dcm.
Keying them by path in an object listed integer-like names first and let two paths that differ only in leading slashes overwrite each other.
Each compressed transfer syntax has its own decoder. The instance is read as its Pixel Data value and its frames decode on shared codec workers that start on first use, each loading a codec's WASM the first time a frame needs it. The samples are then finished by the same code as uncompressed frames. - RLE Lossless: rleFrame.ts, no dependency. - JPEG-LS: CharLS (@cornerstonejs/codec-charls). - JPEG 2000: OpenJPEG (@cornerstonejs/codec-openjpeg). - HTJ2K: OpenJPH, now on the shared codec workers. - JPEG Baseline and Extended: libjpeg-turbo in an 8 bit and a 12 bit build, picked by the precision the stream declares. - JPEG Lossless: @cornerstonejs/jpeg-lossless-decoder-js. - Deflated Explicit VR Little Endian: inflated on the calling thread by the header parser's inflater, then decoded as uncompressed frames. The module no longer loads itk-wasm, and an ESLint rule keeps it out of src/dicom. Its decoders take what went to GDCM: PALETTE COLOR with plain or segmented tables, 8 bit YBR_FULL and YBR_FULL_422 color, samples of 1 and 12 bits allocated, big endian 8 and 32 bit samples, and instances with overlay planes, a Modality LUT Sequence or an ICC profile. Overlay planes and ICC profiles are not applied. Color takes no rescale, and one sample per pixel with a missing or unknown photometric interpretation decodes as grayscale. A transfer syntax the decoder table does not list fails as having no decoder. Each frame takes its own Pixel Value Transformation. Where GDCM and other libraries differ, the decoders follow pydicom, DCMTK, fo-dicom and highdicom: samples are masked to Bits Stored at every width, a Modality LUT Sequence replaces the rescale for grayscale other than X-Ray Angiographic and Radiofluoroscopic images, and one fragment is one frame when the counts match, whatever the Basic Offset Table says. JPEG 2000 and HTJ2K keep a codestream precision above Bits Stored, and codestreams of 8 bits or fewer are widened where the header allocates 16. A JPEG frame the header calls RGB is decoded without a color transform unless its own JFIF or Adobe segment states one. Workers are built as ES modules, so the codec worker fetches its 12 bit JPEG build only for a stream that needs it. RT Image objects are imported as images; other radiotherapy objects are still dropped at their Modality. Files skipped for a radiotherapy modality or for holding no image raise one notice per reason per session rather than one per file. A multi-frame instance loads its middle frame first, as a multi-file stack does.
Collections: - A replan never merges two loaded volumes. An instance that would join them becomes a volume of its own. - A later copy with the same facts becomes the source for slices that failed or never loaded. - An anonymous collection keeps its id when a sibling splits it. - One failing collection or cine clip no longer fails its whole series. - Concatenation parts whose frame offsets tile load as one volume. - Split parts take their own orientation, the in-plane tolerance grows with distance along the stack, positions within 1e-3 mm count as one plane, and passes interleaved on an even lattice stay one volume. - Frames of one instance that lean in orientation are warned about. Parsing: - Read each sequence item in the VR form its first element shows, so undefined length UN elements holding explicit VR items load, and accept delimiter items with a nonzero length. - Without file meta that names the data set's syntax, read it in the VR form its first element shows, with a warning. - Treat the JPIP Referenced Deflate syntaxes as deflated. - Trim NUL padding from Modality and Specific Character Set. Decoding: - Follow High Bit only when no word sets a bit below the samples. - Read the LUT Descriptor as unsigned 16 bit and ignore empty LUT Data. - Decode 16 bit RGB JPEG Lossless, and deflated YBR_FULL_422 that inflates to full samples as fully sampled color. - Read indirect palette segment offsets as byte offsets and swap big endian 8 bit palette entries. - Load JPEG 2000 codestreams deeper than Bits Stored, and NM frames that are not one reconstructed stack, with a warning. - Ignore an unused malformed Basic Offset Table, join every fragment of a single frame past a stray FF D9 and accept a nonzero pad after a cine EOI. - Decode instances with more frames than a call takes arguments, and packed samples past bit 2^31. - Replace a codec worker whose decode failed; a stale worker error no longer resets its replacement. Loading: - Decoding yields to the next task after 30 ms. - A failed batched read fails only the runs of units it held, never a unit already decoding. - A grayscale thumbnail is windowed to its own slice's values, so it does not depend on which slices have been announced. - A single chunk read is not copied. - A deleted DICOMweb split volume can be downloaded again, and a clip whose first load failed completes and shows its thumbnail once playback reads its first frame. src/dicom now uses undefined for absent values, and store specs record through injected collaborators instead of reading stores.
Browser pages under tests/fixtures/dicom-pages build straight from the module source and check calibrated voxel hashes and collection composition without VolView startup. Playwright specs drive them, and the application, against generated instances and pinned public files. Existing specs follow the loader's changed behavior. Corpus entries record facts about each file, derived by a highdicom based reference tool in tests/fixtures/dicom-pages/reference, apart from what the loading module is expected to produce. Files highdicom cannot read cite the tags their geometry comes from, and the tool checks those values. Files stay at their public sources, and the manifests hold URLs, checksums and, for new entries, licenses and attribution. Every e2e run downloads the files of the volume and composition manifests, and the CI dataset cache keys on both. The volume manifest covers transfer syntaxes, palette and YBR color, MONOCHROME1, multiframe and non-image files, plus generated OCT geometry patterns, an encapsulated PDF, signed multi-frame HTJ2K and RLE variants. An extended manifest covers RT dose, YBR ultrasound, XA and RF multi-frame, a Siemens mosaic, SEG, a Key Object Selection, a large radiograph and a file without a preamble. It runs with DICOM_CORPUS=extended or the manual workflow, skips sources it cannot reach and fails on changed files.
PaulHax
force-pushed
the
dicom-loading
branch
from
November 30, 2026 00:46
dabac4f to
09f511f
Compare
This branch has not been deployed
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.
Replaces #994, now opened from a branch in this repository. It also includes #1047 (SliceThickness slice spacing), #1053 (HTJ2K decoding), decoders for every transfer syntax VolView loads, which take DICOM pixel decoding off GDCM and itk-wasm, MONOCHROME1 display handling and a DICOM test corpus.
DICOM files and URLs share one metadata-first pipeline that loads volumes frame by frame. Collections are planned the same way for batch and incremental imports, splitting incompatible acquisitions and pixel geometries while keeping stable identities, reconstruction details and session provenance.
The loader lives in
src/dicom, split intocoreandvtk. Lint keepscorefree of application, Vue, Pinia, vtk.js and itk-wasm imports andvtkfree of application state and itk-wasm.src/dicom/README.mddescribes the layout and invariants.AbortSignal, plans collections with a pure registry reducer, and allocates and fills aVolumebuffer it owns. A runtime owns the request pool, metadata workers and the codec decoders, anddispose()stops everything it started. Core imports no Vue, Pinia, vtk.js, itk-wasm or application code.vtkImageDatawithout copying and widens the scalar range as slices arrive.Loading order and decoding:
rleFrame.ts, no dependency.@cornerstonejs/codec-charls, MIT).@cornerstonejs/codec-openjpeg, MIT).@cornerstonejs/codec-openjph, MIT).@cornerstonejs/codec-libjpeg-turbo-8bit, ISC) and a 12 bit build (@cornerstonejs/codec-libjpeg-turbo-12bit, ISC). The worker picks the build from the sample precision the stream declares.@cornerstonejs/jpeg-lossless-decoder-js(MIT), plain JavaScript.worker.formatinvite.config.ts), which applies to every worker in the app.Cine:
splitEncapsulatedFrames: one fragment per frame when the counts match, else a Basic Offset Table whose entries each start a fragment, else JPEG End Of Image markers.dicom-parseris no longer a dependency.Behavior changes for reviewers:
MR16BitsAllocated_8BitsStored.dcmin the GDCM test data, so that file now shows the opposite polarity.The browser test pages under
tests/fixtures/dicom-pagesbuild straight from the module source and check calibrated voxel hashes and collection composition without VolView startup. The pages that compared GDCM with the other decoders and that tested recovery of a failed GDCM worker are removed with GDCM.DICOM corpus:
tests/fixtures/dicom-pages/referencederives the facts with highdicom and pydicom, independent of VolView. Files highdicom cannot read list the tags their geometry comes from, and the tool checks those values against the file. Its README covers adding a file.tests/dicomExtendedCorpus.jsonis a slower tier run withDICOM_CORPUS=extendedor the manual "Extended DICOM corpus" workflow. It covers RT, ultrasound, palette and YBR color, SEG, non-image objects, large radiographs and files without a preamble. A source that cannot be reached is skipped; a changed file fails.