Test compute_maxwell_basis.
(regularize, n, int_order)
| 1886 | ], |
| 1887 | ) |
| 1888 | def test_compute_maxwell_basis(regularize, n, int_order): |
| 1889 | """Test compute_maxwell_basis.""" |
| 1890 | raw = read_raw_fif(raw_small_fname).crop(0, 2) |
| 1891 | assert raw.info["bads"] == [] |
| 1892 | raw.del_proj() |
| 1893 | rank = compute_rank(raw)["meg"] |
| 1894 | assert rank == 306 |
| 1895 | raw.info["bads"] = ["MEG 2443"] |
| 1896 | kwargs = dict(regularize=regularize, int_order=int_order, verbose=True) |
| 1897 | raw_sss = maxwell_filter(raw, **kwargs) |
| 1898 | want = raw_sss.get_data("meg") |
| 1899 | rank = compute_rank(raw_sss)["meg"] |
| 1900 | assert rank == n |
| 1901 | S, pS, reg_moments, n_use_in = compute_maxwell_basis(raw.info, **kwargs) |
| 1902 | assert n_use_in == n |
| 1903 | assert n_use_in == len(reg_moments) - 15 # no externals removed |
| 1904 | xform = S[:, :n_use_in] @ pS[:n_use_in] |
| 1905 | got = xform @ raw.pick(picks="meg", exclude="bads").get_data() |
| 1906 | assert_allclose(got, want, atol=1e-16) |
| 1907 | |
| 1908 | |
| 1909 | @testing.requires_testing_data |
nothing calls this directly
no test coverage detected