Showing posts with label Concentration. Show all posts
Showing posts with label Concentration. Show all posts

Tuesday, April 29, 2014

Concentration - Birds Beat the Internet

Now I'm getting serious.  In my last post, I finally saw for myself what "concentration" looks like in my EEG signals.  And now I'm totally hooked.  Now I want to expand my goals.  How?  Well, let's see how my concentration varies during natural activities, not just during my synthetic concentration exercise.  Where to start?  Well, how about at breakfast?  For me, breakfast includes some eating, some Internet, some bird watching...good stuff!  I hoped that my new EEG metric for "concentration" might reveal some interesting trends about my brain while breakfasting.  And, as you'll see, I was not disappointed...

Today's Breakfast Attire...Electrodes on the Forehead and Ear Lobes.

Goal:  My goal was to record some EEG signals to see how my concentration varies with different natural activities.  Today, I recorded EEG while breakfasting.

Setup:  My setup for recording my EEG was similar to the previous post -- a gold electrode on the forehead, a gold electrode on my left ear lobe as reference, and a ear clip electrode on my right ear as bias.  Today, I also added a second gold electrode to my forehead (Chan 1 is my left, Chan 2 is might right).  The picture above shows their locations.  To keep the wires out of my face (important for eating), I looped the electrode wires over my ears.  I connected the electrodes to my OpenBCI V2 board (shown below) and recorded the data using my GUI in Processing.  My electrode impedances measured about 20 kOhm.

My Usual Connection to my OpenBCI Board.  Confusingly, my electrode breakout
is mislabeled..."SRB1" is actually SRB2.

Procedure:  Since I wanted to record natural activities, I did not define a rigid test procedure prior to the test.  Without a scripted procedure, it's really tough to know what you did (and exactly *when* you did it) during a long test such as this.  To address this problem, I setup my camera to record a video of the whole test.  That video is my "truth".  In the movie (some example frames are below), I saw that I spent some time setting up the electrodes, some time eating my food, some time on the Internet (reading and writing), some time gazing out the window at the birds (my favorite part), and some time doing more work on the Internet.  Finally, at the end, I did my regular EEG concentration test -- counting backwards by 3 from 100.  I've got all this as one long EEG record.

I used my camera to record a movie of me eating breakfast.  I used this
as a record of "truth" to see what activity caused what EEG signal.

Data, The Quick Overview:  The EEG spectrogram below is the whole data record as seen my the electrode on the left side of my forehead.  As you can see, there's a block of activity at the beginning (up to 240-300 sec).  This is what was recorded while I was attaching the electrodes to my head.  After that, there's a block of activity from 300-650 sec with some really crazy signals, followed by a long block with more typical EEG signals.  What was happening during that crazy time?

The Complete EEG Record During Breakfast.  Chewing is clearly a very
intense signal that masks all true EEG activity.

Chewing Destroys EEG Signals:  By aligning the EEG data with the movie, it is clear that this period from 300-650 seconds is when I was eating my breakfast.  That morning, breakfast was some wheat Chex and grapefruit juice.  Pretty exciting?  No?  Well, the EEG signals sure are exciting.  See all that strong broadband red activity?  That's the effect that chewing has on EEG.  Dramatic!  I don't know if the cause is muscle artifact or if it is the jiggling of the electrode wires (or both), but the signals are huge!  If you zoom in (not shown), you can see each individual chew.  So, if you wanted a "CCI" (a Chew-Computer Interface) in addition to a "BCI" (Brain-Computer Interface), an EEG system would be a great way to do it.  But, if you wanted to see brainwaves while eating (like I was hoping to see), the act of chewing will basically destroy your data.

The Rest of My Data:  After eating, I still had another 20 minutes (1200 sec) of EEG data, so it wasn't too sad that chewing destroyed the early part of my data.  The spectrogram below zooms in on just the data after my chewing.  This looks like a more normal EEG recording.  Below the spectrogram, I show some processed results.  Specifically, I show the magnitude of the EEG signal in just the 22-100 Hz band, which was chosen based on the "count backwards by 3" experiment in my previous post.  So, if "counting backwards by 3" is considered "concentration", then this blue line is a measure of concentration.  At least, it is a measure of one type of concentration.  In the figure, note that my concentration level does seem to change in response to my different activities.  I find this to be very cool.

Zooming in on the activity after my chewing.  The top plot is the spectrogram of the data.
The bottom plot shows the magnitude of the portion of the EEG in the 22-100 Hz band.

