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

Function test_correction

mne/preprocessing/tests/test_hfc.py:66–90  ·  view source on GitHub ↗

Apply HFC and compare to previous computed solutions.

(order)

Source from the content-addressed store, hash-verified

64@testing.requires_testing_data
65@pytest.mark.parametrize("order", [1, 2, 3])
66def 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

Callers

nothing calls this directly

Calls 9

read_raw_filFunction · 0.90
compute_proj_hfcFunction · 0.90
pick_channelsFunction · 0.90
_unpack_matFunction · 0.85
apply_projMethod · 0.80
add_projMethod · 0.80
load_dataMethod · 0.45
extendMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected