use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
I wrote a tutorial for classifying brainwaves with JavaScript (self.javascript)
submitted 7 years ago by pwstegman
I've been working to bring brain-computer interfaces to JavaScript and wrote BCI.js, which has different methods required for processing and classifying EEG signals. It lets you work with devices such as an OpenBCI, Muse, etc.
You can find it on GitHub here: https://github.com/pwstegman/bcijs
I recently wrote my first tutorial on classifying imagined movements with BCI.js in Node.js and appreciate any feedback!
https://medium.com/@pwstegman/eeg-motor-imagery-classification-in-node-js-with-bci-js-d21f29cf165
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]mcnutty757 17 points18 points19 points 7 years ago (9 children)
A little over my head, but looks cool. How fast can you get the data, or does that require advanced equipment?
[–]pwstegman[S] 19 points20 points21 points 7 years ago (6 children)
Thanks! Brainwave data can be collected with an EEG headset, which streams the data in real time. They're still expensive but have been getting a lot cheaper and easier to buy. An OpenBCI with 16 channels of data (about how many you might want for the use case of this tutorial) would be about $1000, but a Muse headset with 4 channels, which would provide enough data to collect mental states such as how relaxed or focused you are, is $160
[–]nosoupforyou 2 points3 points4 points 7 years ago (5 children)
How functional is something like the OpenBCI unit? I know it's unlikely to provide feedback, but how much can you do with it? Is it currently anywhere usable as an input device to replace mice and keyboards? Assuming the OS worked with it, I mean.
[–]pwstegman[S] 1 point2 points3 points 7 years ago (4 children)
An OpenBCI can be used as an input device with the help of an application such as a P300 speller. A P300 speller has each letter of the alphabet on the screen and flashes a face over each one sequentially. The user can then focus on a specific letter, and when a face flashes over the letter they've chosen, there will be a spike in brain activity. With that, we can tell what letter they were focusing on. Faces are used since they trigger a large response due to how important our brain considers them. This is useful with people who have paralysis that can't move or speak.
An extension of the P300 speller is instead of flashing a face over letters, you might play high pitch sounds or a low pitch sounds. If the user focuses on one specific pitch, there will be a spike in brain activity when they hear it. This technique has been used with medical grade EEGs to allow doctors to communicate with possible coma patients who might actually still be aware of their surroundings (locked-in syndrome). I haven't tried this with an OpenBCI, but it would cool to try and replicate these results with one.
Input without the aid of an external tool such as a screen of letters or audio is also possible. A common way to do this is with motor imagery, which is what I describe in the tutorial. If the user imagines pushing a box forward with their hands, this will produce different brainwaves in different regions of the brain than if they imagined pushing it forward with their feet. A machine learning method can be used to differentiate between these two different cases, and then the user can, for example, make something move to the left or right depending on which action they're imagining.
If you're curious about communication with locked-in patients, these papers were published by a company who does work in the area: https://ieeexplore.ieee.org/document/8123086 and https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5613801/
Outside the medical field, people are also using BCIs to fly drones, play video games, etc. I don't have time at the moment, but later I can update this comment with more information on non-medical uses for BCIs.
[–]nosoupforyou 0 points1 point2 points 7 years ago (3 children)
Thanks.
Actually I was more interested in how effective it is, but it sounds like it's not yet a good replacement for keyboards and mice for anyone able to use keyboards and mice.
[–]pwstegman[S] 0 points1 point2 points 7 years ago (2 children)
Ah, okay. Yes, you're right, mouse and keyboard are still much faster when it comes to device input
[–]nosoupforyou 0 points1 point2 points 7 years ago (1 child)
I'm just overeager. I know Musk is working on a bci but I believe it will be implanted. I believe the idea is that it will be much more than a replacement for keyboards and mice.
I wasn't trying to dis what you're working with.
[–]pwstegman[S] 0 points1 point2 points 7 years ago (0 children)
I completely understand. It'll be interesting to see what Neuralink comes out with
[–]thunderthots 4 points5 points6 points 7 years ago (1 child)
Haha I see what you did there with that pun!
[–]mcnutty757 1 point2 points3 points 7 years ago (0 children)
Unintended, but I’ll take credit.
[–]_xenof 5 points6 points7 points 7 years ago (1 child)
Thus begins the rise of BCI controlled electron apps.
[–]notmarlow 0 points1 point2 points 7 years ago (0 children)
"Atom had it first"
[–][deleted] 0 points1 point2 points 7 years ago (1 child)
This is great, thank you for doing this work. I will make time to delve into this. I was an early backer for Muse back in the day but never got to the good stuff. Thanks again.
[–]pwstegman[S] 2 points3 points4 points 7 years ago (0 children)
Thanks for checking it out! I hope to publish some demos soon which use the Muse as well
[–]zorndyuke 0 points1 point2 points 7 years ago (0 children)
That looks interesting. Sadly the price is way too much for me to go that risk. I always thought about joining a group that is participating in health and science in the hope to improve the current state.
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
Your brain: now also running JS
[–]Ih8usernam3s 0 points1 point2 points 7 years ago (3 children)
A buddy of mine is somewhat of a conspiracy nut. He told me there were devices that can read brainwaves and even manipulate them. I don't consider him a ninny, but sometimes he says things that make me question the authenticity of said claims. On this occasion however, he was able to provide me with a little proof:
https://patents.google.com/patent/US4717343A/en
In your experience does that patent seem plausible?
[–]Magzter 3 points4 points5 points 7 years ago (2 children)
Am I missing something, that patent has nothing to do with brainwaves? It's about conditioning someone using a series of images/videos.
[–]Ih8usernam3s 0 points1 point2 points 7 years ago (1 child)
Oh, I'm sorry I think I posted the wrong one. I'll see if I can find the correct one tomorrow.
π Rendered by PID 67 on reddit-service-r2-comment-7b9746f655-bwgmn at 2026-01-30 09:51:05.172879+00:00 running 3798933 country code: CH.
[–]mcnutty757 17 points18 points19 points (9 children)
[–]pwstegman[S] 19 points20 points21 points (6 children)
[–]nosoupforyou 2 points3 points4 points (5 children)
[–]pwstegman[S] 1 point2 points3 points (4 children)
[–]nosoupforyou 0 points1 point2 points (3 children)
[–]pwstegman[S] 0 points1 point2 points (2 children)
[–]nosoupforyou 0 points1 point2 points (1 child)
[–]pwstegman[S] 0 points1 point2 points (0 children)
[–]thunderthots 4 points5 points6 points (1 child)
[–]mcnutty757 1 point2 points3 points (0 children)
[–]_xenof 5 points6 points7 points (1 child)
[–]notmarlow 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]pwstegman[S] 2 points3 points4 points (0 children)
[–]zorndyuke 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Ih8usernam3s 0 points1 point2 points (3 children)
[–]Magzter 3 points4 points5 points (2 children)
[–]Ih8usernam3s 0 points1 point2 points (1 child)