Birds are Better than the Internet:  Looking at the graph above, you can see that my concentration level starts pretty low while I'm working on the Internet.  Surprisingly, the movie shows that I'm not passively reading.  No, it shows that I am actively engaged (mostly typing a reply regarding a theremin).  Given this engagement, I would have expected my concentration to be strong.  Nope.  Compare this to the next section of time, where I'm simply gazing out the window at the birds and trees.  My apparent concentration level (or, at least, my EEG activity in the 22-100 Hz band) gets noticeably higher.  Wow!  Then, when I return to my Internet work, it drops strongly.  I guess that birds are more stimulating than the Internet!  Go birds!

Stronger Concentration Today:  At the end of this test, I closed my eyes and relaxed, which caused my the EEG signal level to drop, as expected.  Then, I opened my eyes and did my concentration exercise where I count backwards by 3.  This portion of my test repeats what I did in my previous post.  In today's recording, however, my signal levels were much higher.  As shown in the plot below, today's data shows 2.8 uV with my eyes closed and 7.6 uV while counting backwards.  Compare this to the previous post where I showed only 2.0 uV and 3.4 uV, respectively.  So, I was 3.4 uV and now I'm 7.6 uV.  This means that my "concentration" intensity is nearly twice as strong!  Why?  Was it because this data was from the morning, when I was fresher and could maybe concentrate "stronger"?  I don't know.  I do find it interesting, though.

Quantifying the EEG Signal Level During the Different Periods.

Summary So Far:  Even with just this simplistic analysis, the data has been way more surprising than I would have guessed.  I would have thought that breakfast would have been a little boring...I mean, I'm just sitting there.  But this data has been surprisingly rich.  Three things have surprised me:
  1. Chewing makes huge signals as seen by an EEG system
  2. Birds and trees stimulate my brain* more than the Internet
  3. My peak concentration level* can change a lot day-to-day
(* In both cases, "my brain" and "concentration level" really just mean "my EEG signals in the 22-100 Hz band".  But it sounds a lot less exciting when said that way.)

One More Thing...:  At this point, I figured that I was done.  I mean, three new findings is certainly enough excitement for me.  But then I remembered that I had data from the 2nd electrode that was on my forehead.  We already looked at the data from the left electrode (spectrogram repeated below).  What did the data from the right electrode show?  Its data as shown as the 2nd spectrogram below, though it's not particularly exciting by itself...it shares many of the signatures seen in the first electrode.  The excitement comes when I examine the "coherence" of the signals between these two electrodes.  The coherence as a function of time and frequency is shown in the third plot.  It looks pretty boring, except right there at the end.  What is happening there?

Measuring the Coherence Between the Left and Right Electrodes on my Forehead.
For the "concentration" signals prior to counting backwards, the signals are
not coherent.  For the counting backwards, they are coherent.  Why?!?
What is Coherence?:  Coherence is a measure of how two signals move together -- if one signal gets stronger, does the other get stronger, too?  If one gets weaker, does the other get weaker at the same time?  Signals that move together have a high coherence (ie, a value near 1.0).  Signals that do not move together have low coherence (near 0.0).  I've analyzed the coherence a couple of times before, such as in this earlier post.

Today's Coherence Data:  For today's data, the coherence plot above shows a few interesting features.  First, in the lower frequencies (10 Hz and below), this plot shows that the signals from the two electrodes on my forehead exhibit high coherence (the plot has a lot of red).  OK.  Above 10 Hz, though, the signals from these two electrodes are not coherent (blue).  Fine.  At then end, though, while I'm counting backwards, these higher frequency EEG signals suddenly become coherent (red). Whoa!  What happened?!?

Counting Backward Must be Different:  If "concentration" is reflected as activity in the 22-100 Hz band, this coherence plot suggests that my "concentration" is different at the end compared to the rest of the test. It appears that the Internet and the gazing outdoors both induce independent (ie, not coherent) activity in the left and right sides of my forehead.  Then, at the end, it appears that my counting exercise causes synchronized (ie, coherent) activity on both sides of my forehead.  Counting backwards must require different brain activity than the concentration associated with the Interent and birds.  While this sounds obvious, these objectively-recorded EEG signals are saying the same thing.  I think that's amazing.

Next Steps:  I've discovered many features in this single recording that get me really excited.  Before I get too excited, I should repeat the experiment.  If these phenomena appear again (especially the finding regarding the coherence), I would feel a lot more confident that it is true.  At that point, I would be really interested in seeing if something similar happens in other people.  If so, perhaps its a known phenomenon discussed in the literature.  Perhaps there is a known cause and a description of the brain mechanism(s) in action.  I'm interested to know!

