pymmcore-plus / useq-schema

An implementation agnostic schema for describing a sequence of events during a multi-dimensional imaging acquisition.
https://pymmcore-plus.github.io/useq-schema/
BSD 3-Clause "New" or "Revised" License
15 stars 5 forks source link

feat: add Autofocus Plan #91

Closed fdrgsp closed 1 year ago

fdrgsp commented 1 year ago

This PR adds an hardware autofocus device plan to useq-schema and implements its use in the MDASequence iter_sequence method (and MDAEvent).

The basic logic is that a user can specify the axes that should be used for the hardware autofocus (e.g. p, t, etc.) and the yielded MDAEvent will have info on weather to perform autofocus or not on the specified axis.

merge after #93 .

Example of use in https://github.com/pymmcore-plus/pymmcore-plus/pull/199 and https://github.com/pymmcore-plus/pymmcore-widgets/pull/147.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 98.26% and project coverage change: +0.33 :tada:

Comparison is base (7486cf9) 96.11% compared to head (e9b0e68) 96.44%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #91 +/- ## ========================================== + Coverage 96.11% 96.44% +0.33% ========================================== Files 10 11 +1 Lines 618 704 +86 ========================================== + Hits 594 679 +85 - Misses 24 25 +1 ``` | [Impacted Files](https://app.codecov.io/gh/pymmcore-plus/useq-schema/pull/91?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymmcore-plus) | Coverage Δ | | |---|---|---| | [src/useq/\_mda\_sequence.py](https://app.codecov.io/gh/pymmcore-plus/useq-schema/pull/91?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymmcore-plus#diff-c3JjL3VzZXEvX21kYV9zZXF1ZW5jZS5weQ==) | `97.66% <97.77%> (-0.30%)` | :arrow_down: | | [src/useq/\_\_init\_\_.py](https://app.codecov.io/gh/pymmcore-plus/useq-schema/pull/91?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymmcore-plus#diff-c3JjL3VzZXEvX19pbml0X18ucHk=) | `100.00% <100.00%> (ø)` | | | [src/useq/\_autofocus.py](https://app.codecov.io/gh/pymmcore-plus/useq-schema/pull/91?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymmcore-plus#diff-c3JjL3VzZXEvX2F1dG9mb2N1cy5weQ==) | `100.00% <100.00%> (ø)` | | | [src/useq/\_grid.py](https://app.codecov.io/gh/pymmcore-plus/useq-schema/pull/91?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymmcore-plus#diff-c3JjL3VzZXEvX2dyaWQucHk=) | `100.00% <100.00%> (ø)` | | | [src/useq/\_mda\_event.py](https://app.codecov.io/gh/pymmcore-plus/useq-schema/pull/91?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymmcore-plus#diff-c3JjL3VzZXEvX21kYV9ldmVudC5weQ==) | `90.74% <100.00%> (+0.94%)` | :arrow_up: | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/pymmcore-plus/useq-schema/pull/91/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymmcore-plus)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

tlambert03 commented 1 year ago

as discussed, perhaps a top level AutoFocusPlan on the sequence itself is a good idea here:

class AutoFocusPlan(UseqModel):
    device_name: str
    af_motor_position: float = 0
    axes: Tuple[str, ...] = Field(default_factory=tuple)