NeuroAnalyzer tutorials: Process EEG (4)

Electrode pops: these are gradual change of the amplitude, than rapid changes of amplitude, followed by gradual change of the amplitude. Here are examples of two pops:

To remove pops:

remove_pops!(eeg)                      # all channels
remove_pops!(eeg, ch=3, repair=false)  # do not repair, just detect
remove_pops!(eeg, window=2.0)          # use 2-second window
remove_pops!(eeg, r=10)                # use 10-sample detection segments

(!) remove_pops() and remove_pops!() must be applied to a continuous (non-epoched signal).

(!) It is recommended do demean (remove_dc()) the signal prior to removing pops.

The same segment after removal:

remove_pops() and remove_pops!() return the list of detected pops:

eeg_new, pl, ls, rs = remove_pops(eeg)

pl contains the list of pop locations: [channel, sample number]. ls and rs are the list of segments lengths before and after the pop that start at zero-crossing. Repairs are done within these segments. Using these segments we may visualize the pop:

pl[1][1] # channel
pl[1][2] # pop locations
s = eeg.data[pl[1][1], (pl[1][2] - 400):(pl[1][2] + 400), 1]
p = Plots.plot(s, legend=false)
Plots.vline!([400], ls=:dot)
Plots.plot!([399, (399 - ls[1])], [0, 0], lc=:black)
Plots.plot!([401, (401 + rs[1])], [0, 0], lc=:black)
plot_save(p, file_name="images/pop_example.png")

s = eeg_new.data[pl[1][1], (pl[1][2] - 400):(pl[1][2] + 400), 1]
p = Plots.plot(s, legend=false)
Plots.vline!([400], ls=:dot)
Plots.plot!([399, (399 - ls[1])], [0, 0], lc=:black)
Plots.plot!([401, (401 + rs[1])], [0, 0], lc=:black)
plot_save(p, file_name="images/pop_repaired_example.png")