forked from mne-tools/mne-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MRG] RealTime client refactor (mne-tools#6141)
* Add an example using the LSLClient n_chan --> n_channels * Refactor FTClient; Add MockLSLStream, refactor test to use mock stream * update reference and whats new * fixing some errors * update style * temp * improvements to the realtime module currently the test is breaking when it comes to using the RtEpochs object. * minor fix * move the RtEpochs testing to separate PR * cleanup * fix the way super is called * updated the MockLSLStream to take raw instance * add time dilation factor, cleanup * add more info on lsl identifier * address ci * skip running test with multiprocessing on windows Windows runs into a problem with multiprocessing: 'https://stackoverflow.com/questions/50079165/' * cleaned up the windows check * update the pylsl requirement to 1.12 this is compatible across platforms
- Loading branch information
1 parent
a3adefb
commit c9fa690
Showing
13 changed files
with
286 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -954,6 +954,7 @@ Realtime | |
|
||
FieldTripClient | ||
LSLClient | ||
MockLSLStream | ||
MockRtClient | ||
RtEpochs | ||
RtClient | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" | ||
============================================================== | ||
Plot real-time epoch data with LSL client | ||
============================================================== | ||
This example demonstrates how to use the LSL client to plot real-time | ||
collection of event data from an LSL stream. | ||
For the purposes of demo, a mock LSL stream is constructed. You can | ||
replace this with the stream of your choice by changing the host id to | ||
the desired stream. | ||
""" | ||
# Author: Teon Brooks <[email protected]> | ||
# | ||
# License: BSD (3-clause) | ||
import matplotlib.pyplot as plt | ||
|
||
from mne.realtime import LSLClient, MockLSLStream | ||
from mne.datasets import sample | ||
from mne.io import read_raw_fif | ||
|
||
print(__doc__) | ||
|
||
# this is the host id that identifies your stream on LSL | ||
host = 'mne_stream' | ||
# this is the max wait time in seconds until client connection | ||
wait_max = 5 | ||
|
||
|
||
# Load a file to stream raw data | ||
data_path = sample.data_path() | ||
raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif' | ||
raw = read_raw_fif(raw_fname, preload=True).pick('eeg') | ||
|
||
# For this example, let's use the mock LSL stream. | ||
stream = MockLSLStream(host, raw, 'eeg') | ||
stream.start() | ||
|
||
# Let's observe it | ||
plt.ion() # make plot interactive | ||
_, ax = plt.subplots(1) | ||
with LSLClient(info=raw.info, host=host, wait_max=wait_max) as client: | ||
client_info = client.get_measurement_info() | ||
sfreq = int(client_info['sfreq']) | ||
print(client_info) | ||
|
||
# let's observe ten seconds of data | ||
for ii in range(10): | ||
plt.cla() | ||
epoch = client.get_data_as_epoch(n_samples=sfreq) | ||
epoch.average().plot(axes=ax) | ||
plt.pause(1) | ||
plt.draw() | ||
# Let's terminate the mock LSL stream | ||
stream.stop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,16 @@ | |
|
||
# Authors: Christoph Dinh <[email protected]> | ||
# Martin Luessi <[email protected]> | ||
# Mainak Jas <[email protected]> | ||
# Mainak Jas <[email protected]> | ||
# Matti Hamalainen <[email protected]> | ||
# Teon Brooks <[email protected]> | ||
# | ||
# License: BSD (3-clause) | ||
|
||
from .client import RtClient | ||
from .epochs import RtEpochs | ||
from .lsl_client import LSLClient | ||
from .mock_lsl_stream import MockLSLStream | ||
from .mockclient import MockRtClient | ||
from .fieldtrip_client import FieldTripClient | ||
from .stim_server_client import StimServer, StimClient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.