If you want to connect to the NeuroSky ThinkGear API -- what they call the ThinkGear Socket Protocol -- this code shows you how to do it, at least in Scala. It consists of a few pieces of code I pulled from this GitHub repo. I wrote this code to help debug a problem I was seeing with the data.
The RawReader class does all the work. It opens a socket on the right port, then sends the necessary JSON to that socket to get things started. After that I just read the raw data that the API writes to the socket.
This is the fifth in a series of tests using the NeuroSky MindWave headset, their ThinkGear software, and my own custom software to record brainwaves over time, and graph them. I intentionally tried to focus/concentrate very hard at the beginning of this test, and then transitioned into meditation. I continued to meditate throughout the session, but according to their software/hardware, I tailed off at the end. In my opinion, this is a problem with their hardware -- it becomes less accurate as you use the system longer.
The premise is this: You put on a MindWave headset, start the recorder, and then do whatever you want to do -- work, meditate, sleep, whatever -- and the recorder records your brainwaves while you do those things. It writes the data in a CSV format so you can graph it, or do anything else you want with it.
After hearing about ShadajL’s presentation at Scala Days 2013 using a MindWave headset, I decided to buy a headset to see how if it really works. After a little while I got the hang of using the headset, so I decided to try ShadajL’s NeuroSky Scala library (named neuro-thinkgear) to see how it works as well.
I ordered one of these Brainwave Starter Kits today. It includes something called a MindWave Mobile device, which is supposed to provide some brainwave biofeedback. I did this out of curiosity after learning that a young developer created a Scala game that he can play with biofeedback.
I woke up this morning thinking it must be about 200 days to Christmas. Foregoing any easier ways to determine that, I decided it would be a good time to use the nscala-time library, a Scala wrapper around Joda Time.
Sticking with the time theme, I haven’t much free time today, so without further ado, here is some Scala code that determines the number of days between today and Christmas: