Analyze Segments

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

Often it is required to analyze only a segment of data, e.g. part of a spectrogram or topographical map region. seg_select() helps selecting regions of the matrix data.

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
plot_heatmap(z; x = x, y = y)

A segment of interest can be extracted, default shape is rectangular.

seg_select(z)

Tip: Place the selection corners using left clicks. Right click undoes the last action. Press Enter when ready or close the window to cancel.

(1, 21, 26, 48)

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:

seg_select(z; shape = :c)

Click left mouse button to place the selection center and use mouse wheel to size the selection up and down.

Tip: Circular segments are always returned as vectors.

(40, 88, 50, 98)

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

Extract the segment data:

seg = (1, 21, 26, 48)
seg_extract(z, seg)
26×28 Matrix{Float64}:
 0.368982  …  0.280894
 ⋮         ⋱  ⋮       
 0.607025     0.181195

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

seg_extract(z, seg; v = true)
728-element Vector{Float64}:
 0.36898150531802143
 ⋮
 0.1811948283805509

Extracting circular segment (will always be returned as a vector):

seg = (40, 88, 50, 98)
seg_extract(z, seg; c = true)
617-element Vector{Float64}:
 0.12405041789935467
 ⋮
 0.06729477499820313