Skip to content

feat(multipoint): restore channel settings when loading acquisition YAML#590

Open
hongquanli wants to merge 1 commit into
masterfrom
feat/restore-channel-settings-from-yaml-drop
Open

feat(multipoint): restore channel settings when loading acquisition YAML#590
hongquanli wants to merge 1 commit into
masterfrom
feat/restore-channel-settings-from-yaml-drop

Conversation

@hongquanli

Copy link
Copy Markdown
Contributor

Summary

Dragging a previous acquisition (folder or acquisition.yaml) onto the Wellplate Multipoint widget restored only the channel selection and order — the per-channel exposure time, analog gain, and illumination intensity recorded in the YAML were ignored, so reproducing an acquisition still required re-entering them by hand. This PR restores those settings on drop.

Changes

  • acquisition_yaml_loader.py: parse the full channels: section into a new ChannelYAMLSettings dataclass (exposure, gain, intensity). Values absent from older YAMLs or non-numeric parse to None and are simply not restored.
  • AcquisitionYAMLDropMixin._restore_channel_settings: persist the parsed values through ConfigRepository.update_channel_setting() — the same path as live-control spinbox edits — respecting the current confocal/widefield mode.
    • Channels missing from the current configuration are skipped with a warning (consistent with the existing selection-restore behavior).
    • Out-of-range values (exposure ≤ 0, gain < 0, intensity outside 0–100) are skipped: update_channel_setting bypasses pydantic assignment validation, so persisting a bad value from a hand-edited YAML would make the whole profile fail validation on next startup.
  • UI refresh: new signal_channel_settings_restored on both multipoint widgets, connected in gui_hcs.py to a new LiveControlWidget.refresh_current_mode_settings() that re-reads the active channel's values and re-applies the mode — without applying the live per-channel Z-offset, since the channel didn't change.

Deliberately not restored

Z-offset. z_offset_um is documented as sample-dependent (relative to the laser AF reference; "re-capture or reset when starting a new sample"), so importing an old sample's offsets could cause unwanted Z moves during acquisition.

The Flexible Multipoint widget gets the same signal for consistency, but its drop handler still shows "not supported yet" and never loads — no behavior change there.

Testing

  • Two new loader tests: full nested channel settings; missing/partial/non-numeric values.
  • New test_acquisition_yaml_channel_restore.py: restore + repo call args, confocal mode pass-through, unknown-channel / None / out-of-range skips, repo failure not counted, signal emitted only when something was restored.
  • Related suites pass (166 tests: YAML loader, channel restore, channel sequence, config repo, live control offset).
  • Note: 4 pre-existing failures in test_HighContentScreeningGui.py in my environment are unrelated — they fail identically on master (PyQt6 fallback vs the PyQt5-only activated[str] overload at widgets.py:4235).

🤖 Generated with Claude Code

Dropping a previous acquisition onto the wellplate multipoint widget
restored only the channel selection and order; exposure time, analog
gain, and illumination intensity recorded in acquisition.yaml were
ignored, so reproducing an acquisition required re-entering them by
hand.

- Parse per-channel settings from the channels section into a new
  ChannelYAMLSettings dataclass (None for values absent from older
  YAMLs).
- Restore them via ConfigRepository.update_channel_setting — the same
  persistence path as live-control edits — respecting the current
  confocal/widefield mode. Out-of-range values are skipped with a
  warning since update_channel_setting bypasses pydantic assignment
  validation and a bad persisted value would break profile loading.
  Channels missing from the current configuration are skipped.
- Z-offset is deliberately not restored: it is sample-dependent
  (relative to the laser AF reference), so an old acquisition's
  offsets don't transfer and could cause unwanted Z moves.
- New signal_channel_settings_restored on both multipoint widgets,
  wired in gui_hcs to LiveControlWidget.refresh_current_mode_settings
  so the live panel re-reads the active channel's values without
  applying the live Z-offset.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant