mne_realtime.LSLClient#

class mne_realtime.LSLClient(info=None, host='localhost', port=None, wait_max=10.0, tmin=None, tmax=inf, buffer_size=1000, verbose=None)[source]#

LSL Realtime Client.

Warning

This object is deprecated in favor of mne_lsl.stream.StreamLSL.

Parameters:
infoinstance of mne.Info | None

The measurement info read in from a file. If None, it is generated from the LSL stream. This method may result in less info than expected. Also, the channel type of the LSL stream must be one the MNE supported channel types: ‘ecg’, ‘bio’, ‘stim’, ‘eog’, ‘misc’, ‘seeg’, ‘ecog’, ‘mag’, ‘eeg’, ‘ref_meg’, ‘grad’, ‘emg’, ‘hbr’ or ‘hbo’. If the channel type is EEG, the standard_1005 montage is used for electrode location.

hoststr

The LSL identifier of the server. This is the source_id designated when the LSL stream was created. Make sure the source_id is unique on the LSL subnet. For more information on LSL, please check the docstrings on StreamInfo and StreamInlet in the pylsl.

portint | None

Port to use for the connection.

wait_maxfloat

Maximum time (in seconds) to wait for real-time buffer to start

tminfloat | None

Time instant to start receiving buffers. If None, start from the latest samples available.

tmaxfloat

Time instant to stop receiving buffers.

buffer_sizeint

Size of each buffer in terms of number of samples.

verbosebool, str, int, or None

If not None, override default verbose level (see mne.verbose() for more).

get_data_as_epoch(n_samples=1024, picks=None, timeout=None)[source]#

Return n_samples from LSL in FIFO order.

Parameters:
n_samplesint

Number of samples to fetch.

picksstr | array_like | slice | None

Channels to include. Slices and lists of integers will be interpreted as channel indices. In lists, channel type strings (e.g., ['meg', 'eeg']) will pick channels of those types, channel name strings (e.g., ['MEG0111', 'MEG2623'] will pick the given channels. Can also be the string values 'all' to pick all channels, or 'data' to pick data channels. None (default) will pick all channels. Note that channels in info['bads'] will be included if their names or indices are explicitly provided.

timeoutfloat | None

Maximum amount of time to wait for data from LSL if None: waits for 5x n_samples / sfreq

Returns:
epochinstance of EpochsArray | None

The samples fetched as an Epochs object. None if no data was returned from pylsl.

get_measurement_info()#

Return the measurement info.

Returns:
self.infodict

The measurement info.

iter_raw_buffers()[source]#

Return an infinite iterator over raw buffers.

register_receive_callback(callback)#

Register a raw buffer receive callback.

Parameters:
callbackcallable()

The callback. The raw buffer is passed as the first parameter to callback.

start()#

Start the client.

start_receive_thread(nchan)#

Start the receive thread.

If the measurement has not been started, it will also be started.

Parameters:
nchanint

The number of channels in the data.

stop()#

Stop the client.

stop_receive_thread(stop_measurement=False)#

Stop the receive thread.

Parameters:
stop_measurementbool

Also stop the measurement.

unregister_receive_callback(callback)#

Unregister a raw buffer receive callback.

Parameters:
callbackcallable()

The callback to unregister.

Examples using mne_realtime.LSLClient#

Plot real-time epoch data with LSL client

Plot real-time epoch data with LSL client