Apply HFC and compare to previous computed solutions.
(order)
| 64 | @testing.requires_testing_data |
| 65 | @pytest.mark.parametrize("order", [1, 2, 3]) |
| 66 | def test_correction(order): |
| 67 | """Apply HFC and compare to previous computed solutions.""" |
| 68 | binname = fil_path / "sub-noise_ses-001_task-noise220622_run-001_meg.bin" |
| 69 | raw = read_raw_fil(binname) |
| 70 | raw.load_data() |
| 71 | raw.info["bads"].extend([b for b in bads]) |
| 72 | projs = compute_proj_hfc(raw.info, order=order, accuracy="point") |
| 73 | raw.add_proj(projs).apply_proj() |
| 74 | |
| 75 | mat = _unpack_mat(loadmat(fil_path / f"{fname_root}_hfc_l{order}.mat")) |
| 76 | |
| 77 | proj_list = projs[0]["data"]["col_names"] |
| 78 | picks = pick_channels(raw.ch_names, proj_list, ordered=True) |
| 79 | mat_list = mat["coil_label"] |
| 80 | mat_inds = pick_channels(mat_list, proj_list, ordered=True) |
| 81 | |
| 82 | want = mat["trial"][mat_inds] |
| 83 | got = raw.copy().add_proj(projs).apply_proj()[picks, 0:300][0] * 1e15 |
| 84 | assert_allclose(got, want, rtol=1e-7) |
| 85 | |
| 86 | # Now with default accuracy: not super close with tol but corr is good |
| 87 | projs = compute_proj_hfc(raw.info, order=order) |
| 88 | got = raw.copy().add_proj(projs).apply_proj()[picks, 0:300][0] * 1e15 |
| 89 | corr = np.corrcoef(got.ravel(), want.ravel())[0, 1] |
| 90 | assert 0.999999 < corr <= 1.0 |
| 91 | |
| 92 | |
| 93 | @testing.requires_testing_data |
nothing calls this directly
no test coverage detected