Skip to main content

Python bindings for LabRecorder recording

Project description

Overview

The LabRecorder is the default recording program that comes with LSL. It allows to record all streams on the lab network (or a subset) into a single file, with time synchronization between streams.

File Format

The file format used by the LabRecorder is XDF. This is an open general-purpose format that was designed concurrently with LSL and supports all features of LSL streams. The project page is here. There are importers for MATLAB, EEGLAB, BCILAB, Python, and MoBILAB.

Getting LabRecorder

The releases page contains archives of past LabRecorder builds. Try downloading and installing an archive that matches your platform. Note for Ubuntu users: The deb will install LabRecorder to /usr/LabRecorder though we might change this to /usr/local/bin/LabRecorder in the future.

If there are no archives matching your target platform, or the ones available don't run, then continue reading below. If the instructions don't help then please post an issue to the repo's issues page.

Dependencies

For LabRecorder to work on your system, you might need to first install some dependencies, specifically liblsl and optionally Qt.

Windows

The Windows archives ship with nearly all required dependencies. If you have not already installed it via another program, you may need to install the Visual C++ Runtime Redistributable.

If you suspect you are missing a dependency, try running DependenciesGui.exe then navigating to the LabRecorder.exe. It's important to launch Dependencies.exe from the same environment that you would use to launch this application: if you launch this application by double-clicking the executable in Windows' finder then do the same on the Dependencies.exe icon; if you launch this application in a Terminal window, then use that same Terminal to launch Dependencies.

MacOS

In the near future, many LSL Apps (especially LabRecorder) will not ship with their dependencies and will look for the dependencies to be installed on the system. The easiest way to manage the dependencies is by using homebrew:

  • Install homebrew: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • brew install labstreaminglayer/tap/lsl
  • brew install qt

You can then install LabRecorder directly from homebrew: brew install labrecorder

Run it with open /usr/local/opt/labrecorder/LabRecorder/LabRecorder.app

Linux Ubuntu

The Ubuntu releases do not typically ship with their dependencies, so you must download and install those:

  • Download, extract, and install the latest liblsl-{version}-{target}_amd64.deb from its release page
    • We hope to make this available via a package manager soon.
      • Quick ref Ubuntu 24.04: curl -L https://github.com/sccn/liblsl/releases/download/v1.17.4/liblsl-1.17.4-noble_amd64.deb -o liblsl.deb
      • Quick ref Ubuntu 22.04: curl -L https://github.com/sccn/liblsl/releases/download/v1.17.4/liblsl-1.17.4-jammy_amd64.deb -o liblsl.deb
    • You can install liblsl directly by double-clicking on the deb, or with sudo dpkg -i {filename}.deb or sudo apt install {filename}.deb
  • See the bottom of the lsl build env docs.
    • For most cases, this will amount to installing Qt and its dependencies:
      • Ubuntu >= 22.04: sudo apt-get install qt6-base-dev freeglut3-dev

Usage

The LabRecorder displays a list of currently present device streams under "Record from Streams". If you have turned on a device after you have already started the recorder, click the "Update" button to update the list (this takes ca. 2 seconds).

For testing, you can use a "dummy" device from the lslexamples found in the liblsl release assets (for example SendData).

If you cannot see streams that are provided on another computer, read the section Network Troubleshooting on the NetworkConnectivity page.

You can select which streams you want to record from and which not by checking the checkboxes next to them.

labrecorder-default.png

Note that if you have multiple streams with the same name and host, it is impossible to check only 1. If any is checked then they will all be recorded.

The entry in "Saving to..." shows you the file name (or file name template) where your recording will be stored. You can change this by modifying the Study Root folder (e.g., by clicking the browse button) and the File Name / Template field. If the respective directory does not yet exist, it will be created automatically (except if you do not have the permissions to create it). The file name string may contain placeholders that will be replaced by the values in the fields below. Checking the BIDS box will automatically change the filename template to be BIDS compliant. If the file that you are trying to record to already exists, the existing file will be renamed (the string _oldX will be appended where X is the lowest number that is not yet occupied by another existing file). This way, it is impossible to accidentally overwrite data.

