mne_lsl.lsl.StreamInfoπŸ”—

class mne_lsl.lsl.StreamInfo(name, stype, n_channels, sfreq, dtype, source_id)[source]πŸ”—

Base Stream information object, storing the declaration of a stream.

A StreamInfo contains the following information:

  • Core information (name, number of channels, sampling frequency, channel format, …).

  • Optional metadata about the stream content (channel labels, measurement units, …).

  • Hosting information (uID, hostname, …) if bound to a StreamInlet or StreamOutlet.

Parameters:
namestr

Name of the stream. This field can not be empty.

stypestr

Content type of the stream, e.g. "EEG" or "Gaze". If a stream contains mixed content, this value should be empty and the description of each channel should include its type.

n_channelsint β‰₯ 1

Also called channel_count, represents the number of channels per sample. This number stays constant for the lifetime of the stream.

sfreqfloat β‰₯ 0

Also called nominal_srate, represents the sampling rate (in Hz) as advertised by the data source. If the sampling rate is irregular (e.g. for a trigger stream), the sampling rate is set to 0.

dtypestr | dtype

Format of each channel. If your channels have different formats, consider supplying multiple streams or use the largest type that can hold them all. One of ('string', 'float32', 'float64', 'int8', 'int16', 'int32'). 'int64' is partially supported. Can also be the equivalent numpy type, e.g. np.int8.

source_idstr

A unique identifier of the device or source of the data. If not empty, this information improves the system robustness since it allows recipients to recover from failure by finding a stream with the same source_id on the network.

Attributes

as_xml

Retrieve the entire stream_info in XML format.

created_at

Timestamp at which the stream was created.

desc

Extended description of the stream.

dtype

Channel format of a stream.

hostname

Hostname of the providing machine.

n_channels

Number of channels.

name

Name of the stream.

protocol_version

Version of the LSL protocol.

session_id

Session ID for the given stream.

sfreq

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

source_id

Unique identifier of the stream's source.

stype

Type of the stream.

uid

Unique ID of the StreamOutlet instance.

Methods

get_channel_info()

Get the FIFF measurement Info in the description.

get_channel_names()

Get the channel names in the description.

get_channel_types()

Get the channel types in the description.

get_channel_units()

Get the channel units in the description.

set_channel_info(info)

Set the channel info from a FIFF measurement Info.

set_channel_names(ch_names)

Set the channel names in the description.

set_channel_types(ch_types)

Set the channel types in the description.

set_channel_units(ch_units)

Set the channel units in the description.

get_channel_info()[source]πŸ”—

Get the FIFF measurement Info in the description.

Returns:
infoInfo

Info containing the measurement information.

get_channel_names()[source]πŸ”—

Get the channel names in the description.

Returns:
ch_nameslist of str or None | None

List of channel names, matching the number of total channels. If None, the channel names are not set.

Warning

If a list of str and None are returned, some of the channel names are missing. This is not expected and could occur if the XML tree in the desc property is tempered with outside of the defined getter and setter.

get_channel_types()[source]πŸ”—

Get the channel types in the description.

Returns:
ch_typeslist of str or None | None

List of channel types, matching the number of total channels. If None, the channel types are not set.

Warning

If a list of str and None are returned, some of the channel types are missing. This is not expected and could occur if the XML tree in the desc property is tempered with outside of the defined getter and setter.

get_channel_units()[source]πŸ”—

Get the channel units in the description.

Returns:
ch_unitslist of str or None | None

List of channel units, matching the number of total channels. If None, the channel units are not set.

Warning

If a list of str and None are returned, some of the channel units are missing. This is not expected and could occur if the XML tree in the desc property is tempered with outside of the defined getter and setter.

set_channel_info(info)[source]πŸ”—

Set the channel info from a FIFF measurement Info.

Parameters:
infoInfo

Info containing the measurement information.

set_channel_names(ch_names)[source]πŸ”—

Set the channel names in the description. Existing labels are overwritten.

Parameters:
ch_nameslist of str

List of channel names, matching the number of total channels.

set_channel_types(ch_types)[source]πŸ”—

Set the channel types in the description. Existing types are overwritten.

The types are given as human readable strings, e.g. 'eeg'.

Parameters:
ch_typeslist of str | str

List of channel types, matching the number of total channels. If a single str is provided, the type is applied to all channels.

set_channel_units(ch_units)[source]πŸ”—

Set the channel units in the description. Existing units are overwritten.

The units are given as human readable strings, e.g. 'microvolts', or as multiplication factor, e.g. -6 for 1e-6 thus converting e.g. Volts to microvolts.

Parameters:
ch_unitslist of str | list of int | array of int | str | int

List of channel units, matching the number of total channels. If a single str or int is provided, the unit is applied to all channels.

Notes

Some channel types doch_units not have a unit. The str none or the int 0 should be used to denote this channel unit, corresponding to FIFF_UNITM_NONE in MNE-Python.

property as_xmlπŸ”—

Retrieve the entire stream_info in XML format.

This yields an XML document (in string form) whose top-level element is <info>. The info element contains one element for each field of the StreamInfo class, including:

  • the core elements name, type (eq. stype), channel_count (eq. n_channels), nominal_srate (eq. sfreq), channel_format (eq. dtype), source_id

  • the misc elements version, created_at, uid, session_id, v4address, v4data_port, v4service_port, v6address, v6data_port, v6service_port

  • the extended description element desc with user-defined sub-elements.

Type:

str

property created_atπŸ”—

Timestamp at which the stream was created.

This is the time stamps at which the stream was first created, as determined by mne_lsl.lsl.local_clock() on the providing machine.

Type:

float

property descπŸ”—

Extended description of the stream.

It is highly recommended that at least the channel labels are described here. See code examples on the LSL wiki. Other information, such as amplifier settings, measurement units if deviating from defaults, setup information, subject information, etc.. can be specified here, as well. Meta-data recommendations follow the XDF file format project.

Important: if you use a stream content type for which meta-data recommendations exist, please try to lay out your meta-data in agreement with these recommendations for compatibility with other applications.

property dtypeπŸ”—

Channel format of a stream.

All channels in a stream have the same format.

Type:

dtype | "string"

property hostnameπŸ”—

Hostname of the providing machine.

Type:

str

property n_channelsπŸ”—

Number of channels.

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

Type:

int

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.

Type:

str

property protocol_versionπŸ”—

Version of the LSL protocol.

The major version is version // 100. The minor version is version % 100.

Type:

int

property session_idπŸ”—

Session ID for the given stream.

The session ID is an optional human-assigned identifier of the recording session. While it is rarely used, it can be used to prevent concurrent recording activities on the same sub-network (e.g., in multiple experiment areas) from seeing each other’s streams (can be assigned in a configuration file read by liblsl, see also Network Connectivity in the LSL wiki).

Type:

str

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.

Type:

float

property source_idπŸ”—

Unique identifier of the stream’s source.

The unique source (or device) identifier is an optional piece of information that, if available, allows endpoints (such as the recording program) to re-acquire a stream automatically once if it came back online.

Type:

str

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.

Type:

str

property uidπŸ”—

Unique ID of the StreamOutlet instance.

This ID is guaranteed to be different across multiple instantiations of the same StreamOutlet, e.g. after a re-start.

Type:

str

Examples using mne_lsl.lsl.StreamInfoπŸ”—

Low-level LSL API

Low-level LSL API