Electrode Locations

Initialize NeuroAnalyzer
using NeuroAnalyzer
eeg = load("files/eeg.hdf")

Electrode Naming by Brain Region

Each electrode is labeled based on the brain lobe or area it records from:

  • Fp: Pre-frontal
  • F: Frontal
  • T: Temporal
  • C: Central (near the motor cortex)
  • P: Parietal
  • O: Occipital

Midline Electrodes (Z)

  • “Z”: Electrodes placed on the midline sagittal plane of the skull.
    • Examples: FpZ, Fz, Cz, Pz, Oz
    • Purpose: Serve as reference/measurement points for symmetry and grounding.

Left/Right Hemisphere Conventions

  • Odd Numbers (1, 3, 5, 7): Electrodes on the left hemisphere.
  • Even Numbers (2, 4, 6, 8): Electrodes on the right hemisphere.
  • Applies to EEG and EOG (electrooculogram for eye movements).

Special Electrode Locations

  • Chin/EMG Electrodes:
    • Typically labeled as Right, Left, and Reference/Common.
    • Used for recording muscle activity (e.g., during sleep studies).
  • “A” or “M” Electrodes:
    • A1 and A2: Placed on the earlobes.
    • M1 and M2: PLaced on the mastoid process (bone behind the ear).
    • Purpose: Record ipsilateral mid-temporal activity and serve as reference electrodes.
    • Note: The mastoid process is less prominent in children and some adults.

The 10/20 System

  • Standard Layout: Uses 21 electrodes (19 scalp electrodes + 2 reference electrodes, G1 and G2).
  • 10/20 Rule: Electrodes are placed at 10% or 20% intervals of the total distance between standard landmarks (nasion to inion, and left to right preauricular points).
  • Purpose: Ensures consistent, reproducible electrode placement across subjects.

Modified Combinatorial Nomenclature

The Modified Combinatorial Nomenclature (MCM) extends the 10/20 system by adding intermediate electrode sites and updating naming conventions. It allows for higher spatial resolution in EEG recordings.

Electrode Naming and Placement

  • Left Hemisphere Numbers: 1, 3, 5, 7, 9 represent 10%, 20%, 30%, 40%, 50% of the inion-to-nasion distance, respectively.
  • New Letter Codes: Introduced for intermediate electrode sites:
    • AF: Between Fp and F
    • FC: Between F and C
    • FT: Between F and T
    • CP: Between C and P
    • TP: Between T and P
    • PO: Between P and O

Renamed Electrodes

The MCN updates the following 10/20 system electrode names:

  • T3T7
  • T4T8
  • T5P7
  • T6P8

High-Resolution Systems

10/5 System (5% System)

  • Concept: Increases electrode density by placing electrodes at 5% intervals of the inion-to-nasion and left-to-right distances.
  • Purpose: Provides higher spatial resolution for more precise source localization.

10/10 System (Chatrian, 1985)

  • Electrode Count: 74 electrodes (compared to 21 in the 10/20 system).
  • Placement: Uses 10% divisions to fill in intermediate sites halfway between existing 10/20 system electrodes.
  • Advantage: Provides even higher spatial resolution for detailed brain mapping.

or alternatively:

Landmarks for Electrode Placement

Front to Back Right to Left
nasion tragus R
10% 10%
Fp 8
20% 20%
F 4
20% 20%
C Z (midline)
20% 20%
P 3
20% 20%
O 7
10% 10%
inion tragus L

EOG Electrodes

Electrode Naming and Placement

  • EOG1: Placed on the left side of the face, near the outer canthus of the left eye.
  • EOG2: Placed on the right side of the face, near the outer canthus of the right eye.

Types of Eye Movements Tracked

  • VEOG (Vertical EOG):
    • Measures vertical eye movements (e.g., blinks, upward/downward gaze).
    • Typically represented in red on recordings.
  • HEOG (Horizontal EOG):
    • Measures horizontal eye movements (e.g., left/right gaze).
    • Typically represented in green on recordings.

Purpose

  • Artifact Detection: Helps identify and remove eye movement artifacts from EEG recordings.
  • Sleep Studies: Used to monitor REM (Rapid Eye Movement) sleep and distinguish sleep stages.
  • Cognitive Research: Tracks eye movements during tasks involving visual attention or reading.

