Implementation details🔗
Processing🔗
The StreamLSL and EpochsStream object
support processing in real-time of their internal buffers. The processing is done
sequentially and this page presents the available processing and their application
order.
StreamLSL🔗
Processing is applied to new samples available in the
StreamInlet before rolling the buffer of the
StreamLSL object and adding those new processed samples to it.
The processing is defined in the private _acquire method of the class
StreamLSL, method called by the background acquisition thread
(automatic acquisition) or by the method mne_lsl.stream.StreamLSL.acquire()
(manual acquisition).
Add channels that were added with
mne_lsl.stream.StreamLSL.add_reference_channels(). The channels are added as an array of zeros at the end of the buffer along the channel axis.Apply the rereferencing schema requested with
mne_lsl.stream.StreamLSL.set_eeg_reference().Apply filters added with
mne_lsl.stream.StreamLSL.filter()andmne_lsl.stream.StreamLSL.notch_filter(). The filters are applied one at a time, in the order they were added.Run any custom callback function added with
mne_lsl.stream.StreamLSL.add_callback().
EpochsStream🔗
Processing is applied to new events and samples available to a
EpochsStream before rolling the buffer of the
EpochsStream object and adding new epochs to it.
The processing is defined in the private _acquire method of the class
EpochsStream, method called by the background acquisition
thread (automatic acquisition) or by the method
mne_lsl.stream.EpochsStream.acquire() (manual acquisition); and in the private
_process_data function which operates on the newly acquired data array of shape
(n_epochs, n_samples, n_channels).
Note
MNE-Python offers similar processing to a Raw and
Epochs object. However, mne-lsl differs in this regard by offering
some processing at the StreamLSL level and some at the
EpochsStream level. For instance, filters are applied
to a StreamLSL object while baseline correction is
applied to a EpochsStream object.
Select which events are new since the last acquisition and which events are retained. For instance, an event too close to the end of the buffer is discarded for now since it is not possible to cut an entire epoch from it. This event will be acquired and added to the buffer as soon as it will be possible to cut an entire epoch from it.
Process the newly acquired data array of shape
(n_epochs, n_samples, n_channels).Apply PTP and flatness rejection defined by the arguments
reject,flat,reject_tminandreject_tmax.Apply baseline correction defined by the arguments
baseline,tminandtmax.Apply detrending defined by the argument
detrend.