Backyard Brains Logo

Neuroscience for Everyone!

+1 (855) GET-SPIKES (855-438-7745)

items ()

[Summer’16 Internship] Arduino, EEG, and Free Will: First steps

Many EEG experiments are done using 21 electrode helmets to gain better localization resolution. In our case, this will not be necessary. Since the secondary motor area generates the readiness potential, the strongest RP signal is found immediately over that region, contralateral to the side of the body performing the task. In our case, the right hand is used, so our two electrode EEG headband will be positioned over C3 and Cz, according to the 10-20 chart.

The RP has an amplitude of 1/10th that of an alpha wave, so there will be no way for a human to look at a recording and see the RP building before a wrist flex. We’re hunting for a tiny signal in a lot of noise, so the RP will only be visible after a ton of averaging.

I’ve got the device built: It’s just an Arduino with the Backyard Brains Heart/Brain Shield and the Muscle Shield stacked on top. Analog data from both shields is converted to digital by the Arduino and sent to the computer by USB, where I’m using the free Backyard Brains Spike Recorder software to visualize and record both channels. There are a lot of issues with RF noise, so I’ve had to look around for a good location away from fluorescent lights and power cables. Perhaps an anti-static wristband would be useful.

I’m using MATLAB to process the recording, recognize the muscle spikes, and average the EEG signals before and after the onset of the action. This is the tricky part for me, since I have very little experience programming in MATLAB.

Debugging and free coffee

Initial results from my first test were… underwhelming. There were a ton of artifacts in the signal. Among these were EOG (electrooculography) and static discharge.

The eye is a dipole, with the cornea being positive and the retina negative. Electric fields caused by movement of this dipole can result in huge artifacts in scalp potential recordings. There are a few ways to control for this. The first option is to manually remove individual trials that are polluted by EOG movement. The second way is to place additional electrodes around the orbital bone and record two channels of EOG movements while also recording EEG on the scalp. Then we would use some algorithm to subtract EOG movement artifacts from the EEG signal afterwards. Alternatively, I could instruct the subjects to fixate their eyes on a certain point. The issue with this method is it requires the subject to put extra attention on maintaining their eye position, which is a bad confounding factor if our experiment has to do with conscious decision making. The best low-tech solution to this issue is… to have subjects close their eyes. It’s not perfect, as the eyes tend to slowly drift when the eyelids are closed, but the reduction in movement is good enough for these purposes. Also alpha waves tend to pollute the signal when the subject’s eyes are closed, so my solution to that is to offer subjects free coffee. Caffeine is a known suppressor of alpha wave production, and plus it entices people to volunteer to participate in the study.

The issue of static is harder to deal with. Wearing an anti-static cuff only gets you so far. Putting down an anti static mat also helps a bit, but there’s still a fair deal of DC drift in the signal. Part of me is convinced EEG has a fairly significant voodoo component to it….

By Patrick Glover

BYB’s Odd Consciousness Detector

Welcome! This is Kylie Smith, a Michigan State University undergraduate writing to you from a basement in Ann Arbor. I am studying behavioral neuroscience and cognition at MSU and have been fortunate enough to have landed an internship with the one and only Backyard Brains for the summer. I am working on The Consciousness Detector – an effort to bring neuroscience equipment to the DIY realm in a way that allows us to learn about EEGs, attention, and consciousness. It is my mission to create an oddball task that elicits the P300 signal in such a way that can be detected on BYB’s EEG machine. Let me break it down:

An oddball task is an attentional exercise in which a participant sees or listens to a series of repeating stimuli. These stimuli are infrequently interrupted by a novel stimulus called the oddball stimulus. The participant is asked to count or press a button for each oddball stimulus that is seen. Named so for its positive change in voltage occurring around 300 ms after the appearance of the oddball, the P300 can be seen when the participant is attending to the stimuli and the oddball they had been waiting for arrives.  This signal can be detected by an electroencephalogram, or EEG. EEGs use a series of small, flat discs, called electrodes, in contact with the scalp to detect changes in voltage through the skull. The EEG detects the changes in the electrical activity of neurons and transmits the detected signals to a polygraph to be analyzed. Outside of my project, EEGs can be used to help diagnose certain neurological disorders and help pinpoint locations of activity during seizures.

So why is this project worthwhile? Consistent with BYB’s mission statement, we want to bring neuroscience to everyone. Your average neuroscientist spends years learning the mechanisms behind brain funtion in order to use this knowledge practically. Then the equipment must be conquered – it is often complicated and lots of time is dedicated to mastery. By hacking their own EEG and producing it from basic electronic components, BYB is able to bring this machinery to you – and that is an incredible thing. Learning the principles behind EEG recording and how to use such a machine is something that few have the opportunity to do – and now you can do it in your living room! The idea behind The Consciousness Detector is used in the medical field. Patients with severe brain damage can be given an auditory oddball task to objectively predict recovery of consciousness through the P300 that is or is not present (If interested, please see: Cavinato et al. (2010) Event-related brain potential modulation in patients with severe brain damage). We are bringing medical techniques used to predict prognosis to you. Yay!

