Skip to content
Merged
Changes from 2 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
54dd4a1
Raising meaningful warnings/errors for interpolate_bads, when supplie…
1himan Dec 1, 2025
be254c4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 1, 2025
7f5d63b
Improved logic and error message
1himan Dec 3, 2025
0fa2ba9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 3, 2025
272c38a
Removed my custome testing file
1himan Dec 3, 2025
04d2f7e
minor changes
1himan Dec 3, 2025
db1b993
Fixing CI tests
1himan Dec 3, 2025
8ea167e
Merge branch 'main' into interpolate_bads_bugfix
1himan Dec 4, 2025
8c0a5a9
Merge branch 'main' into interpolate_bads_bugfix
1himan Dec 13, 2025
feb4415
Merge branch 'main' into interpolate_bads_bugfix
1himan Dec 16, 2025
63f8dd5
Validation warning while processing docstring for .interpolate_bads()…
1himan Dec 21, 2025
c566b90
Merge branch 'interpolate_bads_bugfix' of https://github.com/1himan/m…
1himan Dec 21, 2025
c1bcbc5
Indentation fix
1himan Dec 21, 2025
fec6daf
CLI check fix
1himan Dec 21, 2025
fdff96d
Merge branch 'mne-tools:main' into interpolate_bads_bugfix
1himan Dec 24, 2025
d84c11f
this fixes the cli tests
1himan Jan 2, 2026
54c82e5
Merge branch 'main' into interpolate_bads_bugfix
1himan Jan 3, 2026
78ad836
Made suggested changes
1himan Jan 7, 2026
9358051
Improved tests
1himan Jan 7, 2026
2d19ecb
Fixed linting errors
1himan Jan 7, 2026
68f7039
Merge branch 'main' into interpolate_bads_bugfix
1himan Jan 7, 2026
4915ff0
Rmoved redundancy
1himan Jan 8, 2026
e4b7bb9
Merge branch 'main' into interpolate_bads_bugfix
1himan Jan 10, 2026
68dbb28
Added dev entries, and fixed test logic
1himan Jan 13, 2026
fecd9c9
Merge branch 'main' into interpolate_bads_bugfix
1himan Jan 13, 2026
a3f70e3
Fixing ci tests
1himan Jan 13, 2026
fc9621f
Merge branch 'main' into interpolate_bads_bugfix
1himan Jan 17, 2026
4238184
Merge branch 'main' into interpolate_bads_bugfix
1himan Jan 20, 2026
3828f82
Polish
1himan Jan 20, 2026
1f335df
Merge branch 'main' into interpolate_bads_bugfix
1himan Jan 27, 2026
c1fe227
Merge branch 'main' into interpolate_bads_bugfix
1himan Feb 12, 2026
bce4d64
Merge branch 'main' into interpolate_bads_bugfix
1himan Feb 20, 2026
c801334
Change on_bad_position behavior from 'raise' to 'warn'
1himan Feb 23, 2026
5907250
More meaningful error and warning message to the user
1himan Feb 23, 2026
590861c
fixed ruff error
1himan Feb 23, 2026
a2ab8c9
Adding final suggestions
1himan Feb 25, 2026
7b1e697
Merge branch 'main' into interpolate_bads_bugfix
1himan Feb 25, 2026
a026239
Merge branch 'main' into interpolate_bads_bugfix
1himan Mar 5, 2026
4c551d9
Merge branch 'main' into interpolate_bads_bugfix
1himan Mar 6, 2026
5a3fedb
Merge branch 'main' into interpolate_bads_bugfix
1himan Mar 10, 2026
9512936
Adding version:1.12
1himan Mar 12, 2026
7a79dd1
Reverting changes
1himan Mar 12, 2026
72aa5de
Reverting changes
1himan Mar 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions mne/channels/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ def interpolate_bads(
method=None,
exclude=(),
verbose=None,
**kwargs,
Comment thread
1himan marked this conversation as resolved.
Outdated
):
"""Interpolate bad MEG and EEG channels.

Expand Down Expand Up @@ -896,6 +897,28 @@ def interpolate_bads(

_check_preload(self, "interpolation")
_validate_type(method, (dict, str, None), "method")
bads_to_check = self.info["bads"]
for ch_name in bads_to_check:
try:
ch_idx = self.ch_names.index(ch_name)
ch_loc = self.info["chs"][ch_idx]["loc"]
is_loc_invalid = np.allclose(ch_loc, 0.0, atol=1e-16) or np.any(
np.isnan(ch_loc)
)
except ValueError:
continue
Comment thread
1himan marked this conversation as resolved.
Outdated

if is_loc_invalid:
msg = (
f"Bad channel '{ch_name}' is missing valid sensor position (loc) information. "
"Interpolation cannot proceed correctly."
Comment thread
1himan marked this conversation as resolved.
Outdated
)
_on_missing(
kwargs.get("on_no_position", "error"),
msg + " If you want to continue despite missing positions, set "
"on_no_position='warn' or 'ignore'.",
Comment thread
1himan marked this conversation as resolved.
Outdated
)

method = _handle_default("interpolation_method", method)
ch_types = self.get_channel_types(unique=True)
# figure out if we have "mag" for "meg", "hbo" for "fnirs", ... to filter the
Expand Down
Loading