Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add openBCI example documentation #31

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions examples/openBCI_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- 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()

56 changes: 56 additions & 0 deletions examples/openBCI_tutorial.md
Original file line number Diff line number Diff line change
@@ -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)