Overview: Functional Connectivity & Cross-Coherence
In clinical neurophysiology and systems neuroscience, functional connectivity evaluates the statistical interdependence between spatially remote neurophysiological events. While standard time-domain analysis of intracranial electroencephalography (iEEG) traces reveals localized amplitude fluctuations, it often fails to uncover underlying network synchrony, especially in the presence of noise or volume conduction.
Cross-coherence is a powerful frequency-domain mathematical tool that quantifies this functional connectivity. By measuring the linear correlation between two signals as a function of frequency, coherence reveals how distinct brain regions phase-lock and communicate. This metric is particularly crucial in epileptology. During the pre-ictal state, cortical networks may appear normal in the time domain, yet exhibit pathological hypersynchrony in specific high-frequency bands (such as the Beta or Gamma range) indicating the recruitment of adjacent tissue into the epileptogenic network. During a focal seizure, coherence between the epileptogenic focus and surrounding margins will approach maximum theoretical limits ($1.0$), reflecting the overwhelming rhythmic entrainment of the seizure discharge.
This interactive laboratory simulates a 16-channel clinical recording array, allowing users to dynamically select spatial electrode pairs (e.g., Left Frontal versus Right Parietal) and calculate real-time Welch periodogram magnitude-squared cross-coherence. This provides immediate diagnostic insight into localized vs. globalized seizure propagation pathways without relying on heavy off-line processing pipelines.
How To Use: Interactive Terminal Configuration
This virtual workstation operates as a serverless, single-page application. To investigate functional connectivity within the dataset, use the right-hand control panel to manipulate the signal processing pipeline:
1. Initiating the Interactive Display: Click the Start Demo button at the top of the controls panel. This initiates a smooth, $60\text{ FPS}$ continuous temporal playback loop that scrolls the timeline across $100\text{ seconds}$ of recording. You will observe background, interictal, and active tonic-clonic epileptic discharge phases. Clicking any slider or dropdown immediately halts the automated playback, returning total manual control to the user.
2. Dataset Selection: Use the Data Stream Source dropdown to toggle between Synthetic Seizure Dynamics and Real Patient iEEG (NeuroVista I004). Selecting the Real Patient stream triggers an asynchronous JavaScript loader to retrieve and parse the raw recording directly into local browser memory. Toggle transitions are seamless.
3. Spatial Channel Selection: Use the Channel A (Cyan) and Channel B (Green) dropdown menus to select the two electrodes for cross-coherence comparison. By default, the system compares Channel 0 (background) against Channel 7 (the theoretical epileptogenic epicenter). Try selecting Channel 7 and Channel 8 (Epicenter vs. Margin) to observe near-perfect coherence during the seizure phase (Seconds $35\text{--}75$).
4. Navigating the Epileptic Event: Use the Timeline Scroller to move through the recording window. Set the slider to $0\text{--}30\text{ seconds}$ to inspect baseline background activity, where cross-coherence remains low and chaotic. Advance to $45\text{--}75\text{ seconds}$ to observe massive synchronization across multiple frequency bands as the seizure propagates across the cortical tissue.
5. Modifying Signal Parameters: Toggle TSA Detrending to apply linear regression subtraction, removing baseline DC offsets caused by electrode impedance shifts. Use the Window Display Size slider to dynamically adjust the sampling duration analyzed by the Fast Fourier Transform (FFT) array. A larger window increases frequency resolution but reduces temporal precision.
Technical Details: Mathematical Algorithm Implementations
This application implements an advanced signal processing pipeline entirely client-side using JavaScript, optimizing high-performance multi-canvas rendering. The core algorithms underlying the visualizations are outlined below:
1. Time-Series Analysis (TSA) Detrending
To eliminate baseline offset and slow linear drift, the active time window $x[n]$ of length $N$ is detrended by computing the linear least-squares regression line $y[n] = m \cdot n + c$, where:
$$m = \frac{N \sum n x[n] - \sum n \sum x[n]}{N \sum n^2 - (\sum n)^2}, \quad c = \frac{\sum x[n] - m \sum n}{N}$$
The detrended signal $x_{\text{detrend}}[n] = x[n] - y[n]$ ensures a zero-mean baseline centered on the horizontal axis.
2. Welch's Power Spectral Density (PSD)
The middle canvas displays the individual frequency power spectra of Channel A and Channel B, computed using Welch's periodogram method. The detrended signal is divided into overlapping segments, multiplied by a Hanning window to minimize spectral leakage, and transformed using a Radix-2 Cooley-Tukey Fast Fourier Transform (FFT). The auto-spectral density $P_{xx}(f)$ is derived as the squared magnitude of the FFT coefficients averaged across all segments.
3. Cross-Spectral Density & Magnitude-Squared Coherence
The bottom canvas calculates the statistical phase consistency between the two channels. First, the cross-spectral density $P_{xy}(f)$ is computed by multiplying the complex FFT of Channel A by the complex conjugate of the FFT of Channel B.
The magnitude-squared coherence $C_{xy}(f)$ is then computed as the squared magnitude of the cross-spectral density divided by the product of the individual auto-spectral densities:
$$C_{xy}(f) = \frac{|P_{xy}(f)|^2}{P_{xx}(f) P_{yy}(f)}$$
This generates a normalized index ranging from $0$ to $1$. A value of $1$ indicates perfect linear correlation and phase-locking at that specific frequency $f$, implying strong functional connectivity between the two recorded anatomical sites. A value near $0$ indicates total asynchronous independence.
Future Directions
Future development phases for this analytical workspace will focus on integrating higher-order connectivity metrics, such as the Phase Lag Index (PLI) and the Imaginary Part of Coherency (iCOH), which mathematically eliminate spurious zero-lag correlations caused by volume conduction artifacts through the skull and scalp. Furthermore, we plan to implement a dynamic topographical 3D head model (using WebGL/Three.js) to visually map real-time coherence networks as colored connectivity splines between physical 10-20 system electrode locations, providing a complete spatial-spectral diagnostic dashboard.
Related Diagnostics Platforms
Explore BioniChaos's suite of interactive neurological and electrophysiological visualization applications: