mne-tools / mne-tools/mne-python
Add a "neighbor" method to `interpolate_bads` that works without exact sensor positions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.5k
- Forks
- 1.6k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 100
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_badsmethod should have a newmethodargument calledneighborsand 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing interpolate_bads methods and the find_ch_adjacency entry point. Define how mne.channels.make_adjacency should build an adjacency matrix, how the neighbors method uses adjacency, and what happens when too few good neighbors exist. Done means adjacency-based interpolation works without exact sensor positions and its edge cases are specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100