Wednesday, November 6, 2013

Waveforms from Homemade Electrodes

As follow-up to my surprisingly popular post on my homemade electrodes, ERPOLOGY asked to see the EEG traces.  Well, since making graphs is one of my most favorite things to do (NERD ALERT!), I'm happy to oblige.

First, as a reminder of what I did, I built some EEG electrodes out of really cheap materials.  To see how well they worked, I stuck them to my head using Ten20 conductive paste in locations approximating Cz (top of head) and C3 (side of head).  The spectrogram above shows the data that I recorded.  As you can see, the test contains several test conditions:
  1. Closed Eyes (to see Alpha Waves)
  2. Open Eyes and Relaxed (to see Mu Waves)
  3. Open Eyes While Moving Hand (to suppress my Mu Waves)
Time-Domain Plots

OK, now let's make the new plots.  First, I've chosen short excerpts from each of the three periods.  I've plotted them below.  Note that these plots are zoomed way in so that you can count the period of the Alpha waves and of the Mu waves.

First, below, I show a trace from when my eyes were closed and I was generating Alpha Waves due to my Posterior Dominant Rhythm (PDR).  Remember, my electrodes were not on the back of my head -- they were on the side of my head.  So the PDR Alpha waves are not as pure looking as you might expect.  If you count the peaks, though, you'll see that there are about 9-10 cycles per second (ie, 9-10 Hz), which is what we saw in the spectrogram at the top.

Next, below, I show a trace from when my eyes were open and I was trying very hard to be relaxed (an oxymoron).  I was successful in generating some Mu waves.  They're shown below.  If you could the peaks, you'll get 10-12 waves per second (depending on how you count).  Based on the spectrogram, the frequency of my Mu waves is a little bit higher than my PDR Alpha waves.  This is probably confirmed by the peak-counting in the plot below.

The last time-domain plot, below, is for when I open and close my hand.  This should suppress my Mu waves.  In the spectrogram, they do appear to be absent.  In the plot below, they appear to be absent as well.  Good.

Frequency-Domain Plot

Before we finish, let's go back to the frequency domain...but let's plot a regular spectrum and not a spectrogram.  While the spectrogram is great for getting a sense of what is happening throughout the test, it is not the best tool for being quantitative.  Sometimes a simple spectrum plot is better.  

For the spectrum plot below, I took a long sample of each activity (10s of seconds, several thousand data points), I performed a series of 512-point FFTs and I averaged the FFT results together to get a nice, smooth spectrum for each condition.  By plotting the averaged spectrum for each condition all on the same graph, I can quantify the differences between the three conditions.  Here are the results:

As you can see, the Alpha waves were definitely at a lower frequency (9.3-9.8 Hz using my data reading cursor) than my Mu waves (11.7 Hz).  As I mentioned during the discussion of the time-domain plots, the spectrogram showed this fairly well.  But, a basic spectrum plot like this one makes it much easier to see and quantify the difference between the two.

Also, this graph implies that the Mu waves were about half the amplitude of the Alpha waves.  While it is true that Alpha are clearer in the spectrogram, which suggests that the Alpha were stronger, the primary reason that the Alpha were clearer is because I was able to sustain the Alpha waves more steadily than the Mu waves.  Detailed examination of the data shows that my Mu waves came and went every few seconds.  Therefore, in the averaged FFT plot, the apparent amplitude of the Mu waves will appear to be smaller simply because it includes all those short periods where the Mu waves temporarily went away.  That's a risk with using a heavily-averaged spectrum plot.  You gotta know your tool.

Finally, this spectrum plot nicely shows how clenching my hand (the red trace) suppresses the Mu waves completely.  Again, that was clear in the spectrogram, but this plot shows it very nicely as well.


With this extra detailed view of the data, you can start to see how you could design a signal processing chain to detect Mu waves.  Looking at the frequency plot, it is clear that you would need a really tight filter...maybe about 1 Hz wide.  For me, the filter would need to be centered on 11.7 Hz.  You might have your own special frequency.  Finally, because this plot shows that the energy in my PDR Alpha overlap with my Mu, you might want to sense the frequencies on either side of your Mu waves.  If there is energy on either side of Mu, then it's likely that the energy inside your Mu frequency band is from something else...such as PDR Alpha.

Without a graph like this, designing the signal processing would be much harder.  With this graph, I get all sorts of ideas.  This is why I like graphs so much...they can give quick insight into complex data.

If you've made it this far...thanks for reading!  You're awesome!

Follow-Up: Want to see my data from this experiment?  Check out my github!


  1. I have to ask. Do you use a certain software to make these graphs? Or do you write miniature software to handle the files and create the visuals?

    1. For these plots, I used Matlab to do the analysis. More recently, I've switched to doing my analysis and plotting in Matlab. In either case, I've shared some of my data and analysis routines on my GitHub:

  2. Have you done any classification based upon the tasks, if yes, how the feature extraction analysis is done? have you taken all trials into consideration and used specific algorithm for feature extraction or you have used algorithm on each trial separately ? Would be greatly appreciated if you would clear my confusion

    1. I have done no automated classification of Mu waves vs Alpha waves. I have only done this qualitative examination in the frequency and time-frequency domains. Sorry.