Skip to content

Commit 900c81e

Browse files
committed
incorporated feedback on pull request mne-tools#13759 again
1 parent 99f531e commit 900c81e

1 file changed

Lines changed: 17 additions & 21 deletions

File tree

mne/channels/interpolation.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -490,28 +490,24 @@ def _interpolate_to_meg(inst, sensors, origin, mode):
490490
# Get source MEG info
491491
info_from = pick_info(inst.info, picks_meg_good)
492492

493-
# Design target info like source, except for channel info and
494-
# some (possibly) related fields
493+
# Update target info to accommodate the desired channel info
494+
# and reset some channel and machine-related fields to avoid
495+
# confusion later on.
496+
# NOTE: We don't change the original 'dev_head_t'.
497+
# Some keys require as default an empty list.
495498
info_to = deepcopy(info_from)
496-
info_to._unlocked = True # make all info fields modifiable
497-
# Update channel info to the desired one
498-
info_to["chs"] = deepcopy(info_cano["chs"])
499-
info_to["ch_names"] = deepcopy(info_cano["ch_names"])
500-
info_to["nchan"] = deepcopy(info_cano["nchan"])
501-
# Reset some channel and machine-related fields to avoid confusion later on
502-
info_to["device_info"] = None
503-
info_to["helium_info"] = None
504-
info_to["proj_id"] = None
505-
info_to["proj_name"] = None
506-
info_to["gantry_angle"] = None
507-
# we keep original 'dev_head_t'
508-
info_to["ctf_head_t"] = None
509-
info_to["dev_ctf_t"] = None
510-
# info_to['dig'] = None # or should they be removed, too?
511-
info_to["bads"] = []
512-
info_to["projs"] = []
513-
info_to["comps"] = []
514-
info_to._unlocked = False # lock info again
499+
with info_to._unlock():
500+
info_to.update({"chs": deepcopy(info_cano["chs"]),
501+
"ch_names": deepcopy(info_cano["ch_names"]),
502+
"nchan": deepcopy(info_cano["nchan"]),
503+
"device_info": None,
504+
"helium_info": None,
505+
"gantry_angle": None,
506+
"ctf_head_t": None,
507+
"dev_ctf_t": None,
508+
"bads": [],
509+
"projs": [],
510+
"comps": []})
515511

516512
# Compute field interpolation mapping
517513
origin_val = _check_origin(origin, inst.info)

0 commit comments

Comments
 (0)