Skip to content
Merged
Changes from 7 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
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": deepcopy(info_cano["chs"]),
"ch_names": deepcopy(info_cano["ch_names"]),
"nchan": deepcopy(info_cano["nchan"]),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure we need deepcopy here, since info_cano is instantiated within the function (not user-passed) and not otherwise needed, so there's no real risk to it getting mutated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right - I removed the deepcopy.

"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
Loading