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: Event modifiers [WIP] #120

Open tlambert03 opened 1 year ago

tlambert03 commented 1 year ago

This is rough/broken draft of the general idea for a protocol of event modifiers/adders that I mentioned in #41

The crux of it is in the docstring of the EventModifiers class:

Callable object that can modify the yielding of events in a sequence. During iteration of an MDASequence, this object will be called with the event about to be yielded (event), and the upcoming event in the sequence (next_event), which may be None if this is the last event in the sequence. It should return:

  1. MDAEvent: A possibly-modified event to replace this event. The input event may be returned unmodified to keep the event unchanged.
  2. Sequence[MDAEvent]: event(s) to be inserted before event. (The events will NOT be passed to other event modifiers in the chain).
  3. None: to skip this event altogether (i.e. "block" the event.)

It's a generalization of (and would replace) autofocus and keep shutter open plans. but it still needs some work, and feedback, so marking as draft