engines#

Custom MicroManager MDAEngine subclasses used by mesofield.

Three flavours are provided, all subclasses of pymmcore_plus.mda.MDAEngine:

MesoEngine

Drives the mesoscope camera; loads an LED sequence on the Arduino switch in MesoEngine.setup_sequence() and streams images out of the circular buffer in MesoEngine.exec_sequenced_event().

PupilEngine

Drives the pupil camera; optionally pulses an NI-DAQ line at sequence start (used for synchronisation with downstream instruments).

DevEngine

Hardware-free development engine. Streams whatever the camera backend produces with no Arduino/NIDAQ interaction; intended for mock cameras and CI.

class mesofield.engines.MesoEngine[source]#

Bases: MDAEngine

MDA engine for the mesoscope camera.

Loads an LED switching sequence onto an Arduino driver in setup_sequence(), then streams images out of the camera’s circular buffer in exec_sequenced_event(). Subclasses pymmcore_plus.mda.MDAEngine.

__init__(mmc, use_hardware_sequencing=True)[source]#
Parameters:

use_hardware_sequencing (bool)

Return type:

None

set_config(cfg)[source]#

Bind a live ExperimentConfig to this engine.

Called by the Procedure orchestrator after hardware is up so the engine can reach the configured encoder.

Return type:

None

setup_sequence(sequence)[source]#

Perform setup required before the sequence is executed.

Parameters:

sequence (MDASequence)

Return type:

SummaryMetaV1 | None

exec_sequenced_event(event)[source]#

Execute a sequenced (triggered) event and return the image data.

This method is not part of the PMDAEngine protocol (it is called by exec_event, which is part of the protocol), but it is made public in case a user wants to subclass this engine and override this method.

Parameters:

event (SequencedEvent)

Return type:

Iterable[PImagePayload]

teardown_sequence(sequence)[source]#

Perform any teardown required after the sequence has been executed.

Parameters:

sequence (MDASequence)

Return type:

None

class mesofield.engines.PupilEngine[source]#

Bases: MDAEngine

MDA engine for the pupil camera with optional NI-DAQ triggering.

On setup_sequence() an NI-DAQ object may be loaded from the sequence metadata; on exec_sequenced_event() that NI-DAQ is pulsed at sequence start so other instruments can synchronise. Subclasses pymmcore_plus.mda.MDAEngine.

__init__(mmc, use_hardware_sequencing=True)[source]#
Parameters:

use_hardware_sequencing (bool)

Return type:

None

set_config(cfg)[source]#

Bind a live ExperimentConfig.

Caches the configured NI-DAQ device and (when more than one CMMCorePlus is in play) a reference to the primary core.

Parameters:

cfg (ExperimentConfig)

Return type:

None

setup_sequence(sequence)[source]#

Resolve the NI-DAQ from sequence metadata and reset it for the run.

Parameters:

sequence (MDASequence)

Return type:

SummaryMetaV1 | None

exec_sequenced_event(event)[source]#

Execute a sequenced (triggered) event and return the image data.

This method is not part of the PMDAEngine protocol (it is called by exec_event, which is part of the protocol), but it is made public in case a user wants to subclass this engine and override this method.

Parameters:

event (SequencedEvent)

Return type:

Iterable[PImagePayload]

teardown_sequence(sequence)[source]#

Perform any teardown required after the sequence has been executed.

Parameters:

sequence (MDASequence)

Return type:

None

class mesofield.engines.DevEngine[source]#

Bases: MDAEngine

Hardware-free development engine for mock cameras and CI.

Streams images out of the camera’s circular buffer with no Arduino or NI-DAQ interaction. Use this engine for development and tests that don’t have access to physical rig hardware.

__init__(mmc, use_hardware_sequencing=True)[source]#
Parameters:

use_hardware_sequencing (bool)

Return type:

None

set_config(cfg)[source]#

Bind a live ExperimentConfig to this engine.

Return type:

None

exec_sequenced_event(event)[source]#

Execute a sequenced (triggered) event and return the image data.

This method is not part of the PMDAEngine protocol (it is called by exec_event, which is part of the protocol), but it is made public in case a user wants to subclass this engine and override this method.

Parameters:

event (SequencedEvent)

Return type:

Iterable[PImagePayload]

teardown_sequence(sequence)[source]#

Perform any teardown required after the sequence has been executed.

Parameters:

sequence (MDASequence)

Return type:

None