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.:
# data at 2560 sample across 19 channels
= eeg.data[1:19, 2560, 1]
s # prepare planar interpolation
= plinterpolate(s, locs=locs, ch=1:19)
z, x, y # preview
heatmap(x, y, z) Plots.
Next, a segment of interest has to be extracted:
= iselect_seg(z) seg
(!) 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.
Output:
(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) seg
For circular segment coordinates are: center (row and column) and peripheral point (row and column).
To extract the segment data:
= seg_extract(z, seg) m
Output:
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) v
Output:
783-element Vector{Float64}:
0.44931180669912063
⋮
0.6177368628322506
If segment is circular, use shape=:c
parameter when
extracting:
= seg_extract(z, seg, shape=:c) m
(!) Circular segments are always returned as vectors.
Alternatively, use iselect_seg()
with
extract=true
parameter.
= iselect(z, extract=true, v=true) seg
or combine these two functions:
= seg_extract(z, iselect_seg(z)) seg