The Block/Task field can be overwriten or selected among a list of items found in the configuration file.

Click "Start" to start a recording. If everything goes well, the status bar will now display the time since you started the recording, and more importantly, the current file size (the number before the kb) will grow slowly. This is a way to check whether you are still in fact recording data. The recording program cannot be closed while you are recording (as a safety measure).

When you are done recording, click the "Stop" button. You can now close the program. See the xdf repository for tools and information on how to use the XDF files.

Preparing a Full Study

When preparing a new study, it is a good idea to make a custom configuration file which at least sets up a custom storage location for the study. See the documentation in the file LabRecorder.cfg for how to do this -- it is very easy! You can override this by making a shortcut for the LabRecorder program (e.g. on the desktop) and appending in its properties the command-line arguments -c name_of_you_config.cfg. You can also create a batch script. You can also load the config while the program is already running, but this can easily be forgotten during an experiment, so we recommend to follow the shortcut route.

In addition to the storage location, if your experiment has multiple blocks (e.g., SubjectTraining, PreBaseline, MainBlock, PostBaseline or the like) you can make the recording process even more straightforward for the experimenters by setting up a default list of block names. Again, take a look at the existing config files.

Since it is too easy to forget to turn on or check all necessary recording devices for a study, we recommend to also make a list of "required" streams (by their name) and put it into the config file. These streams will be pre-checked when starting the program, and any missing stream will be displayed in red. If such a stream is still not green when starting the recording, the experimenter will get a message box to confirm that he/she really wants to record without including the device.

Remote Control

If you check the box to EnableRCS then LabRecorder exposes some rudimentary controls via TCP socket.

Currently supported commands include:

  • select all
  • select none
  • start
  • stop
  • update
  • filename ...

filename is followed by a series of space-delimited options enclosed in curly braces. e.g. {root:C:\root_data_dir}

  • root - Sets the root data directory.
  • template - sets the File Name / Template. Will unselect BIDS option. May contain wildcards.
  • task - will replace %b in template
  • run - will replace %n in template (not working?)
  • participant - will replace %p in template
  • session - will replace %s in template
  • acquisition - will replace %a in template
  • modality - will replace %m in template. suggested values: eeg, ieeg, meg, beh

For example, in Python:

import socket
s = socket.create_connection(("localhost", 22345))
s.sendall(b"select all\n")
s.sendall(b"filename {root:C:\\Data\\} {template:exp%n\\%p_block_%b.xdf} {run:2} {participant:P003} {task:MemoryGuided}\n")
s.sendall(b"start\n")
lr = tcpip('localhost', 22345); 
fopen(lr)
fprintf(lr, 'select all');
fprintf(lr, ['filename {root:C:\Data\} '...
            '{task:MemoryGuided} ' ...
            '{template:s_%p_%n.xdf ' ...
            '{modality:ieeg}']); 
fprintf(lr, 'start');

Misc Features

The LabRecorder has some useful features that can add robustness if things go wrong during the experiment:

If a network connectivity error happens while recording (e.g., a network cable pops out that connects to the source of a data stream), you have usually 6 minutes (think 5) to plug it back it in during which the data will be buffered on the sending machine. If it takes you longer to fix the problem, you will have some gap in your recording.

If a device program or computer crashes while recording, you will for sure lose data, but any device program that transmits an associated device serial number will be picked up automatically by the recorder when it comes back online (these programs are called "recoverable"), without a need to stop and re-start the recording.

You should check the health of your device to be sure, however, for example using an online stream viewer program (see, for example, ViewingStreamsInMatlab). Also, be sure to test whether it is in fact recoverable before relying on this feature (you can test this with a viewer by turning the device app off and back on).

