NeuroAnalyzer tutorials: Loading electrode positions

The following electrode locations are supported:

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:

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.

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

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

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

(!) In 19-channel systems, T7/T8 channels are sometimes labeled as T3/T4.

The position of fiducial EEG electrodes are:

The position of the fiducial head points are:

Of course, as seen below, the spherical model is not the perfect representation of the head surface.

(!) Please note that in sagittal CT/MRI images, the nose is directed to the left. Due to the NeuroAnalyzer convention (the nose points towards +Y), these images are always flipped horizontally, so that the nose is directed to the right.

Loading electrode positions

Load electrode positions:

# a wrapper function selecting proper import based on file extension
locs = import_locs("locs/standard-10-20-cap19-elmiko.ced")
# load LOCS format
locs = import_locs_ced("locs/standard-10-20-cap19-elmiko.ced")

Add electrode positions to EEG object:

add_locs!(eeg, locs=locs)

Load electrode positions directly into EEG object:

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

Plotting electrode positions

Preview electrodes:

p = plot_locs(locs, ch=1, grid=true)
plot_save(p, file_name="images/locs_1.png")

(!) Grid is useful for placing electrodes manually.

(!) IN: inion, NAS: nasion, RPA: right pre-auricular. LPA: left pre-auricular.

p = plot_locs(locs, ch=1:19, selected=1:2, head_labels=false, ch_labels=true)
plot_save(p, file_name="images/locs_19.png")

Also, electrodes loaded into EEG object may be previewed:

plot_locs(eeg, ch=1)

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

p = plot_locs(eeg, cart=false)
plot_save(p, file_name="images/locs_polar.png")

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

p = plot_locs(eeg, cart=true)
plot_save(p, file_name="images/locs_cartesian.png")

To plot a XZ plane (front, coronal):

p = plot_locs(eeg, plane=:xz)
plot_save(p, file_name="images/locs_xz.png")

To plot a YZ plane (side, sagittal):

p = plot_locs(eeg, plane=:yz)
plot_save(p, file_name="images/locs_yz.png")

To plot a small plot (e.g. to use it with another channels plot), use the large=false option:

p = plot_locs(eeg, selected=1:19, large=false)
plot_save(p, file_name="images/locs_small.png")

(!) Channel labels are not shown if large=false.

(!) Channel colors are consistent across various plot types.

To add locations plot locs to another plot:

p1 = plot(eeg, ch=1:4)
p2 = plot_locs(eeg, ch=1:4, selected=1:4, large=false, transparent=true)
add_plot_locs(p1, p2, file_name="images/add_locs.png")

(!) If the file_name is not provided, the output image is opened in the interactive viewer (iview_plot()).

(!) If you need to save the image to a variable for further processing, set the file_name="" and view=false:

c = add_plot_locs(p1, p2, file_name="", view=false)
iview_plot(c)

Viewing and editing electrode positions

View electrode data:

locs_details(eeg, ch=1)

Edit electrode position:

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

Convert spherical to Cartesian coordinates:

locs_sph2cart!(locs)

Convert Cartesian to spherical coordinates:

locs_cart2sph!(locs)

Convert Cartesian to spherical coordinates:

locs_cart2sph!(locs)

Flip or swap 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 electrode locations:

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

(!) 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="locs/standard-10-20-cap19-elmiko.locs")
locs_export(locs, file_name="locs/standard-10-20-cap19-elmiko.ced")
locs_export(locs, file_name="locs/standard-10-20-cap19-elmiko.tsv")

3D preview

Preview electrodes in 3D:

p = plot_locs3d(locs, d=3, interactive=false, selected=1:2)
p = plot_locs(eeg, selected=1:4, d=3, interactive=false)
plot_save(p, file_name="images/locs3d.png")

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

To plot using spherical coordinates (radius, theta and phi):

p = plot_locs3d(locs, cart=false)
plot_save(p, file_name="images/locs3d_sph.png")

To use interactive plot:

plot_locs(eeg, selected=1:2, d=3, interactive=true)
iplot_locs3d(locs, selected=1:2)

(!) Hold the left mouse button and move mouse to rotate the view.

(!) Press the right mouse button to reset the view.

(!) Press t for top view, s for side view and f for front view.

(!) Press ctrl-q to close the window.

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.

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