ZhuangLab / storm-control

Microscope control software
Other
66 stars 68 forks source link

Bug fix in focus lock scan functionality #95

Closed MoffittLab closed 4 years ago

MoffittLab commented 4 years ago

We identified a problem in which the focus lock fails to properly scan for the focus if the lock target is close to zero. The problem appears to be that when it starts the scan, no spots are present on the camera; thus, the qpd returns an 'is_good' dictionary element of False and an 'offset' element of zero. However, if the desired lock target is too close to zero, the default offset value is considered 'in focus' and the scan stops immediately in the wrong focal plane.

The solution we propose is to check theis_good element of the qpd_state. If this element is not true, the scan continues independent of the 'offset' value.

HazenBabcock commented 4 years ago

Makes sense, thanks.

I think you will also want to set the 'sum_warning_low' value and/or the 'background' parameter correctly for your setup. As it is now the focus lock seems to (inconsistently and for reasons that are no longer obvious to me) use two different things to decide on whether the QPD values are usable. One if the 'is_good' value and the other is the 'sum'. In the line that you changed, the 'sum' check should also have failed if there were no spots on the camera. The focus lock uses the QPDs 'sum_warning_low' value for self.sm_min_sum if you did not explicitly set it to something else (so it won't be -1.0 as you might suspect from looking at the appParameters() method).