Supplementary Figure 8: Flowchart and performance of autofocus routine using the ETL. | Nature Methods

Supplementary Figure 8: Flowchart and performance of autofocus routine using the ETL.

From: NeuBtracker—imaging neurobehavioral dynamics in freely behaving fish

Supplementary Figure 8

(a) The electrically focus-tunable lens (ETL) can be controlled from the acquisition GUI for calibration of the system and optimizing the focus for each experimental run, reporter line and developmental stage used. It can also be run via an autofocus routine to enable, e.g., refocusing for long-term recordings or screens. The routine operates by computing a focus measure of each acquired frame. If this measure is lower than a threshold, additional focus measures are obtained from images acquired by varying the focal length of the ETL in both directions. A 2nd-degree polynomial is fitted to the obtained focus measures vs. the focal lengths that were acquired. If the residuals of the fit are small, the ETL is set to the focal length that resulted in the largest focus measure. If the residuals are large, the maximum of the fitted curve is used to set the ETL to the corresponding focal length. (b) To systematically demonstrate the performance of the autofocus algorithm, we moved an arena containing a larva tg(HuC:H2B-GCaMP6s) out of focus and let the focus routine adjust the focal length of the ETL to recover focus. In the panels beneath the flowchart, three representative cases are shown. The left panel shows the case in which a drop of the focus measure occurred after a downward movement of the stage at 7 seconds (cyan, left y-axis). The control currents (-80 to -130 mA) that were sent to the ETL to change focal length and regain focus are plotted in orange (right y-axis). The bottom graph displays the focus measure against the ETL position for 10 acquisitions acquired at different focal lengths. The large black dot shows the estimation of the optimal focal length that was then used to recover focus. The middle graph shows a case in which the estimated optimal focal length (large black dot) falls outside the range of measurement that were taken; still, focus was recovered by setting the ETL to the predicted focal length. The right panel shows an instance in which the arena movement was continuing. This resulted in the focal measures from the acquisitions shown in red together with the fitted function and the estimated focal length. Since the first term of the fitted polynomial (shown in red) was negative, the routine selected the maximum focal measure it found among its acquired images (as opposed to the estimate) to set the focal length of the ETL. (c) Fine-focusing of the ETL (mΑ control currents correspond to submicron steps in the focal length) on a larval brain. (d) To showcase the focal length range of the ETL, fish swimming in different depths in a 10 mm deep arena were brought in focus. The bottom frame focuses on the right fish located close to the surface (fish is tilted). The top frame was acquired 200 ms later and focused on the left fish swimming at a greater depth.

Back to article page