If a device is displayed in red when you start recording (and it is checked), it will be added to the ongoing recording by the time when it comes online. This can be useful when a device can only be turned on while the recording is already in progress. Again, it is advisable to check that the device is in fact discoverable and added. The LabRecorder brings up a console window in the background which shows a list of all streams that are added to the recording -- this is a good place to check whether a late stream did get picked up successfully during a live recording.

Build Instructions

Please follow the general LSL App build instructions.

Python bindings

LabRecorder includes optional Python bindings for the recording class (module name: labrecorder). Enable them with -DLABRECORDER_BUILD_PYTHON=ON and make sure pybind11 is installed on your system.

Install pybind11

  • macOS (Homebrew): brew install pybind11
  • Ubuntu/Debian: sudo apt-get install pybind11-dev
  • Windows: use vcpkg (vcpkg install pybind11) or a pybind11 CMake package on your PATH

Configure + build

cmake -S . -B build -DLABRECORDER_BUILD_PYTHON=ON
cmake --build build --target labrecorder

Usage (with pylsl)

import sys
from pylsl import resolve_streams

sys.path.append("build")
import labrecorder

streams = resolve_streams()
with labrecorder.Recording("out.xdf", streams):
    input("Recording... press Enter to stop\n")

Publish to PyPI

uv build
uv publish

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

