MCPcopy
hub / github.com/mne-tools/mne-python / _read_cross_talk

Function _read_cross_talk

mne/preprocessing/maxwell.py:2899–2920  ·  view source on GitHub ↗
(cross_talk, ch_names)

Source from the content-addressed store, hash-verified

2897
2898
2899def _read_cross_talk(cross_talk, ch_names):
2900 sss_ctc = dict()
2901 ctc = None
2902 if cross_talk is not None:
2903 sss_ctc = _read_ctc(cross_talk)
2904 ctc_chs = sss_ctc["proj_items_chs"]
2905 # checking for extra space ambiguity in channel names
2906 # between old and new fif files
2907 if ch_names[0] not in ctc_chs:
2908 ctc_chs = _clean_names(ctc_chs, remove_whitespace=True)
2909 ch_names = _clean_names(ch_names, remove_whitespace=True)
2910 missing = sorted(list(set(ch_names) - set(ctc_chs)))
2911 if len(missing) != 0:
2912 raise RuntimeError(f"Missing MEG channels in cross-talk matrix:\n{missing}")
2913 missing = sorted(list(set(ctc_chs) - set(ch_names)))
2914 if len(missing) > 0:
2915 warn(f"Not all cross-talk channels in raw:\n{missing}")
2916 ctc_picks = [ctc_chs.index(name) for name in ch_names]
2917 ctc = sss_ctc["decoupler"][ctc_picks][:, ctc_picks]
2918 # I have no idea why, but MF transposes this for storage..
2919 sss_ctc["decoupler"] = sss_ctc["decoupler"].T.tocsc()
2920 return ctc, sss_ctc
2921
2922
2923@verbose

Callers 2

compute_fine_calibrationFunction · 0.85
_prep_maxwell_filterFunction · 0.85

Calls 4

_read_ctcFunction · 0.85
_clean_namesFunction · 0.85
setFunction · 0.85
warnFunction · 0.85

Tested by

no test coverage detected