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

Function test_equalize_bads

mne/preprocessing/tests/test_interpolate.py:49–76  ·  view source on GitHub ↗

Test equalize_bads function.

(interp_thresh, inst_type)

Source from the content-addressed store, hash-verified

47@pytest.mark.parametrize("interp_thresh", [0.0, 0.5, 1.0])
48@pytest.mark.parametrize("inst_type", ["raw", "epochs", "evoked"])
49def test_equalize_bads(interp_thresh, inst_type):
50 """Test equalize_bads function."""
51 raw, epochs, evoked = _load_data()
52
53 if inst_type == "raw":
54 insts = [raw.copy().crop(0, 1), raw.copy().crop(0, 2)]
55 elif inst_type == "epochs":
56 insts = [epochs.copy()[:1], epochs.copy()[:2]]
57 else:
58 insts = [evoked.copy().crop(0, 0.1), raw.copy().crop(0, 0.2)]
59
60 with pytest.raises(ValueError, match="between 0"):
61 equalize_bads(insts, interp_thresh=2.0)
62
63 bads = insts[0].copy().pick("eeg").ch_names[:3]
64 insts[0].info["bads"] = bads[:2]
65 insts[1].info["bads"] = bads[1:]
66
67 insts_ok = equalize_bads(insts, interp_thresh=interp_thresh)
68 if interp_thresh == 0:
69 bads_ok = []
70 elif interp_thresh == 1:
71 bads_ok = bads
72 else: # interp_thresh == 0.5
73 bads_ok = bads[1:]
74
75 for inst in insts_ok:
76 assert set(inst.info["bads"]) == set(bads_ok)
77
78
79def test_interpolate_bridged_electrodes():

Callers

nothing calls this directly

Calls 6

equalize_badsFunction · 0.90
setFunction · 0.85
_load_dataFunction · 0.70
cropMethod · 0.45
copyMethod · 0.45
pickMethod · 0.45

Tested by

no test coverage detected