bsl.lsl.StreamOutlet

class bsl.lsl.StreamOutlet(sinfo, chunk_size=1, max_buffered=360)[source]

An outlet to share data and metadata on the network.

Parameters:
sinfoStreamInfo

The StreamInfo object describing the stream. Stays constant over the lifetime of the outlet.

chunk_sizeint 1

The desired chunk granularity in samples. By default, each push operation yields one chunk. An Inlet can override this setting.

max_bufferedfloat 0

The maximum amount of data to buffer in the Outlet. The number of samples buffered is max_buffered * 100 if the sampling rate is irregular, else it’s max_buffered seconds.

Attributes

dtype

Channel format of a stream.

has_consumers

Check whether StreamInlet are currently connected.

n_channels

Number of channels.

name

Name of the stream.

sfreq

Sampling rate of the stream, according to the source (in Hz).

stype

Type of the stream.

Methods

get_sinfo()

StreamInfo corresponding to this Outlet.

push_chunk(x[, timestamp, pushThrough])

Push a chunk of samples into the StreamOutlet.

push_sample(x[, timestamp, pushThrough])

Push a sample into the StreamOutlet.

wait_for_consumers(timeout)

Wait (block) until at least one StreamInlet connects.

get_sinfo()[source]

StreamInfo corresponding to this Outlet.

Returns:
sinfoStreamInfo

Description of the stream connected to the outlet.

push_chunk(x, timestamp=0.0, pushThrough=True)[source]

Push a chunk of samples into the StreamOutlet.

Parameters:
xlist of list | array of shape (n_samples, n_channels)

Samples to push, with one element for each channel at every time point. If strings are transmitted, a list of sublist containing (n_channels,) is required. If numericals are transmitted, a numpy array of shape (n_samples, n_channels) is required.

timestampfloat

The acquisition timestamp of the sample, in agreement with local_clock. The default, 0, uses the current time.

pushThroughbool

If True, push the sample through to the receivers instead of buffering it with subsequent samples. Note that the chunk_size defined when creating a StreamOutlet takes precedence over the pushThrough flag.

push_sample(x, timestamp=0.0, pushThrough=True)[source]

Push a sample into the StreamOutlet.

Parameters:
xlist | array of shape (n_channels,)

Sample to push, with one element for each channel. If strings are transmitted, a list is required. If numericals are transmitted, a numpy array is required.

timestampfloat

The acquisition timestamp of the sample, in agreement with local_clock. The default, 0, uses the current time.

pushThroughbool

If True, push the sample through to the receivers instead of buffering it with subsequent samples. Note that the chunk_size defined when creating a StreamOutlet takes precedence over the pushThrough flag.

wait_for_consumers(timeout)[source]

Wait (block) until at least one StreamInlet connects.

Parameters:
timeoutfloat

Timeout duration in seconds.

Returns:
successbool

True if the wait was successful, False if the timeout expired.

Notes

This function does not filter the search for bsl.lsl.StreamInlet. Any application inlet will be recognized.

property dtype

Channel format of a stream.

All channels in a stream have the same format.

property has_consumers

Check whether StreamInlet are currently connected.

While it does not hurt, there is technically no reason to push samples if there is no one connected.

Returns:
consumersbool

True if at least one consumer is connected.

Notes

This function does not filter the search for bsl.lsl.StreamInlet. Any application inlet will be recognized.

property n_channels

Number of channels.

A stream must have at least one channel. The number of channels remains constant for all samples.

property name

Name of the stream.

The name of the stream is defined by the application creating the LSL outlet. Streams with identical names can coexist, at the cost of ambiguity for the recording application and/or the experimenter.

property sfreq

Sampling rate of the stream, according to the source (in Hz).

If a stream is irregularly sampled, the sampling rate is set to 0.

property stype

Type of the stream.

The content type is a short string, such as "EEG", "Gaze", … which describes the content carried by the channel. If a stream contains mixed content, this value should be an empty string and the type should be stored in the description of individual channels.