From the beginning, I was excited to create my own version of a brain-computer interface (BCI) - see my initial ideas . I started off by creating a heart rate monitor with a digital interface as a proof of concept - see my Minimum Viable Product and bluetooth improvement. After succeeding, I worked with Kassia Love to custom-build an EEG BCI designed to detect electrical activity from the scalp, amplify and filter the signal, and stream data to a computer for visualization and analysis (see details here). We did this through modifying a heart rate monitor and detecting when eyes are open versus closed! See my video of inspiration below for my EEG:
void loop() {
if (pulseSensor.sawStartOfBeat()) {
int bpm = pulseSensor.getBeatsPerMinute();
Serial.println(bpm);
if (deviceConnected) {
char buffer[8];
sprintf(buffer, "%d", bpm);
pCharacteristic->setValue(buffer);
pCharacteristic->notify();
}
}
}
The first step is to properly wire up the circuit based on some initial instructions available here. It requires modifying a heart rate board, seen above, which joins and disrupts some connections. Then the EEG can compare between two electrodes, and be ready to record from the occipital lobe (where vision takes place on the back of the head), as seen in the diagram above. Then I soldered the wires to metal and sewed it to the headband. I was able to do some preliminary recordings which can be seen in the chart.
float rawMv = (float)vReal[SAMPLES - 1];
// --------- FFT + INSTANT BAND POWERS ---------
FFT.windowing(FFTWindow::Hamming, FFTDirection::Forward);
FFT.compute(FFTDirection::Forward);
FFT.complexToMagnitude();
deltaBP = bandPower(DELTA_LOW, DELTA_HIGH);
thetaBP = bandPower(THETA_LOW, THETA_HIGH);
alphaBP = bandPower(ALPHA_LOW, ALPHA_HIGH);
betaBP = bandPower(BETA_LOW, BETA_HIGH);
gammaBP = bandPower(GAMMA_LOW, GAMMA_HIGH);
I used the website/Kassia's code as a starting point. Once I got serial print to print signals working, I added bluetooth to the arduino so that the noise from the computer wouldn't interfere. I was able to get the bluetooth to connect to my website: arduino file to set up the serial print, python EEGserver.py in terminal to set up connection, and then using html go to the index. The website displayed the raw signal, which is easiest to see changes in, in addition to alpha/beta/delta/gamma/theta. Problems arised (trying to train a model to predict eyes open versus closed & very noisy data), but we were ultimately able to see small differences and record actual data! To run 1) upload arduino, 2) run python server, 3) double click index file to bring up website page.
Finally after getting a working version via bluetooth, I miniturized by soldering the heart rate monitor, lipobattery, and ESP32 on a protoboard. I sewed a small pouch onto the headband, in addition to sewing rivets and the wires to be hidden. This way, the headband connects via bluetooth with no additional bulky parts.
Thank you Nathan for your excellent teaching, Kassia for all your EEG help, Bobby for being a test subject and being available, the PS70 teaching staff for their dedication, and my classmates for inspiring me!