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', channel_names: Sequence[str] | None = None)[source]#
Bases:
objectThread-safe LSL outlet that broadcasts NF feature values.
Creates a single-source LSL stream with
n_channelsfloat32 channels (one per active NF modality). Channel labels are published in the stream description, so subscribers can select a value by name rather than by position – taken fromchannel_namesif given, otherwise from the modality names on the firstpush()call.- Parameters:
- stream_name
str, default “ANT_NF” LSL stream name visible to subscribers.
- stream_type
str, default “NF” LSL content type (arbitrary string; “NF” is ANT convention).
- n_channels
int, 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.- srate
float, default 0.0 Nominal sample rate in Hz.
0.0marks the stream as irregular (i.e. one sample per NF window, not a fixed rate).- source_id
str, default “ant_nf_outlet” Unique source identifier embedded in the stream info.
- channel_namessequence
ofstr|None, defaultNone Channel labels to publish in the stream description. When omitted, they are taken from the modality names on the first
push(), which rebuilds the outlet once and so briefly drops any subscriber that had already resolved the stream. Pass them here when they are known in advance to avoid that.
- stream_name
- Raises:
ImportErrorIf neither
mne_lslnorpylslis 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', channel_names: Sequence[str] | None = None) 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
Modality names from the most recent
push()call.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:
- Raises:
ValueErrorIf
modalitiesandvalueshave different lengths, or if a value is not a number.