urish / muse-js Goto Github PK
View Code? Open in Web Editor NEWMuse 2016 EEG Headset JavaScript Library (using Web Bluetooth)
Home Page: https://medium.com/@urish/reactive-brain-waves-af07864bb7d4
License: MIT License
Muse 2016 EEG Headset JavaScript Library (using Web Bluetooth)
Home Page: https://medium.com/@urish/reactive-brain-waves-af07864bb7d4
License: MIT License
These lines of code seems no longer relevant with Muse 2S (I don't know where the limit lies but it is higher, if the mechanism is still the same).
https://github.com/urish/muse-js/blob/4e864578c55dd7e26d85b429863f47ccabac54a0/src/muse.ts#L233C1-L256C1
As you can see in the screenshot, the index continues to increase in a regular manner. The timestamp drastically jump though.
Thank you Urish for this really amazing project.
I have a project that is using LSL and wondering how to make RxJS data stream visible to LSL?
Cheers
Raw EEG is cool, but FFT'ed absolute readings are more practical.. I'm not sure if it should be included in this package, or via external dependency (eeg-processing.js
and eeg-algorithms.js
), but I'm adding this issue here as placeholder because the need is real.
Looking at muse-io - Muse Elements Data for couple of processed streams that would be great to mirror:
/muse/elements/*_absolute (relative are easy to calculate from these)
/muse/elements/horseshoe ffff, /muse/elements/is_good iiii
Muscle Movement: /muse/elements/blink i, /muse/elements/jaw_clench i
Your package has a potential to solve a big problem, as muse left the 2016 headset without muse-io, nor a normal desktop SDK (no mac/linux, win10 UWP sucks..) your solution is better for developers who need to package client-apps, and not simply run single-machine research.
Thanks!
We are students from HTW Berlin and trying to do an art installation using the data from Muse 2. We are still in the beginning phase of it, but we saw that you are all quite a pro sourcing out the data from Muse 2. We just wanted to see if anyone would be down to connect to answer some questions about the code and share your knowledge with us?
Best :))
Just noticed that muse-js is running into a similar issue that Muse LSL did before this PR: alexandrebarachant/muse-lsl#37
When a headband is charged from empty all the way to full, it will often go into a different preset mode ('bootloader') and require a 'reset to headset mode' command (0x03 2a 31 0a
) before it's BLE characteristics are made available for connection.
Attempting to connect to the headset in this mode leads to the following error:
No Characteristics matching UUID 273e000b-4c4d-454d-96be-f03bac821358 found in Service with UUID 0000fe8d-0000-1000-8000-00805f9b34fb.
I suggest that we add a getDeviceInfo check to the connect function and handle a 'bootloader' device state by sending a reset command with the sendCommand
function
Is there a way to get the headsets battery percentage?
Hello everyone,
As the title suggests, are the raw file data saved in mVolts or uVolts?
I need information on Muse 2 Headband Bluetooth protocol. How did you get this information on the Muse? Can you help me?
Hello,
This is a question rather than an issue. Would muse-js work with Muse S?
I have seen the demo source but it's not clear if it's possible to subscribe only to one electrode reading.
I have a muse 2014 headset and would love to get it working with Node. Can someone point me in the right direction of how to add support for it? Are there any technical limitations I should be aware of?
I have noticed on my Muse (2016), that when I connect it to my PC using USB, a COM port appears.
Typing "h" or "v" i get some strings back.
I wonder what else is possible to do using the USB port directly.
The Muse 2016 device has several presets, enabling different features. Currently we always use preset number 20, which includes the AUX electrode. However, for users who don't need the AUX electrode, we can use present number 21, which excludes this electrode.
See this page for more information about the presets.
on eegedu.com
when I try to connect to a muse 2016 ** (edit) with
await window.source.connect();
I get
Connection error: NotFoundError: No Characteristics matching UUID 273e000b-4c4d-454d-96be-f03bac821358 found in Service with UUID 0000fe8d-0000-1000-8000-00805f9b34fb.
and cannot connect
This does not occur when using a newer muse-S.
Working on a Microsoft Surface Pro 3 running windows 10 with the Creators update and can't seem to get the web bluetooth to find the muse in my vicinity.
I added the Web Bluetooth Polyfill successfully but that doesn't seem to make a difference
The SP3 does seem to support Bluetooth LE but there might be an issue with how the driver works with Windows 10. I've ordered the ASUS BT400 adapter and will try that next but was wondering if there were any other suggestions to get this working.
Amazing project! Thought our new Muse (2016 model) would be unusable with our Mac/PC based neurofeedback apps until we found Muse-JS:)
As I understand it, Muse-JS reads raw EEG data from each electrode (TP9, AF7, AF8, TP10), but is there a simple way to read absolute band powers (delta, theta, alpha, etc.), or other data, from Muse-JS, without needing to manually decode the raw EEG data from Muse-JS?
I looked through your code, but didn't spot any way to simply parse or decode/compute band powers. Muse-IO & Muse Monitor both provided live band powers data (via OSC paths muse/elements/delta_absolute etc), as well as raw EEG data, but they're no longer feasible options & we'd love to consider using Muse-JS moving forward. Thanks for any feedback!
Hey @urish can I open this one back up and suggest a feature I can help with to expose the PPG data in the Muse 2 and Muse S headbands.
based on the address of the data in the raw packets here:
#42 (comment)
I think the main parsing of the data files happens here:
https://github.com/urish/muse-js/blob/master/src/muse.spec.ts
I believe a function would be needed here to parse the data, and define data types in another file:
https://github.com/urish/muse-js/blob/master/src/lib/muse-parse.ts
Hey,
Not an issue, just a question. I've noticed the Client doesn't have an "unsubscribe" function - is that automatic on disconnect()? I ask because I'm going to be using it in an office setting, so I want to make certain Person A's dataset doesn't accidentally get mixed with Person N's.
Does this library expose the mellow & concentration values?
I'm getting data each 460ms. and 12 readings per electrode.
Is there a way to decrease the sample rate or increment the 12 readings?
Is anyone discussing how to code for these devices anywhere? Would this wiki be a place?
I'm trying to manually access my Muse S and I keep getting access error reading from the gatt data, or trying to bond. What am I missing?
Hi!
My friend @Th4n05 and I have worked with Muse2016 and your packet for a few month. Sometimes Muse disconnect during the acquisition. We know that Muse is a strange stuff but when it disconnect we want that it reconnect automatically. You could say 'you can do it, create a new MuseClient or something else'. We don't know why but after reconnection the EEG stream don't work.
@Th4n05 understands that if we remove takeUntil()
in muse-utils.js the problem is resolved but we don't understand why this happens also when we create a new MuseClient instance.
Do you have any ideas?
Hello
Accelerometer data is always 0.00
: x=-0.00g, y=-0.00g, z=0.00
just changes -/+ ... Any idea why
I run into some strange behaviour trying to plot EEG and PPG simultaneously. I'm using a Muse-S.
Below I added the basic code to reproduce the behaviour. Connect to the muse and then subscribe to both the zipped Observables.
try {
this.muse.enablePpg = true;
await this.muse.connect();
await this.muse.start();
await this.muse.deviceInfo();
zipSamples(this.muse.eegReadings).subscribe(console.log);
zipSamplesPpg(this.muse.ppgReadings).subscribe(console.log);
} catch (err) {
window.alert(err.toString());
this.connectionError.next('Connection failed: ' + err.toString());
} finally {
this.connecting.next(false);
}
I hope the issue is clear, it's quite hard to describe. I suspect a bug in the zipSamplesPpg, but I can't seem to figure out how to fix it.
What type of window does muse js use?
For example there are these windows
Window types:
boxcar
triang
blackman
hamming
hann
bartlett
flattop
parzen
bohman
blackmanharris
nuttall
barthann
kaiser (needs beta)
gaussian (needs standard deviation)
general_gaussian (needs power, width)
slepian (needs width)
dpss (needs normalized half-bandwidth)
chebwin (needs attenuation)
exponential (needs decay scale)
tukey (needs taper fraction)
Is there a function to evaluate if the 4 electrodes are well placed?
If there is not, how can we measure this?
Hey there, cool project! I was wondering if the source code for https://muse-eeg-app.firebaseapp.com/ was available somewhere? The demo app in this repo is much more bare-bones, thanks!
OS: Mac OS 10.14.5
Node: 12.4
I used the Node.js example:
const noble = require('noble');
const bluetooth = require('bleat').webbluetooth;
const { MUSE_SERVICE, MuseClient } = require('muse-js');
async function connect() {
let device = await bluetooth.requestDevice({
filters: [{ services: [MUSE_SERVICE] }]
});
const gatt = await device.gatt.connect();
const client = new MuseClient();
await client.connect(gatt);
await client.start();
// Now do whatever with muse client...
client.eventMarkers.subscribe((event) => {
console.log(event);
});
}
noble.on('stateChange', (state) => {
if (state === 'poweredOn') {
connect();
}
});
The headset is switched on. Are there any prerequisites:
I get the err after stating my index.js:
(node:29173) UnhandledPromiseRejectionWarning: requestDevice error: no devices found
(node:29173) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:29173) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
PS: I changed the package from xpc-connection
to xpc-connect
in noble because xpc-connection
was deprecated.
Hi,
Following your demo I was trying to connect my Muse device in my implementation.
I can see the I can connect to device as I can reach this line of code, also I get the message Connected to Device name: Muse-7144
and then Client Started!
which is here.
But after that I don't get any thing, I wear my device and I have tested it with other implementations like eeg-explorer and it works pretty good.
Not sure what is going wrong here.
Any help ??
In order to perform ERP experiments with Muse js, event markers corresponding to stimulus presentation onset will have to be added to the stream of EEG data with as much temporal accuracy as possible.
Emotiv includes this feature in their API: an injectMarker
function that allows you to add an event annotation included in EEG data stream based on a label and timestamp passed to it.
To make my app compatible with both devices I plan on adding this feature to muse-js over the next few weeks. Off the top of my head I think adding a new eventMarkers Observable that can be triggered imperatively with a Subject and then merged with the EEG data at some point should be able to do this
I've been noticing a high incidence of NaN values in some of the experimental data collected in the BrainWave app.
One of the most recent experiments collected on OSX has NaNs throughout the entire dataset.
NaNDataset.zip
I'll back when I get to the bottom of this. My suspicion is that this might be a web bluetooth specific issue
Hey, I'm trying to test this out on my linux machine. I'm using Fedora 25.
I'm not the best at debugging node/javascript tracebacks. :\
[jnaulty@emarginata muse-js]$ yarn --version
1.3.2
[jnaulty@emarginata muse-js]$ npm -v
3.10.10
[jnaulty@emarginata muse-js]$ node -v
v6.12.0
[jnaulty@emarginata muse-js]$ yarn start
yarn run v1.3.2
$ node demo/fuse
app ->
└── (6 files, 29.5 kB) default
demo/src/main.js
src/muse.js
src/lib/muse-interfaces.js
src/lib/muse-parse.js
src/lib/muse-utils.js
src/lib/zip-samples.js
└── [email protected] 1.8 kB (0 files)
└── [email protected] 2.9 kB (0 files)
└── [email protected] 9.8 kB (0 files)
└── [email protected] 171.6 kB (0 files)
Size: 215.5 kB in 139ms
---------------------------------------------------
Development server running http://localhost:4445
---------------------------------------------------
events.js:160
throw er; // Unhandled 'error' event
^
Error: watch /home/jnaulty/github/muse-js/node_modules/rxjs/operators/publishLast.js ENOSPC
at exports._errnoException (util.js:1020:11)
at FSWatcher.start (fs.js:1451:19)
at Object.fs.watch (fs.js:1478:11)
at createFsWatchInstance (/home/jnaulty/github/muse-js/node_modules/chokidar/lib/nodefs-handler.js:37:15)
at setFsWatchListener (/home/jnaulty/github/muse-js/node_modules/chokidar/lib/nodefs-handler.js:80:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/jnaulty/github/muse-js/node_modules/chokidar/lib/nodefs-handler.js:228:14)
at FSWatcher.NodeFsHandler._handleFile (/home/jnaulty/github/muse-js/node_modules/chokidar/lib/nodefs-handler.js:255:21)
at FSWatcher.<anonymous> (/home/jnaulty/github/muse-js/node_modules/chokidar/lib/nodefs-handler.js:473:21)
at FSReqWrap.oncomplete (fs.js:123:15)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[jnaulty@emarginata muse-js]$
Does muse-js support the new version of Muse (aka Muse 2)?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.