fix: skip focus-map interpolation for single-FOV snap acquisitions#577
Merged
hongquanli merged 1 commit intoJul 4, 2026
Conversation
Snap Images in Wellplate Multipoint mode crashed with "ValueError: Region current not found" when a per-well focus map was loaded. run_acquisition(acquire_current_fov=True) creates a temporary ScanCoordinates region named "current" for the one-off snap. The focus_map block then unconditionally calls focus_map.interpolate(x, y, "current"), but the focus map was fit by well IDs (e.g. B1, B2) with fit_by_region=True, so "current" is not in region_surface_fits and the call raises. Snap Images is a manual snapshot: the stage is already at the user's chosen Z (on_snap_images sets set_z_range(z, z) from the current stage position), so overriding Z from the focus map is not the intended behavior for the single-FOV path. Gate the focus_map block on `not acquire_current_fov` so it applies only to real multi-region acquisitions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a crash when clicking Snap Images in Wellplate Multipoint mode while a per-well focus map is loaded.
Bug
Steps to reproduce (on master)
main_hcs.py), switch to Wellplate Multipoint mode.fit_by_region=True— one surface per well). The focus map ends up keyed by well ID (B1,B2, …).ValueError: Region current not found.Root cause
run_acquisition(acquire_current_fov=True)atmulti_point_controller.py:722-735creates a temporaryScanCoordinateswith a single region literally named"current"for the one-off snap. Immediately after, the focus-map block (multi_point_controller.py:774-784) runs unconditionally:With
fit_by_region=True,FocusMap.interpolaterequiresregion_id ∈ region_surface_fits(core.py:1931-1933)."current"is never in that dict, so the call raises.Fix
Gate the focus-map block on
not acquire_current_fovso it applies only to real multi-region acquisitions:Rationale: Snap Images is a manual snapshot.
on_snap_imagesatwidgets.py:8547-8548already setsset_z_range(z, z)fromstage.get_pos().z_mm— the user's currently focused Z. Overriding that Z with a focus-map interpolation was never the intended behavior for the single-FOV path, so skipping the block is the correct semantics and resolves the region-name mismatch.How to verify the fix
Using focus surface for Z interpolationshould still appear for full acquisitions, and NOT for Snap Images.🤖 Generated with Claude Code