usingNeuroAnalyzerusingCairoMakieCairoMakie.activate!(type="png")# Quarto sets a default figure size (672 × 480 px), which overrides the sizes of# NeuroAnalyzer figures: remove itdelete!(CairoMakie.Makie.CURRENT_DEFAULT_THEME, :resolution)# remove the default figure size set by Quarto in the Makie theme:# NeuroAnalyzer plots set their own sizeset_theme!()eeg =load_neuro("files/eeg/eeg.hdf")# standard 10/5 positions (2-D layout)std_locs =import_locs("files/locs/standard_1005_2D.tsv")
Brain Region
Each electrode label starts with one or two letters naming the brain region under the electrode:
Fp: pre-frontal (frontopolar)
F: frontal
T: temporal
C: central (over the sensorimotor cortex)
P: parietal
O: occipital
Midline Electrodes
z (“zero”): electrodes on the midline (sagittal plane) of the head, e.g. Fpz, Fz, Cz, Pz, Oz.
Midline electrodes are often used as reference or ground sites and for comparing the two hemispheres.
Left and Right Hemisphere
Odd numbers (1, 3, 5, 7, 9): electrodes over the left hemisphere.
Even numbers (2, 4, 6, 8, 10): electrodes over the right hemisphere.
Numbers increase with the distance from the midline (e.g. C1 is close to Cz, C5 is close to T7).
The same rule is used for EOG electrodes (e.g. EOG1 left, EOG2 right).
Other Electrodes
A1 and A2: on the earlobes (auricular).
M1 and M2: on the mastoid processes (the bone behind the ear).
Both pairs are used as reference electrodes; they also pick up mid-temporal activity of the ipsilateral hemisphere. The mastoid process is less prominent in children and some adults.
Chin (EMG) electrodes: usually labeled Left, Right and Reference/Common; they record muscle activity (e.g. in sleep studies).
The 10/20 System
Standard layout: 21 electrodes: 19 scalp electrodes and 2 earlobe reference electrodes (A1, A2).
10/20 rule: electrodes are placed at 10% or 20% intervals of the distances between anatomical landmarks: nasion to inion (front to back) and left to right preauricular point (through the vertex).
Purpose: consistent, reproducible electrode placement across subjects, independent of the head size.
The 19 scalp electrodes of the 10/20 system (modern names, see below):
The Modified Combinatorial Nomenclature (MCN) extends the 10/20 system with intermediate electrode sites and makes the electrode names consistent. It allows a higher spatial resolution of EEG recordings.
New Letter Codes
Intermediate rows between the 10/20 rows are named by combining the letters of the neighboring rows:
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
Numbers
Numbers give the position along a row, counted from the midline: in the 10/10 system, consecutive electrodes are 10% of the coronal (left-right) arc apart, e.g. C1, C3, C5 and T7 lie 10%, 20%, 30% and 40% to the left of Cz.
Renamed Electrodes
All electrodes of the same coronal line get the same letter, so four 10/20 electrodes are renamed:
T3 → T7
T4 → T8
T5 → P7
T6 → P8
Tip: In 19-channel systems, the old names (T3, T4, T5, T6) are still common.
High-Resolution Systems
10/10 System
Electrodes: about 70-80 positions (compared with 21 in the 10/20 system).
Placement: 10% divisions: intermediate sites halfway between the 10/20 electrodes (Chatrian et al., 1985; American Clinical Neurophysiology Society guidelines).
The 10/10 electrodes (without the inferior row: F9, FT9, T9, TP9, P9 and their right-side counterparts, placed below the level of T7/T8):
Artifact detection: identifying and removing eye movement artifacts from the EEG, e.g. using ICA (see ICA): eye movement components have large, slow (< 4 Hz) deflections and a frontal topography (VEOG: Fp1, Fp2; HEOG: F7, F8 with opposite polarities).
Sleep studies: monitoring REM (rapid eye movement) sleep and scoring sleep stages.
Cognitive research: tracking eye movements during tasks involving visual attention or reading.
ECG Electrodes
Placement
ECG electrodes record the heart activity during EEG studies, e.g.:
Under the right clavicle (just below the right collarbone).
Left midclavicular line, slightly lower than the right clavicle electrode.
5th left intercostal space (between the 5th and 6th ribs).
Purpose
Heart rate monitoring: heart rate and rhythm.
Artifact detection: identifying and removing cardiac artifacts (e.g. pulse artifacts) from the EEG.
Integration with EEG: correlating heart rate variability (HRV) with brain activity.
Picks and Clusters
Electrode clusters are groups of electrodes analyzed together to study a brain region or function. Averaging over a cluster improves the signal-to-noise ratio and simplifies the functional interpretation.
Common Electrode Clusters
Cluster
Electrodes (10/20 and 10/10)
Brain Region / Function
Frontal
Fp1, Fp2, F3, F4, F7, F8, Fz
Frontal lobe: executive function, attention, decision-making, working memory
Regional analysis: localized functions (e.g. visual processing in the occipital cluster).
Functional networks: connectivity between brain regions (e.g. fronto-parietal networks of attention).
Noise reduction: combining signals of neighboring electrodes reduces noise.
Clinical applications: abnormal patterns in specific regions (e.g. epileptic activity in the temporal clusters).
Electrode Positions in NeuroAnalyzer
Coordinate System
Electrodes are positioned along the X, Y and Z axes (Cartesian coordinates). The head center is at [0, 0, 0]. The X axis runs from left to right, the Y axis from back to front (the nose points towards +Y) and the Z axis from bottom to top.
Electrode positions are stored in the OBJ.locs DataFrame, with the columns:
label: 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 (elevation)
first(eeg.locs, 5)
5×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
F3
0.65
129.0
-0.55
0.67
0.5
1.0
129.0
30.0
4
F4
0.65
51.0
0.55
0.67
0.5
1.0
51.0
30.0
5
C3
0.51
180.0
-0.72
0.0
0.7
1.0
180.0
43.82
Tip: The example recording stores positions already scaled to the unit sphere.
By default, plots use the polar coordinates for the top (XY) view and the spherical coordinates for the front (XZ), side (YZ) and 3-D views (converted internally to X, Y and Z). With cart = true, the Cartesian coordinates are used for all views.
Units
Electrode positions are stored as they are in the source file, in its original units (e.g. mm, cm or m; FIFF positions are in meters). Importing only converts the axes orientation to the NeuroAnalyzer convention (nose towards +Y); it does not scale the coordinates. Positions are never modified by functions that only use them.
Functions that need positions on a unit sphere scale a temporary copy of the whole montage, so that the outermost electrode is at radius 1:
plots (plot_locs(), plot_locs3d(), plot_topo(), topographic layouts of plot_psd(), plot_erp(), etc.),
Spherical splines (sphinterpolate(), csd()), the surface Laplacian reference (reference_slap()) and REST (reference_rest()) project the positions on the unit sphere themselves, so they also work with any units.
For example, the positions in this GEO file are in millimeters:
geo =import_locs("files/locs/EEG10-10_UI_Jurak_2007.geo")r =sqrt.(geo.loc_x .^2.+ geo.loc_y .^2.+ geo.loc_z .^2)println("Electrodes: ", size(geo, 1))println("Largest distance from the origin: ", round(maximum(r); digits =1))
Electrodes: 80
Largest distance from the origin: 119.5
They are plotted without any conversion:
plot_locs(geo; ch_labels =false, gui =false)
To scale the positions explicitly (polar, Cartesian and spherical radius equal to 1 for the outermost electrode), use locs_normalize():
geo_n =locs_normalize(geo)r =sqrt.(geo_n.loc_x .^2.+ geo_n.loc_y .^2.+ geo_n.loc_z .^2)println("Largest distance from the origin: ", round(maximum(r); digits =1))
Largest distance from the origin: 1.0
Tip: Keep the original units if physical distances are needed: e.g. od2conc() (with partial path length factors ≠ 1) uses the source-detector distances in mm and dipole_fit() expects positions in mm (loc_scale = 1e-3). Normalized positions give wrong results in such computations.
Head Dimensions
The head is modeled as a sphere with its center at the axes origin. Electrode positions follow the 10-20 International system, based on the nasion-inion and the left-right preauricular distances. Compared with the 10-20 standard, NeuroAnalyzer electrode positions are slightly tilted forward: the horizontal plane at the Fpz/T7/Oz/T8 level is parallel to the ground and the Cz electrode is at the top of the head.
Tip: For the horizontal (top) view, the fiducial points are the inion (IN), nasion (NAS), left and right preauricular points (LPA, RPA).
Tip: For the coronal (front) view, the fiducial points are the left and right preauricular points (LPA, RPA).
Tip: For the sagittal (side) view, the fiducial points are the inion (IN) and nasion (NAS).
On the unit sphere, the landmark electrodes are at:
The spherical model is a simplified representation of the head and does not perfectly match the real head shape, which is asymmetrical and non-spherical.
Electrode positions based on the spherical model may deviate slightly from the real positions on the scalp.
Despite this, the spherical model is widely used for standardization and ease of computation.
Views
Top view (XY plane): the distribution of electrodes on the top of the head, their symmetry and spatial arrangement.
Front view (XZ plane, coronal): electrodes over the frontal region and both hemispheres.
Side view (YZ plane, sagittal): electrodes over the frontal, central, parietal and occipital regions along the midline.
Imaging Convention
In standard sagittal CT/MRI images, the nose is directed to the left.
In NeuroAnalyzer, the nose points towards +Y, so sagittal images are flipped horizontally (the nose is directed to the right).
Supported File Formats
import_locs() selects the importing function based on the file extension:
Extension
Function
Source
Coordinates
.ced
import_locs_ced()
EEGLAB
polar, Cartesian and spherical
.locs
import_locs_locs()
EEGLAB
polar
.elc
import_locs_elc()
ASA / ANT Neuro, EETrak
Cartesian
.tsv
import_locs_tsv()
BIDS electrodes.tsv (name, x, y, z)
Cartesian
.sfp
import_locs_sfp()
BESA / EGI
Cartesian
.csd
import_locs_csd()
CSD toolbox
spherical and Cartesian
.geo
import_locs_geo()
EGI GeoScan
Cartesian
.mat
import_locs_mat()
MATLAB 2-D layout (Cpos, Cnames)
2-D Cartesian
.txt
import_locs_txt()
spherical theta/phi list (e.g. BioSemi)
spherical
.dat
import_locs_dat()
Neuroscan
Cartesian
.asc
import_locs_asc()
Neuroscan
Cartesian
.csv
import_locs_csv()
NeuroAnalyzer
all
.fif
import_locs_fiff()
MNE / Elekta (MEG and EEG)
Cartesian (m)
Tip: FIFF locations are read using import_locs_fiff() (not via import_locs()); import_fiff() loads them together with the data.
If a file contains one coordinate set only, the other sets are calculated from it (e.g. polar and spherical from Cartesian).
Typical Workflow
Import the locations file: locs = import_locs(file_name).
Check the orientation: plot_locs(locs) should show the frontal electrodes at the top (nose) and the left hemisphere on the left.
If needed, fix the orientation: flip (locs_flipx!(), locs_flipy!()), swap the axes (locs_swapxy!()) or rotate (locs_rotz!()).
Add the positions to the recording: add_locs!(eeg; locs = locs) (matched by channel labels).
Check the result: plot_locs(eeg; ch = "eeg"), or open the interactive editor: edit_locs!(eeg).
Tip: The polar, cart and spherical arguments select the coordinate sets that are modified, e.g. locs_flipy!(locs; polar = false) keeps the polar coordinates.
Rotating electrode locations:
# rotate around the Z axislocs_rotz!(locs; a =10)# rotate around the Y axis, keep the Cartesian coordinateslocs_roty!(locs; a =10, cart =false)# rotate around the X axis, keep the polar coordinateslocs_rotx!(locs; a =10, polar =false)
Tip:a is the rotation angle in degrees; a positive angle rotates anti-clockwise around the X and Z axes and clockwise around the Y axis.
Scaling (radius multiplied by the scaling factor):
locs_scale!(locs; r =1.2)
Normalizing the positions to the unit sphere:
locs_normalize!(locs)
Centering the positions at the origin, or moving the origin (the shift is in the units of the positions):
locs_center!(locs)locs_origin!(locs; z =-0.1)
Generating standard 10/10 positions for channels with known labels:
locs_generate!(locs)
Saving electrode positions (CED, LOCS and TSV formats; CSV for NEURO objects only); the format is selected by the file name extension:
Tip: The mesh opacity is set using the mesh_alpha argument, from 1 (opaque) to 0 (transparent).
Tip: The cam argument sets the initial camera position: elevation and azimuth (in degrees).
Interactive Channels and Locations Editor
Called without ch, edit_locs() opens the interactive editor (EEG and MEG objects):
# edit in-place: changes are written to eeg after clicking "Apply"edit_locs!(eeg)# or edit a copy: returns the edited object (unchanged if cancelled)eeg_new =edit_locs(eeg)
The window opens maximized. The current channel is shown in red in 4 views: top (X-Y), front (X-Z), side (Y-Z) and 3-D.
Selecting a channel: choose it from the list, step through the channels using the ◄ / ► buttons, or click its electrode in one of the 2-D views.
Channel properties: the label, type (e.g. “eeg”) and unit (e.g. “μV”) of the current channel. Changing the type sets the default unit of that type.
Coordinates: the Cartesian (X, Y, Z), spherical (radius, θ, φ) and polar (radius, θ) coordinates of the current channel are shown and edited as stored, in their original units. A typed value is applied after pressing Enter or leaving the field. A channel without a location gets one when any of its coordinates is entered.
Transformations of all locations: flip over the X/Y/Z axis, swap the X and Y axes, center, rotate around the X/Y/Z axis (angle in degrees), scale by a factor, normalize to the unit sphere, move the origin along the X/Y/Z axis, convert between the coordinate sets and generate standard 10/10 positions. The “Apply to” check boxes select the coordinate sets (polar, Cartesian, spherical) modified by flipping, swapping, centering, rotating, scaling and normalizing.
Tip:ref and eog channels are usually placed at fixed positions, so they are not affected by the transformations (except for the conversions and generating the 10/10 positions).
Undo: every change of the locations can be undone (up to 50 steps).
File: enter a file path to load locations from a file (any supported format) or to save them (CED, LOCS, TSV or CSV; saving over an existing file requires a second click).
View: the “Cartesian coordinates” switch selects the coordinates used for plotting: when on, the Cartesian coordinates are used for all views; when off, the polar coordinates are used for the top view and the spherical coordinates for the front, side and 3-D views. Channel labels may be shown in all views.
Delete channel removes the current channel (a second click confirms); deleting clears the undo history.
All changes are made to a copy of the object: click “Apply” to keep them, or “Cancel” (or close the window) to discard them.
Tip: Numeric fields accept numbers only.
10/20 Channels on a Grid
A simplified layout of the 10/20 channels on a grid:
fig =plot_gridlocs()
It is possible to draw over that template:
CairoMakie.scatter!(fig[1, 1],0, 0; markersize =50, color =:red, alpha =0.5)fig