Added configuration options to auto trigger a USB relay to turn on a tACS (Transcranial Alternating Current Stimulation) device when eye movements are detected. Works with the Yocto-LatchedRelay for now, will add more relays or tACS devices by request. The text box lets you select the target device, “ANY” should work if you only have one. The first drop down list is the state it will change the relay to during REM, and the second drop down list is the state it will change the relay to when REM ends.
Also added a new channel, NZT-48, that will play a video when the Beta channel is above the threshold and pause it when it is below. The algorithm needs to be set to Beta for this to work and the text box needs to point to a video file on your computer. This one works for me: Burn E, and it helps the kids pay attention.
Hi
I am a student and I have a project for the Science of the Engineer section.
In this project i use Arduino for receiving data from the headset Mindwave.
Here is my problem:
I’d use the attention and eye blinking signals to control a servo motor but I can not get this data!
Thank you for your help !
Can you access the raw EEG data? If it spikes; it is probably a blink. What code are you using to receive the attention data?
thanx for reply 🙂
no, i cant accces raw EEG data !
i’m using that code :
///////////////////////////////////////////////////////////////
// Arduino Bluetooth Interface with Mindwave
////////////////////////////////////////////////////////////////////////
#include // library for software serial
SoftwareSerial mySerial(5, 6); // RX, TX
int LED = 8; // yellow one
int LED1 = 7; //white one
int BAUDRATE = 57600;
// checksum variables
byte payloadChecksum = 0;
byte CalculatedChecksum;
byte checksum = 0; //data type byte stores an 8-bit unsigned number, from 0 to 255
int payloadLength = 0;
byte payloadData[64] = {0};
byte poorQuality = 0;
byte attention = 0;
byte meditation = 0;
// system variables
long lastReceivedPacket = 0;
boolean bigPacket = false;
boolean brainwave = false;
void setup() {
pinMode(LED, OUTPUT);
pinMode(LED1, OUTPUT);
digitalWrite(LED, HIGH); // hello sequence
delay(100);
digitalWrite(LED, LOW);
delay(100);
Serial.begin(57600); // Bluetooth
delay(500);
mySerial.begin(4800); // software serial
delay(500);
mySerial.print(“Communicating… “);
mySerial.println();
}
byte ReadOneByte() {
int ByteRead;
// Wait until there is data
while(!Serial.available());
//Get the number of bytes (characters) available for reading from the serial port.
//This is data that’s already arrived and stored in the serial receive buffer (which holds 64 bytes)
ByteRead = Serial.read();
return ByteRead; // read incoming serial data
}
unsigned int delta_wave = 0;
unsigned int theta_wave = 0;
unsigned int low_alpha_wave = 0;
unsigned int high_alpha_wave = 0;
unsigned int low_beta_wave = 0;
unsigned int high_beta_wave = 0;
unsigned int low_gamma_wave = 0;
unsigned int mid_gamma_wave = 0;
void read_waves(int i) {
delta_wave = read_3byte_int(i);
i+=3;
theta_wave = read_3byte_int(i);
i+=3;
low_alpha_wave = read_3byte_int(i);
i+=3;
high_alpha_wave = read_3byte_int(i);
i+=3;
low_beta_wave = read_3byte_int(i);
i+=3;
high_beta_wave = read_3byte_int(i);
i+=3;
low_gamma_wave = read_3byte_int(i);
i+=3;
mid_gamma_wave = read_3byte_int(i);
}
int read_3byte_int(int i) {
return ((payloadData[i] << 16) + (payloadData[i+1] < 169) //Payload length can not be greater than 169
return;
payloadChecksum = 0;
for(int i = 0; i < payloadLength; i++) { //loop until payload length is complete
payloadData[i] = ReadOneByte(); //Read payload
payloadChecksum += payloadData[i];
}
checksum = ReadOneByte(); //Read checksum byte from stream
payloadChecksum = 255 – payloadChecksum; //Take one’s compliment of generated checksum
if(checksum == payloadChecksum) {
poorQuality = 200;
attention = 0;
meditation = 0;
}
brainwave = false;
for(int i = 0; i 0 && attention 40){
digitalWrite(LED1, HIGH);
}
else
digitalWrite(LED1, LOW);
}
}
}
Hi,
Could you also add a configuration options to activate the digital output 1 of an arduino for an adjustable time (1 to 10 minutes) upon REM blink detection?
http://playground.arduino.cc/Interfacing/CPPWindows
PS : I am still experimenting around with my arduino, while waiting for the Yocto to ship…Thanks
https://github.com/todbot/arduino-serial
This is the snapshot of the trigger waveform once REM hits the target value, the 40Hz kicks in
Elite. What tACS device did you use for that recording? And did you feel more self-aware!?
Select sinusoidal wave at less than 1mA
http://www.gtec.at/Products/Hardware-and-Accessories/g.Estim-Specs-Features
but I think this works too…but the waveform is biphasic symmetrical square not sinusoidal
http://www.jacesystems.com/products/electrotherapy_tristim.htm
Both are medical devices and have a built in current limit feature and complete electrical isolation from the mains….
The top of the line tacs that worked in the study was
http://www.neuroconn.de/dc-stimulator_plus_en/
Thanks for the links… still reading the specs on the arduino. I could always just send a mouse click if you leave the mouse over the Start button on the Estim program if all else fails.
May I ask how much they cost and if it is possible for someone who is not a medical professional to get one?
You could try the Jace stim, it gives a fixed 2mA dose with a symmetrical biphasic AC waveform
http://www.amazon.com/JACE-TriStim-Tri-Stim/dp/B007G4TVCG
You could also try used medical equipment off amazon or ebay
I also got a Zeo headband for better REM detection and a Basis B1 to check if the Neurosky REM algorithm matched. The Basis REM is most accurate.
Click to access Validation-of-Basis-Science-Advanced-Sleep-Analysis.pdf
Will need your help to configure an REM trigger for the Zeo LSD plugin
Thanks!
Thanks! Can you get me some logs from the Zeo plugin, then I can work on the trigger there…
http://www.sleepstreamonline.com/rdl/api.html
Select
ZeoRawData.Utility.sleepStages 0x02 : ‘REM’Rapid eye movement(possibly dreaming)
http://www.sleepstreamonline.com/rdl/starting.html
Thanks. This is the only printout I have seen from the Zeo plugin (I don’t have one myself):

