> For the complete documentation index, see [llms.txt](https://nigelrogasch.gitbook.io/tesa-user-manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nigelrogasch.gitbook.io/tesa-user-manual/plot_teps/plot_data.md).

# Plot data

This function plots TMS-evoked activity averaged over trials. Timing of the TMS pulse is indicated with a red dashed line. Output from peak analyses can also be plotted, as well as confidence intervals across trials.

&#x20;

![](/files/-LmJDGMVr962HHik1X_b)

**Example butterfly plot generated by tesa\_plot.** Data from one individual plotted using default settings. Red line indicates timing of TMS pulse.

## EEGLAB user interface

![](/files/-LmJDGMXuDYkjnAYahls)

**1.** Select the data to plot. All will plot a butterfly plot with all electrodes. Individual electrodes can be selected, as well as ROI and GMFA analyses.

**2.** Define the time limits for the x axis (in ms).

**3.** Define the amplitude limits for the y axis (in uV). Leave blank for auto-scaling.

**4.** Turn on/off 95% confidence intervals calculated across trials. This is only available for single electrode and ROI plots.

**5.** Turn on/off the peak analysis results for ROI and GMFA analyses. The + marks the peak and the dotted box indicates the time window. Peaks that were found are green and peaks not present are red. Note that [tesa\_peakanalysis](/tesa-user-manual/analyse_tms_evoked_potentials/analyse_peaks.md) needs to be run before this option is possible.

## Scripts

### Base function

`tesa_plot( EEG );` Default use.

`tesa_plot( EEG, 'key1',value1... );` Custom inputs.

### Pop function

`pop_tesa_plot( EEG );` Pop up window.

'''pop\_tesa\_plot( EEG, 'key1',value1... );''' Custom inputs.

### Required inputs

| Input | Description          | Example | Default |
| ----- | -------------------- | ------- | ------- |
| EEG   | EEGLAB EEG structure | EEG     | -       |

### Optional inputs (key/value pairs)

| Key                                                                          | Input value               | Description                                                                                                                                                                                                                                                                                                                                               | Example     | Default     |
| ---------------------------------------------------------------------------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | ----------- |
| 'xlim'                                                                       | \[min,max]                | Integers describing the x axis limits in ms.                                                                                                                                                                                                                                                                                                              | \[-200,600] | \[-100,500] |
| 'ylim'                                                                       | \[min,max]                | Integers describing the y axis limits in ms. If left blank, the plot will automatically scale.                                                                                                                                                                                                                                                            | \[-10,10]   | \[ ]        |
| 'elec'                                                                       | 'string'                  | String describing a single electrode for plotting. If left blank, a butterfly plot of all electrodes will be plotted.                                                                                                                                                                                                                                     | 'Cz'        | \[ ]        |
| 'CI'                                                                         | 'on' or 'off'             | Plot confidence interval calculated across trials. This option is not available for GMFA and butterfly plots.                                                                                                                                                                                                                                             | 'on'        | 'off'       |
| **Options for plotting output from tesa\_tepextract and tesa\_peakanalysis** |                           |                                                                                                                                                                                                                                                                                                                                                           |             |             |
| 'tepType'                                                                    | 'data' or 'ROI' or 'GMFA' | 'data' input extracts data for plotting from EEG.data. 'ROI' input selects a ROI generated by tesa\_tepextract. 'GMFA' input selects a GMFA generated by tesa\_tepextract. Note that if multiple ROIs or GMFAs are present, 'tepName' must also be included to determine which one to plot.                                                               | 'ROI'       | 'data'      |
| 'tepName'                                                                    | 'string'                  | String is either the name of a ROI or GMFA generated by tesa\_tepextract. The default names generated by tesa\_tepextract are 'R1','R2'... etc. however the user can also define names. This is required if multiple ROIs or GMFAs are present.                                                                                                           | 'motor'     | \[ ]        |
| 'plotPeak'                                                                   | 'on' or 'off'             | If 'on', peaks identified with tesa\_peakanalysis will also be plotted. A box defining the lower and upper time limits in which the peak was searched will also be plotted. Green indiciates that a peak was found, red a peak was not detected. Note that tesa\_peakanalysis must be run prior to using this function and 'tepType' must also be called. | 'on'        | 'off'       |

### Examples

`pop_tesa_plot(EEG, 'xlim', [-200,600], 'ylim', [-10,10], 'elec', 'P1', 'CI', 'on');` Plot the average of electrodes P1 and P3, rescale the axes and include confidence intervals.

`pop_tesa_plot(EEG, 'tepType', 'ROI', 'tepName', 'parietal', 'plotPeak', 'on', 'CI', 'on');` Plot the output from a ROI analysis called parietal including detected peaks and confidence intervals.

`pop_tesa_plot(EEG, 'tepType', 'GMFA', 'plotPeak', 'on');` Plot output from a GMFA analysis including detected peaks


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://nigelrogasch.gitbook.io/tesa-user-manual/plot_teps/plot_data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
