Skip to content

Read TIFF-based whole-slide formats (SVS/NDPI/SCN) as RGB units; a conversion helper for WebP/PNG/JPEG #294

Open

Description

@guijacquemet

Context

Owner decisions (2026-11-13, MorphoFeature #220 RGB data-flow audit, gap 2):

  • a thin reader for TIFF-based whole-slide formats;
  • a conversion helper for small RGB formats.

Today preprocessing reads only TIFF and OME-Zarr. Other extensions are skipped as "not an image".

Evidence (Aperio CMU-1-Small-Region.svs from the OpenSlide test data, preprocessing v0.5.2, tifffile):

  • tifffile parses the SVS: is_svs, series Baseline (2967, 2220, 3) axes YXS, photometric RGB, JPEG-compressed 240 px tiles, plus Thumbnail, Label and Macro series. With imagecodecs installed it decodes them.
  • As slide.svs, preflight skips it: "1 file is not an image (TIFF or OME-Zarr)".
  • Renamed slide_as.tif, it is read (YXS, mapping C = samples) and then refused: "1 image contain more than one image … several series … not supported yet". The thumbnail, label and macro series cause this.

Proposal: thin reader

  1. Extensions: accept .svs, .ndpi, .scn (and other formats that tifffile identifies as a whole-slide TIFF variant) through the existing TIFF path. imagecodecs becomes an optional extra ([wsi]). Without it, refuse with a message naming the extra; never skip silently.
  2. Baseline-image rule:
    • Analyse only the full-resolution baseline series.
    • The associated images (label, macro, thumbnail) are listed in the run record as ignored and are never read: the slide label can carry patient identifiers.
    • This is an explicit, recorded exception to the "more than one image" refusal, limited to these named associated series. Any other multi-series file is still refused.
  3. Pyramid levels: level 0 only, unless a level is chosen explicitly (Design: windowed (lazy) Y/X reads of one plane for very large images (whole-slide OME-Zarr) #179: no default level). The physical pixel size comes from the format's own metadata (e.g. Aperio MPP) when the format states it. Otherwise it is undeclared. It is never inferred from magnification.
  4. Lazy reads: real slides are about 100k px per side. Histograms (plane_histograms.csv) must stream tiles, and patching needs windowed reads (Design: windowed (lazy) Y/X reads of one plane for very large images (whole-slide OME-Zarr) #179, CellPatcher [Sad Catapella B5][Scientific integrity] Reused TIFF-converted Zarr copies are not validated against their stored pixels #87). Until then, refuse planes over the memory limit with the existing named error.
  5. RGB declaration: these files carry photometric RGB, so image_type = "rgb" matches the header (no override needed; compare MorphoBricks-Spec Masks have no plane identity (T/Z) #36 for MINISBLACK files).
  6. Tests: decode parity of the baseline with tifffile on a small public SVS (downloaded and checksum-checked in a test that skips without network, never committed); the associated series are recorded and not read; refusal without imagecodecs; multi-series files other than these are still refused.

Non-TIFF whole-slide formats (MRXS, CZI, VSI) are out of scope here. They enter by a documented conversion: bioformats2raw --series 0 slide.mrxs slide.zarr to OME-Zarr. --series 0 keeps only the baseline, or the same multi-series refusal applies.

Proposal: conversion helper for WebP/PNG/JPEG

A small helper, usable from the notebook and the API:

  • Conversion: writes each image as photometric-RGB TIFF (uint8, YXS) next to the source or into a chosen folder.
  • Record: the source file name, format, size and SHA-256 are recorded in a sidecar that the run picks up.
  • Lossy formats: WebP and JPEG are refused unless the user acknowledges lossy compression explicitly, and that acknowledgement is recorded. Alpha is refused, never dropped silently.
  • Not a reader: the helper writes TIFF before discovery, so preprocessing itself stays TIFF/OME-Zarr only.

Refs MorphoFeature #220, MorphoBricks-Spec #36, #179, CellPatcher #87.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions