Objective: 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 may 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.Approach: 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.Main results: 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 of information from endogenous activity is retained, we demonstrate that SANAR's performance exceeds that of one of the widely used approaches, independent component analysis, in the time domain as well as the frequency domain.Significance: This approach allows for the analysis of iEEG data, single channel or multiple channels, during DCS, a crucial step in advancing our understanding of the effects of periodic stimulation and developing new therapies. Rogasch et al., 2014) in the case of multi-channel recordings. Apart from these approaches, Kalman Filtering have been used to suppress stimulation artifacts in neurophysiological data (Morbidi et al., 2007;Morbidi et al., 2008). The approach involves fitting separate generative models for the artifact and for the neurophysiological data and applying the Kalman filter to extract the artifact-free data of interest. Yet another approach is to use the spectral information of the artifacts using matched filters (Allen et al., 2010;Sun et al., 2014) or empirical mode decomposition (Al-ani et al., 2011;Santillan-Guzman et al., 2013) to separate neurophysiological signal from artifacts.While these methods have been successfully applied, there are some limitations. The TS algorithm tends to suffer from the template bias, which arises from the possible deviation of the designed