skills/exploratory-data-analysis/references/microscopy_imaging_formats.md
Reviewed: 2026-07-23 Executable scope: Metadata-only PNG/JPEG and TIFF/OME-TIFF inspection. Pixels are never decoded by bundled tools.
| Format | Bundled inspection | Depth |
|---|---|---|
.png, .jpg, .jpeg | Optional, pillow==12.3.0 | Width, height, mode, frame count, format, and metadata-entry count |
.tif, .tiff | Optional, tifffile==2026.7.14 | Bounded page/series structure, axes, shape, dtype class, BigTIFF/OME flags |
.ome.tif, .ome.tiff | Optional, tifffile==2026.7.14 | Same structural metadata; OME-XML values are not emitted or semantically validated |
| ND2/CZI/LIF and other vendor microscopy | No | Reference-only vendor/Bio-Formats workflow |
| DICOM/NIfTI/MRC | No | Reference-only medical/neuro/EM workflow |
| SVS/NDPI and other whole-slide formats | No | Reference-only WSI workflow |
| OME-Zarr/Zarr | No | Directory/store formats are outside the regular-file boundary |
No bundled script supports “all Pillow formats” or “all tifffile formats.” Only the registered suffixes above are accepted. Unknown formats fail closed.
Images and metadata can contain protected health information, accession numbers, specimen labels, GPS/EXIF fields, user comments, XML, external references, or adversarial text. The inspectors:
--root;load(), asarray(), imread(), image codecs, or thumbnail
generation;Metadata-only access reduces decompression risk but is not a sandbox. Keep libraries pinned and inspect untrusted images in an isolated, resource-limited process when risk warrants it.
Pillow's Image.open() is lazy: it identifies the container and reads enough
header information to construct an image object. The bundled inspector closes
the object without decoding pixels.
For quantitative EDA, retain the acquisition-native image and compare container metadata to instrument records. Do not compute intensity statistics from display/export JPEGs.
TIFF is a flexible container, not a single pixel organization. It can contain
multiple pages, tiles/strips, pyramids, SubIFDs, private/vendor tags, external
storage, and many compression schemes. A .tif suffix alone does not imply
microscopy or OME conformance.
The bundled tifffile inspector reports:
It does not read tag values, decode compressed segments, validate every IFD, open external storage, or establish that axes/series interpretation is scientifically correct.
OME-TIFF stores one or more image planes in TIFF and embeds an OME-XML metadata block. Multi-file datasets can use UUID-based references. The OME specification is richer than a filename convention.
Before quantitative analysis, use OME-aware validation to confirm:
TiffData plane-to-IFD mapping;The bundled inspector deliberately does not emit OME-XML because it may contain
identifiers or prompt-like text. is_ome_tiff=true is not a validation result.
ND2, CZI, LIF, VSI, proprietary whole-slide files, and similar formats require a version-aware vendor reader or Bio-Formats. Capabilities vary by library, native dependency, file generation version, and series type. Do not choose a reader only from a suffix.
Workflow:
DICOM is a clinical standard with extensive metadata and possible PHI. A
single .dcm may be one instance in a study/series. Use institutional policy,
approved de-identification, and DICOM-aware tools. Do not print patient, study,
series, accession, date, burned-in annotation, or private-tag values.
Validate dimensions, voxel sizes, affine/qform/sform, units, orientation,
scaling, and time axis with neuroimaging tooling. .nii.gz is compressed and
is not decompressed by bundled scripts.
SVS, NDPI, and related formats are large tiled pyramids and may contain label or macro images with identifiers. Use OpenSlide/tiffslide or a validated vendor reader, inspect associated images, and sample bounded tiles. Split by patient before tile generation to prevent leakage.
uv pip install \
"pillow==12.3.0" \
"tifffile==2026.7.14" \
"numpy==2.5.1"
Pillow 12.3.0 was released 2026-07-01 and requires Python 3.10+. tifffile 2026.7.14 was released 2026-07-14 and requires Python 3.12+. Imagecodecs is not installed or invoked by the metadata-only inspector.
All links accessed 2026-07-23.
Image module and decompression-bomb protection.