Repository navigation
Open Zeiss CZI images, in 2D and 3D - #572
Merged
Merged
Conversation
A `.czi` URL (or Zenodo's `.czi/content`) now opens as an image-only dataset when each channel, z plane, time point and scene is one full-resolution subblock: a confocal stack, or a tile scan ZEN has stitched (Phase 39 M1). - src/czi/: the ZISRAW container (file header, DV directory, subblock and metadata segments), planes by C/Z/T/S with pyramid copies left out and other dimensions read at their first coordinate, and the metadata XML (scaling, significant bits, channel names, dyes, colours, display windows, scene names). - Uncompressed subblocks are read in bands of whole rows, as ND2 frames are; Zstd0 and Zstd1 (with or without its low/high byte split) are decoded whole in the strip decode workers through geotiff's Zstandard decoder. Gray8, Gray16, Bgr24 and Bgr48; colour pixels turned RGB as tiles are cut. - Scenes are the `p` axis, named `Scene`; `#c=`, `#z=`, `#t=`, `#p=` select a plane. - Display windows are DisplaySetting Low/High times the pixel type's maximum (libCZI's definition); colours `#AARRGGBB` or `#RRGGBB`, read as Bio-Formats does. - Mosaics, JPEG, JPEG XR and LZW subblocks, 32-bit and float pixels, and multi-file CZIs are refused with a message. - ND2's range reads and plane selections move unchanged to src/data/rangeFileReads.ts and src/data/planeSelection.ts, shared by both readers. - Docs: Phase 39 plan, a CZI section in docs/modalities/image.md, and the format lists in the user-facing docs.
Phase 39 M2, on top of M1. - JPEG (compression 1) and LZW (2) subblocks are decoded whole in the strip decode workers, as Zstandard ones are. A JPEG subblock is a whole JPEG file that decodes to RGB, so it is not swapped, and its frame header must match the subblock; LZW is TIFF's LZW over BGR pixels, swapped like uncompressed data. Both follow czifile. Lossless JPEG (3) and chunked compression (7) stay refused. - A subblock whose data is exactly its pixels' size is read as raw rows whatever its compression says, as czifile does (a writer bug). - The 3D view: the loader lists its own volume levels (x/y halvings down to 64 px, every z plane), reads each plane whole, two at a time per channel, and averages each square of pixels into a voxel as the bands arrive. Its reads use bands the 2D view holds but add nothing to the band cache or the persistent cache (StripBandCache.peek, write: false). - Volumes are keyed by the image's position too, so another CZI scene (or BigDataViewer view) is read instead of the last one shown again. - jpegFrameHeader in jpegSequential.ts; the test LZW encoder moves to src/test/lzwFixtures.ts. - Docs: Phase 39 M2 (mosaics are now M3, JPEG XR M4), the CZI and 3D View sections, and the format notes.
…ort-ec312e # Conflicts: # README.md # docs/image-only-and-geojson.md # docs/user-guide.md # src/data/morphologyImage.ts # src/datasets/datasetFactory.test.ts # src/datasets/datasetFactory.ts
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.
Phase 39 M1 and M2: a Zeiss CZI URL (or Zenodo's
.czi/content) opens as an image-only dataset when each channel, z plane, time point and scene is one full-resolution subblock: a confocal stack, or a tile scan ZEN has stitched. M2 (second commit) adds JPEG and LZW subblocks and the 3D view. No gallery example is added.What's in it
src/czi/: a reader written for the app from Zeiss's CZI layout, as libCZI reads it.cziFormat.ts: segments, the file header,DVdirectory entries, subblock headers, the metadata segment and the Zstd1 header.cziLayout.ts: planes by C/Z/T/S. Pyramid copies are left out, mosaics are counted, and other dimensions (phase, rotation, illumination, view, block) are read at their first coordinate, with a notice.cziMetadata.ts: scaling, significant bits, channel names and dyes, colours, display windows, and scene names.paxis, labelledScene.#c=,#z=,#t=and#p=select a plane, as for ND2.Low/Hightimes the pixel type's maximum (libCZI defines them as fractions of the pixel-type range).#AARRGGBBor#RRGGBB, read as Bio-Formats reads them; libCZI's parser fails on 6 digits, which the test file uses.Name (Fluor), e.g.Ch2-T1 (Alexa Fluor 568).bioformats2raw: mosaics, JPEG/JPEG XR/LZW, 32-bit and floating-point pixels, compressed subblocks over 128 MB, and multi-file CZIs.#c/z/t/pparsing move unchanged intosrc/data/rangeFileReads.tsandsrc/data/planeSelection.ts, which both readers now share.Diagnose Datasetrange-checks CZI files.docs/plan/phases/39-czi.md, a CZI section indocs/modalities/image.md, the data contract, and the format lists in the README, user guide, hosting, image-only, manifest and UI-reference docs.Checked
Image 4_Stitch.czi(7.25 GB on webatlasdata1) is an LSM 700 confocal stack stitched in ZEN 2014: 2 channels × 194 z planes, each an uncompressed 2,851 × 3,277 Gray16 subblock. Measured in headless Chromium with the GPU on the dev server, from a cold cache, at about 9 MB/s to the bucket:Z planesliderThe plane the app showed matches a standalone Python render of the same subblocks' bytes.
Tests run on synthetic CZI files from
src/test/cziFixtures.ts, with Zstandard written bynode:zlib. They cover the container, metadata, layout, open request counts, per-channel and per-plane tiles, shared bands, subblock metadata, both Zstandard forms, colour, scenes, missing planes, long directories, hiddenContent-Range, and each refusal.Passing locally: the full vitest suite (6,696 tests),
tsc -b,eslint ., Prettier,check:docsandvite build. The Playwright e2e suite was not run locally.M2: JPEG, LZW and 3D (second commit)
czifile:czifiledoes. This works around a known writer bug.loadVolumereads each plane whole, two at a time per channel, and averages each square of pixels into a voxel as the bands arrive.StripBandCache.peek, andwrite: falseon the persistent cache).jpegFrameHeaderinjpegSequential.ts, and the test LZW encoder moved tosrc/test/lzwFixtures.ts.Checked (M2)
Zeiss-5-SlidePreview-Zstd0.cziand-Zstd1-HiLo.czi(real Bgr48 files, CC0): the loader's pixels matched Python's owncompression.zstddecode at every sampled point, in both files. This also confirms M1's Zstandard paths on real data.Plate1-Blue-A-02-Scene-1-P2-E1-01.czi(3 channels × 21 planes, 672 × 512): opened in 3D at full resolution in 8 s, with 131 requests and 43.2 MB (the whole file).Image 4_Stitch.cziin 3D: the planner takes level 4 of 7, 357 × 410 × 194 voxels per channel, and reads the whole 7.25 GB file at about 9.5 MB/s. The full run was still going at commit time (206 of 388 planes in 400 s).tsc -b, ESLint, Prettier,check:docsandvite build.Known gaps
Image 4_Stitch.czi, OpenSlide's two Zstandard slide previews (48-bit colour), and an idr0011 stack. JPEG, LZW, scene and other-dimension files have been tried only as synthetic ones.