IO and DAQ Support
Motif can control hardware outputs (such as flashing LEDs, triggering of optogenetics hardware) and the reading of sensor data (such as temperature sensors, light sensors, pressure sensors, etc), all within the recording software.
While recording, Motif then saves the values of any outputs and sensors beside the video in a format that allows measurements to be precisely aligned with which frame number and frame timestamp they occurred.
Note
Motif's built in IO support is designed for relatively low sample rates of ≤100Hz. If you need a higher sampling rate then please contact support@loopbio.com
IO Outputs can be controlled via the REST API, from experiment scripts, and can be configured to appear in the WebUI.
A small example of some of the supported sensors and outputs from the Phidgets IO backend
Controlling IO From the WebUI
The "I/O & Scheduled" tab provides a simple way to see the state of any configured outputs and sensors.
Note
The WebUI only updates the value of configured sensors at 2Hz, which means if you have configured a fast sample rate, the values here will update much slower. However, the full data will be present in the data file.
Info
The screenshot above shows the result of the example script here scheduling the flashing of the two configured LEDs (red and green). The corresponding configuration for this is here
Supported IO Types
Motif supports a number of different backends - however once configured, all backends are conceptually alike. Motif takes care of integrating the IO values with the recording to make combining the data easy.
Note
Integration and configuration of an IO backend is an advanced task. Please contact support@loopbio.com for advice and help.
- Phidgets
Phidgets are low-cost sensors and controllers which are the easiest way to add support for controlling outputs (e.g. LEDs or other electro-mechanical devices like motors, or servos). Motif supports all Phidgets devices including the following extensive list of sensors (see here).- Temperature/Humidity
- Distance
- Light/Sound
- Motion
- Voltage/Current
- Load Cells
- FSR
- Proximity
- Touch / Human Input
- Gas Pressure
- Rotary Position
- Linear Position
- Adapters
- pH/ORP
- HTTP
The HTTP backend allows Motif to integrate sensors that expose their information over a HTTP GET (json) endpoint, or outputs that can be controlled using HTTP POST (json) requests. - ZMQ (advanced use)
The ZQM backend allows you to integrate an out of process measurement or control system of your own design, and providing you expose those values over ZMQ in the correct manner, Motif will take care of including them in the resulting data file. - National Instruments DAQ Devices (Windows only)
On Windows Motif can integrate with NI DAQs and record data a very high sampling rates. This module is additional to the normal Motif package, please contact support@loopbio.com
Example: Phidgets LEDs and Temperature Sensor
The following example configuration file snippet (i.e. not the whole file) configures the IO backend as can be seen in the screenshot above
IO: Backend: phidgets Outputs: - name: led_red device_type: 'DigitalOutput' port: 0 - name: led_green device_type: 'DigitalOutput' port: 1 Sensors: - name: temperature device_type: '1124' port: 2 fs: 1 UI: Outputs: - default_val: 0 label: Red LED max_val: 1 min_val: 0 step: 1 name: led_red - default_val: 0 label: Green LED max_val: 1 min_val: 0 step: 0.1 name: led_green Sensors: - {name: 'temperature'}
IO Format
The default format for saving IO values is json. If the current recording is an imgstore (see: recording to an imgstore), then the IO data is stored inside the imgstore directory. The data can then be loaded using the imgstore API.
If the current recording is to a single file, then the extra data is saved to a json file with
the same name, but with .extra_data.json
appended.
In both cases the .extra_data.json
files contain a list of json records. For the example above,
a snippet from an extra data file contains;
[{"frame_index": 8314, "frame_time": 1559671159.517081, "sensor_time": 1559671159.54632, "is_recording": true, "recording_sequence_number": 2, "recording_start": 1559670882.357428, "frame_number": 3554885, "temperature": 27.26}, {"led_red": 0, "recording_sequence_number": 2, "frame_index": 8328, "is_recording": true, "frame_time": 1559671159.983759, "frame_number": 3554899, "recording_start": 1559670882.357428}, {"recording_sequence_number": 2, "frame_index": 8328, "is_recording": true, "led_green": 1, "frame_time": 1559671159.983759, "frame_number": 3554899, "recording_start": 1559670882.357428}, {"frame_index": 8344, "frame_time": 1559671160.517131, "sensor_time": 1559671160.545529, "is_recording": true, "recording_sequence_number": 2, "recording_start": 1559670882.357428, "frame_number": 3554915, "temperature": 27.26}]
(many values omitted)
Note the presence of the following values in every row:
frame_index
the current frame number of this recordingframe_number
the current frame number of the camera (since synchronization or power on, consistent across multiple cameras in a multiple camera synchronized Motif system)frame_time
unix timestamp of current frameis_recording
true if camera is currently recordingrecording_start
unique identifier of this recording
Additionally:
- rows with configured sensors (e.g.
temperature
are omitted at the configured sample rate - rows with the value of any output (e.g.
led_red
,led_green
) are written any time an output changes