[Eeglablist] EEGLAB, BioSemi, BioSig, and means

Bradley Voytek bradley.voytek at gmail.com
Sun Apr 6 11:09:23 PDT 2008


Ah the ongoing saga between Matlab and BioSemi's dynamic range!

Christina Karns of University of Oregon and I have been in
communication regarding a strange EEGLAB phenomenon we were both
experiencing. When we were plotting our channel spectra (Plot >
Channel spectra and maps) the resulting spectra were "spiky"--that is,
the spectra were saw-toothed with a peak-to-peak (10*log10) power of
about 40-60 uV^2/Hz. Needless to say, this isn't what normal EEG
spectra tend to look like.

See the images "raw-spectrum.jpg" and "raw-spectrumZoomed.jpg" for
examples (these data are from different subjects, with the "zoomed"
version consisting of a different number of time points than the
non-zoomed version so you can see the saw-toothed shape).


We suspected several possible causes, but in the end tracked it back
to an issue with means (once again). More specifically, somewhere
along the way there were some rounding errors being introduced,
resulting in some strange spectra.

The easiest fix seems to be the simple addition of a one-line for loop
in "pop_biosig" during the process of importing the BDF files after
line 274 (after the "extract events" loop but before the "referencing"

% remove *real* channel mean
for numChans = 1:size(EEG.data,1);
   EEG.data(numChans, :) = single(double(EEG.data(numChans, :)) -
mean(double(EEG.data(numChans, :))));

This just removes the true mean from each channel during the import
process by casting each channel as a double and removing the
double-cast channel mean, then reverting to class single. There's no
need to convert the entire dataset to "double"--that needlessly takes
up a huge amount of space. The nice thing about doing this before the
reference step is that if you're referencing to multiple channels at
once, you might not be referencing your signal to the real mean of the
input reference channels because of rounding errors introduced by
BioSemi's huge dynamic range, though this remains to be tested
thoroughly by me.

I don't think that removing the mean from each channel should have any
effect on most post-processing; it's just removing the DC. However if
I'm missing something obvious, please let me know. Also, by doing this
at the import step, you can almost guarantee you're side-stepping any
hidden rounding issues that may crop up in other scripts.

For comparison, I've included the power spectra from the exact same
dataset, once after importing normally, and one after adding my for
loop to pop_biosig ("raw-spectrum.jpg") and reimporting the BDF file
("meansRemoved-spectrum.jpg"). You'll notice the power spectrum looks
a lot more like a regular EEG spectrum now!


I was worried that this effect may be introducing artifacts into my TF
decompositions, but as you can see from the final two attached images,
there doesn't seem to be a difference between the two methods (
"raw-TF.jpg" and "meansRemoved-TF.jpg"), though I haven't looked more
closely than an eyeball comparison yet. I also compared the ERPs from
the two different import methods, and the difference waves seem to be
mostly flat (although I was getting small differences... perhaps due
to rounding errors in the reference step?)


This may require more testing, of course, but this first round seems
to be encouraging, in that the real differences seem to manifest
mainly in the spectra and nothing else.


Bradley Voytek
Ph.D. Candidate, Neuroscience

University of California, Berkeley
Helen Wills Neuroscience Institute
132 Barker Hall
Berkeley, CA 94720-3190

More information about the eeglablist mailing list