Wednesday, October 15, 2014

Detecting Alpha Waves - Guard Bands

In my previous post, I discussed a simple algorithm for detecting Alpha rhythms: (1) use an FFT spectrum to measure the EEG amplitude in the Alpha band and (2) compare this value to a fixed detection threshold to decide if Alpha are present.  As shown in the figure below, this approach yields good detection sensitivity (it correctly flags 66% of the eyes-closed data blocks) and a reasonably low number false alarms (it incorrectly flags 15 data blocks).  While this is good, I think that I can do better.  Let's talk about how...

Example EEG data (top) showing Alpha rhythms when my eyes are closed.  At each time slice, I measure the peak of the spectrum in the Alpha band (7.5-11.5 Hz), which yields the blue trace on the bottom.  By looking for any value above 3.5 uVrms, we are able to detect the presence of Alpha waves (as indicated by the red circles)

Alpha Band Detection is Not Specific Enough:  In the simple Alpha band detection algorithm discussed above, we are sensitive to any signal with lots of energy in the Alpha (7.5-11.5 Hz) band.  The problem is that there are signals besides Alpha rhythms that have energy in the Alpha band.  For example, the bottom plot below shows the spectrum (black line) for a segment of eyes-closed Alpha waves.  The plot  also shows the spectrum (red line) for a segment of "other" activity that is no an Alpha rhythm (it is probably motion artifact from the EEG lead wires).  As can be seen, both spectra show substantial energy in the Alpha band, and so they would both be flagged as "Alpha!" using my simple threshold detection approach.  For the segment of "other" activity, this would be a false alarm.  I don't want that.  I want to improve my algorithm to reject this kind of false alarm.

Two spectra: (1) a segment of eyes-closed Alpha rhythm that I do want to detect and (2) a segment of "other" EEG activity that I do not want to detect.  Both, however, show a high amplitude in the Alpha band.  So, my original detection rule that is simply based on the Alpha amplitude would not reject the "other" activity.

Introduce "Guard" Bands:  One way of distinguishing between the two example spectra above is to introduce "guard" bands on either side of the Alpha band.  The idea is that we measure the signal amplitude both in the Alpha band and in the guard bands.  Based on the plots above, we know that true eyes-closed Alpha activity will not show much energy in the guard bands whereas the confusing "other" activity can be rejected because it does show energy in the guard bands.

If we measure the mean EEG amplitude in the guard bands, as well as in the Alpha band, we can distinguish between the two signals.  True Alpha rhythms will not have much energy in the guard bands whereas most of our confusing "other" activity will show substantial energy in the guard bands.

Evaluating the Guard Amplitude:  To quantify the amplitude in the guard bands, I simply take the average of all the spectrum values that fall within our two guard bands (3-6.5 Hz and 13-18 Hz).  When I apply do this for our EEG data, I get the green trace shown in the middle plot below.  As you can see, it stays low during all of the legitimate eyes-closed Alpha activity and it jumps high only during the confusing other activity.  This looks promising!

Combined Detection Rules:  Based on this graphs above of the guard amplitude (green line) and of the Alpha amplitude (blue line), it looks like a good combination of rules would be to look for points where the Alpha amplitude is greater than 3.5 uVrms and, simultaneously, where the guard amplitude is less than 2.5 uVrms.  When I apply these detection rules, I get the red circles shown in the figure above.  Looks pretty good!  You'll note that the addition of the guard band has successfully rejected the false alarms that we had been getting at t=58, t=77, and t=123.  This is exactly what I was hoping for.

Quantifying the Improvement:  Compared to yesterday's results (tabulated below), this new detection algorithm obtains nearly the same sensitivity (65% vs 66%) with a greatly reduced number of false alarms (2 vs 15).  This is definitely an improvement in my Alpha detecting algorithm.
Guard       N_TRUE      N_FALSE
None        101 (66%)   15
2.5 uVrms   100 (65%)   2

Moving Forward:  For this example EEG recording, I am satisfied with the performance of this algorithm.  It would give me quite reliable performance while still being nicely sensitive.  This EEG recording was pretty "clean", however -- its Alpha was pretty strong and there was not too much confusing "other" activity.  I have other EEG recordings that are more difficult.  Next time, we'll look at those harder recordings, you'll see that even the combined Alpha+Guard algorithm is insufficient, and I'll discuss yet another extension (hopefully an improvement!) on this detection approach.

Follow-Up:  I further optimize this algorithm by using ROC curves to attack, head-on, the trade-off between sensitivity and false alarms.  Check it out here.


  1. Just thought a shame there are no comments on such an amazing article. :D