mocks#

Synthetic devices for headless / GUI-only iteration.

These mock devices produce realistic data on daemon threads without any serial or camera hardware. They are used by the scaffold --rig dev template and by the test suite.

Mock encoder

Produces random click counts via BaseDataProducer.

Usage in hardware.yaml:

encoder:
  type: mock
  sample_interval_ms: 100

Or programmatically:

from mesofield.devices.mocks import MockEncoderDevice
dev = MockEncoderDevice({"id": "encoder", "sample_interval_ms": 50})
dev.start()
...
dev.stop()

Mock camera

Subclasses BaseCamera for the cosmetic + manifest surface every camera shares, and BaseDataProducer for the buffer + record() mechanism every queue-pushing producer needs.

YAML registration via type: mock_camera:

camera:
  type: mock_camera
  primary: true
  width: 64
  height: 64
  frame_interval_ms: 50
  output:
    suffix: meso
    file_type: ome.tiff
    bids_type: func
class mesofield.devices.mocks.MockEncoderDevice[source]#

Bases: BaseDataProducer

Synthetic encoder that records random click counts.

__init__(cfg=None, **kwargs)[source]#
Parameters:
Return type:

None

class mesofield.devices.mocks.MockFrameProducer[source]#

Bases: BaseCamera, BaseDataProducer

Synthetic camera producing real OME-TIFF + frame metadata JSON.

__init__(cfg=None, **kwargs)[source]#
Parameters:
Return type:

None

arm(config)[source]#

Per-run prep: set up the writer + (optionally) an MDA sequence.

The default body fits both MMCamera (which needs a sequence) and OpenCV/Mock (where set_sequence is a no-op). Subclasses override only when they need additional prep.

Parameters:

config (ExperimentConfig)

Return type:

None

snap()[source]#

Capture a single frame outside any recording, return it as an ndarray.

Used by the GUI’s snap button. Implementations should NOT alter recording state – snap is preview-only – but they SHOULD call _save_snap_png() so each snap also lands a *_snap.png.

Return type:

ndarray

start_live()[source]#

Begin continuous live preview WITHOUT writing to disk.

Subscribers receive frames via image_ready (Qt) / signals.data (psygnal). No recording side-effects; pair with stop_live().

Return type:

None

stop_live()[source]#

End the continuous live preview started by start_live().

Return type:

None

save_data(path=None)[source]#

Replay buffered frames through the standard mesofield writer.

Parameters:

path (str | None)

Return type:

str | None

property calibration: Dict[str, Any]#

Camera-specific constants worth recording in the AcquisitionManifest.