Skip to content

feat: allow negative FOV overlap to introduce spacing between tiles#555

Open
mpiersonsmela wants to merge 1 commit into
Cephla-Lab:masterfrom
mpiersonsmela:feat/negative-fov-overlap
Open

feat: allow negative FOV overlap to introduce spacing between tiles#555
mpiersonsmela wants to merge 1 commit into
Cephla-Lab:masterfrom
mpiersonsmela:feat/negative-fov-overlap

Conversation

@mpiersonsmela
Copy link
Copy Markdown

@mpiersonsmela mpiersonsmela commented Jun 1, 2026

Summary

Allows the FOV Overlap spinbox in both Flexible and Wellplate multipoint acquisition modes to accept negative values, which introduce spacing between adjacent FOVs (useful for sparse sampling).

Motivation

This is useful for sparse imaging over a large well, in cases where cells may not be evenly distributed (so looking at the center of the well may not be representative).

Today the spinbox is bounded setRange(0, 99). The downstream math already does the right thing for negatives:

step_size_mm = fov_size_mm * (1 - overlap_percent / 100)

A negative overlap (e.g. -50%) produces a step ~1.5× the FOV — tiles end up spaced apart rather than overlapping. The only thing blocking the feature was the input bound.

Changes

  • software/control/widgets.pyFlexibleMultiPointWidget: setRange(0, 99)setRange(-1000, 99)
  • software/control/widgets.pyWellplateMultiPointWidget: setRange(0, 99)setRange(-1000, 99)
  • software/control/microscope_control_server.py — MCP server's overlap_percent Pydantic field: ge=0, le=50ge=-1000, le=99 so YAML / API callers can also pass negative overlap. (Note: the previous le=50 was already inconsistent with the UI bound of 99; this aligns them.)

A lower bound of -1000% gives a step size of up to ~11× the FOV — effectively unlimited for any realistic plate, while keeping the spinbox UI well-behaved.

Safety

  • Out-of-bounds FOVs generated by extreme spacing are already filtered downstream by ScanCoordinates.validate_coordinates() against SOFTWARE_POS_LIMIT, so no additional bounds checking is needed.
  • control/core/geometry_utils.py already guards step_size <= 0 for the pathological overlap >= 100% case.
  • No changes to scan-coordinate or geometry logic.

Test plan

  • Spinbox accepts -50 in both wellplate and flexible mode; live FOV preview shows tiles spaced ~1.5× FOV apart
  • Very negative values (e.g. -500) don't crash near stage limits — out-of-range FOVs are silently dropped
  • YAML load with overlap_percent: -25 passes Pydantic validation
  • Positive overlap (e.g. 10%) behaves unchanged — regression check

🤖 Generated with Claude Code

The FOV Overlap spinbox in flexible and wellplate multipoint widgets
previously rejected negative values (setRange(0, 99)). The downstream
math already handles negatives correctly:

    step_size_mm = fov_size_mm * (1 - overlap_percent / 100)

A negative overlap simply produces a step larger than the FOV size,
spacing tiles apart rather than overlapping them — useful for sparse
sampling. The only thing blocking the feature was the spinbox bound
(and the matching ge=0 in the MCP server's Pydantic field).

Changes:
- widgets.py (FlexibleMultiPointWidget): setRange(0, 99) -> (-1000, 99)
- widgets.py (WellplateMultiPointWidget): setRange(0, 99) -> (-1000, 99)
- microscope_control_server.py: Field(..., ge=0, le=50) -> ge=-1000, le=99
  (also widens the upper bound to match the existing UI range)

A lower bound of -1000% gives a step size of up to ~11x the FOV —
effectively unlimited for any realistic plate. Out-of-bounds FOVs
generated by extreme spacing are already filtered downstream by
ScanCoordinates.validate_coordinates() against SOFTWARE_POS_LIMIT,
so no additional bounds checking is needed. The geometry_utils.py
helpers already guard against step_size <= 0 for the pathological
overlap >= 100% case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants