Category Archives: EEG

First steps to realtime EEG and BCI on Raspberry Pi

I just compiled the FieldTrip realtime EEG interface on the Raspberry Pi. The code compiled out of the box, not a single line of code needed to be changed thanks to the existing cross-platform support for the old Apple PPC-G4 and the Neuromag HPUX-RISC MEG system. Streaming data to and from the FieldTrip buffer over TCP/IP works like a charm.

I’ll add my binaries for the Raspberry Pi to the regular FieldTrip release.

The next step will be to compile some of the EEG acquisition drivers, e.g. for OpenEEG and BrainVision.

Eventually it would be nice to also get BCI2000 to work on the Pi. According to Juergen large parts of BCI2000v3 should compile on the ARM… I look forward to gving it a try.

Average reference for dipole fitting

Here is a question that I get asked occasionally. I have slightly edited the question and my answer to it, which both were posted to the EEGLAB email discussion list.

Question: I’m using EEGLAB-DIPFIT to localize independent components using the spherical head model. Apparently the software requires the data to use the average reference. Why is this?

Answer: In principle you could use an arbitrary reference in your source reconstruction. The practical reason to use an average reference over the sampled electrodes in source estimation is that this prevents the solution to be biassed due to forward modelling errors at the reference electrode. Let me give a partially intuitive, partially mathematical explanation.

Assume that you would use left mastoid as reference. That would mean that the measured value “V” at each electrode “x” is V_x, so the list of all measured values in the N channels is

V_C3-V_M1
V_Cz-V_M1
V_C4-V_M1
...
V_M1-V_M1 (this is zero)
V_M2-V_M1

Those values can be modeled using the source model and the volume condution model. Now, lets assume a spherical volume conduction model. That is especially inaccurate for low electrodes, and the bony structure of the mastoid is definitely not modelled appropriately in a spherical model. So for the model potential “P” we would have the value at each of the N electrode also referenced to the model mastoid
electrode:

P_C3-P_M1
P_Cz-P_M1
P_C4-P_M1
...
P_M1-P_M1 (this is zero)
P_M2-P_M1

The source estimation algorithm tries to minimize the quadratic error between model potential distribution and the measurement, so the error term to be minimized is

Total_Error
= sum of quadratic error over all channels
= [(V_C3-V_M1)-(P_C3-P_M1)]^2 + ....
= [(V_C3-P_C3)-(V_M1-P_M1)]^2 + .... (here the terms are re-ordered)

So for each channel the error term consists of a part that corresponds to the potential at the electrode of interest, plus a part that corresponds to the reference electrode. The error term corresponding to the reference electrode is identical over all channels (i.e., repeats in each channel), hence for each channel you are adding some error term for the reference electrode. Therefore, the minimum error (“minimum norm”) solution will be one that especially tries to minimize the model error at the reference electrode (since that is included N times). In the case of a mastoid reference we know that there is a large volume conductor model error at M1, hence the source solution would mainly try to minimize that error term. The result would be that the source solution would be biassed, because it tries to reduce the (systematic) error at the reference.

The solution is to use an average reference (average over all measured electrodes). That implicitely assumes that the model error over all electrodes is on average zero, hence the minimum norm solution is not biassed towards a specific reference electrode.

P.S. The maths in my explanation above are rather sloppy, but the argument still holds for a more elaborate mathematical derivation which would assume the forward model inaccuracies are uncorrelated over electrode sites.

High-density EEG electrode placement

Some time ago we wrote an article on electrode placement for high-resolution EEG measurement (referred to as the 5% article). After its apearance I have noticed that there is a demand for a concise and methodological overview of electrode placement systems. With this page I want to share some of my knowledge on this subject. This page contains non-technical comments on the different standards for electrode placement. Continue reading

EEGLAB workshop

From 17-19 September 2005, the second EEGLAB workshop will be held in Porto, Portugal. I will be giving a lecture on the use of the DIPFIT plugin (i.e., dipole analysis of ICA components). The new version 2 of the DIPFIT plugin will be introduced during he workshop, which means that the link between FieldTrip and EEGLAB is finally official.

For more information about the workshop, you can look here. For more information about the relation between FieldTrip and EEGLAB, you can look here and here.