mne_rt.LSLSender#

class mne_rt.LSLSender(stream_name: str = 'ANT_NF', stream_type: str = 'NF', n_channels: int = 8, srate: float = 0.0, source_id: str = 'ant_nf_outlet')[source]#

Bases: object

Thread-safe LSL outlet that broadcasts NF feature values.

Creates a single-source LSL stream with n_channels float32 channels (one per active NF modality). Channel labels are set from the modality names on the first push() call.

Parameters:
stream_namestr, default “ANT_NF”

LSL stream name visible to subscribers.

stream_typestr, default “NF”

LSL content type (arbitrary string; “NF” is ANT convention).

n_channelsint, default 8

Maximum number of channels in the outlet. If fewer modalities are active, unused channels are filled with 0.0. You can leave this at the default and the outlet will resize automatically on first push if needed.

sratefloat, default 0.0

Nominal sample rate in Hz. 0.0 marks the stream as irregular (i.e. one sample per NF window, not a fixed rate).

source_idstr, default “ant_nf_outlet”

Unique source identifier embedded in the stream info.

Raises:
ImportError

If neither mne_lsl nor pylsl is installed.

Examples

Basic usage:

sender = LSLSender(stream_name="ANT_NF")
sender.push(["sensor_power", "erd_ers"], [0.42, -1.2])
sender.close()

Context-manager usage:

with LSLSender() as sender:
    for value in nf_stream:
        sender.push(["sensor_power"], [value])

Added in version 1.0.0.

__init__(stream_name: str = 'ANT_NF', stream_type: str = 'NF', n_channels: int = 8, srate: float = 0.0, source_id: str = 'ant_nf_outlet') None[source]#

Methods

__init__([stream_name, stream_type, ...])

close()

Destroy the LSL outlet and release resources.

push(modalities, values)

Push one NF sample into the LSL outlet.

push_value(modality, value)

Push a single-channel NF value.

Attributes

channel_labels

Modality names from the most recent push() call.

n_channels

Current number of channels in the LSL outlet.

push(modalities: Sequence[str], values: Sequence[float]) None[source]#

Push one NF sample into the LSL outlet.

Parameters:
modalitiessequence of str

Active modality names (used to set channel labels on first call).

valuessequence of float

Corresponding NF feature values, same length as modalities.

Raises:
ValueError

If modalities and values have different lengths.

push_value(modality: str, value: float) None[source]#

Push a single-channel NF value.

Parameters:
modalitystr

Modality name.

valuefloat

NF feature value.

close() None[source]#

Destroy the LSL outlet and release resources.

After calling this the sender should not be used again.

property n_channels: int#

Current number of channels in the LSL outlet.

property channel_labels: list[str]#

Modality names from the most recent push() call.