## 4 TMS Study Protocol and EEG Recording
### EEG Signal Preprocessing and Analysis  
A series of advanced EEG cleaning procedures is applied to the data to improve signal quality and enhance the sham stimulation EPs. First, the segment of data from 5 ms prior to 25 ms after the TMS stimulus is removed and replaced with piecewise cubic spline interpolation. The data are then filtered with a zero-phase high pass FIR filter at 4 Hz, electrooculographic artifact correction is performed with multiple adaptive regression with the Conventional Recursive Least Squares Algorithm (CRLS) [26], and line noise at 50 and 100 Hz is removed using multi-tapering and Thompson' F-statistic [27]. Bad channels are detected using a Random Sample Consensus (RANSAC) procedure [28] and removed. Large burst artifacts are corrected using Euclidean distance Artifact Subspace Reconstruction (ASR) [29], and segments of data that cannot be adequately corrected are marked, so that the corresponding stimulations can be excluded from the analysis. Independent component analysis (ICA) is then used to remove stimulation-induced muscle artifact and persistent muscle activity [30]. Finally, the removed channels are replaced by spherical interpolation, the data are transformed to current source density (CSD) estimates [31; 32] and are filtered with a zero-phase low pass FIR filter at 45 Hz. The final signal's frequency range (4-45 Hz) corresponds to the range of typical TEPs we have observed in the case of verum TMS stimulation using the setup of this study (deep TMS with an H7 coil). In addition, it is similar to the frequency content of TEPs elicited with focal stimulation at the central area, as disclosed by ERSP analysis [33; 34].  
The analysis is performed on the Sham TMS AEPs, obtained by epoching the data into trials with duration of 1 s (0.5 s pre- and post-TMS) and averaging the individual trials. For each subject, there is a different number of usable trials based on the number of stimulations administered by the clinician and the data quality after the preprocessing, but the median number of trials for both groups (healthy and epileptic) was the same, equal to 31 (see Table 1 for more information). We study the AEPs as a signal, and also as the Cortical Evoked Activity (CEA) measure which is the area under the curve of the rectified AEP for a given time window. We estimate CEA values for the period from 25 to 275 ms, so as to include the auditory N100 component of the AEP. We constrain our analysis on a waveform of interest which is the average of the signals at the nine central channels FC1, FCz, FC2, C1, Cz, C2, CP1, CPz, CP2 (corresponding to the core stimulation area). The specific nine-channel ROI was chosen for two reasons. First, it was identical to the ROI that was employed in the context of a broader study on the diagnostic accuracy of deep TMS-EEG in epilepsy, thereby ensuring the relevance of the findings of the present study with the clinical one. Second, this particular ROI corresponds roughly to the topography of the TMS-evoked AEP [35]. Accordingly, both when using verum and sham stimulation, the employed ROI is appropriate for the purpose of the study.  
For the statistical analysis of the results, we employ a linear mixed-effects model [36], cluster-based permutation tests [37] and exponential model fitting with nonlinear least squares. All computations are performed in SPSS and MATLAB using custom scripts and the EEGLAB toolbox [38].