(cross_talk, ch_names)
| 2897 | |
| 2898 | |
| 2899 | def _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 |
no test coverage detected