NeuroAnalyzer tutorials: Analyze: Calculate and plot PSD slope

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

Calculate PSD data using Welch periodogram:

p, f = psd(eeg,
           ch="all",
           db=true)
(p = [20.86097649400893 20.02139238914571 … -18.324266687815015 -21.33493908532894; 38.74691493371749 37.66242118737642 … -6.50338653053586 -9.523458648290768; … ; 24.06325908691505 23.064973511708736 … -15.382080883383951 -18.396491485933446; 27.168062206841892 29.421512664301837 … -10.642427378126493 -13.664957578924732;;;],
 f = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0  …  119.0, 120.0, 121.0, 122.0, 123.0, 124.0, 125.0, 126.0, 127.0, 128.0],)

Draw scatter plot of PSD data, channel 1 (Fp1):

scatter(f,
        p[1, :],
        ms=1,
        legend=false)

Calculate and plot PSD slope:

lf, ls, pf = psd_slope(eeg,
                       ch="Fp1",
                       db=true)
Plots.plot!(pf,
            lf[1, :, 1],
            title="slope = $(round(ls[1, 1], digits=2))")

Calculate PSD slope of the alpha band:

f, p, f = psd_slope(eeg,
                    ch="Fp1",
                    frq_lim=(8, 14),
                    db=true)
(lf = [-3.283325493363775 -3.8007687545386304 … -5.870541799238049 -6.3879850604129045;;;],
 ls = [-0.5174432611748552;;],
 pf = [8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0],)