Follow-Up:  Interested in getting the EEG data from this post?  Try downloading it from my github!

Tuesday, April 22, 2014

Detecting Concentration

A couple of weeks ago, Sparkfun's new product post was all about the Neurosky Mindwave.  What really grabbed my attention was Nick Poole's video of his hack of using the Mindwave to bend a spoon.  That was a really fun and creative way to use EEG to interact with the physical world.  What also grabbed my attention was that it was yet another example of consumer EEG system saying that it detects "concentration", as if it were a well-known and well-defined EEG signature.  Along with terms like "focus" and "relaxation", I always felt that a word like "concentration" was too amorphous for serious consideration.  I mean, what exactly do "concentration" brain waves look like?  What is the signature?  I don't know.  But, given the coolness of Nick's demo, I decided to do some EEG Hacking to find out!



Neurosky Mindwave Electrode Setup:  I don't own a Neurosky Mindwave so I can't use that hardware to explore these "concentration" brain waves.  But, I do have an OpenBCI system, and it's pretty flexible, so I'll try that instead.  The main question is how to setup the electrodes.  Looking at the videos for the Mindwave, and looking at the Sparkfun hack pages, the Mindwave appears to use an electrode on the forehead and then another on an ear clip.  I'm assuming that the one on the ear clip is the reference electrode.  It does not appear to use a bias electrode, probably because they found that it was not needed for this body-mounted, battery-powered system.

