Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions doc/changes/dev/13759.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
When interpolating from axial to planar gradiometers, set info fields "chs", "ch_names", and "nchan", according to the interpolated data,
reset info fields "device_info", "helium_info", "gantry_angle", "ctf_head_t", "dev_ctf_t", "bads", "projs", and "comps" to [] or None, and
preserve all remaining info fields.
by :newcontrib:`Christoph Huber-Huber`.
1 change: 1 addition & 0 deletions doc/changes/names.inc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
.. _Chris Mullins: https://crmullins.com
.. _Christian Brodbeck: https://github.com/christianbrodbeck
.. _Christian O'Reilly: https://github.com/christian-oreilly
.. _Christoph Huber-Huber: https://github.com/chsquare
.. _Christopher Dinh: https://github.com/chdinh
.. _Chun-Hui Li: https://github.com/iamsc
.. _Clemens Brunner: https://github.com/cbrnr
Expand Down
28 changes: 25 additions & 3 deletions mne/channels/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

# 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)
with info_to._unlock():
info_to.update(
{
"chs": info_cano["chs"],
"ch_names": info_cano["ch_names"],
"nchan": 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)
mapping = _map_meg_or_eeg_channels(info_from, info_to, mode=mode, origin=origin_val)
Expand Down
3 changes: 3 additions & 0 deletions mne/channels/tests/test_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,11 @@ def test_interpolate_to_meg(monkeypatch):
monkeypatch.setattr( # for speed
mne.channels.channels, "_ALLOWED_INTERPOLATION_MODES", ("point",)
)
evoked.resample(evoked.info["sfreq"] / 2) # speed up even more
kwargs = dict(mode="point", origin=(0.0, 0.0, 0.04))
evoked_ctf = evoked.interpolate_to("ctf151", **kwargs)
# test whether .info["sfreq"] was preserved across interpolation
assert evoked_ctf.info["sfreq"] == evoked.info["sfreq"]
evoked_ctf.pick(evoked_ctf.ch_names[::4])
evoked_rt = evoked_ctf.interpolate_to("neuromag", **kwargs).pick(evoked.ch_names)
corrcoef = np.corrcoef(evoked.data.ravel(), evoked_rt.data.ravel())[0, 1]
Expand Down
Loading