manager#
- class mesofield.data.manager.DataQueue[source]#
Bases:
objectThread-safe queue for data streaming between devices and consumers.
Registered DataProducer (the
DataManager) devices can push data packets to this queue, which can then be consumed by other parts of the system.- push(device_id, payload, *, timestamp=None, device_ts=None, **meta)[source]#
Add a new data packet to the queue.
- pop(block=True, timeout=None)[source]#
Return the next
DataPacketfrom the queue.- Parameters:
- Return type:
- class mesofield.data.manager.DataPaths[source]#
Bases:
objectStructured storage for all output paths used by the
DataSaver.Relies on the
ExperimentConfigto generate paths based on the experiment’s BIDS directory using the make_path method, which relies on HardwareDevices implementing a file_type, bids_type.These paths can then be passed to HardwareDevice.save_data(path)
- class mesofield.data.manager.DataSaver[source]#
Bases:
objectHelper class for saving experiment data to disk.
This class handles saving configuration, hardware data, notes, timestamps, and camera data to disk.
Takes paths generated from
DataPathsinstance and calls Device.save_data(path) on all hardware devices that implement this method.(NOTE: If a device does not implement save_data, it will be skipped.)
Takes an
ExperimentConfigto save configuration.- save_queue(rows, path=None)[source]#
Save queued data rows to CSV file specified in DataPaths or override path.
Rows are produced by
DataManager._queue_writer_loopas[queue_elapsed, packet_ts, device_ts, device_id, payload]. If any payload is adict, its keys are fanned out into dedicated columns; thepayloadcolumn then holds the non-dict payloads only (blank when a row has dict columns).
- __init__(cfg, logger=<factory>)#
- Parameters:
cfg (ExperimentConfig)
logger (Logger)
- Return type:
None
- class mesofield.data.manager.DataManager[source]#
Bases:
objectWrapper providing
DataSaverandDataQueue.- setup(config, devices=None)[source]#
Attach configuration and optionally register devices.
- Parameters:
config (ExperimentConfig)
- Return type:
None
- register_devices(devices)[source]#
Register a list of hardware devices with the manager.
Any device exposing a
mesofield.signals.DeviceSignalsbundle ondevice.signalsis registered. Devices that do not emit onsignals.data(e.g. stimulus devices) are still tracked but contribute nothing to the queue.
- start_queue_logger(path=None)[source]#
Begin capturing
DataQueuecontents.- Parameters:
path (str | None)
- Return type:
None
- stop_queue_logger()[source]#
Stop the queue logging thread and flush data to disk.
- Return type:
None
- register_hardware_device(device)[source]#
Track a hardware device and connect its data stream to the queue.
Devices expose a uniform
mesofield.signals.DeviceSignalsbundle ondevice.signals. We simply connectsignals.datato push(payload, device_ts)packets onto the queue. Devices that never emit onsignals.data(e.g.StimulusDevice) are registered but never produce queue entries.- Parameters:
device (Any)
- Return type:
None