Repository navigation
fix: apply channel z_offset to stage position z when there is no z_plan - #274
Merged
tlambert03 merged 2 commits intoOct 7, 2026
Merged
tlambert03 merged 2 commits into
tlambert03 merged 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #274 +/- ##
=======================================
Coverage 93.62% 93.63%
=======================================
Files 33 33
Lines 2589 2591 +2
=======================================
+ Hits 2424 2426 +2
Misses 165 165 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
thanks! |
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.
Problem
Channel.z_offsetis only applied in_xyzpos()when z comes from az_plan. When z comes only from the stage position, theelif position:branch usesposition.zand drops the offset. So the same sequence behaves differently depending on whether a z-stack is enabled. User-visible: pymmcore-widgets' channel table has a Z offset column, which has no effect unless a z-plan is also set.With
z_plan={"range": 2.0, "step": 1.0}the offset is applied (channelbgets 4/5/6 vsa's -1/0/1).Channel.z_offsetis documented as a relative Z offset in microns, with no mention of requiring a z-stack. pymmcore-plus doesn't readz_offsetitself (the offset is meant to be baked intoevent.z_poshere), so nothing else applies it.Fix
Add the channel
z_offsetin theelif position:branch too. The two branches are mutually exclusive, so the offset is never applied twice. If the position has no z (position.z is None),z_posstaysNone: there is nothing to offset.Test
Added to
tests/test_sequence.py:test_channel_z_offset_without_z_plan: fails onmain([10.0, 10.0] != [10.0, 15.0]), passes with the fix.test_channel_z_offset_with_z_plan: offset applied once (unchanged behaviour).test_channel_z_offset_without_position_z:z_posstaysNone.Behaviour change
Sequences with a nonzero
z_offsetand noz_planwill now move Z per channel, where before the offset was ignored.z_offsetdefaults to0.0, so only sequences that set it explicitly are affected.Not covered (possible follow-ups)
stage_positions, or a position withoutz,z_posstaysNone("don't move Z") and the offset is still dropped. The docstring describes the offset as relative to the current position, which an event can't express without a notion of the current z (there is already a TODO about this in_xyzpos). Supporting it would likely mean resolving the offset in the engine.stage_positions=[{"x": 0, "y": 0, "z": 3, "sequence": {"channels": [{"config": "b", "z_offset": 5.0}]}}],z_posis still3.0:_position_offsetsforces z to the parent event's z whenever the sub-sequence has noz_plan, which overwrites the sub-sequence channel's offset. Separate code path, so I left it out of this PR.