Smartphone Video-Based EEG Electrode Localization

Evrim Evirgen
Neuropsychology Lab, Department of Psychology, School of Medicine and Health
Carl von Ossietzky Universität Oldenburg
⚠️ Research Prototype — Under active development. Validated on styrofoam head model. Human subject validation planned.

Abstract

Accurate localization of EEG electrodes is essential for reliable source analysis. A 5 mm sensor shift can introduce 2–12 mm of source localization error. Traditional approaches such as electromagnetic digitizers and structured-light 3D scanners are reliable but require expensive equipment (€5,000–€20,000) or complex setup.

We present an open-source pipeline that replaces dedicated digitization hardware with a smartphone video recording. The pipeline uses VGGT (Visual Geometry Grounded Transformer) for 3D reconstruction, YOLOv8 for electrode detection, and depth-based unprojection to localize EEG electrode positions in 3D space — requiring only a ~45-second smartphone video and a single physical head measurement.

Pipeline

The pipeline processes a smartphone video in four steps to produce 3D electrode coordinates in a head-centered coordinate system.

1
Video Recording

Video Recording

Mark landmarks, record ~45 sec with a 1080p smartphone camera.

2
VGGT Reconstruction

3D Reconstruction

VGGT extracts 3D point cloud, camera poses, and depth maps from 28 frames.

3
Electrode Detection

Electrode Detection

YOLOv8 auto-detection with 80% confidence filter + manual correction.

4
Head Coordinate Transform

Head Coordinate Transform

Landmark alignment, real-world scaling, and 3D coordinate extraction.

How It Works

Key processing steps from the pipeline source code.

3D Reconstruction with VGGT

Script 1 · Step 2
# Extract 28 evenly-spaced frames from video
frames = extract_frames(video_path, n=28)

# Run VGGT — returns 3D point cloud,
# camera poses, and depth maps
vggt_data = run_vggt_full(frames, crop_info)

# Output contains:
#   depths:     (28, 518, 518)  depth maps
#   extrinsics: (28, 4, 4)     camera poses
#   intrinsics: (28, 3, 3)     camera params
#   points:     (28, 518, 518, 3) point maps
VGGT processes 28 video frames in a single forward pass (~3 sec on GPU) to produce dense 3D reconstruction with camera parameters. Interact with the 3D point cloud above — drag to rotate, scroll to zoom.

Multi-View Electrode Triangulation

Script 1 · Step 3
# Unproject 2D click to 3D using depth map
def unproject_pixel(u, v, depth_map,
                     intrinsic, extrinsic):
    z = depth_map[int(v), int(u)]
    fx, fy = intrinsic[0,0], intrinsic[1,1]
    cx, cy = intrinsic[0,2], intrinsic[1,2]

    # Camera-space 3D point
    x_cam = (u - cx) * z / fx
    y_cam = (v - cy) * z / fy
    P_cam = [x_cam, y_cam, z, 1.0]

    # Transform to world coordinates
    P_world = inv(extrinsic) @ P_cam
    return P_world[:3]
Multi-view triangulation
Each electrode click is unprojected from 2D to 3D using VGGT's depth maps and camera parameters. Multiple observations from different viewpoints are averaged for robust localization.

Head Coordinate Transform

Script 2 · Step 5
# Build coordinate system from landmarks
origin = (LPA + RPA) / 2

# X-axis: left → right (LPA → RPA)
x_axis = normalize(RPA - LPA)

# Y-axis: back → front (INION → NAS)
y_axis = normalize(NAS - INION)
y_axis = orthogonalize(y_axis, x_axis)

# Z-axis: down → up (cross product)
z_axis = cross(x_axis, y_axis)

# Scale to real-world mm
scale = ear_to_ear_mm / norm(RPA - LPA)

# Transform all electrodes
for electrode in electrodes:
    pos_mm = (electrode - origin) @ R * scale
Head coordinate system
Anatomical landmarks define a head-centered coordinate system. A single physical measurement (ear-to-ear distance) scales the reconstruction from arbitrary VGGT units to millimeters.

Pipeline Output: 3D Electrode Positions

24 electrodes and 3 anatomical landmarks localized on the VGGT 3D reconstruction, from a single 45-second smartphone video recording.
Drag to rotate · Scroll to zoom · Hover electrodes for labels

Validation Study

Validated on a styrofoam head model with a 24-channel EEG cap:
10 digitizer recordings (ground truth) vs. 10 smartphone video recordings.

Accuracy Head Map
Inter-Method Accuracy. Per-electrode Euclidean distance between pipeline and digitizer mean positions. Central and posterior electrodes show lowest errors; frontal and temporal sites show higher errors due to limited camera coverage.
Accuracy Boxplot
Accuracy Distribution. Mean error 4.82 ± 1.67 mm across 24 electrodes (well-reconstructed recordings only).
Recording Repeatability
Intra-Method Repeatability (Per-Recording). Each dot represents one recording session's mean error. Pipeline 2.7 mm vs. digitizer 2.6 mm.
Electrode Repeatability
Intra-Method Repeatability (Per-Electrode). Each dot represents one electrode from one recording. Full spread of individual observations.
Variability Comparison
Repeatability Comparison (Spatial Variance). Side-by-side comparison of digitizer vs. pipeline internal consistency.

BibTeX

@software{evirgen2025video_eeg,
  title   = {Video-based EEG Electrode Registration Pipeline},
  author  = {Evrim Evirgen},
  year    = {2025},
  url     = {https://github.com/evrim06/video-eeg-electrode-registration}
}

References

Clausner, T., Dalal, S. S., & Crespo-García, M. (2017). Photogrammetry-based head digitization for rapid and accurate localization of EEG electrodes and MEG fiducial markers. Frontiers in Neuroscience, 11, 264.
Homölle, S., & Oostenveld, R. (2019). Using a structured-light 3D scanner to improve EEG source modeling with more accurate electrode positions. Journal of Neuroscience Methods, 326, 108378.
Mazzonetto, I., Castellaro, M., Canale, R. J., & Bhatt, S. (2022). Smartphone video-based photogrammetry for the 3D localization of EEG and fNIRS sensors. Scientific Reports, 12, 10862.
Shirazi, S. Y., & Huang, H. J. (2019). More reliable EEG electrode digitizing methods can reduce source estimation uncertainty. Frontiers in Neuroscience, 13, 1159.
Taberna, G. A., Marino, M., Ganzetti, M., & Mantini, D. (2019). Spatial localization of EEG electrodes using 3D scanning. Journal of Neural Engineering, 16(2), 026020.
Wang, J., Chen, M., Karaev, N., Vedaldi, A., Rupprecht, C., & Novotny, D. (2025). VGGT: Visual Geometry Grounded Transformer. arXiv.
Jocher, G., Chaurasia, A., & Qiu, J. (2023). Ultralytics YOLOv8 (Version 8.0.0) [Computer software].