Table of Contents
Fetching ...

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.

A software-based focus system for wide-field optical microscopy

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 ( ) well within the depth of field ( for 20× and 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.

Paper Structure

This paper contains 32 sections, 3 equations, 11 figures, 1 table, 1 algorithm.

Figures (11)

  • Figure 1: Schematic of iPFS operation. (A) A marker on the external surface of the microscope slide is kept in focus, serving as a reference for all distances in the Z axis. (B) The algorithm maintains sample focus by tracking the marker over time. (C) The $\upmu$Manager iPFS script interface.
  • Figure 2: Experimental setup used to characterise the stability of the iPFS algorithm. (A) Schematic of the setup. The 16 marker positions used to evaluate stability are shown as coloured dots. (B) Photograph of the actual sample. (C) Images of individual markers. (D) Sharpness-maximizing Z positions versus time, for all 16 markers (20x magnification). (E) Corresponding sharpness metric as a function of time. (F) Normalized probability distribution of changes in marker position, showing the deviation between consecutive measurements: $z_\mathrm{focus}(t+3\ \mathrm{min}) - z_\mathrm{focus}(t) = \Delta z_\mathrm{focus}$. (G) Normalized sharpness curves for all markers at the end of the experiment.
  • Figure 3: Imaging fluorescent beads using iPFS. (A) Experimental setup. Green circles represent fluorescent beads (not to scale) on top of a 1mm-thick agarose slab (orange), and sealed with silicone grease (yellow). An example image of the beads in both bright field and fluorescence is also shown. (B-C) Normalised sharpness of the beads along the z-direction (40x objective), at four different locations on the slide (curves in different colours), in fluorescence (B) and bright-field (C). See Figure \ref{['fig:sh_prof_dots_x20']} for the same plot for the 20x objective. (D) iPFS maintains focus despite sample movement (20x objective). Red line: $z_\mathrm{beads}$, the $z$ coordinate of maximum sharpness $S_{\rm beads}(z)$ for the beads at one position. Black line: $z_\mathrm{mark}$, the position of the tracked marker. Green line: $z_\mathrm{mark}$ offset by $d(0)$, the initial difference between the marker and the beads' sharpest image. Perfect drift compensation would make the green line overlap with the red line. (E) Sharpness function $S_{\rm beads}(\delta z + z_\mathrm{beads}(0) + (z_\mathrm{mark}(t)-z_\mathrm{mark}(0)))$, where $\delta z$ is the offset from the corrected $z$ coordinate of the beads' sharpest image. Dark green line: offset $\Delta z$ of the sharpest image (maximum of $S(\delta z)$). (F) $\Delta z$ versus time for all six imaged locations. (G) Histogram of $\Delta z$ for all six locations and all time points. The FWHM (black line) has been obtained from a smooth curve (red line) fitted to the histogram.
  • Figure 4: Comparison between iPFS and PFS for the 20x objective. (A) Deviation between the position of the sharpest image of fluorescent beads and the position found by iPFS and PFS. (B) Histogram of $\Delta z$ (the same quantity as the one plotted in Figure \ref{['fig:beads']}G), for all positions and time points.
  • Figure 5: Comparison between iPFS and PFS for the 40x objective. (A) The deviation between the position of the sharpest image of fluorescent beads and the position found by iPFS and PFS. (B) Histogram of $\Delta z$ for all positions and time points.
  • ...and 6 more figures