> 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/remove_minimise_tms_muscle_activity/plot-and-remove-components.md).

# Plot and remove components

This function plots independent components following ICA and allows users to classify components for removal using a dropdown menu. Each plot includes a butterfly plot of the EEG data with and without the current IC, the average time course of the component, the trial-by-trial amplitude of the component, the topography of the component, and the power spectrum of the component. Infomration on the % mean variance (of total variance) accounted for by each component is also provided.&#x20;

Users can interactively alter the x and y axes of the plots by selecting 'Update plots'. Note that three figures sizes are available: 'small','medium' and 'large'.&#x20;

When satisfied with classification, press the 'Next' button to continue to the next component. Users can scroll backwards and forward through components by selecting the 'Next' and 'Back' buttons, or skip to another component by selecting the component number from the dropdown menu. Users can also skip to the 'Finish' from this dropdown. &#x20;

Components are classified as one of the following:  keep, reject, reject - TMS-evoked muscle, reject - blink,  reject - eye movement, reject - muscle, reject -  electrode noise, or reject - sensory . If a component classification algorithm has been used to classify components in TESA, this can be used as an input to tesa\_compplot to automatically mark components for rejection. If a component is selected for rejection, it is plotted as red on subsequent plots, if not it is plotted as blue. Following removal, a before-and-after plot is generated and users can select whether to continue or repeat the process. Component numbers and % variance represented by each component selected for  removal is stored in the EEG structure =>  EEG.icaCompClass.xxx

Note that tesa\_compplot is automatically called by tesa\_compselect if 'compCheck' is 'on'.

For further information on selecting components, please read:

* [Rogasch NC et al. (2014) Removing artefacts from TMS-EEG  recordings using independent component analysis: Importance for assessing prefrontal and motor cortex network properties. NeuroImage, 101:425-439 ](https://www.sciencedirect.com/science/article/abs/pii/S105381191400620X)
* [Rogasch NC et al. (2017) Analysing concurrent transcranial magnetic stimulation and electroencephalographic data: A review and introduction to the open-source TESA software NeuroImage, 147:934–951](https://www.sciencedirect.com/science/article/pii/S1053811916305845?via%3Dihub)

![](/files/-MAANCw_34M9JCMfIvkB)

**Independent component plotting.** Interactive figure providing information on each independent component, including: temporal, spatial and spectral features; classification (if tesa\_compselect run); and the effect of removing the IC has on the overall data.&#x20;

## EEGLAB user interface

![](/files/-MAAKGWYt3Tqpajlgx2k)

**1.** Select the IC classification from the drop down menu (if required). Note that tesa\_compselect is required for this option.

**2.** Set the size of the plotted figures. Three sizes are possible: small, medium and large.

**3.** Set the time course limits (x axis limits) for the component time course plots.

**4.** Set the frequency limits (x axis limits) for the component frequency plots.

**5.** Set the y-axis scaling for the frequency plot. Four scaling options are possible: raw, log, log10 and dB.

**6.** Turn on or off whether to save the IC weights in the EEG structure (useful for post hoc analysis of classified component features). Note turning this on will lead to larger file sizes.

## Scripts

### Base function

`EEG = tesa_compplot( EEG );` Default use

`EEG = tesa_compplot( EEG, 'key1',value1... );` Custom input

### Pop function

`EEG = pop_tesa_compplot( EEG );` Pop up window

`EEG = pop_tesa_compplot( EEG, 'key1',value1... );` Custom input

### Required inputs

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

### Optional inputs (key/value pairs)

| Key               | Input value                       | Description                                                                                                                                                                                                                                                                                                                                           | Example                | Default     |
| ----------------- | --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ----------- |
| **Plot settings** |                                   |                                                                                                                                                                                                                                                                                                                                                       |                        |             |
| 'compClassInput'  | EEGLAB structure field            | Location in EEGLAB structure where output from TESA components classification algorithms are stored (e.g. tesa\_compselect). Note that the number of components that have been classified must match the the number of components currently stored in the data (i.e. this won't work if you have already removed the components in tesa\_compselect). | EEG.icaCompClass.TESA1 | \[ ]        |
| 'saveWeights'     | 'on' or 'off'                     | Saves the winv (topoplot weights) and icaact (time course weights) that the classification was performed on. Note this will increase the storage size of the files.                                                                                                                                                                                   | 'on'                   | 'off'       |
| 'figSize'         | 'small' or 'medium' or 'larger'   | Determines the size of the figures that are plotted displaying the information on the components.                                                                                                                                                                                                                                                     | 'medium'               | 'small'     |
| 'plotTimeX'       | \[start,end]                      | Vector with integers for plotting the component time course (in ms).                                                                                                                                                                                                                                                                                  | \[-300,600]            | \[-200,500] |
| 'plotFreqX'       | \[low,high]                       | Vector with integers for plotting the frequency distribution of components (in Hz)                                                                                                                                                                                                                                                                    | \[2,45]                | \[1,100]    |
| 'freqScale'       | 'raw' or 'log' or 'log10' or 'db' | y-axis scaling for the frequency plots                                                                                                                                                                                                                                                                                                                | 'log10'                | 'log'       |

### Outputs

| Output | Description          |
| ------ | -------------------- |
| EEG    | EEGLAB EEG structure |

### Examples

`EEG = pop_tesa_compplot( EEG, 'compClassInput', EEG.icaCompClass.TESA1 );` % Loads automated component classifications performed by tesa\_compselect

`EEG = tesa_compplot( EEG, 'figSize', 'small','plotTimeX',[-600,600], 'plotFreqX', [2,45], 'freqScale', 'db' );` Changes the size of the figure and the x axis' of the time course and frequency plots, and the scale of the y-axis on the frequency plots.


---

# 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/remove_minimise_tms_muscle_activity/plot-and-remove-components.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.
