You need channel locations, but these are available in your data. Maybe they are somehow incorrect? Can you plot the montage maybe? Otherwise, I have no idea what’s going on, but I have only ever used interpolation for EEG channels, so maybe someone else with MEG experience can chime in?
I really don’t know what is happening, but could it be the case that your syntax necessarily excludes channel 79?
I just have been looking at this example where they specifically mention the exclude=[] syntax, when calling pick_types, as a trick to make the interpolation work. At least it seems like it’s worth a shot.
If this channels’ activity is constantly zero (?) and is included in the interpolation maybe this is the problem then? I mean the fact that you compute a dot product with an all-zeros vector; it will be an all-zeros vector.
Not taking this channel into account, or hacking this channels’ values and replacing them with ones maybe would solve your problem then.
I am not sure whether this is what the parameter exclude of interplolate_bads is trying to solve.
(But there must be a better way to do it than hacking; someone with a better grasp of the source code could answer this I guess)
And interestingly, it seems that the interpolation has been done. However, the values of this channel are much smaller (near zero) after the interpolation. Is it due to the dot calculation?
Ah, I see. It’s this difference in orders of magnitude that this channel introduces to the computations; your calculations must internally be something like this Xe-12 * Ye-14 = X*Ye-(12+14), X being the sum of all “good” channels.
Can’t say for sure, but I would:
Try to see the raw activity (before filtering) for diagnostic purposes.
Try re-referencing (CAR ???) if that’s a valid pre-processing step for what you are trying to do.
Try adding MEG 079 as a channel to be excluded during the interpolation.
I tried your suggestions and they helped a lot. The problem was finally solved by excluding the reference channels and also adding origin=(0.,0.,0.01) (the default is origin=(0.,0.,0.04) when calling .interpolate_bads(). Happily the interpolation is now working well!
If I change the origin for example to origin = (0,0,0.01) as the OP or to origin = (0,0,0) (see image) some kind of interpolation is applied to the data.
However, no change can be detected with the default settings for the origin (i.e., origin = "auto") even though my data includes digitalisation points, hence this should work. Setting the origin to (0,0,0.1) or (0,0,0) seems a bit arbitrary, though. Could it be possible that the interpolate_bads() function accidentally determines the wrong origin (i.e., the head center in head coordinates rather than the head center in device coordinates)?
The same problem also occurs when trying to interpolate bad channels based on raw data. The first screenshot shows the continuous data with bad channels marked and the second screenshot after interpolation.
I just compared the data of both the raw and the interpolated file. The data actually seems to differ a bit (the magnitude of the difference is just very small)!