> 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/fastica.md).

# FastICA

This function runs FastICA using some common settings applied for TMS-EEG data analysis. See the publications listed below for further details. tesa\_fastica uses EEGLAB pop\_runica function. A stabilization option is also included which can help if data are not converging.

* [Korhonen, Hernandez-Pavon et al (2011) Removal of large muscle artifacts from transcranial magnetic stimulation-evoked EEG by independent component analysis. Med Biol Eng Compt, 49:397-407.](http://www.ncbi.nlm.nih.gov/pubmed/21331656)
* [Rogasch et al (2014) Removing artefacts from TMS-EEG recordings using independent component analysis: Importance for assessing prefrontal and motor cortex network properties. NeuroImage, 101: 429-435.](http://www.ncbi.nlm.nih.gov/pubmed/25067813)

Note that this script requires that the FastICA algorithm is included in the Matlab path. The package can be downloaded from: <http://research.ics.aalto.fi/ica/fastica/code/dlcode.shtml>

After running FastICA, this function also ranks and sorts the components by percentage variance explained by each time course.

After running this function, independent components representing artifacts can be automatically detected using the [automatic component selection](/tesa-user-manual/remove_minimise_tms_muscle_activity/auto_comp_select.md) function.

## EEGLAB user interface

![](/files/-LmJDLmhhjAeuPlkbKDI)

**1.** Select the approach for FastICA from the drop down menu. The symmetric approach is more stable and is therefore recommended.

**2.** Select the contrast function (g) from the drop down menu.

**3.** Turn on or off the stabilization version of the FastICA algorithm. This can help if FastICA is not converging. See the FastICA help for further information.

## Scripts

### Base function

`EEG = tesa_fastica( EEG );` Default use

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

### Pop function

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

`EEG = pop_tesa_fastica( 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 |
| --------------- | ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------- |
| 'approach'      | 'symm' or 'defl'                      | Symmetric or deflation approach for FastICA. The symmetric approach is more reliable and therefore highly recommended. See Korhonen et al for details.                      | 'symm'  | 'symm'  |
| 'g'             | 'tanh' or 'gauss' or 'pow3' or 'skew' | Contrast function for FastICA. Either 'tanh' or 'gauss' perform equally well for TMS-EEG analysis. See Korhonen et al for details.                                          | 'gauss' | 'tanh'  |
| 'stabilization' | 'on' or 'off'                         | Controls whether FastICA uses stabilized version which detects 'strokes' (i.e. when algorithm gets stuck between 2 points and won't converge) and halves the learning rate. | 'on'    | 'off'   |

### Outputs

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

### Examples

`EEG = pop_tesa_fastica( EEG );` Default use

`EEG = pop_tesa_fastica( EEG, 'g', 'gauss', 'stabilization', 'on' );` Uses the gauss contrast function and turns on the stabilized FastICA version to aid with convergence.


---

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

```
GET https://nigelrogasch.gitbook.io/tesa-user-manual/remove_minimise_tms_muscle_activity/fastica.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.
