ica.find_bads_muscle gives a TypeError

  • MNE version: 1.1
  • operating system: Windows 10

Hi! I was trying to use ica.find_bads_muscle on my epochs, but it gives the following error:

Using multitaper spectrum estimation with 7 DPSS windows
Traceback (most recent call last):
File “*Miniconda3\envs\mne\lib\site-packages\IPython\core\interactiveshell.py”, line 3398, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File “”, line 1, in <cell line: 1>
File “”, line 12, in find_bads_muscle
File “*site-packages\mne\preprocessing\ica.py”, line 1653, in find_bads_muscle
slopes = np.polyfit(np.log10(freqs), np.log10(psds).T, 1)[0]
File “<array_function internals>”, line 180, in polyfit
File “*site-packages\numpy\lib\polynomial.py”, line 640, in polyfit
raise TypeError(“expected 1D or 2D array for y”)
TypeError: expected 1D or 2D array for y

I’ve also used ica.find_bads_eog, and that worked fine on my dataset. Thanks for taking a look.

@alexrockhill may be the best person able to answer this one

Thanks for pointing this out, it’s a bug in MNE where we didn’t test the implementation on epochs! It should work just fine for raw objects though, but we’ll have to fix the code for epochs.