using NeuroAnalyzer
using Plots
eeg = load("files/eeg.hdf");NeuroAnalyzer tutorials: Calculate and plot PSD slope
Load data:
Calculate PSD data using Welch periodogram:
p, f = psd(eeg, ch="all", db=true)(p = [19.072115171958426 18.477655517286436 … -19.05177477622109 -22.059516911184026; 18.1492822860229 17.86233437201902 … -18.972406450309784 -21.983182581810844; … ; 20.30503678721386 19.89942102519797 … -16.58692218545011 -19.602239724621178; 26.119689962454476 29.21800948676856 … -11.057574156312082 -14.07784239749047;;;],
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, ps, frq = psd_slope(eeg, ch="Fp1", frq_lim=(8, 14), db=true)(lf = [-4.308386220222163 -4.752628776771912 … -6.529599002970912 -6.973841559520661;;;],
ls = [-0.4442425565497494;;],
pf = [8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0],)