Revolutionizing EEG Education & Engineering
- Real-time visualization of brain-to-scalp signal propagation
- Zero dependencies, browser-based, works offline
- Comprehensive reference electrode simulation
- 3D brain view with source visualization
"See what the brain sees... on the scalp"
- We measure tiny voltages on the scalp (~1-100 μV)
- These signals originate from billions of neurons inside the brain
- Volume conduction distorts and spreads the signals
| Problem | Question | Difficulty |
|---|---|---|
| Forward | Given a source, what do we measure? | Solvable |
| Inverse | Given measurements, where's the source? | Ill-posed |
This tool visualizes the Forward Problem in real-time.
V(r) = (p · R) / |R|³
- p = dipole moment (neural current × orientation)
- R = vector from source to electrode
- Inverse-cube falloff = rapid signal decay with distance
| Layer | Conductivity | Effect |
|---|---|---|
| Brain | 0.33 S/m | Good conductor |
| Skull | 0.0042 S/m | 80x more resistive - blurs signals |
| Scalp | 0.33 S/m | Good conductor |
The skull is the main culprit in signal distortion!
Scalp Electrode
↑
═════════════════ Scalp
↑ Volume Conduction
───────────────── Skull (80x resistance!)
↑
═════════════════ CSF
↑
──┼── Apical Dendrites (current sink during EPSP)
│
● Soma (cell body)
│
──┴── Axon (current source)
- Geometric Alignment: Perpendicular to cortical surface
- Spatial Separation: Long dendrites create dipole moment
- Synchronization: ~10,000-50,000 neurons must fire together!
Key Insight: Only synchronized cortical patches produce measurable scalp signals
Cross-section of cortical fold:
Scalp Surface
════════════════════
↑ RADIAL dipole (gyrus top)
┌─────●─────┐
│ ↑ │
│ ←──●──→ │ TANGENTIAL dipoles (sulcus walls)
│ │ │
└─────┴─────┘
Sulcus
| Orientation | Location | Pattern | % of Cortex |
|---|---|---|---|
| Radial | Gyri (tops) | Focal, symmetric | ~1/3 |
| Tangential | Sulci (walls) | Dipolar, +/- poles | ~2/3 |
Most brain activity is tangential - producing dipolar patterns!
Nasion (nose)
│
Fp1 Fpz Fp2 ← Frontal pole
╲ │ ╱
F7 ── F3 ─ Fz ─ F4 ── F8 ← Frontal
╱ │ ╲
T3 ── C3 ─ Cz ─ C4 ── T4 ← Central (motor)
╲ │ ╱
T5 ── P3 ─ Pz ─ P4 ── T6 ← Parietal
╱ │ ╲
O1 Oz O2 ← Occipital (visual)
│
Inion
- X-axis: Left (-) → Right (+)
- Y-axis: Posterior (-) → Anterior (+)
- Z-axis: Inferior (-) → Superior (+)
21 electrodes capture the whole-head spatial pattern
- 3D Brain View: WebGL-powered interactive anatomy
- Coronal Slice: Cross-sectional with MRI background
- Scalp Topomap: Classic 10-20 electrode heatmap
- Point Dipoles: Quick, educational
- Active Regions (Blobs): Realistic distributed sources
- Multiple Sources: Complex configurations
- Reference Schemes: None, Average, Single, CMS/DRL
- Noise Simulation: Gaussian, impedance, mains hum
- Time Series: CSV import, playback, animation
-
Position Effect
- Surface source → strong, focal signal
- Deep source → weak, spread signal
-
Orientation Effect
- Radial (90°) → symmetric pattern
- Tangential (0°/180°) → dipolar pattern
-
Amplitude Effect
- Scales the color intensity linearly
Key Insight: Small changes in source position cause large changes in scalp pattern
- Radius: 0.02 - 0.4 (normalized units)
- Gaussian Distribution: Smooth falloff from center
- 3D Orientation: θ (tilt) and φ (rotation)
| Single Dipole | Blob |
|---|---|
| Point source | Extended region |
| Sharp gradients | Smooth gradients |
| Less realistic | More realistic |
| Fast computation | Slightly slower |
Cortical activation is distributed, not point-like!
V = L × s
Where:
┌────┐ ┌─────────────────────┐ ┌────┐
│ V₁ │ │ L₁₁ L₁₂ L₁₃ ... │ │ px │
│ V₂ │ = │ L₂₁ L₂₂ L₂₃ ... │ × │ py │
│ ...│ │ ... ... ... ... │ │ pz │
│ Vₙ │ │ Lₙ₁ Lₙ₂ Lₙ₃ ... │ │ ...│
└────┘ └─────────────────────┘ └────┘
↑ ↑ ↑
Electrode Sensitivity Dipole
Potentials Matrix Moments
- Each row = one electrode's sensitivity to all source components
- Each column = one source component's contribution to all electrodes
- Superposition: Multiple sources simply add together!
The forward problem is a matrix multiplication
- EEG measures voltage differences, not absolute voltage
- Every electrode is relative to some reference
- Different references → different-looking signals!
| Reference | Formula | Use Case |
|---|---|---|
| None | V = V | Theoretical only |
| Average | V' = V - mean(all) | Research |
| Single | V' = V - Vref | Clinical |
| CMS/DRL | Hardware + feedback | Modern systems |
┌─────────────────────────────────────┐
│ │
▼ │
[CMS Electrode] → [Integrator] → [DRL Electrode]
│ (-G) │
│ │
└─────── Body Impedance ──────────┘
- DRL Gain: 1-1000 (typical: 100)
- Time Constant: 0.1-10 ms
- Body Transfer: Attenuation + phase lag
- Phase Margin: Stability indicator
Upload custom frequency response LUTs!
H_DRL(s) = -G / (1 + sτ)
Frequency Response:
|H(jω)| = G / √(1 + (ωτ)²)
Phase: φ(ω) = -90° - arctan(ωτ)
L(s) = H_DRL(s) × H_body(s) × η
Where:
- H_body(s) = α / (1 + sRC) [Body impedance model]
- α = attenuation (0.5-0.9)
- η = injection efficiency
CMRR_total = CMRR_amp + 20·log₁₀(G × η) dB
Example: G=100, η=0.8 → +38 dB improvement!
DRL can boost CMRR from 80 dB to >110 dB
- DRL is a feedback loop
- Too much gain + phase lag = oscillation
- Patient safety concern in real systems
| Phase Margin | Status | Indicator |
|---|---|---|
| > 45° | Safe | Green |
| 20-45° | Caution | Yellow |
| < 20° | Unstable | Red |
- Body impedance (skin prep quality)
- DRL circuit bandwidth
- Electrode placement
| Source | Control | Effect |
|---|---|---|
| Thermal | Noise slider | Random baseline fluctuation |
| Impedance | Per-electrode | Signal attenuation + mismatch |
| Mains Hum | 50/60 Hz | Common mode interference |
- Show students why skin prep matters
- Demonstrate DRL rejection of mains hum
- Visualize impedance mismatch artifacts
time,motor_left,motor_right,visual
0.000,0.0,0.0,0.0
0.004,0.2,0.1,0.0
0.008,0.5,0.3,0.0
...- Map each CSV column to one or more sources
- Create realistic multi-source animations
- Playback at 0.25x to 4x speed
- Simulate seizure propagation
- Show motor cortex activation patterns
- Demonstrate P300 responses
- Orbit Controls: Drag to rotate
- Zoom: Scroll wheel
- Preset Views: Front, Top, Side
- Brain Opacity: Adjustable transparency
- Inside Brain: Orange (blob) / Blue (dipole)
- Outside Brain: Red + "INACTIVE" label
- Orientation Arrow: Shows moment direction
3D view helps build spatial intuition!
- Enable/disable any electrode
- Grayed-out electrodes excluded from:
- Average reference calculation
- CMS averaging
- Export data
- Simulate bad electrode connections
- Model reduced montages (e.g., only frontal)
- Educational: show effect of removing electrodes
| Action | 2D Views | 3D View |
|---|---|---|
| Zoom In | Scroll up / + | Scroll up |
| Zoom Out | Scroll down / - | Scroll down |
| Pan | Shift + drag | Right-click drag |
| Reset | ⟲ button | Reset button |
Perfect for focusing on specific regions during demos!
- Instant snapshot
- All 21 electrodes
- CSV format
- Full animation sequence
- Every time point × every electrode
- Ready for MATLAB/Python analysis
time,Fp1,Fp2,F7,F3,Fz,F4,F8,T3,C3,Cz,C4,T4,...
0.000,0.12,-0.45,0.78,0.23,...
0.004,0.13,-0.44,0.79,0.24,...- Pure HTML/CSS/JavaScript
- Three.js loaded from CDN (only external)
- No build tools, no npm, no webpack
- Works offline once loaded
- 60 FPS rendering
- Real-time physics calculations
- Efficient Delaunay interpolation
- Modular ES6 architecture
- Comprehensive documentation
- Easy to extend and modify
- Forward vs inverse problem visualization
- Volume conduction effects
- Dipole orientation importance
- Reference electrode effects
- Impedance impact demonstration
- Artifact recognition
- DRL circuit design validation
- Custom transfer function testing
- Montage optimization
| Feature | Our Tool | Typical Alternatives |
|---|---|---|
| Setup | Open HTML file | Install MATLAB/Python packages |
| Cost | Free | Expensive licenses |
| Platform | Any browser | OS-specific |
| 3D View | Built-in | Requires plugins |
| DRL Sim | Full model | Not available |
| Learning Curve | Minutes | Hours/Days |
Democratizing EEG education!
- Realistic head model (BEM forward model)
- EEG file format import (EDF, BDF)
- More electrode systems (64, 128, 256)
- Source localization inverse solver
- Mobile-optimized interface
- API for programmatic control
- Open source (MIT License)
- GitHub repository
- Issue tracker for feature requests
-
Basic Dipole (3 min)
- Move, rotate, scale
- Show INACTIVE state
-
Blob Mode (2 min)
- Extended sources
- 3D orientation
-
Reference Comparison (4 min)
- Average vs Single vs CMS/DRL
- Enable mains hum, show rejection
-
Signal Quality (2 min)
- Add noise and impedance
-
Time Series (2 min)
- Upload CSV, play animation
-
Q&A (2 min)
-
The skull distorts everything - 80x less conductive than brain
-
Orientation matters as much as position - radial vs tangential
-
Reference choice changes the picture - always document your reference
-
DRL is a feedback loop - phase margin = stability
-
Real signals are noisy - impedance and mains hum are everywhere
-
This tool is free and works anywhere - share with your colleagues!
- Live Demo: https://adityaasopa.github.io/EEG-Forward-Model/
- GitHub: https://github.com/AdityaAsopa/EEG-Forward-Model
git clone https://github.com/AdityaAsopa/EEG-Forward-Model.git
open index.html- README.md - Full documentation
- TOUR_GUIDE.md - Step-by-step walkthrough
- PRESENTATION_SLIDES.md - This handout
Repository: github.com/AdityaAsopa/EEG-Forward-Model
Issues & Features: Use GitHub Issues
Documentation: See README.md
| Key | Action |
|---|---|
| Delete | Remove selected source |
| A | Rotate counter-clockwise |
| D | Rotate clockwise |
| W | Increase amplitude |
| S | Decrease amplitude |
Single Dipole:
V(r) = (1/4πσ) × (p · R) / |R|³
Regularized (avoid singularity):
V(r) = (p · R) / (|R|³ + ε)
Weight at sample point:
w(r) = exp(-r²/2σ²)
Total contribution:
V = Σ wᵢ × V_dipole(rᵢ)
Transfer Function:
H(s) = -G / (1 + sτ)
Where:
- G = DC gain
- τ = time constant
Loop Gain with Body:
L(s) = H_DRL(s) × H_body(s) × η
Where:
- η = injection efficiency
- H_body = body transfer function
Phase Margin:
PM = 180° - |∠L(jω₀)|
Blue → White → Red
| Value | Color |
|---|---|
| -1.0 | Blue (negative) |
| -0.5 | Light blue |
| 0.0 | White (neutral) |
| +0.5 | Light red |
| +1.0 | Red (positive) |
Auto-scaling normalizes to max absolute value
Electrode mesh (top view):
Fp1 ────────── Fp2
│╲ Fz ╱│
│ ╲ ● ╱ │ Triangles connect
│ ╲ ╱ │ neighboring electrodes
F7───F3──F4───F8
│ ╱ │╲ ╱ │
│ ╱ │ ╲ │
T3───C3─Cz─C4───T4
For point P inside triangle ABC:
P = u·A + v·B + w·C (where u + v + w = 1)
Interpolated value: V_P = u·V_A + v·V_B + w·V_C
Result: Smooth, continuous potential field from 21 discrete measurements
| Assumption | Reality | Error Impact |
|---|---|---|
| Homogeneous conductivity | Anisotropic tissues | ~10-20% |
| Spherical/ellipsoidal head | Complex folded cortex | Position errors |
| Point dipole sources | Distributed patches | Oversimplification |
| Static (quasi-static) | Dynamic at high freq | Valid < 1 kHz |
| Model Type | Accuracy | Speed | Use Case |
|---|---|---|---|
| This tool | ~80% | Real-time | Education |
| BEM | ~95% | Seconds | Research |
| FEM | ~98% | Minutes | Clinical |
- Understanding EEG principles
- Demonstrating concepts
- DRL circuit exploration
- Quick prototyping
- Clinical source localization
- Quantitative analysis
- Individual patient modeling
This is an educational tool - not a clinical diagnostic!
| Parameter | Value | Implication |
|---|---|---|
| Minimum neurons | 10,000 - 50,000 | Small patches invisible |
| Cortical patch | 6-10 cm² | Need extended activation |
| Timing window | ~10 ms | Must be synchronous |
| Alignment | Perpendicular to cortex | Random orientations cancel |
Single neuron: ● → Invisible (~0.00001 μV)
Small patch: ●●● → Still invisible
●●●
Synchronized: ↑↑↑↑↑ → Measurable (~1-100 μV)
large patch: ↑↑↑↑↑
(>10,000 neurons ↑↑↑↑↑
aligned & timed)
EEG is a population measure - individual neurons cannot be detected
Center: (0, 0, -0.05)
Radii: rx=0.75, ry=0.80, rz=0.70
Brain:Skull:Scalp = 1 : 0.013 : 1
(Skull is ~80x more resistive)
ε = 10⁻³ (prevents 1/r³ singularity)
Gain: 100
Time constant: 1 ms
Injection efficiency: 0.8
3×3×3 = 27 sample points
Gaussian weighting: w(r) = exp(-r²/2σ²)
End of Presentation Handout
Thank you for your attention!
EEG Dipole Demo v2.0 - Making EEG Forward Modeling Accessible to Everyone