OpenBCI Electrode Setup:  To mimic the Mindwave setup, I put a gold cup electrode on my forehead  and another on my left ear lobe.  The one on my forehead was plugged into Channel 1 of my OpenBCI board and the one on my ear lobe was used as the reference.  Because my system is not battery powered, I did use a bias electrode, which was an ear clip electrode placed on my right ear lobe (this is the first time I've tried the ear clip electrodes).  I also chose to stick another gold cup electrode on the back of my head, just to see what happened back there during this experiment.  Oh, and to attach my electrodes, I used standard Ten20 conductive paste.  My impedance check showed about 30 kOhm for each electrode, so not too bad.

Using OpenBCI (V2), 3 gold cup electrodes, and one ear clip.
Oh, and some guy's brain, too.

Procedure:  Watching Nick's video, he says that he is able to trigger the Mindwave's concentration detector by mentally counting backwards by 3, starting from 100.  This sounds pretty straight-forward and he clearly had good success with it.  Frankly, I was a little more skeptical about my own ability to make it happen.  So, in my data, to make it clear to me where I was trying to concentrate, I closed my eyes for a short period before and after my mental counting.  I did this because, by closing my eyes, I would generate strong alpha waves (10 Hz) that would clearly show up in the data.  As a result, after the test, I could look for the data between the two alpha wave recordings...this would be the period when I was concentrating.  Let's see what I got.

My First Look at the Data:  The spectrogram below shows how I typically look at an EEG recording for the first time.  Note that frequency is on the vertical axis and time is on the horizontal axis.  You can definitely see the signature of the alpha waves (that horizontal stripe around 10 Hz) at the beginning and at the end of my recording.  In the middle is the period of time when I was concentrating.  In this plot, I don't see anything interesting during the concentration portion of the test.  I just see some "noise" that looks little different from everything around it.  Bummer.

You can definitely see the alpha waves from my eyes being closed.  Good.
But, is anything happening during concentration?

Higher Frequencies?  But then I remembered reading somewhere (like in one of my own early posts?) that "concentration" was usually seen as increased activity in the higher EEG frequencies -- the so-called Beta waves (13-30 Hz).  So, I replotted the data where, this time, I zoomed way out on the frequency axis.  As you can see below, I'm now showing zero to 100 Hz.  In this new plot, you can clearly see that there is more EEG activity when I was concentrating compared to when I was not.  Now we're getting somewhere!

By zooming out to see the higher frequencies, it does look like there are more activity
in the high frequencies (20-100 Hz) when I am concentrating.  Cool!  (Note: the dark
horizontal stripe in the middle is the effect of my 60 Hz notch filter.)

Comparing the Spectra:  While spectrograms like the one above are helpful for quick qualitative views of both time and frequency, it is difficult to be quantitative with a spectrogram.  So, in the plot below, I show the average spectrum for a period of strong concentration (t = 90-130 sec) and I show the average spectrum for a period where my eyes were closed and my mind was especially quiet (t = 155-178 sec).  As can be seen below, the two spectra are definitely different, especially for frequencies above 22 Hz.

Comparing the average frequency spectrum with my eyes closed (t=90-130 sec)
to the average spectrum while concentrating (t=155-178 sec).  Note that
above 22 Hz, concentration exhibits more signal energy.

Detecting Concentration:  With the knowledge that, in my brain, "concentration" starts to show itself as increased EEG energy above 22 Hz, I can now contemplate building a concentration detector.  The key is to filter my EEG data so that I can assess the intensity of EEG activity in frequencies above 22 Hz.  Then, I'd pick a threshold to which I can compare the EEG intensity level.  If my EEG signals are stronger than my threshold, my detector would say that I am concentrating.  If I'm weaker than the threshold, my detector would say that I am not concentrating.  Sounds pretty easy, right?

Applying to My Recorded Data:  In the figure below, I apply this idea to the data that we've been discussing.  The top plot is the same spectrogram that I showed below.  The bottom plot is what happens when I filter the EEG data to show the intensity just for frequencies between 22 and 100 Hz.  You can see, the trace does indeed move up and down to reflect whether I'm concentrating or not.  Specifically, for the sustained concentration (t = 90-130 sec), my filtered EEG signal is running about 3.4 uVrms.  Then, when I close my eyes and relax (after t = 140 sec), my EEG signals drop down to about 2.0 uVrms.  So, if I were to define a threshold for detecting concentration, I might put it somewhere in the middle...say, around 2,7 uVrms.

Measuring the EEG amplitude in the 22-100 Hz frequency band.  Note how it is low while
my eyes are closed and that it goes higher while concentrating.

Feeling Some Success:  The plot above is making me pretty excited.  It suggests that I have conscious control over my EEG signals.  To date, I've only had strong success with controlling my Alpha waves (by opening and closing my eyes).  I've also had some small success with Mu waves, but they're really hard for me to get.  So, seeing this concentration-induced Beta (13-30 Hz) and Gamma (30-100 Hz) is pretty darned exciting.

Criticism: A critic reading this post might argue that I have not proven any link to concentration.  A critic might say that the increased high frequency EEG energy could just be a natural result of opening my eyes.  Based on the data shown so far, that would be a fair criticism.

Gathering More Eyes-Open Data:  To counter this criticism, the data below is from another test that I performed using the same setup.  In this test, I performed a similar procedure where I started with my eyes closed, had a period with my eyes open, and then finished with my eyes closed.  Unlike the previous test, though, I did not do my concentration exercise during the eyes-open period.  As a result, we should be able to see whether the increased high-frequency EEG activity is due to concentration or due to simply having my eyes open.

A second EEG test where I was NOT purposely concentrating during the eyes-open portion of the test.  Note that the EEG intensity is much less intense than seen during my previous test where I was purposely concentrating.

Not Concentrating:  In the plot above, you can see that there is a trend in my EEG signal strength, but that it is not related to the opening of my eyes.  At the beginning, when my eyes were closed, my high-frequency EEG signals were pretty low at 1.9 uVrms.  Then, when I opened my eyes (t = 210 sec), my EEG intensity increase only slightly to 2.0 uVrms and stayed that way for quite a while.  I think that this is strong evidence that simply opening your eyes does not specifically trigger increased Beta and Gamma activity.

Wandering Mind:  In the second half of my eyes-open period, we do see that my EEG intensity drifts upward.  Eventually, it averages about 2.5 uVrms.  Perhaps this increase reflects that I got bored and started thinking about my next EEG test.  Regardless of the reason, you'll note that even the increase to 2.5 uVrms still does not exceed the 2.7 uVrms threshold that we set a couple of paragraphs ago.  So, this small increase does not meet our criteria for "concentration".

Conclusion:  I think that this second data set is good evidence to declare that intense (>2.7 uVrms) Beta and Gamma activity is not due simply to opening my eyes.  I am feeling pretty confident that the intense high frequency EEG activity seen in the first data set is due to my concentration.  This means that Beta and Gamma activity is under my conscious control, which is the most exciting EEG result that I've had in a long time.

Next Steps:  Being under conscious control means that I could potentially use "concentration" as part of a brain-computer interface for future hacks.  I'm always looking for ways that I can try to control things in the physical world using just my brain waves.  Perhaps with some practice, I could use this technique to compete with Nick Poole in a spoon-bending competition!

Follow-Up:  I recorded my concentration level while eating breakfast, and found some really cool changes!
Follow-Up:  Interested in getting the data from this post?  Try downloading it from my github!