## 2 Materials and Methods
### EEG Signal Preprocessing and Analysis  
A cascade of advanced cleansing procedures is applied to the EEG data in order to correct artifacts, improve signal quality and enhance TEPs. First, the segment of data from 5 ms prior to 25 ms after the TMS stimulus is removed and replaced with shape-preserving piecewise cubic spline interpolation. This data segment is contaminated with the stimulus artifact, particularly at higher SIs, and the data are practically irrecoverable. The EEG data are then filtered with a zero-phase high pass FIR filter at 4 Hz to suppress slow fluctuations [41] and alleviate the decay artifact that is often observed after TMS administration. Automatic electrooculographic artifact correction is performed using multiple adaptive regression with adaption procedure the conventional recursive least squares algorithm (CRLS) [42], where the EOG signal is regressed out from each EEG signal individually. Line noise at 50 and 100 Hz is removed using multi-tapering and Thompsons' F-statistic [43]. This procedure adaptively estimates and removes sinusoidal noise from the data and is preferable to notch filtering, which may significantly distort the signal. Bad channels are detected using a random sample consensus (RANSAC) procedure [44] based on the correlation between neighboring channels (bad channels have low correlation with their neighboring ones) and removed along with the channels initially designated as problematic by the examining physician. Large-amplitude artifacts in the data (for instance, epileptiform discharges or movement artifacts) are automatically corrected using the Euclidean distance artifact subspace reconstruction (ASR) [45], and segments of data that cannot be adequately corrected are marked so that the corresponding TMS trials are excluded from the analysis. Independent component analysis (ICA) is then used to remove TMS-induced muscle artifact (components with high power in the time window up to 30 ms post TMS), and persistent muscle activity (components with high power in the frequency band 30-100 Hz) [46]. The removed channels are replaced by spherical interpolation using Legendre polynomials of degree 7 to calculate unbiased expected channel values. Finally, the data are transformed to current source density (CSD) estimates [47; 48] and are filtered with a zero-phase low pass FIR filter at 45 Hz. Transformation to CSD reduces the impact of volume conduction and enhances the spatial resolution [49]. We note that the frequency band that is retained after the two filters (4-45 Hz) is where the majority of the TEP-relevant activity lies for motor cortex stimulation [50].  
The analysis is performed on TEPs, estimated by epoching the data into trials of duration 1000 ms (500 ms pre- and pos-TMS) for the records of dataset A, or of duration 2000 ms (1000 ms pre- and post-TMS) for dataset B, and averaging the individual trials. From the TEPs, we extract individual components for subject-specific latencies, corresponding to (approximately) P60, N75, P90, N110 and P150, as also the cortical-evoked activity (CEA) measure, which is the area under the curve of the rectified TEP for a given time window. We define two CEA values, one for the period 25 to 275 ms, which includes the majority of the TEP activity [51], and 25 to 80 ms to capture only early components (e.g., P60) and avoid the later N100, which may correspond to propagated activity. The E-field values computed on the cortical surface are projected to the sensor space by a simple nearest-to-the-electrode correspondence procedure.  
For the statistical analysis of the EEG and E-field data, we employ covariance (\(\sigma\)), [PERSON]'s correlation (\(\rho\)), the global field potential (GFP--the standard deviation across electrode sites at any given time point), and exponential model fitting with nonlinear least squares, along with adjusted \(R^{2}\) for model fit evaluation and comparison. All computations are done in MATLAB (The MathWorks Inc., Natick, MA, USA), using custom scripts and the EEGLAB toolbox [52].