mne_rt.ArrayStream#
- class mne_rt.ArrayStream(data: ndarray, info: Info, *, bufsize: float = 3.0, chunk_size: int = 10, n_repeat: int | float = 1)[source]#
Bases:
objectSimulate a live LSL stream from an in-memory numpy array.
Duck-types the subset of
mne_lsl.stream.StreamLSL’s public interface thatRTStreamrelies on (get_data,n_new_samples,connected,info,disconnect,pick,filter,notch_filter,set_montage,set_meas_date), so anRTStreamsession can be driven by a plain numpy array instead of live hardware or a recorded file replayed over LSL. Returned byRTStream.connect_to_array()— not normally instantiated directly.- Parameters:
- data
arrayofshape(n_channels,n_samples) The full recording to stream.
- info
mne.Info Channel/sampling-rate metadata;
info["nchan"]must equaldata.shape[0].- bufsize
float, default 3.0 Ring-buffer size in seconds, mirroring
StreamLSL(bufsize=...).- chunk_size
int, default 10 Number of samples released into the buffer per acquisition tick, mirroring
mne_lsl.player.PlayerLSL’schunk_size.- n_repeat
int|float, default 1 Number of times to loop over
dataonce exhausted. Usenp.inffor an open-ended session.
- data
Notes
Because the entire recording is already available in memory,
filter()andnotch_filter()apply a single zero-phase FIR pass over the whole array (viamne.filter.filter_data()/mne.filter.notch_filter()) rather than a causal online filter — there is no “future data” constraint to respect as there would be for a genuinely live stream. If called while already streaming (asrecord_main()does), samples already pushed into the ring buffer stay unfiltered until they age out — the buffer is fully refreshed, and the transient gone, within onebufsizewindow.If
n_repeatis exhausted before the caller stops requesting data, streaming simply stops advancing:n_new_samplesstays at 0 andget_data()keeps returning the final buffered window.- __init__(data: ndarray, info: Info, *, bufsize: float = 3.0, chunk_size: int = 10, n_repeat: int | float = 1) None[source]#
Methods
__init__(data, info, *[, bufsize, ...])connect()Start the simulated real-time acquisition thread.
Stop the acquisition thread.
filter(l_freq, h_freq)Zero-phase FIR band-pass over the entire underlying array.
get_data([winsize, picks, exclude])Retrieve the latest data from the buffer.
notch_filter(freqs)Zero-phase FIR notch filter over the entire underlying array.
pick([picks, exclude])Restrict the stream to a subset of channels, in-place.
set_meas_date(meas_date)set_montage(montage[, on_missing])Attributes
Number of new samples available since the last
get_data()call.- connect() ArrayStream[source]#
Start the simulated real-time acquisition thread.
- disconnect() ArrayStream[source]#
Stop the acquisition thread.
- property n_new_samples: int#
Number of new samples available since the last
get_data()call.
- get_data(winsize: float | None = None, picks: str | list | None = None, exclude: str | list | tuple = 'bads') tuple[ndarray, ndarray][source]#
Retrieve the latest data from the buffer.
Mirrors
mne_lsl.stream.StreamLSL.get_data(): resetsn_new_samplesto 0 on every call.
- set_montage(montage: Any, on_missing: str = 'warn') ArrayStream[source]#
- set_meas_date(meas_date: Any) ArrayStream[source]#
- pick(picks: Any = None, exclude: Any = ()) ArrayStream[source]#
Restrict the stream to a subset of channels, in-place.
Must be called before
connect()— picking after the acquisition thread has started would change the channel count out from under it mid-stream.