Connecting to an Electroencephalogram (EEG) Device:

MindWave

http://www.neurosky.com/

NeuroSky ThinkGear technology digitizes analog electrical brainwaves to power the user-interface of games, education and investigative applications. A hurdle lies in distinguishing brain signal from the noise that comes from ambient electricity, muscle movement, etc. Such interferences are digitally filtered and eliminated. Raw brain signals are amplified and processed —delivering concise input to the device. Algorithms come from both NeuroSky as well as research institutions and universities, and currently include “attention”, “meditation,” and physical eyeblinks.

The MindWave device can be purchased from online retailers for approximately $80. Before using the device some software utilities will have be installed on the local machine, such as the MindWave Manager, which pairs the headset with a USB receiver called a dongle.

Pairing

Pairing Success

In addition, an open source utility, BrainOSC, needs to be downloaded and installed that converts the output of the MindWave to OSC.
https://github.com/dlublin/BrainOSC

BrainOSC

Note that the IP address of the local machine needs to be used - localhost (127.0.0.1) does not seem to work if the machine is on a network. The port is set to the same port as specified in the Lingo code of the Adobe Director application that is receiving the OSC output. (In our demo we used port 3000).

Run the demo file OSCdecode.dir to inspect the data being sent by BrainOSC. There are 2 fields, "Last OSC Received" and "Full Trace". Note that the data is labeled.

OSCdecode

From this demo we were able to construct our own application, by parsing the bundle and creating global variables of index items in the list. This allowed us to display those values in separate fields, or use the values to manipulate onscreen elements or trigger events, like playing a sound. The demo, MindWave.dir, is on the lab's fileserver in the 323 Groups directory, in the novel interfaces folder.

Director demo

Here are the MindWave-specific data globals declared in the "Declare Globals" Lingo script:

global signal_quality
global contact
global attention
global meditation
global raw
global blink
global total_activity
global delta
global theta
global beta1
global beta2
global gamma1
global gamma2

Here is the parsing of the bundle in the on idle handler of the same script:

if (bundle.count = 16) then
signal_quality = bundle[2][2] & RETURN
contact = bundle[3][2] & RETURN
attention = bundle[4][2] & RETURN
meditation = bundle[5][2] & RETURN
raw = bundle[6][2] & RETURN
blink = bundle[7][2] & RETURN
total_activity = bundle[8][2] & RETURN
delta = bundle[9][2] & RETURN
theta = bundle[10][2] & RETURN
alpha1 = bundle[11][2] & RETURN
alpha2 = bundle[12][2] & RETURN
beta1 = bundle[13][2] & RETURN
beta2 = bundle[14][2] & RETURN
gamma1 = bundle[15][2] & RETURN
gamma2 = bundle[16][2] & RETURN
member("signal_quality").text = signal_quality
member("contact").text = contact
member("attention").text = attention
member("meditation").text = meditation
member("raw").text = raw
member("blink").text = blink
member("total_activity").text = total_activity
member("delta").text = delta
member("theta").text = theta
member("alpha1").text = alpha1
member("alpha2").text = alpha2
member("beta1").text = beta1
member("beta2").text = beta2
member("gamma1").text = gamma1
member("gamma2").text = gamma2
end if

This allows us to treat the values disceetly, to put them in separate fields, or to use the values to trigger events in the interface. Note that we check to see if the count of the items in the index equals 16 in a conditional statement, in case one of the values goes out of range, we loop back through the script until it is found again. If we don't do that the program will crash.

On a looping frame script we use the values to scale a sprite and to play a sound. The function value converts a string to a numerical value.

on exitFrame me
global attention
global blink

sprite(48).width = 200 * value(attention)
sprite(48).height = 200 * value(attention)


if (value(blink) > 0) then
puppetsound "Buzzer"
end if


go the frame
end

The demo file MindWave.dir and the supporting file BrainOSC are in Groups > 323 > Novel Inputs > MindWave on the file server.

Thanks to Ryan Walsh for assistance with this demo.