Live streams

Collector: Lab Streaming Layer

Send EEG, motion-capture and marker streams from LSL (Lab Streaming Layer) to Kymoscope as live channels.

Lab Streaming Layer (LSL)

For labs that already use the Lab Streaming Layer: EEG amplifiers, eye trackers, motion capture, stimulus software and their event markers. Every LSL stream you choose arrives in Kymoscope as channels of one live stream, named <stream name>/<label>, with the units the device declares. Nothing to change on the devices.

LSL to Kymoscope, step by step

  1. Install the collector with the extra on a computer on the same network as the devices (LSL finds streams by multicast; a different subnet or a VPN usually hides them):
    terminal
    pip install "kymoscope-collector[lsl]"
    The wheel brings the LSL library for Windows, macOS and Linux x86_64. On Linux ARM (a Raspberry Pi), install liblsl yourself first.
  2. Start the lab's devices and their LSL apps, so their streams are being sent.
  3. Add the source with streams: all, to see what is there:
    collector.yaml
    api_key: env:KYMOSCOPE_API_KEY
    streams:
      - name: Lab A
        mode: live
        sources:
          - name: Lab A
            type: lsl
            streams: all                  # every LSL stream on the network; first run: look at what is there
  4. List the streams and channels the collector finds:
    terminal
    kymoscope-collector discover --config collector.yaml --source "Lab A" --out tags.csv
    It prints one line per stream and writes every channel to tags.csv:
    output
    INFO source 'Lab A': LSL stream 'BioSemi' (EEG, 4 channels, 500 Hz) as 'BioSemi'
    INFO source 'Lab A': LSL stream 'Markers' (Markers, 1 channels, irregular) as 'Markers'
    Wrote 5 tags to tags.csv
    
    node_id,name,group,sampling_ms,unit,description
    BioSemi/Fp1,BioSemi/Fp1,,2,microvolts,"LSL EEG 'BioSemi' on LAB-PC, 500 Hz"
    BioSemi/Fp2,BioSemi/Fp2,,2,microvolts,"LSL EEG 'BioSemi' on LAB-PC, 500 Hz"
    ...
    Markers/ch1,Markers/ch1,,,,"LSL Markers 'Markers' on LAB-PC, irregular"
    A channel with no label in the stream's description is called ch1, ch2...
  5. Replace all with the streams you want (below), then run the collector as usual. Charts and alerts see the channels like any other live stream.

Choosing streams

collector.yaml
      - name: Lab A
        type: lsl
        streams:
          - {type: EEG}               # every EEG stream
          - {name: "Mocap*"}          # glob patterns work
          - {type: Markers, hostname: STIM-PC}   # all the keys of an entry must match
NameTypeDescription
streamsall | listRequired. all takes every stream on the network. A list entry matches on name, type, source_id and/or hostname (glob patterns); all the keys of an entry must match, any entry may match.
resolve_sseconds
Default: 5
How often to look for new matching streams. A device started later joins while the collector runs, and its channels are added.
max_buffer_sseconds
Default: 30
How much data LSL keeps per stream while the collector is busy.

What arrives

  • Regular streams (a sampling rate, such as EEG at 500 Hz) arrive in blocks at the device's rate. Irregular streams (markers) arrive sample by sample. The stream declares its rate on its own; no hz is needed.
  • Time comes from the device's LSL clock, corrected by LSL to this computer's clock, so streams from different machines line up with each other.
  • Markers. Numeric markers pass as the numbers they are. Text markers (trial_start, stim_left) become a number per distinct text: 0, 1, 2... in order of first appearance, one table per marker channel. Each new code is written to the collector log (one line, such as marker 1 on 'Markers/ch1' = 'stim_left'), and the table is in status.json under the source's markers. The numbers are kept in the collector's state folder, so the same text keeps its number after a restart. A marker channel holds the last marker's value: the line stays flat until the next marker and steps there, instead of sloping from one marker to the next.
  • Two streams with the same name (two identical amplifiers): the second's channels get (2) after the stream name, BioSemi (2)/Fp1. Give each device its own name in its LSL app to avoid it.
  • A stream that stops leaves a gap and, when the same device comes back, continues by itself. A device restarted without a source_id cannot be recognised and shows up as a new stream with (2) channels: ask the lab to set a source_id in the LSL app.

Health

streams, dropped (data beyond the queue), and per stream <name>.samples, <name>.time_correction_ms and <name>.last_sample_age_s (-1 before the first sample).

Troubleshooting

SymptomLikely cause
discover lists nothingThe device is not sending yet, the computers are on different networks, or a firewall blocks LSL (UDP multicast and the TCP ports it opens).
A stream is missing when streams is a listAn entry did not match: run once with all and copy the exact name or type.
Channels named ch1...The device sends no channel labels in its description.
A (2) appearedA restarted device without a source_id, or two devices with one name.
Marker numbers do not match the logThe collector's state folder was deleted or changed: the table starts again from 0.