NeuroAnalyzer tutorials: Analyze EEG (3)

Load data:

using NeuroAnalyzer
using Plots
eeg = load("files/eeg.hdf");
[ Info: Loaded: EEG (24 × 308480 × 1; 1204.996 s)

Often it is required to analyze only a segment of data, e.g. part of the spectrogram or topographical map.

First, a matrix data has to be prepared, e.g.:

# get locs from the EEG object
locs = eeg.locs
# data at 2560 sample across 19 channels
s = eeg.data[1:19, 2560, 1]
# prepare planar interpolation
z, x, y = NeuroAnalyzer._interpolate2d(s, locs[1:19, :loc_x], locs[1:19, :loc_y], 100, :sh, :minmax)
# preview
Plots.heatmap(x, y, z)

A segment of interest can be extracted:

iselect_seg(z)

(!) Place the selection corners using left clicks. Middle click undoes the last action. Press Enter when ready or ctrl-q to cancel and close the window.

(35, 37, 63, 63)

These are coordinates of the left upper corner (row and column) and bottom right corner (row and column) of the segment.

To select a circular segment, use shape=:c parameter:

iselect_seg(z, shape=:c)

For circular segment coordinates are: center (row and column) and peripheral point (row and column).

Extract the segment data:

seg_extract(z, seg)
29×27 Matrix{Float64}:
 0.449312  …  0.488266
 ⋮         ⋱  ⋮         
 0.640943     0.659986

If you need the segment to be extracted as a vector, use the v=true parameter.

seg_extract(z, seg, v=true)
783-element Vector{Float64}:
 0.44931180669912063
 ⋮
 0.6177368628322506

If segment is circular, use shape=:c parameter when extracting:

seg_extract(z, seg, shape=:c)

(!) Circular segments are always returned as vectors.

Alternatively, use iselect_seg() with extract=true parameter.

iselect(z, extract=true, v=true)

or combine these two functions:

seg_extract(z, iselect_seg(z))