Detecting and Removing Eye Movement Artifacts with ICA

  1. Perform Independent Component Analysis (ICA)
  • Purpose: ICA decomposes the EEG signal into independent components (ICs), separating brain activity from artifacts (e.g., eye movements, muscle activity).
  1. Identify Eye Movement Components
  • Visual Inspection:
    • Plot the time series of each IC.
    • Look for components that resemble VEOG (vertical eye movements) or HEOG (horizontal eye movements):
      • VEOG: Large, slow deflections corresponding to blinks or vertical gaze shifts.
      • HEOG: Sharp deflections corresponding to left/right gaze shifts.
  • Frequency Characteristics:
    • Eye movement artifacts typically have low-frequency content (e.g., <4 Hz).
  1. Check Scalp Topography
  • Topographic Maps: Plot the scalp topography of each IC.
    • VEOG Components: Show maximal activity near the frontal/polar regions (e.g., Fp1, Fp2, F7, F8).
    • HEOG Components: Show maximal activity near the lateral frontal regions (e.g., F7, F8).
  • Example: If a component’s topography matches the typical distribution of EOG electrodes, it is likely an eye movement artifact.
  1. Remove Artifact Components
  • Exclude Components: Remove the ICs identified as eye movement artifacts from the EEG data.
  • Reconstruct EEG: Reconstruct the EEG signal without the artifactual components.

ECG Electrode

Electrode Locations

ECG electrodes are placed at the following positions to record heart activity during EEG studies:

  1. Under the Right Clavicle (R Clavicle):
  • Positioned just below the right collarbone.
  1. Left Midclavicular Line (Slightly Lower than R Clavicle):
  • Positioned on the left side of the chest, along the midclavicular line (imaginary vertical line through the midpoint of the clavicle).
  • Placed slightly lower than the right clavicle electrode.
  1. 5th Left Intercostal Space:
  • Positioned on the left side of the chest, in the 5th intercostal space (space between the 5th and 6th ribs).

Purpose

  • Heart Rate Monitoring: ECG electrodes record the electrical activity of the heart to monitor heart rate and rhythm.
  • Artifact Detection: Helps identify and remove cardiac artifacts (e.g., pulse artifacts) from EEG recordings.
  • Integration with EEG: Allows for the correlation of heart rate variability (HRV) with brain activity.

Picks and Clusters

Overview

Electrode clusters refer to groups of electrodes that are analyzed together to study specific brain regions or functions. Clustering helps improve signal-to-noise ratio, spatial resolution, and functional interpretation of EEG data.

Common Electrode Clusters

Electrode clusters are often defined based on brain regions or functional networks:

Cluster Name Electrodes (10/20 System) Brain Region/Function
Frontal Fp1, Fp2, F3, F4, F7, F8, Fz Frontal lobe: Executive function, attention, decision-making, and working memory.
Temporal T7, T8, F7, F8, FT9, FT10 Temporal lobe: Auditory processing, language, and memory.
Central C3, C4, Cz, FC1, FC2, FC5, FC6 Central region: Motor cortex, sensorimotor processing.
Parietal P3, P4, P7, P8, Pz, CP1, CP2, CP5, CP6 Parietal lobe: Spatial orientation, sensory integration, and attention.
Occipital O1, O2, Oz, PO3, PO4, PO7, PO8 Occipital lobe: Visual processing.
Midline Fz, Cz, Pz, Oz Midline structures: Default mode network, global brain states.
Fronto-Central F3, F4, C3, C4, FC3, FC4 Motor planning, cognitive control, and executive function.
Parieto-Occipital P3, P4, O1, O2, PO3, PO4 Visual-spatial integration and attention.

Get channel names by channels picks:

# left fronto-temporal
channel_pick(eeg,
             pick=[:l, :f, :t])
5-element Vector{String}:
 "Fp1"
 "F3"
 "F7"
 "T3"
 "T5"

Tip: Available picks: :central (:c), :left (:l), :right (:r), :frontal (:f), :temporal (:t), :parietal (:p), :occipital (:o).

Get channel names by channels cluster:

channel_cluster(eeg,
                cluster=:f1)
