timeflux.nodes.lsl


Lab streaming layer nodes

The lab streaming layer provides a set of functions to make instrument data accessible in real time within a lab network. From there, streams can be picked up by recording programs, viewing programs or custom experiment applications that access data streams in real time.

lsl

class timeflux.nodes.lsl.Send(name, type='Signal', format='double64', rate=0.0, source=None, config_path=None)

Bases: timeflux.core.node.Node

Send to a LSL stream.

Variables:

i (Port) – Default data input, expects DataFrame.

Parameters:
  • name (string) – The name of the stream.

  • type (string) – The content type of the stream, .

  • format (string) – The format type for each channel. Currently, only double64 and string are supported.

  • rate (float) – The nominal sampling rate. Set to 0.0 to indicate a variable sampling rate.

  • source (string, None) – The unique identifier for the stream. If None, it will be auto-generated.

  • config_path (string, None) – The path to an LSL config file.

Example

graphs:

  - id: Sender
    nodes:
    - id: random
      module: timeflux.nodes.random
      class: Random
    - id: outlet
      module: timeflux.nodes.lsl
      class: Send
      params:
        name: test
    edges:
      - source: random
        target: outlet
    rate: 1

  - id: Receiver
    nodes:
    - id: inlet
      module: timeflux.nodes.lsl
      class: Receive
      params:
        prop: name
        value: test
    - id: display
      module: timeflux.nodes.debug
      class: Display
    edges:
      - source: inlet
        target: display
    rate: 1

Instantiate the node.

update()

Update the input and output ports.

class timeflux.nodes.lsl.Receive(prop='name', value=None, timeout=1.0, channels=None, max_samples=1024, clocksync=True, dejitter=False, monotonize=False, threadsafe=True, config_path=None)

Bases: timeflux.core.node.Node

Receive from a LSL stream.

Variables:

o (Port) – Default output, provides DataFrame and meta.

Parameters:
  • prop (string) – The property to look for during stream resolution (e.g., name, type, source_id).

  • value (string) – The value that the property should have (e.g., EEG for the type property).

  • timeout (float) – The resolution timeout, in seconds.

  • channels (list, None) – Override the channel names. If None, the names defined in the LSL stream will be used.

  • max_samples (int) – The maximum number of samples to return per call.

  • clocksync (bool) – Perform automatic clock synchronization.

  • dejitter (bool) – Remove jitter from timestamps using a smoothing algorithm to the received timestamps.

  • monotonize (bool) – Force the timestamps to be monotonically ascending. Only makes sense if timestamps are dejittered.

  • threadsafe (bool) – Same inlet can be read from by multiple threads.

  • config_path (string, None) – The path to an LSL config file.

Example

# Make sure you have a valid LSL configuration!
# Check the test directory for an example lsl_api.cfg
# See: https://labstreaminglayer.readthedocs.io/info/lslapicfg.html

graphs:

  - id: Sender
    nodes:
    - id: random_1
      module: timeflux.nodes.random
      class: Random
    - id: outlet_1
      module: timeflux.nodes.lsl
      class: Send
      params:
        name: test_1
        type: random
    - id: random_2
      module: timeflux.nodes.random
      class: Random
    - id: outlet_2
      module: timeflux.nodes.lsl
      class: Send
      params:
        name: test_2
    edges:
      - source: random_1
        target: outlet_1
      - source: random_2
        target: outlet_2
    rate: 1

  - id: Receiver1
    nodes:
    - id: inlet
      module: timeflux.nodes.lsl
      class: Receive
      params:
        prop: type
        value: random
        clocksync: false
    - id: display
      module: timeflux.nodes.debug
      class: Display
    edges:
      - source: inlet
        target: display
    rate: 1

  - id: Receiver2
    nodes:
    - id: inlet
      module: timeflux.nodes.lsl
      class: Receive
      params:
        prop: name
        value: test_2
        clocksync: false
    - id: display
      module: timeflux.nodes.debug
      class: Display
    edges:
      - source: inlet
        target: display
    rate: 1

Instantiate the node.

update()

Update the input and output ports.