brain hat (3)

The current BYB EEG headband is being employed to record from the parietal lobe, as this is where the P300 is detected the strongest. A better apparatus for holding electrodes in place will most likely be introduced down the line. I have high hopes to pop some rivets into a home-made brain hat and begin an EEG cap trend. For now, this is what I’m working with:

BYB arduino (3)

Backyard Brain’s EEG system uses two active electrodes, the electrodes recording activity, and a ground to eliminate noise common to the head. I have attempted to begin as simply as possible to determine what kind of oddball task is required to elicit the P300. The arduino shield produced by BYB has  a series of LEDs, shown in the picture to the right, that I have used in my first version of the task. We coded the LEDs to flash in a random sequence with the oddball stimulus flashing 10% of the time, as a smaller probability of seeing the oddball predicts a larger amplitude and more easily detectable P300. The standard and oddball LEDs were assigned to corresponding digital outputs on the arduino and were wired into the analog input so that each flash could be detected on the Spike Recorder app. In the picture below, the green signals represent the standard LED flash and the red represents the oddball LED. Using this method, we can see what occurs 300 ms after the oddball LED is flashed. To ensure that attention is required to detect the oddball, we began by using one green LED as the standard stimulus and the other green LED as the oddball flashing 10% of the time. After getting no response in that department we tried other colored LEDs as the oddball, thinking that two green LEDs may be too similar since the oddball stimulus is intended to be more novel than the standard. No P300 was observed there, either.

example recording (3)

We have written another oddball task using LEDs in which the LEDs randomly flash two at a time. The task of EEG-wearer is to count how often symmetric stimulation occurs across the LED midline. This task gives a more novel oddball and hopefully an easily detectable P300! More oddball options are in the works, including small images for a visual oddball and auditory tasks as well! Stay tuned 🙂

kylie setup 1 (2)


Mind Control. With Lasers.

Coming soon to a backyard near you.

At least, that’s the idea. We’re sure the technology will catch up if we give it enough prodding and throw an intern or two its way. And hey if not? There’s still lasers, sounds like a win/win to me. Wait we don’t get lasers either? This is really going downhill fast. Apparently the higher ups don’t think beams of focused high energy photons wantonly sprayed at the brains of schoolchildren is good science.


I don’t see why anyone would have a problem with this

Ok you know what, how about beams of somewhat lower energy photons, and brains of something whose parents won’t send us more angry letters after little Johnny tattletale has another run in with the burn ward. How about LEDs and a bug? Well then.

Mind control.

Coming soon to a backyard near you.

And it is. Technically. So long as the mind you want to control is our tough lil buddy Drosophila Melanogaster AKA the fruit fly. And so long as the nefarious deeds you want your insatiable army of insect minions to thoughtlessly carry out is…sticking out their tongue. THEN YES. We’ve got mind control.


It’s called optogenetics, and it’s pretty crazy stuff, really. Long story short, we can stick a gene into the fruit flies that makes certain neurons, say, the sweet taste receptor Gr5a, sensitive to certain wavelengths of light-in this case, red light, because it is capable of passing through their exoskeleton into the neurons beneath. That way, if you set the little guys in front of an LED and blast away, they think the Kool Aid man just suplexed their face. And what is a fruit fly’s reaction to opening the floodgates of sugary heaven? They stick out their tongue.

It turns out you can rig up an LED with a microcontroller so that when two wires from the circuit come in contact with the fly, it completes the circuit, treating the fly as a resistor, and activates the LED. This lets us time contact with the fly to when the fly receives light (and therefore sweet-tasting) stimulation.

If that was a little hard to see, here’s an up close and personal version of the events.

And of course, nothing is truly scientific until we’ve mechanized it

It might sound trivial, but there’s actually a lot to getting a response like this without any invasive action other than light stimulation. Optogenetics really opens a lot of possibilites up for experimentation that just weren’t feasible before. It took the world of neuroscience by storm just a few years ago and is on the short list for the Nobel Prize, and we‘ve got a crack team of top scientists working to bring this technology to your own backyard.

Ok, slight exaggeration again, maybe, they’re actually interns working on it. Well, an intern. But we’ve stuck him in our basement with a steady supply of mountain dew and cheetos, and if that’s not science, I don’t know what is.



I’ve just been told that in fact its not actually science. According to them, “good science” involves some sort of method, and numbers, and repeatable experimentation. Apparently blood, sweat and cheeto dust just aren’t enough for some people. We’ll have the intern fill you in on the details.