All Articles / Application Notes

Comparing Autofocus Methods for Automated Microscopes

By Dave Goosen, Mike Fussell

Published on Oct. 25, 2024

Default image for https://www.zaber.com/articles/autofocus

Autofocus is a key feature of many microscope systems. It enables reliable hands-off imaging of large samples like microplates. Zaber's Nucleus microscopy platform supports both software and hardware autofocus. This article provides a summary of the key differences between the two methods and recommends when to use them.

Before selecting an autofocus system, it is worth considering what level of focus is truly required. Applications like high-content imaging and many spatial biology techniques require the sharpest focus possible. Much less sharpness of focus is required for many assays which rely on the unambiguous differentiation between the presence or absence of a fluorescent signal at a given point. It is also worth considering how images will be analyzed. For automated reading of assays, images which may not look great to a human viewer, may be more than sufficient for reliable decision making.

Software Autofocus

Software autofocus works by capturing a vertical stack of images that encompasses the expected focus plane. These images are then analyzed by software to evaluate their sharpness. The focus stage position that corresponds to the sharpest image is determined to be the focus height.

Principle of operation of software autofocus
Software autofocus captures a series of images with a range of focal plane distances. The software then chooses the distance with the highest sharpness score. Many systems work by analyzing edges using a Laplace transformation of the image. In this example, 5 images would be captured before choosing the image at 20.03 mm as the sharpest.


Software autofocus works well for use-cases like adherent cells where the approximate position of the sample is known. For free floating cells or organoids, capturing a wide enough range of focus points to ensure the sample is included may take a very long time - particularly when multiplied out across the 96, 384 or 1536 wells of a microplate! Contrast-based autofocus systems may focus on unintended areas if the contrast of those areas is determined to be better than the intended target. Striking an appropriate balance between speed and focus accuracy is critical. Ideally, the steps of the Z-axis should be small enough that they are within the depth of field of the adjacent images. Smaller steps will result in a higher probability of achieving better focus, but the more steps, the longer the focus time will be. This effect increases as objective magnification and Numerical Aperture increases.


The advantages of software autofocus are:

  • No additional hardware is required.
  • The focusing algorithm is not affected by variations in the thickness of the microplate or slide coverslip.
  • It can work for almost any combination of objective, sample holder, immersion fluid and fixing medium.


The disadvantages of software autofocus are:

  • It is slow. Typically 3-10 images need to be captured at each XY location in order to determine the focus height. Depending on the exposure time required, it can take over 1 second to focus.
  • It is not possible to continuously maintain focus while moving in the XY plane.
  • The extra light exposure required to capture the image stack can be damaging to the sample.


Software autofocus is supported in μManager open source software. You can also use our Python example script as a starting point to implement software autofocus in your own code.

Hardware Autofocus

Hardware autofocus systems directly measure the position of the slide or imaging vessel and do not require images to be captured, analyzed and compared. This means they are much faster than software-based autofocus systems. Without the requirement of directly imaging the sample, hardware autofocus systems greatly reduce the amount of light a sample is exposed to, which prevents photobleaching and phototoxicity of delicate and living samples.

Hardware autofocus systems are ideal for applications which require high throughput fluorescence imaging of live adherent cells. Since hardware autofocus is not damaging to samples, it can run continuously to track a sample as it is moved around and compensate for thermal drift on long duration and time lapse imaging tasks.

Most hardware autofocus systems work by projecting an infrared (IR) laser beam through the objective lens of the microscope and onto the sample where it is reflected back towards an optical sensor which makes the distance measurement. For reflection to take place, there must be an interface surface between materials of sufficiently different indices of refraction (e.g. air-glass). The reflected laser beam returns through the objective lens and back into the autofocus sensor by means of a dichroic mirror, allowing the autofocus laser to share the same beam path as the imaging light without affecting imaging performance. Most sensors use the triangulation principle to convert the reflected light into measurements of the distance and direction to the focal plane. Since the sensor detects and measures the position of the first air-glass interface, the user must set the target focal plane for their particular sample to establishes the offset between the detected surface and the target focal plane.

The IR lasers used by laser AF systems are very low energy. This is advantageous for live cell and long duration imaging where phototoxicity and photobleaching of fluorophores must be avoided.

Operation of HL04 on Nucleus microscope
Basic operation of the HL04 autofocus sensor on a Nucleus inverted microscope


The advantages of hardware autofocus are:

  • It is fast, since no image capture is required.
  • It allows continuous focus tracking so you never lose focus as you move across a sample.
  • It is non-damaging to most biological samples. The low energy IR laser used by the Nucleus autofocus system has a long wavelength of 785 nm which is safe for live cells and does not interfere with commonly used fluorophores.
  • It is simple to use in any software platform. Zaber Motion Library commands allow easy configuration and use of hardware autofocus with Nucleus microscopes.


The disadvantages of hardware autofocus are:

  • It requires extra hardware and adds significant cost to a microscope.
  • It focuses based on a fixed offset from the reflective interface surface, therefore changes in the the distance between this surface and the sample could cause focusing error.
  • It can be difficult or impossible to get hardware autofocus working for certain combinations of objective, sample, fixing media and immersion fluid.
  • Systems from some manufacturers may require AF-specific objectives.

Combining Methods

For automated systems, it is possible to combine software and hardware autofocus for complete hands-off automation. Using software autofocus for the initial focus operation to determine the focus offset is slow, but once it has been completed, subsequent focus operations can use the much faster hardware autofocus.

Zaber's Nucleus Autofocus Sensor

The HL04 hardware autofocus sensor used by Nucleus microscopes triangulates an IR laser reflected off the first air-glass surface of the slide or imaging vessel. In Nucleus systems, the HL04 sensor communicates directly with the X-LDA focus stage. A control loop in the X-LDA reads the position signal from the sensor, applies the require focus offset and adjusts the stage position to move to and maintain focus. This direct sensor to focus stage controller communication is extremely low latency. This maximizes the speed of both single focus actions, and focus tracking. The HL04 does not require autofocus-specific objectives and also works with darkfield objectives.

The HL04 sensor uses a 785 nm wavelength laser which is low energy and safe for live cells. Coupling the sensor to the optical path of the Nucleus microscope requires the MJB25C-F1 junction block. This module houses a 785 nm notch filter to keep laser light from the detector when the focus laser is powered on. A narrow 20 nm notch filter is used rather than the long-pass filter seen in other systems. This improves the utility of Zaber's Nucleus Platform for live cell imaging by supporting long wavelength fluorophores like Cy7.5.

785 nm notch filter and common fluorophores
Transmission plot of 785 nm notch filter relative to excitation and emission spectra of common fluorophores

The advantages of Zaber's hardware autofocus are:

  • It is fast. Focusing can be done in less than 250 ms.
  • Robust focus tracking even on highly tilted and low reflectivity surfaces
  • No requirement for autofocus-specific objectives
  • Full API control for integration into custom systems
  • Narrow notch filter preserves greater range useful long wavelength fluorophores

Conclusion

This article explored three primary methods of autofocus in microscopy: software autofocus, hardware autofocus, and hybrid approaches that combine both. Software autofocus analyzes image stacks to determine the optimal focus, while hardware autofocus uses laser-based measurements for rapid and continuous focusing. Hybrid approaches can leverage the strengths of both methods. The choice of autofocus method depends on factors such as the specific application, required speed, and budget constraints.

To determine the most suitable autofocus solution for your particular needs, feel free to contact Zaber and talk to our microscopy specialists.