A Python implementation of a Lab Streaming Layer (LSL) recorder that saves multiple data streams to XDF files.
Records data from LSL streams (EEG, markers, etc.) to XDF files with proper synchronization. Includes remote control via TCP commands for integration with experiments.
git clone https://github.com/your-username/lab-recorder-python.git
cd lab-recorder-python
# Install dependencies
pip install -r requirements.txtStart recording from all available streams:
python main.py -f my_recording.xdfThe recorder will:
- Find all LSL streams on the network
- Select all of them for recording
- Start recording immediately
- Save to
my_recording.xdf
Stop with Ctrl+C.
# Start recorder with remote control enabled
python main.py -f experiment.xdf
# In another terminal, control the recording
python tools/remote_client.py start
python tools/remote_client.py stop# Terminal 1: Start test streams
python tools/send_dummy.py
# Terminal 2: Record the test data
python main.py -f test.xdf
# Terminal 3: Verify the recording
python tools/inspect_xdf.py test.xdfConnect to localhost:22345 and send these commands:
status- Get current recorder statestreams- List available streamsstart- Begin recordingstop- Stop recordingselect all- Select all streamsfilename newname.xdf- Change output file
├── main.py # Main application entry point
├── labrecorder/ # Core recorder modules
│ ├── recorder.py # Main recorder class
│ ├── streams/ # Stream management
│ ├── xdf/ # XDF file writing
│ ├── remote_control/ # TCP remote control
│ └── utils/ # Configuration and utilities
└── tools/ # Testing and utility scripts
├── streamer.py # Generate test LSL streams
├── tester.py # Verify recordings (pyxdf)
├── alternative_tester.py # Verify recordings (custom)
├── inspect_xdf.py # Examine XDF files
└── remote_client.py # Command-line remote control
python main.py [options]
Options:
-f, --filename FILE Output XDF filename (default: recording.xdf)
-p, --port PORT Remote control port (default: 22345)
--no-remote Disable remote control
--config FILE Use configuration fileNo streams found: Check that LSL streams are running on your network. Test with python tools/streamer.py.
Port already in use: Stop other recorder instances with ./cleanup.sh or kill processes using port 22345.
Recording issues: Check that you have write permissions in the output directory and enough disk space.
Cross-compatibility issues: If pyxdf can't read your files, use python tools/inspect_xdf.py filename.xdf to verify the recording and python tools/alternative_tester.py filename.xdf for validation.
- Python 3.8+
- pylsl (Lab Streaming Layer)
- numpy
- pyxdf (for file verification)