NeuroAnalyzer tutorials: Edit EEG (3)

Detect bad channels and epochs:

bad_m, bad_epochs = detect_bad(e10, method=[:flat, :p2p, :var])
p = plot(e10, ch=1:19, ep=2, bad=bad_m)
plot_save(p, file_name="images/bad_epoch.png")
delete_epoch!(e10, ep=bad_epochs)

See detect_bad() for the list of available methods and parameters use to tune auto-detection.

Remove parts of the signal:

plot(e10, ep=1)
# remove one second
trim!(e10, segment=(1, 1*sr(e10)), keep_epochs=false)
# plot again
plot(e10, ep=1)

plot(e10, ep=2)
# remove segment [16, 17] s
trim!(e10, segment=(16, 17), keep_epochs=false)

Interpolate bad channels 1, 4, 6 in all epochs using planar interpolation:

e10pl = plinterpolate_channel(e10, ch=[1, 4, 6], ep=1:epoch_n(e10))
plot([1, :, 1])
plot!([1, :, 1])

(!) Planar interpolation requires electrode locations. Multiple channels may be interpolated at the same time.

Interpolate channel 1 in epochs 12, 15, 22 using linear regression:

e10lr = lrinterpolate_channel(e10, ch=1, ep=[12, 15, 22])
plot([1, :, 12])
plot!([1, :, 12])

(!) Linear regression interpolation requires ≥ 1 epoch of good signal in interpolated channel, as linear regressor is trained using good epochs. The more epochs with good signal, the better interpolation results. Only single channel may be interpolated at the same time.