Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Fast-EM optical autofocus tests #2840

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/odemis/acq/align/autofocus.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,6 @@ def _DoBinaryFocus(future, detector, emt, focus, dfbkg, good_focus, rng_focus):
if future._autofocus_state == CANCELLED:
raise CancelledError()

if left == right:
logging.info("Seems to have reached minimum step size (at %g m)", 2 * step_factor * min_step)
break

# if best focus was found at the center
if i_max == 1:
step_factor /= 2
Expand All @@ -335,6 +331,13 @@ def _DoBinaryFocus(future, detector, emt, focus, dfbkg, good_focus, rng_focus):
# Clip best_pos in case the hardware reports a position outside of the range.
best_pos = max(rng[0], min(best_pos, rng[1]))
focus.moveAbsSync({"z": best_pos})

if left == right:
# Do this after moving to the best position, because clipping left and right can cause
# left and right to be equal, even when both are unequal to the best position.
logging.info("Seems to have reached minimum step size (at %g m)", 2 * step_factor * min_step)
break

step_cntr += 1

worst_fm = min(focus_levels.values())
Expand Down
Loading