> ## Documentation Index
> Fetch the complete documentation index at: https://docs.autocleaneeg.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Independent Component Analysis (ICA)

> Understand how AutocleanEEG uses ICA to identify and remove artifacts like eye blinks, muscle activity, and heartbeat from EEG data.

## What is ICA?

Independent Component Analysis (ICA) is a powerful technique that separates mixed EEG signals into independent components. Think of it as "unmixing" the cocktail of brain activity, eye blinks, muscle tension, and heartbeat that gets recorded at each electrode.

<Info>
  ICA is particularly effective at removing **stereotypical artifacts** that occur consistently across your recording, such as eye blinks, heartbeat, and muscle activity.
</Info>

## Data Preparation Modes

* **Temporary High-Pass Filtering**: A temporary high-pass filter (typically 1 Hz) can be applied before ICA decomposition to remove slow drifts.
* **Original Data Preservation**: ICA components are fitted on the filtered copy but applied to the original, unfiltered recording.

## Component Classification Modes

AutocleanEEG Pipeline supports three modes for ICA component classification:

### 1. ICLabel (**Default**)

* Runs **ICLabel** (from MNE-ICALabel) on all components.
* Produces probability scores for 7 classes:
  * Brain, Eye, Muscle, Heart, Line noise, Channel noise, Other
* **This is the default and most stable option.**

### 2. ICVision (**Experimental**)

* Runs **ICVision** on all components.
* Provides fine-grained classification using computer vision features.
* Still under evaluation — results may vary.
* Use this mode if you want to test the latest classification research.

### 3. Hybrid: ICLabel + ICVision (**Experimental**)

* First pass: run **ICLabel** on all components.
* Second pass: re-check a configurable subset of components with **ICVision**.
* Produces a full `n_components × 7` confidence matrix.
* Components reprocessed by ICVision are flagged with `annotator="ic_vision"`.
* ICA reports will display `[Vision]` tags for these components.

<Tip>
  Control how many components are rechecked with ICVision by passing\
  <code>icvision\_n\_components</code> to <code>classify\_ica\_components</code>.
</Tip>

## Configuration Options

## Best Practices

### When ICA Works Best

* **Sufficient Data**: At least 20-30 times more data points than channels
* **Consistent Artifacts**: Stereotypical artifacts that occur multiple times
* **Stable Recording**: Minimal electrode movement or impedance changes

### Quality Control

After ICA processing, review the generated outputs:

* **Component Report**: `*_ica_components_all.pdf` shows all components and which were removed
* **Signal Comparison**: `*_raw_vs_cleaned_overlay.png` displays before/after signal comparison
* **Processing Log**: Documents which components were classified and removed

<Tip>
  The number of ICA components typically equals the number of channels. With 128 channels, expect \~118-121 components after excluding bad channels.
</Tip>

## Understanding the Output

### Component Classification Example

From a typical processing run:

```
Identified 23 components for rejection: [0, 1, 2, 4, 7, 8, 12, 13, 17, 18, 20, 28, 30, 31, 32, 35, 38, 45, 50, 64, 70, 98, 115]
Applied ICA, removing components: [0, 1, 2, 4, 7, 8, 12, 13, 17, 18, 20, 28, 30, 31, 32, 35, 38, 45, 50, 64, 70, 98, 115]
```
