# Output peak analysis

This function returns the results for the peak analysis in a table both in the workspace (as output) and in a figure. This can be calculated on either the peak latencies determined using 'tesa\_peakanalysis', or on fixed latencies provided by the user. Users can also opt to have the average amplitude incorporating data points either side of the peak instead of the absolute peak amplitude. Either the average of the TEP curve or the area under the curve (GMFA only) can be calculated. Not that [tesa\_tepextract](/tesa-user-manual/analyse_tms_evoked_potentials/extract_teps.md) needs to be run prior to output peak analysis.

&#x20;

![](/files/-LmJDFKTAwDE-sAVqoIB)

**Example table from output peak analysis.** Values can be copied and pasted from this table into other programs (e.g. SPSS, Excel etc.).

## EEGLAB user interface

![](/files/-LmJDFKVHkUzrLlFuxjn)

**1.** Turn on/off table plot of peak output data.

**2.** Select which TEP to perform the analysis on. Selecting All will perform the analysis on all ROI and GMFA analyses in the data.

**3.** Select the type of calculation to perform, either amplitude of peak or area under the peak (for GMFA only). If area is selected, a value must also be entered in *5*.

**4.** Select whether to perform the analysis at the latency of peaks determined for the individual participant with [tesa\_peakanaysis](/tesa-user-manual/analyse_tms_evoked_potentials/analyse_peaks.md) (individual) or on fixed latencies provided by the user (fixed). If fixed is selected, the peaks for fixed calculation must also be entered in *6*.

**5.** If a value is included here, the function will take the average amplitude +/- the given value either side of the peak (in ms). If left blank, the function will return the absolute amplitude at the peak. A value is required for calculating area under the curve for GMFA.

**6.** \[Required for fixed peak calculation]. Define fixed time points to return amplitude values (as opposed to individual peak latencies). Either one or multiple time points can be given.

## Scripts

### Base function

`output = tesa_peakoutput( EEG );` Default use.

`output = tesa_peakoutput( EEG, 'key1', value1... );` Custom inputs.

### Pop function

`output = pop_tesa_peakoutput( EEG );` Pop up window.

`output = pop_tesa_peakoutput( 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      |
| ------------ | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | ------------ |
| 'winType'    | 'individual' or 'fixed' | Calculates values using either the latencies determined for each individual participant (using tesa\_peakanalysis) or set latencies provided by the user in 'fixedPeak' (see below).                                                                    | 'fixed'                              | 'individual' |
| 'calcType'   | 'amplitude' or 'area'   | Indicates whether to return the average amplitude of the TEP time series or the area under the curve (area under curve only for GMFA analysis). For area under curve, an analysis time window must also be entered using averageWin.                    | 'area'                               | 'amplitude'  |
| 'tepName'    | String                  | String indicating which specific ROI or GMFA TEP to give output for. If not indicated, output for all TEP fields will be given.                                                                                                                         | 'motor'                              | \[ ]         |
| 'averageWin' | integer                 | Integer describing a time window +/- the peak (in ms) in which an average amplitude/area will be taken. If left empty, the absolute amplitude at the peak latency  will be returned. A value is required for calculating area under the curve for GMFA. | 5                                    | \[ ]         |
| 'fixedPeak'  | integer                 | \[Required for 'winType' fixed]. Integer or vector describing fixed latencies for calculating amplitude or area under the curve.                                                                                                                        | 30 (single); \[30,60,100] (multiple) | \[ ]         |
| 'tablePlot'  | 'on' or 'off'           | Plots a table with results from peak analysis.                                                                                                                                                                                                          | 'off'                                | 'on'         |

### Outputs

| Output | Description                                        |
| ------ | -------------------------------------------------- |
| output | Table in workspace with output from peak analysis. |

### Examples

`output = pop_tesa_peakoutput( EEG );` Returns amplitude at individual latencies for all peaks defined with tesa\_peakanalysis.

`output = pop_tesa_peakoutput( EEG, 'averageWin', 5 );` Returns amplitude averaged +/- 5 ms from individual latencies for all peaks defined with tesa\_peakanalysis.

`output = pop_tesa_peakoutput( EEG, 'averageWin', 10, 'calcType', 'area', 'tepName','parietal' );` Returns area under the curve +/- 10 ms from individual latencies for all peaks defined in parietal region of interest using tesa\_peak analysis.

`output = pop_tesa_peakoutput( EEG, 'winType', 'fixed', 'fixedPeak', [30,60,100,180],'averageWin', 5 );` Returns amplitude averaged +/- 5 ms from peaks given in 'fixedPeak'. It is not necessary to run tesa\_peakanalysis for this option


---

# Agent Instructions: 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:

```
GET https://nigelrogasch.gitbook.io/tesa-user-manual/analyse_tms_evoked_potentials/output_peaks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
