Preprocessing Pipeline Optimization for Sensory-Entrained Transcranial Magnetic Stimulation (seTMS)
DOI: Pending DOI
Synopsis
Sensory-Entrained Transcranial Magnetic Stimulation (seTMS) administers TMS pulses time-locked with rhythmic auditory events. Research indicates seTMS to motor cortex enhances cortico-spinal excitability and offers a low-cost method for brain-state TMS^1. Yet, due to a short epoch window and the large amplitude TMS pulse artifact in electroencephalography (EEG), data analysis of cortical effects of seTMS remains largely unexplored. We propose a preprocessing pipeline developed to optimally recover relevant neural data. This will enable further research using EEG of the effects of seTMS on cortical excitability and plasticity.
Background
Transcranial magnetic stimulation (TMS) is a non-invasive brain stimulation technique with established psychiatric applications, including for treatment-resistant depression. Combined with electroencephalography (EEG), TMS-EEG can be used to study cortical excitability and oscillatory dynamics^2. Sensory entrained TMS (seTMS) pairs TMS pulses with rhythmic sounds and enhances cortico-spinal excitability when applied to the motor cortex^1. Pilot EEG data suggest that seTMS applied to the prefrontal cortex can also enhance cortical excitability. However, analyzing these data presents challenges due to the presence of large-amplitude TMS-induced artifacts^3 and the constraints imposed by a shorter epoch window (between successive rhythmic beats). The current project presents a semi-automated preprocessing pipeline optimized for seTMS EEG data, designed to support analysis of Event-Related Spectral Perturbations (ERSPs), Inter-Trial Coherence (ITC), and TMS-Evoked Potentials (TEPs).
Methods
EEG data were pre-processed using custom scripts, TESA v1.1.11^3, and EEGLAB v2025.1.0^4 in MATLAB R2025b. Data were segmented into TMS-locked epochs (−250 to 500 ms), demeaned^3, and conditions merged. Bad electrodes were marked by kurtosis (≥5), reviewed by an expert, and removed^5. To minimize TMS pulse artifact contamination of filtering and ICA^6, the −2 to 10 ms window was zero-padded then cubically interpolated. Data were downsampled from 25 kHz to 1 kHz, and bad epochs visually removed. The −2 to 10 ms window was zero-padded before FastICA^7 identified and removed large-amplitude TMS-evoked artifacts^6. An extended window (−5 to 15 ms) was then zero-padded and interpolated to attenuate residual muscle artifact. Zero-phase fourth-order Butterworth bandstop (57–63 Hz) and bandpass (1–100 Hz)^5,3 filters were applied, and the extended window was again zero padded. To mitigate edge artifacts from filtering epoched data^8 that can bias FastICA, epochs were trimmed to −200 to 450 ms. Missing channels were reconstructed using spherical spline interpolation and data re-referenced to the global average. PCA reduced dimensionality to N − (1 + interpolated channels) to address rank deficiency^9. A second FastICA was run; components were sorted by variance explained and reviewed in TESA to remove non-brain artifacts, retaining components with apparent neural mixing. Zero-padded windows were cubically interpolated. A fourth-order Butterworth low-pass filter at 50 Hz was applied. Epochs were baseline corrected (−200 to −15 ms)^10. Merged conditions were unmerged before TEP analysis.
Results
The proposed pipeline successfully recovered physiologically relevant EEG activity across all participants in our pilot dataset, reducing artifact contamination at each stage while preserving neural signal in the constrained epoch window imposed by the seTMS paradigm. Prior to first round ICA (Panel B), data from participant 1 showed the characteristic large-amplitude TMS pulse artifact and associated muscle artifact in the early post-pulse window, as well as eye-movement and cardiac noise components visible across electrodes. Following the full preprocessing sequence, these artifact sources were substantially attenuated. Time-frequency analysis revealed a consistent two-phase pattern across participants. In the early post-pulse window (<50 ms), event-related spectral perturbation (ERSP) analysis showed high-power, low inter-trial coherence (ITC), suggesting variable-latency, high-amplitude cortical activation. In the later window (>50 ms), power decreased while ITC increased, indicating phase-locked, rhythmically entrained oscillatory activity. This pattern of early high-power/low-coherence followed by later low-power/high-coherence is consistent with a direct TMS-evoked cortical response succeeded by sensory-driven phase resetting. Panel C illustrates TEPs, ERSPs, and ITCs from two representative participants post-preprocessing, demonstrating this two-phase dynamic and the preservation of characteristic TEP components in the post-pulse window. These results validate the pipeline for supporting both spectral and TEP analyses of seTMS EEG data and motivate further investigation of oscillatory dynamics underlying seTMS-enhanced cortical excitability.
Discussion
This preprocessing pipeline enables robust recovery of EEG data in the constrained epoch window imposed by seTMS paradigms, supporting both spectral and TEP analyses. The consistent two-phase pattern of early high-power/low-coherence followed by later low-power/high-coherence activity across participants suggests that seTMS may elicit a direct cortical response that is followed by what appears to be a sensory-driven phase alignment. Further application of this pipeline will allow systematic investigation of these oscillatory dynamics and their relationship to the mechanisms underlying seTMS-enhanced cortical excitability.
Disclosures
This research was supported by the Koret Human Neurosciences Community Laboratory, Wu Tsai Neurosciences Institute, Stanford University (JMR, CJK), the National Institute of Mental Health under award number R01MH126639 (CJK), and a Burroughs Wellcome Fund Career Award for Medical Scientists (CJK).
References
1: Ross, J. M., Forman, L., Gogulski, J., et al. (2025). Sensory entrained TMS (seTMS) enhances motor cortex excitability. Human Brain Mapping, 46(10), e70267. https://doi.org/10.1002/hbm.70267
2: Rogasch, N. C., & Fitzgerald, P. B. (2013). Assessing cortical network properties using TMS–EEG. Human Brain Mapping, 34(7), 1652–1669. https://doi.org/10.1002/hbm.22016
3: Rogasch, N. C., Sullivan, C., Thomson, R. H., Rose, N. S., Bailey, N. W., Fitzgerald, P. B., Farzan, F., & Hernandez-Pavon, J. C. (2017). Analysing concurrent transcranial magnetic stimulation and electroencephalographic data: A review and introduction to the open-source TESA software. NeuroImage, 147, 934–951. https://doi.org/10.1016/j.neuroimage.2016.10.031
4: Delorme, A., & Makeig, S. (2004). EEGLAB: an open source toolbox for analysis of single-trial EEG dynamics including independent component analysis. Journal of Neuroscience Methods, 134(1), 9–21. https://doi.org/10.1016/j.jneumeth.2003.10.009
5: Ross, J. M., Ozdemir, R. A., Lian, S. J., et al. (2022). A structured ICA-based process for removing auditory evoked potentials. Scientific Reports, 12, 1391. https://doi.org/10.1038/s41598-022-05397-3
6: Rogasch, N. C., Thomson, R. H., Daskalakis, Z. J., & Fitzgerald, P. B. (2014). Removing artefacts from TMS-EEG recordings using independent component analysis: Importance for assessing prefrontal and motor cortex network properties. NeuroImage, 101, 425–439. https://doi.org/10.1016/j.neuroimage.2014.07.037
7: Hyvärinen, A. (1999). Fast and robust fixed-point algorithms for independent component analysis. IEEE Transactions on Neural Networks, 10(3), 626–634. https://doi.org/10.1109/72.761722
8: Tanner, D., Morgan-Short, K., & Luck, S. J. (2015). How inappropriate high-pass filters can produce artifactual effects and incorrect conclusions in ERP studies of language and cognition. Psychophysiology, 52(8), 997–1009. https://doi.org/10.1111/psyp.12437
9: Hernandez-Pavon, J. C., Metsomaa, J., Mutanen, T., Stenroos, M., Mäki, H., Ilmoniemi, R. J., & Sarvas, J. (2012). Uncovering neural independent components from highly artifactual TMS-evoked EEG data. Journal of Neuroscience Methods, 209(1), 144–157. https://doi.org/10.1016/j.jneumeth.2012.05.029
10: Brancaccio, A., Tabarelli, D., Zazio, A., Bertazzoli, G., Metsomaa, J., Ziemann, U., Bortoletto, M., & Belardinelli, P. (2024). Towards the definition of a standard in TMS-EEG data preprocessing. NeuroImage, 301, 120874. https://doi.org/10.1016/j.neuroimage.2024.120874
