Initialize NeuroAnalyzer
using NeuroAnalyzer
using Plots
eeg = load("files/eeg.hdf")
e10 = epoch(eeg, ep_len = 10)using NeuroAnalyzer
using Plots
eeg = load("files/eeg.hdf")
e10 = epoch(eeg, ep_len = 10)Amplitude Envelope Correlation (AEC) measures the correlation between the envelopes of two signals (e.g., Hilbert-transformed signals).
Formula:
\[ \text{AEC} = \text{corr}(A_1(t), A_2(t)) \]
where \(A_1(t)\) and \(A_2(t)\) are the amplitude envelopes of the two signals.
Interpretation:
Use Case: Studying co-activation of brain regions in specific frequency bands.
Limitations:
ep = 1
aec = aecor(e10,
e10,
ch1 = "Fp1",
ch2 = "Fp2",
ep1 = ep,
ep2 = ep)
println("AEC: $(aec[1])")AEC: 0.1485864621741476
Tip: aecor() uses the Hilbert transform to calculate instantaneous amplitudes, therefore the signal should be narrowband prior the analysis.
Another approach is to use env_cor(), which provides the p-value for the correlation test.
Calculating upper envelopes for channels “Fp1”, epoch 1 and “Fp2”, epoch 2:
ep = 1
ch1_data = e10.data[get_channel(e10, ch = "Fp1")[1], :, ep]
ch2_data = e10.data[get_channel(e10, ch = "Fp2")[1], :, ep]
env1 = env_up(ch1_data, e10.epoch_time)
env2 = env_up(ch2_data, e10.epoch_time)Calculating Envelope Correlation:
ec_data = env_cor(reshape(env1, 1, :, 1),
reshape(env2, 1, :, 1))
println("EC: $(ec_data.ec[1]), p: $(ec_data.p[1])")EC: 0.038233081217970685, p: 0.053086047967827864
Tip: envelopes must be provided as arrays of shape (channels, samples, epochs).
Envelope-to-Signal Correlation (ESC) is similar to AEC, but the the amplitude of the first signal is signed; and thus the phase information is preserved.
\[ \text{ESC} = \text{corr}(S_1(t), A_2(t)) \]
where \(S_1(t)\) is the first signal and \(A_2(t)\) is the amplitude envelope of the second signal.
ESC uses the Hilbert transform to calculate instantaneous amplitudes, hence the signal should be narrowband.
ep = 1
esc = escor(e10,
e10,
ch1 = "Fp1",
ch2 = "Fp2",
ep1 = ep,
ep2 = ep);
println("ESC: $(esc[1])")ESC: 0.04131366983715709