diff --git a/README.md b/README.md index 0634d23..8f4de78 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,22 @@ # Muse LSL -This is a collection of script to use the muse 2016 BLE headset with LSL. +This is a collection of python script to use the muse 2016 BLE headset with LSL. + +![Blinks](blinks.png) + +## Requirements + +The code rely on [pygatt](https://github.com/peplin/pygatt) for the BLE communication. +pygatt works on linux and OSX, and should work on window provided that you have a BLED112 dongle. + +You will also need to find the mad address of you Muse headset + +## Usage + +to stream data with lsl + +`python muse-lsl.py --address YOUR_DEVICE_ADDRESS` + +Once the stream is up and running, you can visualize stream with + +`python lsl-viewer.py` diff --git a/blinks.png b/blinks.png new file mode 100644 index 0000000..6b7cdb9 Binary files /dev/null and b/blinks.png differ diff --git a/muse-lsl.py b/muse-lsl.py index cd15fbb..96591b1 100644 --- a/muse-lsl.py +++ b/muse-lsl.py @@ -1,11 +1,17 @@ from muse import Muse from time import sleep from pylsl import StreamInfo, StreamOutlet +from optparse import OptionParser -YOUR_DEVICE_ADDRESS = "00:55:DA:B0:06:D6" +parser = OptionParser() +parser.add_option("-a", "--address", + dest="address", type='string', default="00:55:DA:B0:06:D6", + help="device mac adress.") + +(options, args) = parser.parse_args() info = info = StreamInfo('Muse', 'EEG', 5, 256, 'float32', - 'Muse%s' % YOUR_DEVICE_ADDRESS) + 'Muse%s' % options.address) info.desc().append_child_value("manufacturer", "Muse") channels = info.desc().append_child("channels") @@ -22,7 +28,7 @@ def process(data, timestamps): for ii in range(12): outlet.push_sample(data[:, ii], timestamps[ii]) -muse = Muse(address=YOUR_DEVICE_ADDRESS, callback=process) +muse = Muse(address=options.address, callback=process) muse.connect() print('Connected') diff --git a/muse-record.py b/muse-record.py index 4bedb00..2fa2ebd 100644 --- a/muse-record.py +++ b/muse-record.py @@ -1,17 +1,25 @@ from muse import Muse -from time import time, sleep +from time import sleep import numpy as np import pandas as pd -YOUR_DEVICE_ADDRESS = "00:55:DA:B0:06:D6" +from optparse import OptionParser + +parser = OptionParser() +parser.add_option("-a", "--address", + dest="address", type='string', default="00:55:DA:B0:06:D6", + help="device mac adress.") + +(options, args) = parser.parse_args() full_time = [] full_data = [] + def process(data, timestamps): full_time.append(timestamps) full_data.append(data) -muse = Muse(YOUR_DEVICE_ADDRESS, process) +muse = Muse(options.address, process) muse.connect() muse.start()