(evoked, noise_cov, fwd)
| 519 | |
| 520 | |
| 521 | def _bias_params(evoked, noise_cov, fwd): |
| 522 | evoked.pick(picks=["meg", "eeg"]) |
| 523 | # restrict to limited set of verts (small src here) and one hemi for speed |
| 524 | vertices = [fwd["src"][0]["vertno"].copy(), []] |
| 525 | stc = mne.SourceEstimate( |
| 526 | np.zeros((sum(len(v) for v in vertices), 1)), vertices, 0, 1 |
| 527 | ) |
| 528 | fwd = mne.forward.restrict_forward_to_stc(fwd, stc) |
| 529 | assert fwd["sol"]["row_names"] == noise_cov["names"] |
| 530 | assert noise_cov["names"] == evoked.ch_names |
| 531 | evoked = mne.EvokedArray(fwd["sol"]["data"].copy(), evoked.info) |
| 532 | data_cov = noise_cov.copy() |
| 533 | data = fwd["sol"]["data"] @ fwd["sol"]["data"].T |
| 534 | data *= 1e-14 # 100 nAm at each source, effectively (1e-18 would be 1 nAm) |
| 535 | # This is rank-deficient, so let's make it actually positive semidefinite |
| 536 | # by regularizing a tiny bit |
| 537 | data.flat[:: data.shape[0] + 1] += mne.make_ad_hoc_cov(evoked.info)["data"] |
| 538 | # Do our projection |
| 539 | proj, _, _ = mne._fiff.proj.make_projector(data_cov["projs"], data_cov["names"]) |
| 540 | data = proj @ data @ proj.T |
| 541 | data_cov["data"][:] = data |
| 542 | assert data_cov["data"].shape[0] == len(noise_cov["names"]) |
| 543 | want = np.arange(fwd["sol"]["data"].shape[1]) |
| 544 | if not mne.forward.is_fixed_orient(fwd): |
| 545 | want //= 3 |
| 546 | return evoked, fwd, noise_cov, data_cov, want |
| 547 | |
| 548 | |
| 549 | @pytest.fixture |
no test coverage detected