bemobil_mne.preproc.compute_ica#
- bemobil_mne.preproc.compute_ica(raw, filter_bands_ica=(1.0, 100.0), notch_freqs=(50, 100, 150), downsample_ica=250, thresh=0.7, rng_seed=None, exclude_labels=None, include_labels=None, ica_method='amica', amica_kwargs=None)[source]#
Fit ICA on a filtered copy of raw and label components with ICLabel.
- Parameters:
- raw
mne.io.Raw Continuous EEG recording (must contain EEG channels).
- filter_bands_ica
tupleoffloat (l_freq, h_freq)for the ICA-specific bandpass filter.- notch_freqsarray_like
Line-noise frequencies to notch out before ICA.
- downsample_ica
float Target sampling rate for ICA fitting (anti-aliasing applied automatically). Skipped when the recording is already at or below this rate.
- thresh
float ICLabel probability threshold. A component is excluded only when its predicted probability for the artifact label meets or exceeds this value. Set to
-1to use popularity-vote mode: each IC is assigned to whichever class has the highest predicted probability, regardless of the absolute value, mirroring BeMoBIL’siclabel_threshold=-1behaviour.- rng_seed
int|None Random seed passed to
mne.preprocessing.ICAfor reproducibility.- exclude_labels
listofstr|None ICLabel category names to exclude (e.g.
["eye", "muscle"]). Mutually exclusive with include_labels.- include_labels
listofstr|None ICLabel category names to keep; all other categories are excluded (e.g.
["brain", "other"]). Mutually exclusive with exclude_labels.- ica_method
str ICA algorithm to use.
"amica"(default) uses the amica-python implementation of Adaptive Mixture ICA and converts the result to an MNE ICA object viaAMICA.to_mne(). Any other string is passed directly as themethodargument tomne.preprocessing.ICA(e.g."picard","fastica"). If"amica"is requested but theamicapackage is not installed, the method falls back to"picard"with an extended-infomax fit and a warning.- amica_kwargs
dict|None Extra keyword arguments forwarded to
amica.AMICAwhenica_method="amica". Useful for controlling convergence, e.g.{"max_iter": 2000}.Noneuses AMICA defaults. Ignored when a non-AMICA method is used.
- raw
- Returns:
- ica
mne.preprocessing.ICA Fitted ICA object with
ica.excludepopulated according to the label criteria.- ic_labels
dict Output of
mne_icalabel.label_components()containing"labels"and"y_pred_proba"keys.
- ica
- Raises:
ValueErrorIf both exclude_labels and include_labels are provided.