Focus map generation for contrast-based AF

(added in this pull request: Adding focus map generation for contrast AF by catalli · Pull Request #27 · hongquanli/octopi-research · GitHub)

This feature (currently only in the malaria GUI as its own widget but added to the multipoint widget for grid-based multipoints) allows the generation of linear-interpolation based focus maps for contrast AF.

Here is a video demonstrating the focus map in use:

The Focus Map
The focus map is a set of 3 points in 3D space, which together, define a focus plane. Given a set of other x-y coordinates, the corresponding z coordinate can be interpolated to bring the objective in line with this focus plane. While it is enabled, all contrast-based autofocusing is done by interpolating a Z-coordinate to focus on instead of doing an autofocus cycle.

The Focus Map Widget
The Focus Map Widget, currently only in the malaria GUI (users can add it to their own GUI by following the implementation in gui_malaria.py, since it is merely an access point for functionalities added to the autofocus controller), allows direct access to the focus map. It is accessible from the same tab cluster as the multipoint widget.

The user can define their own focus map by navigating to 3 points on the slide which are not linear, and then manually focusing on the slide at those points and clicking the “Add to focus map” option at each one (this is what is done from 0:00 to 0:52 in the linked video). After 3 points are defined and displayed on the focus map widget, the user can click the “Enable focus map” option, which, as shown from 0:52 to 1:23, overrides usual autofocus activity, including during multipoint acquisitions, with interpolation from the focus map. While the focus map is enabled, multipoint acquisitions always “autofocus” at every FOV, since running a whole autofocus cycle is no longer necessary and thus focusing is much faster.

Generating a focus map for a grid acquisition
The grid-based Multipoint Acquisition widget (the non-flexible one) now has a checkbox labeled “Generate focus map.” As demonstrated in the video after 1:23, checking this will cause the microscope to navigate to three corners of the rectangle captured by the multipoint acquisition, perform an autofocus at each (it is recommended the user manually focus at the initial point for the autofocus to work), and use these three points to generate a focus map. After the multipoint acquisition is finished, previous autofocus/focus map behavior (if any) is restored.