From 7b7611102088872b536161b70ca96a4d2899a94b Mon Sep 17 00:00:00 2001 From: Christoph Huber-Huber Date: Mon, 16 Mar 2026 18:15:08 +0100 Subject: [PATCH 1/7] fixed some info fields in MEG interpolation across sensor types using .interpolate_to() to maintain time, filter, and similar information --- mne/channels/interpolation.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/mne/channels/interpolation.py b/mne/channels/interpolation.py index b27f8d70058..1ea6e15afff 100644 --- a/mne/channels/interpolation.py +++ b/mne/channels/interpolation.py @@ -484,13 +484,35 @@ def _interpolate_to_meg(inst, sensors, origin, mode): if len(picks_meg_good) == 0: raise ValueError("No good MEG channels available for interpolation.") - # Load target sensor configuration - info_to = read_meg_canonical_info(sensors) - info_to["dev_head_t"] = deepcopy(inst.info["dev_head_t"]) + # Load target sensor configuration as info file + info_cano = read_meg_canonical_info(sensors) # Get source MEG info info_from = pick_info(inst.info, picks_meg_good) + # Design target info like source, except for channel info and + # some (possibly) related fields + info_to = deepcopy(info_from) + info_to._unlocked = True # make all info fields modifiable + # Update channel info to the desired one + info_to['chs'] = deepcopy(info_cano['chs']) + info_to['ch_names'] = deepcopy(info_cano['ch_names']) + info_to['nchan'] = deepcopy(info_cano['nchan']) + # Reset some channel and machine-related fields to avoid confusion later on + info_to['device_info'] = None + info_to['helium_info'] = None + info_to['proj_id'] = None + info_to['proj_name'] = None + info_to['gantry_angle'] = None + # we keep original 'dev_head_t' + info_to['ctf_head_t'] = None + info_to['dev_ctf_t'] = None + # info_to['dig'] = None # or should they be removed, too? + info_to['bads'] = [] + info_to['projs'] = [] + info_to['comps'] = [] + info_to._unlocked = False # lock info again + # Compute field interpolation mapping origin_val = _check_origin(origin, inst.info) mapping = _map_meg_or_eeg_channels(info_from, info_to, mode=mode, origin=origin_val) From 8313af6cfdf2e2c40cc0ce1034c95c199840c58c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Mar 2026 17:18:57 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne/channels/interpolation.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mne/channels/interpolation.py b/mne/channels/interpolation.py index 1ea6e15afff..e8123cd1474 100644 --- a/mne/channels/interpolation.py +++ b/mne/channels/interpolation.py @@ -495,24 +495,24 @@ def _interpolate_to_meg(inst, sensors, origin, mode): info_to = deepcopy(info_from) info_to._unlocked = True # make all info fields modifiable # Update channel info to the desired one - info_to['chs'] = deepcopy(info_cano['chs']) - info_to['ch_names'] = deepcopy(info_cano['ch_names']) - info_to['nchan'] = deepcopy(info_cano['nchan']) + info_to["chs"] = deepcopy(info_cano["chs"]) + info_to["ch_names"] = deepcopy(info_cano["ch_names"]) + info_to["nchan"] = deepcopy(info_cano["nchan"]) # Reset some channel and machine-related fields to avoid confusion later on - info_to['device_info'] = None - info_to['helium_info'] = None - info_to['proj_id'] = None - info_to['proj_name'] = None - info_to['gantry_angle'] = None + info_to["device_info"] = None + info_to["helium_info"] = None + info_to["proj_id"] = None + info_to["proj_name"] = None + info_to["gantry_angle"] = None # we keep original 'dev_head_t' - info_to['ctf_head_t'] = None - info_to['dev_ctf_t'] = None + info_to["ctf_head_t"] = None + info_to["dev_ctf_t"] = None # info_to['dig'] = None # or should they be removed, too? - info_to['bads'] = [] - info_to['projs'] = [] - info_to['comps'] = [] + info_to["bads"] = [] + info_to["projs"] = [] + info_to["comps"] = [] info_to._unlocked = False # lock info again - + # Compute field interpolation mapping origin_val = _check_origin(origin, inst.info) mapping = _map_meg_or_eeg_channels(info_from, info_to, mode=mode, origin=origin_val) From 707f73f59c4eb3184edafa998af8278bd58b45d8 Mon Sep 17 00:00:00 2001 From: Christoph Huber-Huber Date: Tue, 17 Mar 2026 11:03:27 +0100 Subject: [PATCH 3/7] incorporated feedback on pull request #13759 --- mne/channels/interpolation.py | 38 ++++++++++++++++------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/mne/channels/interpolation.py b/mne/channels/interpolation.py index 1ea6e15afff..ae4388f342f 100644 --- a/mne/channels/interpolation.py +++ b/mne/channels/interpolation.py @@ -490,28 +490,24 @@ def _interpolate_to_meg(inst, sensors, origin, mode): # Get source MEG info info_from = pick_info(inst.info, picks_meg_good) - # Design target info like source, except for channel info and - # some (possibly) related fields + # Update target info to accommodate the desired channel info + # and reset some channel and machine-related fields to avoid + # confusion later on. + # NOTE: We don't change the original 'dev_head_t'. + # Some keys require as default an empty list. info_to = deepcopy(info_from) - info_to._unlocked = True # make all info fields modifiable - # Update channel info to the desired one - info_to['chs'] = deepcopy(info_cano['chs']) - info_to['ch_names'] = deepcopy(info_cano['ch_names']) - info_to['nchan'] = deepcopy(info_cano['nchan']) - # Reset some channel and machine-related fields to avoid confusion later on - info_to['device_info'] = None - info_to['helium_info'] = None - info_to['proj_id'] = None - info_to['proj_name'] = None - info_to['gantry_angle'] = None - # we keep original 'dev_head_t' - info_to['ctf_head_t'] = None - info_to['dev_ctf_t'] = None - # info_to['dig'] = None # or should they be removed, too? - info_to['bads'] = [] - info_to['projs'] = [] - info_to['comps'] = [] - info_to._unlocked = False # lock info again + with info_to._unlock(): + info_to.update({'chs': deepcopy(info_cano['chs']), + 'ch_names': deepcopy(info_cano['ch_names']), + 'nchan': deepcopy(info_cano['nchan']), + 'device_info': None, + 'helium_info': None, + 'gantry_angle': None, + 'ctf_head_t': None, + 'dev_ctf_t': None, + 'bads': [], + 'projs': [], + 'comps': []}) # Compute field interpolation mapping origin_val = _check_origin(origin, inst.info) From bb72cafdce0e3aa89bf1b64b08ef891e4cfbfe6f Mon Sep 17 00:00:00 2001 From: Christoph Huber-Huber Date: Tue, 17 Mar 2026 11:07:16 +0100 Subject: [PATCH 4/7] Revert "incorporated feedback on pull request #13759" This reverts commit 707f73f59c4eb3184edafa998af8278bd58b45d8. --- mne/channels/interpolation.py | 38 +++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/mne/channels/interpolation.py b/mne/channels/interpolation.py index ae4388f342f..1ea6e15afff 100644 --- a/mne/channels/interpolation.py +++ b/mne/channels/interpolation.py @@ -490,24 +490,28 @@ def _interpolate_to_meg(inst, sensors, origin, mode): # Get source MEG info info_from = pick_info(inst.info, picks_meg_good) - # Update target info to accommodate the desired channel info - # and reset some channel and machine-related fields to avoid - # confusion later on. - # NOTE: We don't change the original 'dev_head_t'. - # Some keys require as default an empty list. + # Design target info like source, except for channel info and + # some (possibly) related fields info_to = deepcopy(info_from) - with info_to._unlock(): - info_to.update({'chs': deepcopy(info_cano['chs']), - 'ch_names': deepcopy(info_cano['ch_names']), - 'nchan': deepcopy(info_cano['nchan']), - 'device_info': None, - 'helium_info': None, - 'gantry_angle': None, - 'ctf_head_t': None, - 'dev_ctf_t': None, - 'bads': [], - 'projs': [], - 'comps': []}) + info_to._unlocked = True # make all info fields modifiable + # Update channel info to the desired one + info_to['chs'] = deepcopy(info_cano['chs']) + info_to['ch_names'] = deepcopy(info_cano['ch_names']) + info_to['nchan'] = deepcopy(info_cano['nchan']) + # Reset some channel and machine-related fields to avoid confusion later on + info_to['device_info'] = None + info_to['helium_info'] = None + info_to['proj_id'] = None + info_to['proj_name'] = None + info_to['gantry_angle'] = None + # we keep original 'dev_head_t' + info_to['ctf_head_t'] = None + info_to['dev_ctf_t'] = None + # info_to['dig'] = None # or should they be removed, too? + info_to['bads'] = [] + info_to['projs'] = [] + info_to['comps'] = [] + info_to._unlocked = False # lock info again # Compute field interpolation mapping origin_val = _check_origin(origin, inst.info) From 900c81e8fc1be7c891b3e16309ab781537431a8d Mon Sep 17 00:00:00 2001 From: Christoph Huber-Huber Date: Tue, 17 Mar 2026 11:16:30 +0100 Subject: [PATCH 5/7] incorporated feedback on pull request #13759 again --- mne/channels/interpolation.py | 38 ++++++++++++++++------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/mne/channels/interpolation.py b/mne/channels/interpolation.py index e8123cd1474..0c84d1fdb79 100644 --- a/mne/channels/interpolation.py +++ b/mne/channels/interpolation.py @@ -490,28 +490,24 @@ def _interpolate_to_meg(inst, sensors, origin, mode): # Get source MEG info info_from = pick_info(inst.info, picks_meg_good) - # Design target info like source, except for channel info and - # some (possibly) related fields + # Update target info to accommodate the desired channel info + # and reset some channel and machine-related fields to avoid + # confusion later on. + # NOTE: We don't change the original 'dev_head_t'. + # Some keys require as default an empty list. info_to = deepcopy(info_from) - info_to._unlocked = True # make all info fields modifiable - # Update channel info to the desired one - info_to["chs"] = deepcopy(info_cano["chs"]) - info_to["ch_names"] = deepcopy(info_cano["ch_names"]) - info_to["nchan"] = deepcopy(info_cano["nchan"]) - # Reset some channel and machine-related fields to avoid confusion later on - info_to["device_info"] = None - info_to["helium_info"] = None - info_to["proj_id"] = None - info_to["proj_name"] = None - info_to["gantry_angle"] = None - # we keep original 'dev_head_t' - info_to["ctf_head_t"] = None - info_to["dev_ctf_t"] = None - # info_to['dig'] = None # or should they be removed, too? - info_to["bads"] = [] - info_to["projs"] = [] - info_to["comps"] = [] - info_to._unlocked = False # lock info again + with info_to._unlock(): + info_to.update({"chs": deepcopy(info_cano["chs"]), + "ch_names": deepcopy(info_cano["ch_names"]), + "nchan": deepcopy(info_cano["nchan"]), + "device_info": None, + "helium_info": None, + "gantry_angle": None, + "ctf_head_t": None, + "dev_ctf_t": None, + "bads": [], + "projs": [], + "comps": []}) # Compute field interpolation mapping origin_val = _check_origin(origin, inst.info) From 896b585b6775ff8b37f6c442b9d0e900c198926f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Mar 2026 10:17:12 +0000 Subject: [PATCH 6/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne/channels/interpolation.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/mne/channels/interpolation.py b/mne/channels/interpolation.py index 0c84d1fdb79..eb6aa2885a9 100644 --- a/mne/channels/interpolation.py +++ b/mne/channels/interpolation.py @@ -497,17 +497,21 @@ def _interpolate_to_meg(inst, sensors, origin, mode): # Some keys require as default an empty list. info_to = deepcopy(info_from) with info_to._unlock(): - info_to.update({"chs": deepcopy(info_cano["chs"]), - "ch_names": deepcopy(info_cano["ch_names"]), - "nchan": deepcopy(info_cano["nchan"]), - "device_info": None, - "helium_info": None, - "gantry_angle": None, - "ctf_head_t": None, - "dev_ctf_t": None, - "bads": [], - "projs": [], - "comps": []}) + info_to.update( + { + "chs": deepcopy(info_cano["chs"]), + "ch_names": deepcopy(info_cano["ch_names"]), + "nchan": deepcopy(info_cano["nchan"]), + "device_info": None, + "helium_info": None, + "gantry_angle": None, + "ctf_head_t": None, + "dev_ctf_t": None, + "bads": [], + "projs": [], + "comps": [], + } + ) # Compute field interpolation mapping origin_val = _check_origin(origin, inst.info) From 8efb7561679ac72a1b04a6301c9818e806549ff9 Mon Sep 17 00:00:00 2001 From: Christoph Huber-Huber Date: Mon, 23 Mar 2026 16:44:04 +0100 Subject: [PATCH 7/7] avoid deepcopy in _interpolate_to_meg because not necessary --- mne/channels/interpolation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mne/channels/interpolation.py b/mne/channels/interpolation.py index eb6aa2885a9..0f80e004fd6 100644 --- a/mne/channels/interpolation.py +++ b/mne/channels/interpolation.py @@ -499,9 +499,9 @@ def _interpolate_to_meg(inst, sensors, origin, mode): with info_to._unlock(): info_to.update( { - "chs": deepcopy(info_cano["chs"]), - "ch_names": deepcopy(info_cano["ch_names"]), - "nchan": deepcopy(info_cano["nchan"]), + "chs": info_cano["chs"], + "ch_names": info_cano["ch_names"], + "nchan": info_cano["nchan"], "device_info": None, "helium_info": None, "gantry_angle": None,