Project B: The forward and inverse problems
Put a dipole in a head model and compute the scalp potentials. Then try to go backward. Compare to the spatial map you measured on the phantom. The physics of why scalp EEG is blurry, done by you.
You are skimming: the title, the first figure, and the short version. Switch to Read in the header for the full page, or Deep to open every deep dive.
In Phase 2 you drove a buried dipole and recorded eight electrodes: a measured forward model. Now compute it. Given a source in a head, what does each electrode see? That is the forward problemForward problemGiven a source in the head, compute the voltages on the scalp; it has a unique answer. Glossary entry and it has one answer. Then the question every EEG analyst wants answered: given the electrodes, where was the source? That is the inverse problemInverse problemGiven voltages on the scalp, find the sources; it has infinitely many answers, so every solution leans on assumptions. Glossary entry, and it has infinitely many answers, so every method leans on an assumption. You will build both and feel the difference.
- Set skull resistivity to 1 (no skull). Note the peak amplitude and the lobe width. Now 40. The peak drops and the lobe widens. That is the skull’s blur.
- Push the dipole deep. The pattern spreads over half the head and the amplitude collapses. Deep sources are nearly invisible.
- Turn the orientation to 90 degrees (tangential). The pattern flips sign across the source. This is what a source on a sulcal wall looks like.
- Add the second dipole with 20 degrees separation. Could you tell from the scalp that there are two?
A source's scalp map is a broad positive patch over the right side. How many sources could produce exactly that map?
Infinitely many. Any pattern on the scalp can be produced by a single deep source, by several shallow ones, or by a smooth sheet of activity, and the electrodes cannot tell them apart. Adding electrodes helps a little; it does not change the count. This is why inverse solutions always come with a prior: “the fewest sources,” “the smoothest distribution,” “sources only on the cortical surface.”
Forward, analytically
The interactive solves a two-dimensional version exactly. The three-dimensional equivalent, three concentric spheres for brain, skull, and scalp, was solved by Rush and Driscoll in 1969 as a series in Legendre polynomials. Implement it, or use MNE’s make_sphere_model, which does. Place a dipole, compute the potential at your phantom’s eight electrode positions, and compare to what you measured. The shapes should match; the amplitudes will differ by a factor that is your gelatin’s conductivity, which you can now estimate.
Then the realistic version. MNE ships a template head (fsaverage) with a boundary-element model built from MRI: real skull shape, real cortical surface. Compute the forward solution for every point on the cortex and every electrode of a standard montage. This “leadfield” matrix, thousands of sources by tens of electrodes, is what every source-localization method starts from.
import mne
from mne.datasets import fetch_fsaverage
fs_dir = fetch_fsaverage()
src = mne.setup_source_space('fsaverage', spacing='oct5', subjects_dir=fs_dir.parent)
bem = mne.make_bem_solution(mne.make_bem_model('fsaverage', subjects_dir=fs_dir.parent))
info = mne.create_info(ch_names=mne.channels.make_standard_montage('standard_1020').ch_names, sfreq=250, ch_types='eeg')
info.set_montage('standard_1020')
fwd = mne.make_forward_solution(info, trans='fsaverage', src=src, bem=bem, eeg=True)
Pick one source on the surface, take its column of the leadfield, and plot it as a topographic map. Pick a source in a sulcus, tangential to the scalp, and see the dipolar pattern. Pick a deep one and see almost nothing.
Inverse, honestly
Minimum norm: of all the source distributions that explain the scalp data, choose the one with the least total power. It is a matrix inverse with regularization, MNE does it in two lines, and it produces smooth, blurry, shallow-biased estimates, because that is what the prior asks for. Try it on a single simulated dipole from your own forward model and see how far the estimate spreads. Then add noise and see it move.
Then a different prior, dipole fitting: assume one source and search for the position and orientation that best fit the data. On a single simulated dipole it works beautifully. On two, it finds one somewhere in between. On the real alpha you recorded in Phase 1, it finds something in the occipital lobe, and you now know exactly how much to trust that.
What you will have understood
Why the same scalp pattern does not identify its source. Why a resistive skull makes EEG spatially blurry and MEG, which the skull barely affects, sharper. Why the average reference and the Laplacian do what they do. Why intracortical arrays exist. And why any headline of the form “EEG reveals activity in the amygdala” should be met with a raised eyebrow: deep, small, and far from the scalp is exactly what the forward model says you cannot see.
- Reproduce your phantom’s eight-electrode spatial map with a three-sphere analytic model. Fit the conductivity.
- Build the fsaverage forward model. Plot leadfield topographies for a shallow radial source, a sulcal tangential source, and a deep source.
- Simulate scalp data from one dipole plus noise. Run minimum-norm. Plot the estimate. Measure how far it spreads.
- Run a dipole fit on the same data. Then on two dipoles.
- Run minimum-norm on your own eyes-closed alpha from Phase 1 or 2 (average-referenced). Describe what it shows and what it cannot.