3-element Vector{String}:
 "Fp1"
 "F3"
 "F7"

Tip: Available channel clusters are :f1, :f2, :t1, :t2, :c1, :c2, :p1, :p2, :o1.

Purpose of Electrode Clusters

  • Regional Analysis: Focus on specific brain areas to study localized functions (e.g., visual processing in the occipital cluster).
  • Functional Networks: Investigate connectivity between brain regions (e.g., fronto-parietal networks for attention).
  • Artifact Reduction: Combine signals from multiple electrodes to reduce noise and improve signal quality.
  • Clinical Applications: Identify abnormal patterns in specific regions (e.g., epileptic activity in temporal clusters).

Electrode Positions in NeuroAnalyzer

Electrodes are positioned along X, Y and Z axes (Cartesian coordinates). The head center is at [0, 0, 0]. X axis is left-right, Y axis is back-front (the nose points towards +Y) and Z axis is bottom-top.

Electrode positions are stored in the OBJ.locs DataFrame. It contains the following columns:

  • labels: channel label
  • loc_theta: polar angle
  • loc_radius: polar radius
  • loc_x: Cartesian X
  • loc_y: Cartesian Y
  • loc_z: Cartesian Z
  • loc_radius_sph: spherical radius
  • loc_theta_sph: spherical horizontal angle
  • loc_phi_sph: spherical azimuth angle

Polar coordinates are used to plot electrodes at XY-plane, while spherical coordinates are used to plot electrodes at XZ- and YZ-planes and in 3D view (internally converted to X, Y and Z coordinates). Alternatively, Cartesian coordinates are used for all projections.

Head dimensions are calculated on the basis of head circumference. Head is modeled as the perfect sphere with its center at the axes origin. Electrode positioning is based on 10-20 International system. In this system, electrode positions are based on the head and nasion-inion distance. Compared with the 10-20 standard, NeuroAnalyzer electrode positions are slightly tilted forward, making the horizontal plane at the Fpz/T7/Oz/T8 level perpendicular to the ground level and placing Cz channel at the head center.

Tip: For the horizontal view the fiducial points are inion (IN), nasion (NAS), left and right preauricular area (LPA, RPA)

Tip: For the coronal view the fiducial points are left and right preauricular area (LPA, RPA).

Tip: For the sagittal view the fiducial points are inion (IN) and nasion (NAS).

Tip: In 19-channel systems, T7/T8 channels are sometimes labeled as T3/T4.

The position of fiducial EEG electrodes are:

  • Cz: [0, 0, 1]
  • Fz: [0, 1, 0]
  • T7: [-1, 0, 0]
  • T8: [1, 0, 0]
  • Oz: [0, -1, 0]

The position of the fiducial head points are defined as:

NeuroAnalyzer.fiducial_points
(nasion = (0.0, 1.03, -0.2), inion = (0.0, -1.03, -0.2), lpa = (-1.04, 0.2, -0.2), rpa = (1.04, 0.2, -0.2))

Spherical Head Model

Spherical Model Limitations

  • The spherical model is a simplified representation of the head surface and does not perfectly match the actual head shape.
  • Real Head Shape: The human head is asymmetrical and non-spherical, with variations in curvature and proportions.
  • Implications:
    • Electrode positions based on a spherical model may deviate slightly from actual positions on the scalp.
    • Despite this, the spherical model is widely used for standardization and ease of computation.

Visual Representations

Top View (XY-Plane):

  • Shows the distribution of electrodes on the top of the head.
  • Highlights the symmetry and spatial arrangement of electrodes.

Front View (YZ-Plane):

  • Displays the frontal region of the head.
  • Useful for visualizing electrodes placed on the forehead and frontal lobe.

Side View (XZ-Plane):

  • Shows the lateral view of the head.
  • Helps visualize electrodes on the temporal, parietal, and occipital regions.

NeuroAnalyzer Conventions for Imaging

Sagittal CT/MRI Images:

  • In standard sagittal CT/MRI images, the nose is typically directed to the left.
  • NeuroAnalyzer Convention: The nose points towards +Y (front of the head).
  • Image Flipping: To align with NeuroAnalyzer’s convention, sagittal images are always flipped horizontally so that the nose is directed to the right.

