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.
The pipeline processes a smartphone video in four steps to produce 3D electrode coordinates in a head-centered coordinate system.
Mark landmarks, record ~45 sec with a 1080p smartphone camera.
VGGT extracts 3D point cloud, camera poses, and depth maps from 28 frames.
YOLOv8 auto-detection with 80% confidence filter + manual correction.
Landmark alignment, real-world scaling, and 3D coordinate extraction.
Key processing steps from the pipeline source code.
# 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
# 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]
# 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
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
Validated on a styrofoam head model with a 24-channel EEG cap:
10 digitizer recordings (ground truth) vs. 10 smartphone video recordings.
@software{evirgen2025video_eeg,
title = {Video-based EEG Electrode Registration Pipeline},
author = {Evrim Evirgen},
year = {2025},
url = {https://github.com/evrim06/video-eeg-electrode-registration}
}
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].