fix: populate region_shapes for flexible/single/template regions#554
Open
mpiersonsmela wants to merge 1 commit into
Open
fix: populate region_shapes for flexible/single/template regions#554mpiersonsmela wants to merge 1 commit into
mpiersonsmela wants to merge 1 commit into
Conversation
Only add_region (well-plate) and set_manual_coordinates were populating self.region_shapes. The other add methods — add_flexible_region, add_flexible_region_with_step_size, add_single_fov_region, and add_template_region — wrote region_centers and region_fov_coordinates but skipped region_shapes. validate_region only checks region_centers and region_fov_coordinates, so it returned True for these regions, and the subsequent self.region_shapes[region_id] lookup in get_region_shape raised KeyError. Enabling "Use Focus Map" in flexible multipoint mode goes through region_contains_coordinate -> get_region_shape and crashed. Set region_shapes[region_id] = "Square" in the four missing add methods. region_contains_coordinate only special-cases "Circle" (radius check); rectangular grids correctly fall through to the bounding-box test.
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
KeyErrorthat crashes the GUI when enabling Use Focus Map in flexible-multipoint acquisition after loading a region list.Bug
Repro: switch to flexible multipoint, load a list of regions (e.g.
R0..R3), check Use Focus Map → crash.Root cause
ScanCoordinateskeeps three parallel dicts keyed byregion_id:region_centers,region_fov_coordinates, andregion_shapes. Onlyadd_region(well-plate) andset_manual_coordinatespopulateregion_shapes. The other four add methods write the first two dicts but skipregion_shapes:add_flexible_regionadd_flexible_region_with_step_sizeadd_single_fov_regionadd_template_regionvalidate_regiononly checksregion_centersandregion_fov_coordinates, so it returnsTruefor these regions and the subsequentself.region_shapes[region_id]lookup inget_region_shaperaisesKeyError. The focus-map grid generator hits this path throughregion_contains_coordinate→get_region_shape.Fix
Set
self.region_shapes[region_id] = "Square"in the four missing add methods.region_contains_coordinateonly special-cases"Circle"(radius check); rectangular grids correctly fall through to the bounding-box test, so"Square"is the right value for these grid-based regions.Test plan
master: load region list in flexible mode, enable Use Focus Map →KeyError🤖 Generated with Claude Code