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:
rawmne.io.Raw

Continuous EEG recording (must contain EEG channels).

filter_bands_icatuple of float

(l_freq, h_freq) for the ICA-specific bandpass filter.

notch_freqsarray_like

Line-noise frequencies to notch out before ICA.

downsample_icafloat

Target sampling rate for ICA fitting (anti-aliasing applied automatically). Skipped when the recording is already at or below this rate.

threshfloat

ICLabel probability threshold. A component is excluded only when its predicted probability for the artifact label meets or exceeds this value. Set to -1 to use popularity-vote mode: each IC is assigned to whichever class has the highest predicted probability, regardless of the absolute value, mirroring BeMoBIL’s iclabel_threshold=-1 behaviour.

rng_seedint | None

Random seed passed to mne.preprocessing.ICA for reproducibility.

exclude_labelslist of str | None

ICLabel category names to exclude (e.g. ["eye", "muscle"]). Mutually exclusive with include_labels.

include_labelslist of str | None

ICLabel category names to keep; all other categories are excluded (e.g. ["brain", "other"]). Mutually exclusive with exclude_labels.

ica_methodstr

ICA algorithm to use. "amica" (default) uses the amica-python implementation of Adaptive Mixture ICA and converts the result to an MNE ICA object via AMICA.to_mne(). Any other string is passed directly as the method argument to mne.preprocessing.ICA (e.g. "picard", "fastica"). If "amica" is requested but the amica package is not installed, the method falls back to "picard" with an extended-infomax fit and a warning.

amica_kwargsdict | None

Extra keyword arguments forwarded to amica.AMICA when ica_method="amica". Useful for controlling convergence, e.g. {"max_iter": 2000}. None uses AMICA defaults. Ignored when a non-AMICA method is used.

Returns:
icamne.preprocessing.ICA

Fitted ICA object with ica.exclude populated according to the label criteria.

ic_labelsdict

Output of mne_icalabel.label_components() containing "labels" and "y_pred_proba" keys.

Raises:
ValueError

If both exclude_labels and include_labels are provided.