  Autofocus (AF) methods are extensively used in biomicroscopy, for example to
acquire timelapses, where the imaged objects tend to drift out of focus. AD
algorithms determine an optimal distance by which to move the sample back into
the focal plane. Current hardware-based methods require modifying the
microscope and image-based algorithms either rely on many images to converge to
the sharpest position or need training data and models specific to each
instrument and imaging configuration. Here we propose DeepFocus, an AF method
we implemented as a Micro-Manager plugin, and characterize its Convolutional
neural network-based sharpness function, which we observed to be depth
co-variant and sample-invariant. Sample invariance allows our AF algorithm to
converge to an optimal axial position within as few as three iterations using a
model trained once for use with a wide range of optical microscopes and a
single instrument-dependent calibration stack acquisition of a flat (but
arbitrary) textured object. From experiments carried out both on synthetic and
experimental data, we observed an average precision, given 3 measured images,
of 0.30 +- 0.16 micrometers with a 10x, NA 0.3 objective. We foresee that this
performance and low image number will help limit photodamage during
acquisitions with light-sensitive samples.