Practical Implications

  • Electrode Placement: While the spherical model is not perfect, it provides a consistent and reproducible method for electrode placement.
  • Data Interpretation: Understanding the limitations of the spherical model helps in accurately interpreting EEG data and spatial representations.
  • Visualization: Flipping images horizontally ensures consistency with NeuroAnalyzer’s coordinate system, aiding in accurate data visualization and analysis.

Supported Electrode Position File Formats

CED

  • Use Case: Commonly used in neuroscience research for storing electrode positions alongside neural data.
  • Features:
    • Supports 3D coordinates and channel labels.

LOCS (Electrode Locations File)

  • Format: Custom text-based format used in tools like EEGLAB.
  • Structure:
    • Columns: chan_label, X, Y, Z (Cartesian coordinates), and optionally sph_theta, sph_phi, sph_radius (spherical coordinates).

ELC (Electrode Location File)

  • Format: Text file format used by BrainVision Analyzer and other EEG software.
  • Structure:
    • Typically includes Label, X, Y, Z coordinates, and sometimes Type (e.g., EEG, EOG).
  • Use Case: Compatible with BrainVision’s analysis tools for electrode localization.

TSV (Tab-Separated Values)

  • Format: Generic tab-separated text file.
  • Structure:
    • Columns: label, x, y, z, and optionally additional metadata (e.g., theta, radius).
  • Use Case: Universal format for importing/exporting electrode positions across platforms.

SFP (Standardized Electrode Position File)

  • Format: Used in MNE-Python and FieldTrip.
  • Structure:
    • Columns: label, x, y, z (Cartesian coordinates), and optionally type (e.g., eeg, eog).
  • Use Case: Standardized format for high-density EEG and source localization.

CSD (Current Source Density)

  • Format: Used for Laplacian montages and current source density analysis.
  • Structure:
    • Includes label, x, y, z, and sometimes neighbors (for Laplacian calculations).
  • Use Case: Used in spatial filtering to enhance local activity in EEG data.

GEO (Geometry File)

  • Format: Used in BESA and other source imaging software.
  • Structure:
    • Columns: label, x, y, z, and optionally sphere_radius (for head model fitting).
  • Use Case: Used for source reconstruction and forward modeling.

MAT (MATLAB Format)

  • Format: MATLAB .mat file storing electrode positions as a structure or table.
  • Structure:
    • Variables: labels, X, Y, Z, and optionally theta, phi, radius.
  • Use Case: Used in MATLAB-based EEG toolboxes (e.g., EEGLAB, FieldTrip).

Loading Electrode Positions

import_locs() is a wrapper function that selects proper importing function based on file extension:

locs = import_locs("files/standard-10-20-cap19-elmiko.ced")
19×9 DataFrame
Row label loc_radius loc_theta loc_x loc_y loc_z loc_radius_sph loc_theta_sph loc_phi_sph
String Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64
1 Fp1 1.0 108.0 -0.31 0.95 -0.03 1.0 108.02 -1.72
2 Fp2 1.0 72.0 0.31 0.95 -0.03 1.0 71.98 -1.72
3 F7 1.0 144.0 -0.81 0.59 -0.03 1.0 144.04 -1.72
4 F3 0.65 129.0 -0.55 0.67 0.5 1.0 129.0 30.0
5 Fz 0.51 90.0 0.0 0.72 0.7 1.0 90.0 43.82
6 F4 0.65 51.0 0.55 0.67 0.5 1.0 51.0 30.0
7 F8 1.0 36.0 0.81 0.59 -0.03 1.0 35.96 -1.72
8 T3 1.0 180.0 -1.0 0.0 -0.03 1.0 180.0 -1.72
9 C3 0.51 180.0 -0.72 0.0 0.7 1.0 180.0 43.82
10 Cz 0.0 0.0 0.0 0.0 1.0 1.0 0.0 90.0
11 C4 0.51 0.0 0.72 0.0 0.7 1.0 0.0 43.82
12 T4 1.0 0.0 1.0 0.0 -0.03 1.0 0.0 -1.72
13 T5 1.0 216.0 -0.81 -0.59 -0.03 1.0 -144.04 -1.72
14 P3 0.65 231.0 -0.55 -0.67 0.5 1.0 -129.0 30.0
15 Pz 0.51 270.0 0.0 -0.72 0.7 1.0 -90.0 43.82
16 P4 0.65 309.0 0.55 -0.67 0.5 1.0 -51.0 30.0
17 T6 1.0 324.0 0.81 -0.59 -0.03 1.0 -35.96 -1.72
18 O1 1.0 252.0 -0.31 -0.95 -0.03 1.0 -108.02 -1.72
19 O2 1.0 288.0 0.31 -0.95 -0.03 1.0 -71.98 -1.72

