Problem with interpolate_bads

Hi everyone,
I learned a lot browsing the forum! Thx for that! :blush:
Unfortunately I have some unresolved problems, I hope I can describe it well:

First of all: I’m currently unsing MNE version 0.24.1 and am operating on Windows 10 with Spyder and Python 3.9.7.

When trying to interpolate bad channels with raw.interpolate_bads (or evoked.interpolate_bads) i get the ValueError

array must not contain infs or NaNs

with the following traceback:

Traceback (most recent call last):

File “C:\Users\AUDIOM~1\AppData\Local\Temp/ipykernel_1548/1984669639.py”, line 1, in
raw_interp = raw_chosen.copy().load_data().interpolate_bads(reset_bads=False)

File “”, line 24, in interpolate_bads

File “C:\ProgramData\Anaconda3\lib\site-packages\mne\channels\channels.py”, line 1183, in interpolate_bads
_interpolate_bads_eeg(self, origin=origin, exclude=exclude)

File “”, line 24, in _interpolate_bads_eeg

File “C:\ProgramData\Anaconda3\lib\site-packages\mne\channels\interpolation.py”, line 159, in _interpolate_bads_eeg
interpolation = _make_interpolation_matrix(pos_good, pos_bad)

File “C:\ProgramData\Anaconda3\lib\site-packages\mne\channels\interpolation.py”, line 108, in _make_interpolation_matrix
C_inv = linalg.pinv(C)

File “C:\ProgramData\Anaconda3\lib\site-packages\scipy\linalg\basic.py”, line 1315, in pinv
a = _asarray_validated(a, check_finite=check_finite)

File “C:\ProgramData\Anaconda3\lib\site-packages\scipy_lib_util.py”, line 293, in _asarray_validated
a = toarray(a)

File “C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\function_base.py”, line 488, in asarray_chkfinite
raise ValueError(

I think it has something to do with setting the montage to the standard_1020 but one channel not matching. The raised warning says:

RuntimeWarning: DigMontage is only a subset of info. There are 1 channel position not present in the DigMontage. The required channels are:

[‘IO’].

Consider using inst.set_channel_types if these are not EEG channels, or use the on_missing parameter if the channel positions are allowed to be unknown in your analyses.

(wich is totally fine until i want to interpolate the bad channels :smiley: )

Unfortuantely when I don’t set the montage I also get an error from the interpolation function:

Cannot fit headshape without digitization , info[“dig”] is None

I think my question is: Is the montage really the problem here and (if yes) is there some kind of workaround for this? Maybe setting the position for the IO-channel (wich is the reference channel) manually?

Kind regards,
Leoni

Hello, for interpolation, the algorithm needs to know how channels are arranged, and to know that, all channels need to have a proper location assigned. What is that channel IO…? Is it the inion…?

Maybe you can just drop this channel altogether and then do the interpolation?

I think the error messages that you’re seeing are not very helpful and should be improved.

Best wishes,
Richard

Hello Richard,
thank you for your answer.
Dropping the channel solves the problem.

The IO is an electrode glued to the nose and is used as reference without brain activity. That’s why I was thinking about manually assigning a position or something like that.
Would that be possible?

(Or I need to talk to my supervisors about using an average reference instead.)

Best wishes,
Leoni

Oh, the good old nose-tip reference! :nose:

I think I would then, as one of the very first steps after importing the data, (re)reference to IO, drop IO, and then proceed with the rest of my processing.

Or like you said, drop IO and use something like the common average reference, yes.

In either case I would drop IO before continuing to do further analyses.

I would not try to assign an arbitrary location to that channel.

1 Like

Jup that one :smile:

Thank you a lot for your help, I guess that’s the way to go and so simple too!
Have a nice day!

1 Like