Error interpolating bad MEG channels

MNE version: 1.1.1

Hello,

I am currently preprocessing some MEG data, and i would like to interpolate the bad channels. However, it returns an error.

The line of code i am trying to run is:
filt_raw.interpolate_bads()

And the error i get is:
ValueError: Only 0 head digitization points of the specified kinds ("eeg", "extra",), at least 4 required

If needed here is the code used before trying to interpolate the bad channels:

raw = mne.io.read_raw_fif(filepath_raw);
raw.load_data();

raw.pick_types(meg=True, eeg=False, stim=True)

raw.info['bads'] = ['MEG0422', 'MEG1423', 'MEG2531', 'MEG1341', 'MEG1831', 'MEG2542']

filt_raw = raw.copy().filter(l_freq=1, h_freq=40)

hmm, I would have thought that for MEG interpolation you wouldn’t need those digitized scalp points. I guess maybe we still need a defined origin and sphere, and we derive those from the digitization points. I guess in principle it might be possible to infer an origin from the sensor coil locations, and use a default sphere radius, for cases where no scalp digitization occurred. @larsoner WDYT? Is that even feasible / sane?

In this case you have to pass a sphere because it can’t be automatically determined. (0, 0, 0.04) is probably reasonable for an adult. The interpolation works by projecting good channels to a spherical source space, then projecting back out to the bad sensor(s), so it needs to know a reasonable place to do this.

ahh, OK. I missed that because the param is called origin instead of sphere. so raw_filt.interpolate_bads(origin=(0, 0, 0.04)) should work. Thanks @larsoner.