NeuroAnalyzer tutorials: Stationarity

Load data:

using NeuroAnalyzer
using Plots
eeg = load("files/eeg.hdf");
e10 = epoch(eeg, ep_len=10);
[ Info: Loaded: EEG (24 × 282991 × 1; 1105.43 s)

There are several types of stationarity tests available in NeuroAnalyzer.

To test mean stationarity:

s_m = stationarity(e10, ch="eeg", method=:mean, window=256)
Plots.plot(s_m[1, :, 1], xlabel="time-window points", label="channel 1, epoch 1")

To test variance stationarity:

s_v = stationarity(e10, ch="eeg", method=:var, window=256)
Plots.plot(s_v[1, :, 1], xlabel="time-window points", label="channel 1, epoch 1")

To test phase stationarity using Hilbert transformation:

s_p = stationarity(e10, ch="eeg", method=:hilbert, window=256)
Plots.plot(eeg.epoch_time[1:end-1], s_p[1, :, 1], xlabel="epoch time [s]", label="channel 1, epoch 1", legend=:topright)

To test covariance stationarity based on Euclidean distance between covariance matrix of adjacent time windows:

s_c = stationarity(e10, ch="eeg", method=:cov, window=256)
Plots.plot(s_c[:, 15], label="epoch 15", ylabel="distance between covariance matrices", xlabel="time-window segment", legend=:topright)

To test phase stationarity using Augmented Dickey–Fuller test:

s_adf = stationarity(e10, ch="eeg", method=:adf, window=256)
s_adf[12, :, 1]
2-element Vector{Float64}:
 -3.13
  0.0017

The output is ADF = -3.99 and p = 0.0015, meaning that channel 12, epoch 1 signal is stationary.