micro-manager / pycro-manager

Python control of micro-manager for customized data acquisition
https://pycro-manager.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
165 stars 52 forks source link

Event type depends on time_interval_s #734

Closed miromarszal closed 10 months ago

miromarszal commented 10 months ago

When applying hooks to read or modify events on the fly, the type passed to the function depends on time_interval_s. For any value other than zero, an event is a dict, whereas for time_interval_s=0 the entire list of events is passed to the function.

The code below

from pycromanager import Acquisition, multi_d_acquisition_events

def hook_fn(event):
    print(event)
    return event

with Acquisition(directory='./', post_hardware_hook_fn=hook_fn) as acq:
    events = multi_d_acquisition_events(
        num_time_points=5,
        time_interval_s=1,
        )
    acq.acquire(events)

produces

{'axes': {'time': 0}, 'min_start_time': 0}
{'axes': {'time': 1}, 'min_start_time': 1}
{'axes': {'time': 2}, 'min_start_time': 2}
{'axes': {'time': 3}, 'min_start_time': 3}
{'axes': {'time': 4}, 'min_start_time': 4}

which is what I would expect. However, changing to time_interval_s=0 results in

[{'axes': {'time': 0}}, {'axes': {'time': 1}}, {'axes': {'time': 2}}, {'axes': {'time': 3}}, {'axes': {'time': 4}}]

This leads to unexpected errors.

EDIT: I noticed now that it also happens for anything lower than time_interval_s=0.001.

miromarszal commented 10 months ago

Ok sorry for not reading the docs carefully enough... This is because of sequencing, which is used for short time delays.