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

Function test_priors

mne/forward/tests/test_forward.py:486–517  ·  view source on GitHub ↗

Test prior computations.

()

Source from the content-addressed store, hash-verified

484
485@testing.requires_testing_data
486def test_priors():
487 """Test prior computations."""
488 # Depth prior
489 fwd = read_forward_solution(fname_meeg)
490 assert not is_fixed_orient(fwd)
491 n_sources = fwd["nsource"]
492 info = read_info(fname_evoked)
493 depth_prior = compute_depth_prior(fwd, info, exp=0.8)
494 assert depth_prior.shape == (3 * n_sources,)
495 depth_prior = compute_depth_prior(fwd, info, exp=0.0)
496 assert_array_equal(depth_prior, 1.0)
497 with pytest.raises(ValueError, match='must be "whiten"'):
498 compute_depth_prior(fwd, info, limit_depth_chs="foo")
499 with pytest.raises(ValueError, match="noise_cov must be a Covariance"):
500 compute_depth_prior(fwd, info, limit_depth_chs="whiten")
501 fwd_fixed = convert_forward_solution(fwd, force_fixed=True)
502 depth_prior = compute_depth_prior(fwd_fixed, info=info)
503 assert depth_prior.shape == (n_sources,)
504 # Orientation prior
505 orient_prior = compute_orient_prior(fwd, 1.0)
506 assert_array_equal(orient_prior, 1.0)
507 orient_prior = compute_orient_prior(fwd_fixed, 0.0)
508 assert_array_equal(orient_prior, 1.0)
509 with pytest.raises(ValueError, match="oriented in surface coordinates"):
510 compute_orient_prior(fwd, 0.5)
511 fwd_surf_ori = convert_forward_solution(fwd, surf_ori=True)
512 orient_prior = compute_orient_prior(fwd_surf_ori, 0.5)
513 assert all(np.isin(orient_prior, (0.5, 1.0)))
514 with pytest.raises(ValueError, match="between 0 and 1"):
515 compute_orient_prior(fwd_surf_ori, -0.5)
516 with pytest.raises(ValueError, match="with fixed orientation"):
517 compute_orient_prior(fwd_fixed, 0.5)
518
519
520@testing.requires_testing_data

Callers

nothing calls this directly

Calls 6

read_forward_solutionFunction · 0.90
is_fixed_orientFunction · 0.90
compute_depth_priorFunction · 0.90
convert_forward_solutionFunction · 0.90
compute_orient_priorFunction · 0.90
read_infoFunction · 0.85

Tested by

no test coverage detected