Access raw EEG data from Mindwave Mobile
I ordered a Mindwave mobile from Amazon instead of Neurosky because I already have an Amazon Prime account and it would be much easier to return to Amazon if I don't like it. The device arrived in two days as expected. Have been playing with it for a few days, now I can read the raw EEG data at 512 samples/sec and observe how my brainwave changes when I blink my eyes. Below is a screen snap shot of the raw EEG data with two eye blinks, a partial one in the beginning, and another one in the middle. The home brew program will keep rolling the real time plot to the left as new data arrives.
Overall the Neurosky Mindwave Mobile is reasonable and price is ok. But I find the device a bit challenge to wear. Not only it interferes with my glasses, but also my ear lobe hurts in just a few minutes. Will have to address these later. During the exercise, there are quite a few things need to be ironed out. This blog is essentially the lab log. Shall it be called lablog, or la-blog?
Overall the Neurosky Mindwave Mobile is reasonable and price is ok. But I find the device a bit challenge to wear. Not only it interferes with my glasses, but also my ear lobe hurts in just a few minutes. Will have to address these later. During the exercise, there are quite a few things need to be ironed out. This blog is essentially the lab log. Shall it be called lablog, or la-blog?
Details
C-compiler
First signed up as a Mac developer for free. This is required to get the developer tools. Installed Xcode (Ver 5.0) and its command line tools from Apple. The Xcode package is about 1.5GB and took a while to download.
After install these, the following is needed if you want to compile the code in old fashioned command line. I put them in ~/.bash_profile.
DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer/"
export DEVELOPER_DIR
After install these, the following is needed if you want to compile the code in old fashioned command line. I put them in ~/.bash_profile.
DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer/"
export DEVELOPER_DIR
Plotting Tool
One thing to note here is that aqtClosePlot used in the demo code will clear all color map, as well as create unnecessary flashes during multiple rendering. To work around that, aqtEraseRect was used, which works fine and smoothly.
Read Ones Mind
A few things to note:
- On my Mac, the Bluetooth slave is mounted at /dev/tty.MindWaveMobile-DevA
This is different from the document. - The idea of "bundle" is new to me. And the Neurosky documents are for older Xcode. It took me a while to figure out how to add the "CoreFoundation Framework". In Xcode 5, this can be done at "TARGETS" of the project, under "Build Phases" tab, in the "Link Binary with Library" group.
- The Neurosky ThinkGear bundle is 32-b, need to change the compiler option. In Xcode, this is under "build settings" tab, "Architecture" group.
Put Things Together
The rolling EEG plot came smoothly after the above two. The Mindwave reader output the raw EEG data to stdout, and the other info to stderr. This is piped to the EEG viewer, which plots the data. Of course, a few tweaking are required.
- The raw EEG data rate was is only ~50 points per second, not the stated 512 samples/sec. After a few poking, one has to change the -1 parameter to +1
- numPackets = TG_ReadPackets(connectionID, 1);