Abstract
Cortical oscillations, electrophysiological activity patterns associated with cognitive functions and impaired in many psychiatric disorders, can be observed in intracranial electroencephalography (iEEG). Direct cortical stimulation (DCS) may directly target these oscillations and serve as therapeutic approaches to restore functional impairments. However, the presence of electrical stimulation artifacts in neurophysiological data limits the analysis of the effects of stimulation. Currently available methods suffer in performance in the presence of nonstationarity inherent in biological data. Our algorithm, Shape Adaptive Nonlocal Artifact Removal (SANAR), is based on unsupervised manifold learning. By estimating the Euclidean median of k nearest neighbors of each artifact in a nonlocal fashion, we obtain a faithful representation of the artifact which is then subtracted. This approach overcomes the challenges presented by nonstationarity. SANAR is effective in removing stimulation artifacts in the time domain while preserving the spectral content of the endogenous neurophysiological signal. We demonstrate the performance in a simulated dataset as well as in human iEEG data. Using two quantitative measures that capture how much information from endogenous activity is retained, we demonstrate that SANAR's performance exceeds that of independent component analysis in both the time and frequency domains.
Introduction
Direct Cortical Stimulation (DCS) is a vital tool in clinical neuroscience for mapping brain function and developing neuromodulatory therapies for psychiatric disorders. To evaluate the efficacy of these interventions, researchers must record intracranial EEG (iEEG) concurrently with stimulation. However, the electrical pulses used in DCS are significantly larger than the underlying neural signals, creating massive artifacts that mask brain activity.
A primary challenge in artifact removal is non-stationarity. Physiological factors—such as respiration, cardiac cycles, and subtle changes in brain impedance—cause the shape and amplitude of stimulation artifacts to drift over time. Traditional methods like Template Subtraction or Independent Component Analysis (ICA) often struggle with these dynamic changes, potentially leaving residual noise or distorting the actual neurophysiological signal.
The SANAR Algorithm
To address these limitations, we developed SANAR (Shape Adaptive Nonlocal Artifact Removal), an unsupervised manifold learning framework. SANAR treats artifact variation as a geometric problem rather than a purely statistical one. The pipeline consists of four main stages:
- Segmentation and Denoising: The continuous iEEG signal is segmented into epochs centered on each stimulation pulse. These segments form a matrix that is denoised using singular value optimal shrinkage to separate structured artifacts from random background noise.
- Manifold Learning: SANAR assumes that the non-stationary artifacts lie on a low-dimensional, nonlinear manifold. This geometric representation captures the underlying structure of the artifact's variation.
- Nonlocal Neighbor Search: For each artifact, the algorithm searches the entire recording for its $k$-nearest neighbors based on "diffusion distance." This nonlocal approach allows the algorithm to find similar artifact shapes regardless of when they occurred in the timeline, making it robust against slow physiological drifts.
- Adaptive Template Subtraction: A custom template is generated for each pulse by calculating the Euclidean median of its nearest neighbors. This faithful representation is then subtracted from the raw data.
Experimental Setup
The performance of SANAR was validated using both a controlled "phantom" setup and human clinical data. The phantom setup utilized a saline solution to mimic brain conductivity, with a function generator providing a known ground-truth signal.
The human dataset involved iEEG recordings from a participant with 114 implanted electrodes performing a working memory task while receiving 9.1 Hz periodic stimulation. As shown in the traces and individual pulse examples above, the artifacts exhibit significant variation in relative amplitude, highlighting the non-stationarity that SANAR is designed to handle.
Results and Discussion
SANAR was compared against ICA using two quantitative metrics: the Artifact Residue (AR) index for time-domain cleanliness and Spectral Concentration (SC) for frequency-domain preservation. In both domains, SANAR significantly outperformed ICA:
- Time Domain: SANAR achieved an AR index of 0.388, compared to 0.430 for ICA.
- Frequency Domain: SANAR reached an SC index of 0.096, while ICA scored 0.136.
Beyond these metrics, SANAR demonstrated superior "harmonic cleaning." Stimulation artifacts typically create spikes at the stimulation frequency and its harmonics. While ICA often leaves higher harmonics untouched, SANAR effectively suppressed them, which is critical for analyzing high-frequency gamma-band activity. Furthermore, SANAR can be applied to single-channel data, whereas ICA requires high-density multi-channel recordings.
Conclusion
SANAR provides a robust, geometry-based solution for removing non-stationary stimulation artifacts in iEEG. While currently computationally intensive—requiring approximately 54 minutes to process 110,000 artifacts—future work will focus on optimizing search algorithms for speed. Additionally, adapting SANAR for non-periodic stimulation, such as Transcranial Magnetic Stimulation (TMS), represents a promising avenue for expanding its utility in clinical and research settings.
Summary updated