From 25267f65ce96a1710f311508c18cc6e144c56a44 Mon Sep 17 00:00:00 2001 From: timonmerk Date: Fri, 19 Mar 2021 15:50:58 +0100 Subject: [PATCH 1/3] add openBCI example documentation --- examples/openBCI_test.py | 33 +++++++++++++++++++++ examples/openBCI_tutorial.md | 56 ++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 examples/openBCI_test.py create mode 100644 examples/openBCI_tutorial.md diff --git a/examples/openBCI_test.py b/examples/openBCI_test.py new file mode 100644 index 0000000..2a70a2f --- /dev/null +++ b/examples/openBCI_test.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +""" +Created on Wed Mar 17 18:51:27 2021 + +@author: ICN_admin +""" + +from mne_realtime import LSLClient +import matplotlib.pyplot as plt + +# this is the max wait time in seconds until client connection +wait_max = 5 + + +if __name__ == '__main__': + plt.ion() # make plot interactive + _, ax = plt.subplots(1) + with LSLClient(host="openbci_eeg_id127", wait_max=wait_max) as client: + print("client initialized") + client_info = client.get_measurement_info() + sfreq = int(client_info['sfreq']) + epoch = client.get_data_as_epoch(n_samples=sfreq) + + # let's observe ten seconds of data + for ii in range(100): + print(ii) + plt.cla() + epoch = client.get_data_as_epoch(n_samples=sfreq) + epoch.average().plot(axes=ax) + print(epoch.average().shape) + plt.pause(1) + + plt.draw() \ No newline at end of file diff --git a/examples/openBCI_tutorial.md b/examples/openBCI_tutorial.md new file mode 100644 index 0000000..b49807a --- /dev/null +++ b/examples/openBCI_tutorial.md @@ -0,0 +1,56 @@ +Tutorial OpenBCI LSL integration +1. Install mne real-time environment + +2. Install OpenBCI and install necessary FTDI driver + +3. Install openBCI labstreamlayer: https://docs.openbci.com/docs/06Software/02-CompatibleThirdPartySoftware/LSL + +4. run in a terminal from the OpenBCI_LSL repo + +> $ python openbci_lsl.py --stream +> 2021-03-19 14:24:27.599 ( 6.241s) [ ] common.cpp:50 INFO| git:e762b9e10ad0d77651923c0afa7f435af38e8a9b/branch:refs/tags/v1.14.0/build:Release/compiler:MSVC-19.0.24245.0/link:shared +> 2021-03-19 14:24:27.607 ( 6.249s) [ ] stream_outlet_impl.cpp:86 WARN| Couldn't create multicast responder for 224.0.0.1 (set_option: A socket operation was attempted to an unreachable host) +> 2021-03-19 14:24:27.612 ( 6.255s) [ ] stream_outlet_impl.cpp:86 WARN| Couldn't create multicast responder for 224.0.0.1 (set_option: A socket operation was attempted to an unreachable host) +> +> -------INSTANTIATING BOARD------- +> Connecting to V3 at port COM3 +> Serial established... +> OpenBCI V3 8-16 channel +> On Board ADS1299 Device ID: 0x3E +> LIS3DH Device ID: 0x33 +> Firmware: v3.1.2 +> $$$ +> -------------------------------------- +> LSL Configuration: +> Stream 1: +> Name: openbci_eeg +> Type: EEG +> Channel Count: 8 +> Sampling Rate: 250.0 +> Channel Format: float32 +> Source Id: openbci_eeg_id127 +> Stream 2: +> Name: openbci_aux +> Type: AUX +> Channel Count: 3 +> Sampling Rate: 250.0 +> Channel Format: float32 +> Source Id: openbci_aux_id127 +> +> Electrode Location Montage: +> ['Fp1', 'Fp2', 'C3', 'C4', 'T5', 'T6', 'O1', 'O2'] +> --------------------------------------- +> +> --------------INFO--------------- +> Commands: +> Type "/start" to stream to LSL +> Type "/stop" to stop stream. +> Type "/exit" to disconnect the board. +> Advanced command map available at http://docs.openbci.com +> +> -------------BEGIN--------------- + + +5. start streaming with /run +6. open examples/openBCI_test.py and edit the host_name as the only from the pylsl “Source Id” (in the upper example openbci_eeg_id127 for Stream 1) + From 87af9715e72f4465d0601f3aa602fb3b465c7ed3 Mon Sep 17 00:00:00 2001 From: timonmerk <38216460+timonmerk@users.noreply.github.com> Date: Thu, 18 Nov 2021 10:03:10 +0100 Subject: [PATCH 2/3] Update openBCI_test.py add last line --- examples/openBCI_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/openBCI_test.py b/examples/openBCI_test.py index 2a70a2f..56d87dc 100644 --- a/examples/openBCI_test.py +++ b/examples/openBCI_test.py @@ -30,4 +30,5 @@ print(epoch.average().shape) plt.pause(1) - plt.draw() \ No newline at end of file + plt.draw() + From 693dc3fd956143d7f537a09f41a6c2f9dc53f99e Mon Sep 17 00:00:00 2001 From: timonmerk <38216460+timonmerk@users.noreply.github.com> Date: Thu, 18 Nov 2021 10:04:08 +0100 Subject: [PATCH 3/3] Update openBCI_test.py add last line --- examples/openBCI_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/openBCI_test.py b/examples/openBCI_test.py index 56d87dc..e77c359 100644 --- a/examples/openBCI_test.py +++ b/examples/openBCI_test.py @@ -31,4 +31,4 @@ plt.pause(1) plt.draw() - +