It looks like it should chart the Stage channel. I wonder if the LSD file logs 2 as the sleep stage during REM? You probably won’t be able to see it in the printout on the thousand scale. But it might be in the LSD file. Then all I would need to do is add a Zeo REM channel that triggers the tACS when the Stage channel is on 2?
Do you have logs of the Zeo and NeuroSky comparison? That would be invaluable for me to improve the algorithm!
Exactly! The REM detection algorithm is already built into the Zeo unit and it outputs a “2” on the stage channel when the unit detects REM. My Zeo unit will be delivered in 2 days and will send you the logs comparing neurosky, zeo and basis timelines on REM detection
Will keep you posted
http://www.fisherwallace.ca/collections/all/products/fisher-wallace-electrode-headset
http://stores.amrexusa.com/flextrode-electrodes-fg-02-f/
These electrodes work well with the stim unit
Pro tip: if you right-click on that graph, you can add a note with “Triggered tACS 40Hz” at 18:39:36.
Sure… I will add a configuration option for the arduino COM port and the length of time to send a message to it… defaulted to “1”. Then when it plays the audio track, it will also send “1” to the arduino, or whatever has been configured. Do I send the message to the COM port every second for 1 to 10 minutes?
http://arduino.cc/en/Reference/DigitalWrite
I suppose the digitalWrite(tacs Pin, HIGH); is a loop when REM is triggered
Something from the example :
this waveform should result http://imgur.com/ymRWqpq
Thanks
Thanks! That helped. I have a rough draft ready for testing – let me know where it errors out: ThinkGear EEG 1.1.1!1
I noticed that when the tacs is triggered, the 40Hz signal messes up the Neurosky signal, so the REM value from the gear cannot be used anymore to turn off the tacs. Ideally, the tacs activation should turn off after the set time (1-10 minutes) and allow the Neurosky signal returns to normal, and get ready to trigger again upon the next REM detection in the sleep cycle