Loading electrode positions in the CED format:

locs = import_locs_ced("files/standard-10-20-cap19-elmiko.ced")

Adding electrode positions to the NEURO object:

add_locs!(eeg, locs=locs)

Alternatively, loading electrode positions directly into existing NEURO object:

load_locs!(eeg, file_name="files/standard-10-20-cap19-elmiko.ced")

Plotting Electrode Positions

Preview electrodes:

plot_locs(locs,
          ch=1:19,
          grid=true,
          gui=false)

Tip: Grid is useful for placing electrodes manually.

Tip: IN: inion, NAS: nasion, RPA: right pre-auricular. LPA: left pre-auricular.

To select channels, use sch argument:

plot_locs(locs,
          ch=1:19,
          sch=[1, 2],
          head_labels=false,
          ch_labels=true,
          gui=false)

Previewing electrodes loaded into NEURO object:

plot_locs(eeg,
          ch="eeg",
          gui=false)

By default, for 2D plots, electrodes are placed using polar coordinates (planar theta and radius):

plot_locs(eeg,
          ch="eeg",
          cart=false,
          gui=false)

To use Cartesian (X, Y, Z) coordinates:

plot_locs(eeg,
          ch="eeg",
          cart=true,
          gui=false)

To plot a XZ plane (front, coronal):

plot_locs(eeg,
          ch="eeg",
          plane=:xz,
          gui=false)

To plot a YZ plane (side, sagittal):

plot_locs(eeg,
          ch="eeg",
          plane=:yz,
          gui=false)

To plot a small plot (e.g. to use it with another channels plot), use ps=:m or ps=:s option:

plot_locs(eeg,
          ch="eeg",
          sch="eeg",
          ps=:m,
          gui=false)

Tip: Channel labels are not shown if ps=:m or ps=:s.

Tip: Channel colors are consistent across various plot types.

Tip: It is recommended to disable channel labels for legibility.

Side view:

plot_locs(eeg,
          ch="eeg",
          ch_labels=false,
          plane=:yz)
Warning: Found `resolution` in the theme when creating a `Scene`. The `resolution` keyword for `Scene`s and `Figure`s has been deprecated. Use `Figure(; size = ...` or `Scene(; size = ...)` instead, which better reflects that this is a unitless size and not a pixel resolution. The key could also come from `set_theme!` calls or related theming functions.

@ Makie ~/.julia/packages/Makie/kJl0u/src/scenes.jl:264

Tip: It is recommended to disable channel labels for legibility.

To add locations plot locs to another plot:

ch = ["Fp1", "Fp2", "F3", "F4"]
p = NeuroAnalyzer.plot(eeg,
                       ch="eeg",
                       seg=(20, 30),
                       type=:butterfly,
                       avg=false,
                       gui=false)
pl = plot_locs(eeg,
               ch=ch,
               sch=ch,
               ps=:s,
               gui=false)
pp = add_pl(p, pl)
plot_save(pp,
          file_name = "images/add_pl.png")

Editing Electrode Positions

Viewing detailed electrode data:

locs_details(eeg,
             ch="Fp1")
  Label: Fp1
  Theta: 108.0 (polar)
 Radius: 1.0 (polar)
      X: -0.31 (spherical)
      Y: 0.95 (spherical)
      Z: -0.03 (spherical)
 Radius: 1.0 (spherical)
  Theta: 108.02 (spherical)
    Phi: -1.72 (spherical)
(label = "Fp1", theta_pl = 108.0, radius_pl = 1.0, x = -0.31, y = 0.95, z = -0.03, theta_sph = 108.02, radius_sph = 1.0, phi_sph = -1.72)

Editing electrode position:

edit_locs!(eeg,
           ch="eeg",
           x=-1.0)

