How to handle unstable mixing matrix estimation warning when using

  • MNE-Python version: 0.24
  • MAC OS 11.6.1

I’m encountering a warning when attempting to fit my ica to my raw data. I have a 10-minute EEG recording consisting of 46 channels with sampling rate 250 Hz.

I’ve tried to use the syntax given under the API reference for ICA.

import mne
from mne.preprocessing import ICA
raw ='myfile.edf',preload=True)
raw_filt = raw.filter(l_freq=1, h_freq=None)
ica = ICA(method='fastica',n_components=.999999, random_state=6,max_iter="auto")

In the fitting step, I receive the following warning:

> RuntimeWarning: Using n_components=0.999999 (resulting in n_components_=6) may lead to an unstable mixing matrix estimation because the ratio between the largest (46) and smallest (2.2e-05) variances is too large (> 1e6); consider setting n_components=0.999999 or an integer <= 5

I’m not sure how to address this, particularly since I’ve followed the suggestion and set n_components=.999999 . I observed that setting n_components=5 did not produce a warning, but I’m not sure why.

Also, do I apply the fit to the original raw data or the filtered version?


Hi @PaulF,

I have just encountered the same issue and I am not sure how to fix it. Did you end up finding a solution or an explanation to the problem?


@Giuseppe-1993 what kind of data are you using? MEG, EEG, …? How many channels? Thanks!

Hi @richard,

thank you for your attention. I am using EEG data, 64 channels, recorded using BioSemi. I have a total of 30 participants and this ICA issue seems to happen only on particular datasets. I am now inspecting the data to see if perhaps the dataset itself is corrupted but it does not look like it.

@Giuseppe-1993 would you mind sharing one of the affected datasets and a minimal working example to reproduce the issue you’re seeing?

You can share a link to the data via email:

Hi Richard,

Unfortunately, I am not able to share either the dataset or the code due to IP agreements. However, after careful inspection, I can conclude that the behaviour was very likely due to the low signal-to-noise ratio. After rejecting manually segments of the data that seemed problematic, the ICA issue seems to stop. I will keep you updated should this happen again.