Method / tool

BaSiCPy

Python implementation of the BaSiC algorithm for retrospective flat-field and dark-field estimation in optical microscopy; corrects uneven illumination across an image stack without requiring reference images.

The problem — Every widefield and confocal microscope produces a non-uniform illumination field: brighter in the centre, dimmer at the periphery, with an additive dark-field offset that drifts over a run. Left uncorrected, these gradients encode themselves into every intensity measurement, inflating or suppressing features in a spatially predictable but biologically meaningless way. The effect is especially insidious in high-content screening, where a compound at the plate edge appears phenotypically different from the same compound at the plate centre.

What it is / how it works — BaSiCPy estimates a smooth flat-field and dark-field from the image collection itself — no blank-field acquisition required. It formulates shading correction as a low-rank and sparse decomposition problem solved via the Alternating Direction Method of Multipliers (ADMM). The Python rewrite (peng-lab) adds JAX-backed GPU acceleration, achieving roughly 9× faster flat-field fitting and 2× faster whole-stack correction compared to the original MATLAB BaSiC, while requiring fewer input images to reach reliable estimates. No manual parameter tuning is needed for typical fluorescence imaging.

Where it fits in the pipeline — BaSiCPy belongs at the preprocess stage, applied per channel before segmentation or feature extraction. Running it earlier rather than later is non-negotiable: a shading gradient in the raw images becomes a systematic offset in CellProfiler or DeepProfiler features, and once features are computed the artefact cannot be cleanly separated from biology.

Where it breaks — The low-rank assumption holds when the true signal is sparse relative to the illumination field — it degrades when nearly every image contains a dense, uniform signal (e.g., confluent cultures with saturated nuclei stain). Very short stacks (< ~10 fields) produce noisy estimates. For time-lapse data with rapid intensity drift, BaSiCPy's time-lapse mode should be enabled explicitly.

Verify the correction before trusting it. Overlay the estimated flat-field on representative fields and confirm it tracks the observed vignetting pattern. A correction applied blindly to a mismatched channel can introduce more bias than it removes. The [batch-correction](/lab-notes/batch-correction-without-erasing-biology) step downstream is not a backstop for a broken illumination model.

References

Appears in these notes

← Back to the constellation