# Analyse TMS-evoked potentials

Having successfully cleaned the data, the final stage of analysis is to evaluate the TMS-evoked potentials (TEPs). TEPs are analogous to event-related potentials or ERPs, the only difference being that ERPs are generated by sensory inputs, whereas TEPs are generated by TMS stimulation. As with ERPs, there are numerous different ways to analyse TEPs, such as measuring the amplitude and latencies of different peaks or performing time-frequency analysis to evaluate oscillations (see EEGLABs functionality for performing time-frequency analysis: [http://sccn.ucsd.edu/wiki/Chapter\_11:\_Time/Frequency\_decomposition](http://sccn.ucsd.edu/wiki/Chapter_11:_Time/Frequency_decomposition)).

TESA includes basic analysis functions for peak analysis. These functions allow users to extract a regions of interest (ROI; average over a single or group of electrodes) or global mean field amplitude (GMFA; standard deviation across electrodes over time) averaged across trials, find peak latencies and amplitudes within user-defined windows, and output this data in a table (either for an individual data file or across a group of data files). To output a group analysis table, all data files required for output must be in the same folder with no other files.

&#x20;

![](https://3092694373-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LmJDCxgyXG9A9GA-gSy%2F-LmJDDdbvCHG7SXDX4aP%2F-LmJDLo6RQyE7unXbjtX%2Froi_ex.png?generation=1565854895667613\&alt=media)

**Example region of interest (ROI) analysis.** A ROI averaging across four parietal electrodes (P1, P3, CP1 and CP3) was extracted using tesa\_tepextract. Six _a priori_ peaks were then searched for between user-defined windows of interest using tesa\_peakanalysis; N20 (10-30 ms), P40 (30-50 ms), N60 (50-70 ms), P80 (70-90 ms), N100 (90-110 ms) and P200 (180-220 ms). Of these peaks, 5 were found (plotted in green) and 1 was not (plotted in red). The left and right border of the boxes represent the time windows in which peaks were searched for (the top and bottom borders are meaningless - all amplitudes are considered). Peaks are defined as a data point that is greater than (positive) or less than (negative) a user-defined number of data points either side of the peak (default = 5). This prevents the algorithm from spuriously detecting large amplitude slopes on the border of analysis as peaks (see the P200 for example - if a maximum value was used within this time window, the right border would have retuned as a peak although there is no peak present). If multiple peaks are detected within a window, either the largest peak or the peak closest to the centre latency is returned (user-defined). The latency and amplitude of the detected and undetected peaks was then returned in a table using [tesa\_peakoutput](analyse_tms_evoked_potentials/output_peaks). Here, the amplitude values represent an average +/- 5 ms from the peak latency. Where no peak was found, a NaN value is returned in latency and the amplitude at the centre of the search window is returned (e.g. at 200 ms).

&#x20;

![](https://3092694373-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LmJDCxgyXG9A9GA-gSy%2F-LmJDDdbvCHG7SXDX4aP%2F-LmJDLoAzUkAfXNOl6qT%2Fgmfa_ex.png?generation=1565854892719684\&alt=media)

**Example global mean field amplitude (GMFA) analysis.** A GMFA analysis was performed and the same six peaks were searched for as the ROI analysis. Of these peaks, 3 were found and 3 were not. The results were returned in a table.