Converting spherical to Cartesian coordinates:

locs_sph2cart!(locs)

Converting Cartesian to spherical coordinates:

locs_cart2sph!(locs)

Converting Cartesian to spherical coordinates:

locs_cart2sph!(locs)

Flipping axes (frontal channels should be at the top):

locs_flipx!(locs)
locs_flipy!(locs)

locs_flipy!(locs, planar=false)
locs_flipy!(locs, spherical=false)
locs_flipx!(locs, planar=false)
locs_flipx!(locs, spherical=false)

locs_flipz!(locs)

locs_swapxy!(locs)

Rotate=ing electrode locations:

# rotate around z axis
locs_rotz(locs, a=10)
# rotate around y axis
locs_roty(locs, a=10, cart=false)
# rotate around x axis
locs_rotx(locs, a=10, polar=false)

Tip: a specifies angle of rotation (in degrees). Positive angle rotates anti-clockwise.

Sometimes electrode locations may require scaling (polar radius value is being multiplied by the scaling factor):

locs_scale!(locs, r=1.2)

Alternatively locations may be maximized to a unit circle:

locs_maximize!(locs)

Save electrode positions (CED, LOCS and TSV format are supported), format will be selected based on the file name extension:

locs_export(eeg,
            file_name="files/standard-10-20-cap19-elmiko.locs")
locs_export(locs,
            file_name="files/standard-10-20-cap19-elmiko.ced")
locs_export(locs,
            file_name="files/standard-10-20-cap19-elmiko.tsv")

3-D Preview

Previewing electrodes in 3-D:

p = plot_locs3d(eeg,
                ch="eeg",
                sch=["Fp1", "Fp2"],
                gui=false)
plot_save(p, file_name="images/plot_locs3d.png")

Tip: If gui parameter is true, the plot window is interactive; otherwise is just returns the rendered plot.

When interactive: you can rotate the view by left-clicking and dragging, span the view by right-clicking and dragging and zoom using the mouse wheel.

Keyboard shortcuts:

  • t: top view
  • r: right view
  • l: left view
  • f: front view
  • b: back view
  • Home: reset the view
  • s: save the view as PNG image

Tip: By default, for 3D plots, electrodes are placed using Cartesian coordinates (x, y and z).

Drawing brain mesh together with electrode positions:

p = plot_locs3d(eeg,
            ch="eeg",
            sch=["Fp1", "Fp2"],
            mesh_type=:brain,
            gui=false)
plot_save(p, file_name="images/locs_brain.png")

p = plot_locs3d(eeg,
            ch="eeg",
            sch=["Fp1", "Fp2"],
            mesh_type=:head,
            gui=false)
plot_save(p, file_name="images/locs_head.png")

Tip: Mesh opacity can be set using mesh_alpha parameter, ranging from 1 (no opacity) to 0 (complete opacity).

Tip: The cam parameter sets initial camera position: first parameter is elevation, second - azimuth (both in degrees).

Interactive Channels and Locations Editor

iedit(eeg)

For each channel, its label (e.g. “Fp1”), type (e.g. “eeg”) and units (e.g. “μV”) may be modified.

Also, electrode positions may be manually edit per each channel: polar radius and theta, Cartesian X, Y, Z and spherical radius, theta and phi coordinates may be entered in appropriate fields. Changes are automatically previewed in 4 views: top, front, side and 3D.

A set of transformations may be also applied to the whole locations set: flip over X/Y/Z axis, Swap X and Y axes, rotate around X/Y/Z axis, scale by a factor, normalize to a unit sphere. Each transformation is applied to selected set of coordinates (polar, Cartesian and spherical.)

Set of coordinates used for plotting is selected with the “Plot using Cartesian coordinates” switch: when off - polar coordinates are used for the top projection and spherical coordinates for the frontal, side and 3D projections; when on - Cartesian coordinates are used for all projections.

Also, coordinates may be transformed between projections (Cartesian → polar, Cartesian → spherical, polar → Cartesian, polar → spherical, spherical → Cartesian, spherical → polar).

All changes are done to a temporary object, use the “Apply” button to apply changes to the input object.

Tip: Since :eog and :ref channels are usually placed at fixed positions, they are not affected by transformations.