For this valentines day, my wife got me a MindFlex from Mattel. I have been wanting one of these since they have been on the market. It is a really interesting game where you control a foam ball with your mind. The ball will rise with the more focused you are. Letting your mind wonder and as Morphius likes to say “free your mind”, the ball will lower.
MindFlex doesn’t read your thoughts, rather it picks up on level of activity. There has been fuss about the legitimacy of how this thing works. The popular video of it being placed on a foam head with a damp cloth gives readings. If you would do the same with a medical grade EEG, you would receive random values.
MindFlex uses a NeuroSky chip to compute the brain data. You can have 8 channels of raw wave activity:
- Delta (1-3Hz): sleep
- Theta (4-7Hz): relaxed, meditative
- Low Alpha (8-9Hz): eyes closed, relaxed
- High Alpha (10-12Hz)
- Low Beta (13-17Hz): alert, focused
- High Beta (18-30Hz)
- Low Gamma (31-40Hz): multi-sensory processing
- High Gamma (41-50Hz)
Along with connection quality, and the proprietary attention and meditation values.
Inspired by Eric Mika’s post, I set out to replicate and extend his project. He wrote a library to get the data using an Arduino. He also wrote graphic software to aid in the visuals of the activity in your mind. Eric go’s into better detail about the data the chip gives off. He has a video about the hardware hack, and it is very informative.
Basically, you need a shared ground and a wire extending the Tx pin for the NeuroSky chip circuit. Using images from this teardown of the MindFlex I point out which pins they are. This is in the left pod of the headset:
I have affixed the Arduino to the headset using Velcro, opposed to zip ties. Also I have noticed it is better for the usb port to be facing the back of the head when you wear it. This keeps the cords away from your face. Here are some pictures of the finished mod:
After copying the BrainLibrary into the Arduinos lib, I loaded the BrainSerialOut example that came with the library, I immediately got python reading from the COM port. The data comes as a string containing 11 values: signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma.
When the signal strength is at 0 it is at its strongest. The next two values are the ones I am interested in. If the signal strength isn’t strong enough, you will not get the attention or meditative values.
The next step on my list was to make this data available to what ever can handle sockets like Blender, Android, Iphone, and I think Flash can even handle sockets.
I wrote a server in Python2.6 to forward the data to any connection. It takes the headset a few seconds to give good data. I have also noticed, the connection signal can be finicky.
import serial, sys, socket s = serial.Serial('COM8') sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind(('',1002)) while 1: sock.listen(5) conn, addr = sock.accept() while 1: try: sread = s.readline() conn.send(sread) except: print "connection at %s lost" % addr break
Next was to write a quick game using my new toy. I chose PyGame because it was easy to get going quickly. I plan to switch to 3d when I have the time for it. The game uses the attention value to light a match. There is also a bar on the left side representing the activity in the users mind. Future work includes snuffing the flame with meditative values.