A software-based focus system for wide-field optical microscopy
Ilyas Djafer-Cherif, Bartlomiej Waclaw
TL;DR
This work presents iPFS, a software-based autofocus method for long-term wide-field microscopy that uses markers on the opposite surface and a μManager-compatible Beanshell script to compensate axial drift with only a PC-controlled Z-stage. By tracking a rigid surface via a 3D image stack and applying a sharpness-maximization update, iPFS achieves drift compensation comparable to hardware autofocus systems while maintaining compatibility with transmitted-light and fluorescence imaging. Benchmarks with fluorescent beads across 20× and 40× objectives show iPFS can track drift with sub-micrometer precision ($\approx$ $0.25\,\mu\mathrm{m}$) well within the depth of field ($d\approx 2.2\,\mu\mathrm{m}$ for 20× and $0.7\,\mu\mathrm{m}$ for 40×), and remain effective over extended times (tens of hours) and varying sample conditions. The approach is demonstrated on live-growing E. coli micro-colonies, offering a cost-effective, open-source autofocus alternative suitable for long-term, multi-position imaging and compatible with standard imaging hardware.
Abstract
Long-term time-lapse imaging of biological samples requires correcting for focal drift, which would otherwise gradually push the sample out of focus. We present a software-based method that eliminates this time-dependent blur using only a motorized Z-drive, with no additional hardware. The method relies on imaging marks made on the side of the coverslip opposite to the sample. We provide a Beanshell script implementation, evaluate its performance across multiple objectives, and benchmark it against a hardware autofocus system, finding comparable results. Finally, we demonstrate its effectiveness in live imaging of growing bacterial colonies.
