romainbrette/holypipette

Paramecium autofocus

Closed this issue · 2 comments

I realize there might a rather simple way to know the vertical position of Paramecium (to know where to send the pipette), which is do an autofocus. The basic idea for autofocus is to change z so as to optimize some image criterion such as contrast. Some info in this review:

"The Fibonacci search algorithm is employed for controlling the z-motor of the microscope to reach the focus position that is determined by focus objective functions. Experimental results demonstrate that the variance algorithm provides the best overall performance"

Variance is totally trivial, obtained directly with a numpy call (var). For us, what matters is only reproducibility (across specimens); the actual position does not really matter. We also need to window over the cell, but this is trivially done by the tracking algorithm.

I suggest for a start to do an autofocus on a clicked position. One parameter is the size of the bounding box, which could be 150 µm to capture the whole cell, or a smaller patch (20 um?) to be sure that only the cell is in the bounding box. Something to try.

So I tried using scipy.optimize.golden. It seems to work, with a sleep time of 0.5 s. But perhaps I should use fminbound instead.