Wednesday, April 29, 2009

EEG Analysis Using MATLAB, EEGLAB, and ICA


This quarter has me working in an EEG lab, analyzing the results of EEG experiments with a MATLAB plugin called EEGLAB. I thought I'd write a bit about what a lab monkey like myself does in the name of science and lab experience.

Electroencephalography (EEG) is one of two basic methods of functional brain imaging, the other being fMRI. Whereas fMRI is a fairly good measure of where things are happening in the brain, EEG is an excellent measure of when things are happening. This is because EEG measures the electromagnetic waves associated with neuronal action potentials, and these waves propagate at the speed of light. Only the coordinated activities of a lot of physically aligned neurons create a signal large enough to be measured, so EEG doesn't register all brain activity, but researchers use continue to use it because it's very cheap and has that great temporal resolution.

My involvement begins when a subject shows up for their experiment. We're running a 32 electrode experiment right now, which means that we have to apply 32 electrodes to the subject. The bulk of these are fitted into a snug cap, but we do have to apply 6 by hand. Each electrode is just a small disk of metal connected to a wire and generally surrounded by a plastic housing. To get the best reading possible, each electrode has to make an electrical connection to the scalp. To do this, we fill the electrode housing with an electrolytic gel and make some scratches to the skin below each electrode. And that's the fun part, because generally we have to scratch the skin through a whole in the center of the electrode using the end of a hypodermic needle: we do the scratching by feel alone. It's a little intimidating for your first few goes. We gauge our connection based on the resistance between each electrode and a reference electrode, in our case the right mastoid electrode.

After that 45 minute investment, our only remaining task for the experiment is to project enough motivation into the subject to keep him or her from falling asleep or zoning out during the experiment; such things add noise to our readings. The subject, on the other hand, still has another 40-50 minutes of repetitive stimulus response tasks, which they complete from a comfy recliner, buttons in hand, staring at a computer screen, in a sound proof electro-shielded booth. (Although, as a sticky note on the door warns the researchers, the booth is not completely sound proof. That was probably some hard won information; we experimenters tend to talk about the subject.)

In our experiment, the subject is presented with a control stimulus and and an experimental stimulus. Our goal is to evoke event-related potentials (ERPs), record them via EEG, and then find differences between the two sets of ERPs. Then the experiment concludes, we remove the cap and loose electrodes, vainly try to mop the 23 spots of translucent white gel out of the subject's furiously messy hair, point them to the bathroom, close the door, and try once again to reverse engineer this hack job of a brain that God neglected to code comment. (Note that steps following 'close the door' are a little figurative, science is a highly distributed process that occurs over weeks or years.)

When we compile our data, it's in the form of a series of measurements about one second long. Each measurement period, which we term an 'epoch', contains one stimulus presentation. And we time-lock each epoch by setting each stimulus presentation at time zero. The basic idea is that we want to take an average of epoch activity for each of the stimuli conditions, control and experimental, and then subtract--yes, literally subtract--one from the other. The result will be the average difference between ERPs with respect to the two conditions. Based on the number of trials and magnitude of the difference, we can determine if the difference is statistically significant. And hopefully the nature of the difference means something to the scientist embarking on the investigation.

There are a few complications in this process. Chief among these is that the power of noise in an EEG is significantly higher than that of signal (see signal to noise ratio). Muscle activity produces its own electrical signals, much stronger than those of brain activity. Blinks, for example, can register as high amplitude waves across several channels. There are two simple solutions to this problem of signal-to-noise, and one complicated one.

The simple answers are these: throw away the trials that are corrupted by muscle activity or just let the--hopefully independently distributed--noise get averaged out in the averaging process. Both solutions work, but require a lot more data before we can get a meaningful average difference between test conditions. And because it's much more difficult to recruit and prep test subjects than it is to get hopeful young research assistants willing to pour countless hours into lab work, scientists longed for a way to clean these noise sources out of individual epochs while preserving the brain activity signal.

And this method is called independent component analysis (ICA).I'll use the example of eye blink noise. What if we could identify the location, form, and amplitude of the waves generated by an eye blink? If we could do that, then we would know what the eye blink signal would add to each of the electrode readings, given that we know where each electrode is located. Once we know that, it's easy to subtract that eye blink signal from each electrode. This is what ICA does, though in the general sense. We give it 31 channels of data (one of the 32 channels is a reference channel or ground), and it tries to come up with the most likely set of 31 sources of cranial activity. Each source is just a notional group of neurons working together to produce some relatively regular signal. Of course, there are many more sources than 31, but because we only have 31 channels our model's best guess will contain at most 31 components. I'll post more about the details of ICA later.

So, the method is this: use ICA to transform each epoch from a record of the activity of 31 channels into a record of the activity of 31 components. Then, we identify epochs containing clearly anomalous data. Examples of this would be massive noise across many components, a component's signal drifting towards positive or negative values due to some electrode problem, etc. Then we delete these epochs from the record, leaving a less irregular set of data. This new channel data is more comprehensible to the ICA algorithm--because it's asked to account for fewer oddities--so we run ICA one more time. Then we identify which components correspond to noise--like blinks, horizontal eye movements, muscle tension, electrode drift, etc.--and which correspond to brain activity. When we ultimately find our averages, they are at the channel level, but with the noise components filtered out of the signal. The process leaves some noise behind and unfortunately eliminates some signal, but ultimately it's a great boon.

And that is how I help add to the base of human knowledge.

Science!

No comments:

Post a Comment