Lab Note · updated 2026-06-20
How to Prepare Microscopy Data for AI
Most of the work of applying AI to microscopy is data preparation — formatting, normalization, tiling, and label hygiene — and the single most consequential decision is a split that respects the non-independence of microscopy data. Get the split wrong and every downstream metric is leaked, not earned.
The problem — The model is the small part. The bulk of applying AI to microscopy is upstream: getting pixels into a consistent format and bit depth, normalizing intensities so a model doesn't learn the scanner instead of the biology, tiling large images into model-sized patches without destroying context, and curating labels that are actually correct. Each step is a chance to encode an artifact. The most expensive mistake is invisible: a train/test split that lets information leak from evaluation into training, so the reported accuracy measures memorization, not generalization.
What it is / how it works — Treat preparation as four explicit, recorded operations:
- Format and normalization — canonical channel order, bit depth, and physical pixel size (carried in OME-NGFF), with an intensity normalization chosen deliberately — per-image, per-plate, or reference-based — because it determines whether batch signal survives into the features.
- Tiling — splitting whole-slide or volumetric images into patches at a defined magnification and overlap, so context isn't severed at tile edges and the model sees a consistent physical scale.
- Label hygiene — annotations validated for completeness and class consistency; incomplete masks teach a segmenter that real objects are background.
- Splits that respect non-independence — the load-bearing step. Microscopy data is correlated at the well, slide, patient, and batch level. Splitting at the image level leaks neighbors: tiles from one slide land in both train and test. Kapoor & Narayanan document this leakage as a reproducibility crisis across 17 fields; split at the independent unit — patient, slide, batch — not the image.
Where it breaks — The general failure is letting a hidden correlation cross the split, so the metric is leaked rather than earned — and the correlated unit differs by platform. In digital pathology tiles from one patient's slide in both folds inflate accuracy that collapses on a new scanner. In Cell Painting sibling wells or replicate plates split apart leak the batch, so the model scores the assay instead of the perturbation. In spatial omics adjacent fields of view share cells across a tile boundary, leaking across the split. In light-sheet overlapping crops from one volume appear on both sides. The methodological literature generalizes it: leakage and evaluation noise let benchmark gains outrun real utility. Preparation choices are also data dependencies that belong in the run manifest — and the quality that matters is task-conditioned, not pixel-level.
References
- Kapoor & Narayanan (2023). Leakage and the reproducibility crisis in machine-learning-based science. Patterns.
- Varoquaux & Cheplygina (2022). Machine Learning for Medical Imaging: Methodological Failures and Recommendations. npj Digital Medicine.
- Moore et al. (2021). OME-NGFF: a next-generation file format for expanding bioimaging data-access strategies. Nature Methods.
References
- Kapoor & Narayanan, Leakage and the reproducibility crisis in machine-learning-based science (Patterns, 2023)
- Varoquaux & Cheplygina, ML for Medical Imaging: Methodological Failures (npj Digital Medicine, 2022)
- Moore et al., OME-NGFF: a next-generation file format for expanding bioimaging data-access strategies (Nature Methods, 2021)