Description
Describe the new feature or enhancement
interpolate_bads
has several methods implemented, like the most commonly used spherical spline approach, but also "mne", and "nearest" (for fnirs, although it is not documented what this entails).
All of these methods require 3D sensor positions to work, however, sometimes these may not be available.
As an alternative, it would be great to pass an adjacency matrix (see e.g., find_ch_adjacency
), and have the interpolation be done as a (weighted) average of the neighbors.
This is something that is already supported in FieldTrip: https://github.com/fieldtrip/fieldtrip/blob/55e8f26facac8eaf16ba7222433eba3080803b5c/ft_channelrepair.m#L3-L7
Describe your proposed implementation
- There should be a function to easily create an "mne adjacency matrix" from scratch, for example by passing a dict of neighbors:
mydict = {
ch1: [ch2, ch3], # mapping a channel to its neighbors
...
}
adjacency = mne.channels.make_adjacency(mydict)
.interpolate_bads
method should have a newmethod
argument calledneighbors
and a new parameteradjacency
, which gets used for neighbor interpolation.
Describe possible alternatives
I am not aware of an alternative for channel interpolation when no sensor positions are available.
Additional context
This proposed functionality would have to exhibit some "smart" behavior for cases where too few "good" neighbors are available. Potentially with an additional parameter n_required_good_neighbors
(or similar), and if that threshold is not met, no interpolation happens for the channel in question