usingNeuroAnalyzerimportCairoMakie# Quarto sets a default figure size (672 × 480 px), which overrides the sizes of# NeuroAnalyzer figures: remove itdelete!(CairoMakie.Makie.CURRENT_DEFAULT_THEME, :resolution)usingDataFramesusingStatisticsNeuroAnalyzer.progress_bar =false# resting-state EEG, EEG channels only, 10-second epochseeg =load_neuro("files/eeg/eeg.hdf")eeg =keep_channel(eeg; ch ="eeg")e10 =epoch(eeg; ep_len =10)# theta band (4-8 Hz): the dominant rhythm of this recordinge10_theta = NeuroAnalyzer.filter(e10; ch ="eeg", fprototype =:butterworth, ftype =:bp, cutoff = (4, 8), order =4)
Amplitude Envelope Correlation (AEC) is the correlation between the amplitude envelopes of two narrow-band signals: it measures whether the strength of an oscillation in two regions rises and falls together (co-activation), regardless of the phase relationship.
\[
\text{AEC} = \text{corr}(A_1(t), A_2(t))
\]
where: \(A_1(t)\), \(A_2(t)\) are the amplitude envelopes of the two signals (the absolute value of their analytic signals, obtained using the Hilbert transform).
Interpretation:
AEC = 1: the envelopes change together
AEC = 0: no relationship between the envelopes
AEC < 0: when the amplitude increases in one signal, it decreases in the other
Use case: co-activation of brain regions in specific frequency bands; amplitude coupling is the basis of many resting-state network studies (especially in MEG).
Limitations:
Not phase-specific: it does not capture timing relationships.
Sensitive to volume conduction: a source recorded by two electrodes produces correlated envelopes. In source-space analyses this is reduced by orthogonalizing the signals before the envelopes are calculated (leakage correction, Hipp et al., 2012).
The envelopes change slowly, so long segments are required for a reliable estimate.
The signals must be narrow-band, since the envelope of a broad-band signal is not meaningful; here the theta band (4–8 Hz) is used.
aecor() calculates the AEC between pairs of channels (ch1[i] with ch2[i]) in each epoch:
With a single object, the AEC of all pairs of channels is calculated (channels × channels × epochs):
m =aecor(e10_theta; ch ="eeg")plot_matrix(dropdims(mean(m; dims =3); dims =3); xlabels =labels(e10_theta), ylabels =labels(e10_theta), title ="AEC (4-8 Hz), mean of all epochs")
Envelope Correlation with a Significance Test
env_cor() calculates the correlation of any two envelopes, with the p-value of the correlation test. The envelopes must be arrays of shape (channels, samples, epochs). Here, upper envelopes (cubic spline through the local maxima, see env_up()) of O1 and O2 in the first epoch:
Tip: the samples of an envelope are strongly autocorrelated (the envelope changes slowly), so the p-value of a correlation test that treats each sample as independent is far too small; use surrogate data (e.g. correlations of envelopes from different epochs) to test significance.
Envelope-to-Signal Correlation
Envelope-to-Signal Correlation (ESC; Bruns & Eckhorn, 2004) is the correlation between the (band-limited) signal of one channel and the amplitude envelope of another:
\[
\text{ESC} = \text{corr}(S_1(t), A_2(t))
\]
where: \(S_1(t)\) is the first signal, \(A_2(t)\) is the amplitude envelope of the second signal.
ESC is high when the signal of the first channel follows the amplitude of the second, e.g. when a slow oscillation modulates the amplitude of a faster one (cross-frequency coupling); it is not symmetric. Both signals are filtered in the bands of interest (which may differ) before the calculation.
For signals filtered in the same band, the ESC is close to 0: the signal oscillates around zero many times within each rise and fall of the envelope.
References
Bruns, A., & Eckhorn, R. (2004). Task-related coupling from high- to low-frequency signals among visual cortical areas in human subdural recordings. International Journal of Psychophysiology, 51(2), 97–116.
Hipp, J. F., Hawellek, D. J., Corbetta, M., Siegel, M., & Engel, A. K. (2012). Large-scale cortical correlation structure of spontaneous oscillatory activity. Nature Neuroscience, 15(6), 884–890.