Brain connectivity analysis aims to quantify the statistical dependencies and information flow between different brain regions or electrodes. Understanding these interactions is fundamental to cognitive neuroscience, revealing how distributed neural networks coordinate during perception, cognition, and action.
Key Concepts:
PhysioEEG provides methods ranging from basic coherence to advanced phase-based metrics that mitigate volume conduction artifacts.
Load the PhysioEEG package and create multi-channel test data representing activity from frontal, central, parietal, and occipital regions:
library(PhysioEEG)
library(ggplot2)
# Create 8-channel EEG data with 10-second epochs
# Channels: Fp1, Fp2, C3, C4, P3, P4, O1, O2
eeg <- make_eeg(
n_channels = 8,
n_time = 2500, # 10 seconds at 250 Hz
n_samples = 20, # 20 trials
sr = 250
)
# Set realistic channel names
colData(eeg)$channel_name <- c("Fp1", "Fp2", "C3", "C4", "P3", "P4", "O1", "O2")
colData(eeg)$type <- "EEG"
# Add alpha oscillations (8-12 Hz) to occipital channels to simulate visual cortex activity
# This creates realistic posterior connectivityMagnitude-squared coherence (MSC) quantifies frequency-specific correlation between two signals. It ranges from 0 (no linear relationship) to 1 (perfect linear relationship) at each frequency.
Formula: \(C_{xy}(f) = \frac{|P_{xy}(f)|^2}{P_{xx}(f)P_{yy}(f)}\)
where \(P_{xy}\) is the cross-spectral density and \(P_{xx}\), \(P_{yy}\) are auto-spectral densities.
# Compute coherence between occipital channels (O1-O2) in alpha band (8-12 Hz)
# Expected to show strong coupling due to bilateral alpha rhythm
coh_alpha <- eegCoherence(
eeg,
method = "msc",
freq_range = c(8, 12),
window_size = 500, # 2-second windows for spectral estimation
assay_name = "raw"
)
# Result contains coherence values averaged over the frequency range
print(coh_alpha)
# Compute broadband coherence for theta through gamma
coh_broad <- eegCoherence(
eeg,
method = "msc",
freq_range = c(4, 40),
window_size = 1000, # Longer window for lower frequencies
assay_name = "raw"
)Interpretation: MSC > 0.5 in alpha band between O1-O2 indicates strong bilateral synchronization of visual cortex rhythms. However, MSC is sensitive to volume conduction—high coherence may reflect passive spread rather than true neural coupling.
Imaginary coherence uses only the imaginary part of the cross-spectrum, eliminating zero-lag correlations introduced by volume conduction:
# Compute imaginary coherence to reduce volume conduction artifacts
icoh_alpha <- eegCoherence(
eeg,
method = "imaginary",
freq_range = c(8, 12),
window_size = 500,
assay_name = "raw"
)
# Compare with MSC to identify spurious connectivity
# Large difference suggests volume conduction contaminationGuideline: Use imaginary coherence when you suspect volume conduction artifacts, particularly for nearby electrodes or high signal-to-noise data. Lower values are expected but reflect more genuine neural interactions.
PLV measures phase consistency between two signals across trials, independent of amplitude fluctuations. This makes PLV robust to non-stationarities in signal amplitude.
Formula: \(PLV = \left|\frac{1}{N}\sum_{n=1}^N e^{i\Delta\phi_n}\right|\)
where \(\Delta\phi_n\) is the phase difference between channels at trial \(n\).
# Compute PLV in theta band (4-8 Hz) for frontal-central connectivity
# Theta coupling reflects working memory and cognitive control processes
plv_theta <- eegPLV(
eeg,
freq_range = c(4, 8),
assay_name = "raw"
)
# PLV in alpha band for posterior connectivity
plv_alpha <- eegPLV(
eeg,
freq_range = c(8, 12),
assay_name = "raw"
)
# PLV in beta band (13-30 Hz) for motor coordination
# Expected higher C3-C4 coupling during motor planning
plv_beta <- eegPLV(
eeg,
freq_range = c(13, 30),
assay_name = "raw"
)Interpretation:
PLV is particularly useful for event-related designs where phase consistency changes with experimental conditions. However, PLV can still be affected by volume conduction since zero-lag phase relationships can occur artifactually.
The weighted phase lag index (Vinck et al., 2011) addresses the volume conduction problem by focusing only on non-zero phase lags, eliminating instantaneous correlations.
Key advantage: wPLI is insensitive to volume conduction while maintaining statistical power better than imaginary coherence.
# Compute wPLI in alpha band
# More conservative estimate of true neural coupling
wpli_alpha <- eegWPLI(
eeg,
freq_range = c(8, 12),
assay_name = "raw"
)
# wPLI across multiple frequency bands for comparison
wpli_theta <- eegWPLI(eeg, freq_range = c(4, 8))
wpli_beta <- eegWPLI(eeg, freq_range = c(13, 30))
wpli_gamma <- eegWPLI(eeg, freq_range = c(30, 50))
# Compare PLV vs wPLI to assess volume conduction impact
# Large PLV but small wPLI suggests spurious connectivityWhen to use wPLI:
Trade-off: wPLI may have lower sensitivity than PLV, but higher specificity for genuine neural coupling.
Spectral Granger causality quantifies directed (causal) influence in the frequency domain. It tests whether past values of signal X improve prediction of signal Y beyond Y’s own history.
Interpretation: \(GC_{X\to Y}(f)\) represents the reduction in prediction error for Y when incorporating X’s history, at frequency \(f\).
# Compute Granger causality from frontal to parietal regions
# Tests top-down attentional control hypothesis
gc_frontal_parietal <- eegGrangerCausality(
eeg,
order = 10, # Model order (typically 10-20 for EEG)
freq_range = c(4, 40),
assay_name = "raw"
)
# Model order selection is critical
# Too low: Underfitting, missing dynamics
# Too high: Overfitting, spurious causality
# Rule of thumb: order ≈ 2 × (sampling_rate / lowest_frequency_of_interest)
# For 250 Hz and 4 Hz: order ≈ 2 × (250/4) = 125 samples, but use 10-20 for stability
# Compute bidirectional causality to assess feedback loops
gc_parietal_frontal <- eegGrangerCausality(
eeg,
order = 10,
freq_range = c(4, 40),
assay_name = "raw"
)Important caveats:
Frequency-specific interpretation:
For whole-brain network analysis, compute all-to-all connectivity matrices. This enables graph-theoretic analysis and visualization of network topology.
# Compute comprehensive connectivity matrix using wPLI in alpha band
# Results in 8×8 symmetric matrix for 8 channels
conn_matrix_alpha <- eegConnectivityMatrix(
eeg,
method = "wpli",
freq_range = c(8, 12),
assay_name = "raw"
)
# Connectivity matrix for theta band
conn_matrix_theta <- eegConnectivityMatrix(
eeg,
method = "wpli",
freq_range = c(4, 8),
assay_name = "raw"
)
# Using PLV for comparison (more sensitive but volume conduction prone)
conn_matrix_plv <- eegConnectivityMatrix(
eeg,
method = "plv",
freq_range = c(8, 12),
assay_name = "raw"
)
# Coherence-based matrix (most traditional approach)
conn_matrix_coh <- eegConnectivityMatrix(
eeg,
method = "coherence",
freq_range = c(8, 12),
assay_name = "raw"
)Raw connectivity matrices often contain weak, potentially spurious connections. Thresholding improves interpretability:
# Proportional thresholding: Keep top 20% of connections
threshold_prop <- quantile(conn_matrix_alpha[upper.tri(conn_matrix_alpha)], 0.80)
# Absolute thresholding: Keep connections above physiological significance
threshold_abs <- 0.3 # For wPLI, values > 0.3 often indicate robust coupling
# Statistical thresholding: Compare against surrogate data distribution
# (requires permutation testing, not shown here)
# Apply threshold to matrix
conn_matrix_thresh <- conn_matrix_alpha
conn_matrix_thresh[conn_matrix_thresh < threshold_prop] <- 0Effective visualization reveals network topology and identifies functional hubs.
# Heatmap shows full connectivity structure
# Useful for identifying clusters and bilateral symmetry
eegPlotConnectivity(
eeg,
method = "heatmap",
matrix = conn_matrix_alpha,
threshold = 0.25, # Show only moderate-to-strong connections
labels = colData(eeg)$channel_name,
palette = "RdYlBu" # Red = strong, Blue = weak
)
# Hierarchical clustering can reveal functional modules
# (requires additional analysis, not shown)Interpretation guide:
Circle plots emphasize long-range connections and network topology:
# Circular layout with channels arranged anatomically
# Lines connect functionally coupled regions
eegPlotConnectivity(
eeg,
method = "circle",
matrix = conn_matrix_alpha,
threshold = 0.4, # Higher threshold for clarity
labels = colData(eeg)$channel_name,
palette = "viridis"
)
# Anterior-posterior gradient in alpha connectivity
# Expected pattern: strong occipital-occipital, weaker frontal-occipital
# Compare theta vs alpha network topology
eegPlotConnectivity(
eeg,
method = "circle",
matrix = conn_matrix_theta,
threshold = 0.4,
labels = colData(eeg)$channel_name
)Best practices:
Choosing the appropriate connectivity metric depends on research question, data quality, and analytical goals:
| Method | Sensitivity to Volume Conduction | Directionality | Computational Cost | Best Use Case |
|---|---|---|---|---|
| Coherence (MSC) | High | No | Low | Initial exploration, high SNR data, frequency-specific coupling |
| Imaginary Coherence | Low | No | Low | Nearby electrodes, reducing zero-lag artifacts, exploratory analysis |
| PLV | Moderate | No | Low | Event-related designs, trial-to-trial variability, phase dynamics |
| wPLI | Very Low | No | Moderate | High-density EEG, robust connectivity, eliminating volume conduction |
| Granger Causality | Moderate | Yes | High | Directed influence, feedback loops, testing causal hypotheses |
For exploratory analysis:
# Start with wPLI to get robust, volume-conduction-free overview
conn_explore <- eegConnectivityMatrix(eeg, method = "wpli", freq_range = c(4, 40))
eegPlotConnectivity(eeg, method = "heatmap", matrix = conn_explore, threshold = 0.3)For hypothesis testing:
# Use multiple metrics to triangulate true connectivity
# Convergent evidence across methods strengthens conclusions
# Compare PLV vs wPLI
plv_result <- eegPLV(eeg, freq_range = c(8, 12))
wpli_result <- eegWPLI(eeg, freq_range = c(8, 12))
# If PLV >> wPLI, volume conduction likely present
# If PLV ≈ wPLI, genuine phase coupling more likelyFor directed connectivity:
# Granger causality for testing information flow direction
# Combine with non-directed metrics for comprehensive picture
gc_forward <- eegGrangerCausality(eeg, order = 15, freq_range = c(4, 12))
wpli_baseline <- eegWPLI(eeg, freq_range = c(4, 12))
# Granger without corresponding wPLI suggests spurious causality
# Granger with wPLI suggests genuine directed influenceDifferent frequency bands reflect distinct neural processes:
Connectivity patterns are frequency-specific; analyze multiple bands separately rather than broadband.
PhysioEEG provides a comprehensive toolkit for EEG connectivity analysis, from basic coherence to advanced phase-based metrics robust to volume conduction. Key principles:
For directed connectivity questions, Granger causality provides unique insights but requires careful model selection and stationarity checks.
For more information, see ?eegConnectivityMatrix and
related function documentation.