labrecorder-1.0.0rc0.tar.gz (1.8 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

labrecorder-1.0.0rc0-cp312-cp312-win_amd64.whl (488.3 kB view details)

Uploaded CPython 3.12Windows x86-64

labrecorder-1.0.0rc0-cp312-cp312-musllinux_1_2_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

labrecorder-1.0.0rc0-cp312-cp312-musllinux_1_2_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

labrecorder-1.0.0rc0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

labrecorder-1.0.0rc0-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (1.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

labrecorder-1.0.0rc0-cp311-cp311-win_amd64.whl (487.4 kB view details)

Uploaded CPython 3.11Windows x86-64

labrecorder-1.0.0rc0-cp311-cp311-musllinux_1_2_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

labrecorder-1.0.0rc0-cp311-cp311-musllinux_1_2_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ ARM64

labrecorder-1.0.0rc0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

labrecorder-1.0.0rc0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (1.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

labrecorder-1.0.0rc0-cp311-cp311-macosx_26_0_arm64.whl (692.2 kB view details)

Uploaded CPython 3.11macOS 26.0+ ARM64

File details

Details for the file labrecorder-1.0.0rc0.tar.gz.

File metadata

  • Download URL: labrecorder-1.0.0rc0.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for labrecorder-1.0.0rc0.tar.gz
Algorithm Hash digest
SHA256 01a8268c6555ae3bec52cfed07ddfef72581c3fe59593d71110de62def0fe937
MD5 85e8fd728e7060258594b15049e3f135
BLAKE2b-256 dd9bcef6c51a674c6f2345f81d78346d39d73a76d4362aaaa958076bdab3be59

See more details on using hashes here.

File details

Details for the file labrecorder-1.0.0rc0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for labrecorder-1.0.0rc0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 81d08e8db862b43c421068a60bd5cd5658b781fd57531a91c14f5e76b4d6baba
MD5 e386e5a5ae85ff0e5e1188da1ec8ed02
BLAKE2b-256 36419ba246ee8cebd1190d999a5eca37bd6b902a786927f1ac18282a8d9c6189

See more details on using hashes here.

File details

Details for the file labrecorder-1.0.0rc0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for labrecorder-1.0.0rc0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 64235f99c8d80d3283e4e9316ba6050974ddd57c5463febb12219595157b7aed
MD5 7d46d6a54e6284fd2f684b888b0aa1a4
BLAKE2b-256 0acf5ddfca122a9f61a0b6be8423e3a1ab0747563c4d6858dc02e5104001de26

See more details on using hashes here.

File details

Details for the file labrecorder-1.0.0rc0-cp312-cp312-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for labrecorder-1.0.0rc0-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 029ee8defa0a207160916b5600053cc1afb20fd7ca3c5a238689627b25b5fd06
MD5 8fa68da4b3f64e91f2936d27e2395b9a
BLAKE2b-256 336067c52c4a78c715d9337b11051391f81d790481a75c58d8a37fea9d9a9a12

See more details on using hashes here.

File details

Details for the file labrecorder-1.0.0rc0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for labrecorder-1.0.0rc0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 54aac748721e6bdf664c452517040c483997aad3b8706f9abbdf7f0eb721bcbb
MD5 a26c5e9796c2b34beef7df88a364b855
BLAKE2b-256 95e1207e4f9742cf82a845db57f94290241d8edebf50a67629be9c6180aca7e9

See more details on using hashes here.

File details

Details for the file labrecorder-1.0.0rc0-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for labrecorder-1.0.0rc0-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cd8ee22ad404ed6f5ba7786102a95131dfb86072be23e5623c77795cd3b261d6
MD5 6f95fd2a392d890640b818c7b5c5eb72
BLAKE2b-256 306e0006c4c69f7fc847cf26e920b7792743049a9b79abae5085a1c77e1d3729

See more details on using hashes here.

File details

Details for the file labrecorder-1.0.0rc0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for labrecorder-1.0.0rc0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e2f23b93fbb2b20bbc18b2464ab914e98114b035e390821f0aee9408f446f081
MD5 ad2e394441f4dc19077315dd15a2443e
BLAKE2b-256 26e644c9435a6c4afd9f48053933059567a939233e03d81ebd2380b0c8efe005

See more details on using hashes here.

File details

Details for the file labrecorder-1.0.0rc0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for labrecorder-1.0.0rc0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 51a9fae5f43f551da5fec2446a3f20f67148de8b127484ab6145eba8386ac172
MD5 d74c024df4ce4600e77b95c7e321e56d
BLAKE2b-256 ebb53514bdbf21ee82220bf03d5d2a6bf8151c4a052fe46cfbc1bfd7316315a8

See more details on using hashes here.

File details

Details for the file labrecorder-1.0.0rc0-cp311-cp311-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for labrecorder-1.0.0rc0-cp311-cp311-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 e07902513adb04e5d513944dd64a04067fad3e101719f9f606c6440af298feb4
MD5 5d495840792f9e6b3931e3758ef2ce25
BLAKE2b-256 ee7d559002ce27430187d72498c6463a14aa1d61b1c27f2ad4d083fc8b47cb0c

See more details on using hashes here.

File details

Details for the file labrecorder-1.0.0rc0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for labrecorder-1.0.0rc0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c4db9b58521bc28a26b954a6da10ef88f728468d882fb508ed22a04df4ca8334
MD5 76992fd3cf3e84db2cb6c2cb3a46fe15
BLAKE2b-256 f1889279f12b008ceea39c9edcfe18b776843129f1931e8b9b744ecf327c8d70

See more details on using hashes here.

File details

Details for the file labrecorder-1.0.0rc0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for labrecorder-1.0.0rc0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 acc463def993691dd1dd01b19244945861776197f4dde53f30e8fc3921c9aa89
MD5 9f28e49d8c9b1661359af8e3d4d0b0e1
BLAKE2b-256 8717b3eb83b8f02e11a842edd3b74b4c1aaa3197db1a99e0d75a76de5e4b7b11

See more details on using hashes here.

File details

Details for the file labrecorder-1.0.0rc0-cp311-cp311-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for labrecorder-1.0.0rc0-cp311-cp311-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 d1d280e1208c06de7345d1f612cd0e7d0a9d311f1197f6e26d7418ae8334aeed
MD5 5fdf8efade1cebcf0ed097646ac2ec0a
BLAKE2b-256 f031f2fa62dea1014e2b12ce7322e3e3c7053c4f2e89159fc5f1d8e5deb66141

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page