Test equalize_bads function.
(interp_thresh, inst_type)
| 47 | @pytest.mark.parametrize("interp_thresh", [0.0, 0.5, 1.0]) |
| 48 | @pytest.mark.parametrize("inst_type", ["raw", "epochs", "evoked"]) |
| 49 | def 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 | |
| 79 | def test_interpolate_bridged_electrodes(): |
nothing calls this directly
no test coverage detected