[WIP] fix: handle absolute grid positions in _build_stage_positions_plan#104
[WIP] fix: handle absolute grid positions in _build_stage_positions_plan#104fdrgsp wants to merge 3 commits intopymmcore-plus:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #104 +/- ##
=======================================
Coverage 98.33% 98.33%
=======================================
Files 20 20
Lines 2044 2047 +3
=======================================
+ Hits 2010 2013 +3
Misses 34 34 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| stage_positions=[(0.0, 0.0)], | ||
| grid_plan=useq.GridFromEdges( | ||
| fov_width=50.0, | ||
| fov_height=50.0, | ||
| left=0.0, | ||
| right=100.0, | ||
| top=0.0, | ||
| bottom=100.0, | ||
| ), |
There was a problem hiding this comment.
this is indeed an interesting case. I think an argument could be made that this sequence itself should be an error? I mean... what does it even mean to acquire a grid bounded by (left,right,top,bottom) that is centered around stage_position (0,0)? It just "happens" to be the case here that (0,0) is inside the grid, but what if it weren't?
doesn't this kinda feel like a useq-schema bug? and not an ome-writers one?
| useq.Position( | ||
| x=10.0, | ||
| y=10.0, | ||
| name="grid", | ||
| sequence=useq.MDASequence( | ||
| grid_plan=useq.GridFromEdges( | ||
| fov_width=50.0, | ||
| fov_height=50.0, | ||
| left=0.0, | ||
| right=100.0, | ||
| top=0.0, | ||
| bottom=50.0, | ||
| ) | ||
| ), |
There was a problem hiding this comment.
same here... it becomes even more obvious that it's internally contradictory of you were to have set position to (-10, -10) rather than 10, 10 ... what does it even mean to set the position with an absolute grid?
When a grid plan yields
AbsolutePositionobjects (e.g.GridFromEdges,GridFromPolygon,RandomPoints), adding them to anotherPositionin_build_stage_positions_planis invalid. Previously the code always attemptedpos + gp, which would fail for absolute positions.Two fixes are applied:
Check
gp.is_relativeand usegpdirectly when the grid position is absolute.When an absolute grid position has no row/col (e.g.
GridFromPolygon,RandomPoints), append a positional index to the parent name to ensure uniqueness (e.g.my_pos_0000).