> 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_group.md).

# Plot data (group)

This function plots TMS-evoked activity averaged over participants. Timing of the TMS pulse is indicated with a red dashed line. Confidence intervals across participants can also be plotted.

To use this function, all of the participant files must be in the same folder and all files must have undergone identical [tesa\_peakanalysis](/tesa-user-manual/analyse_tms_evoked_potentials/analyse_peaks.md) runs or have the same electrodes. No other files should be in this folder. Open one file from the folder and run the function on this file and all files in the folder will be averaged and plotted.

&#x20;

![](/files/-LmJDM9bIJFvXtl7MrEp)

**Example group plot for a region of interest analysis with confidence intervals.** Data are averaged across three individuals.

## EEGLAB user interface

![](/files/-LmJDM9dY1DXC7MuLylD)

**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.

### 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'     | \[ ]        |

## Examples

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

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

`pop_tesa_plotgroup(EEG, 'tepType','GMFA');` 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_group.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.
