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

Function test_ctps

mne/preprocessing/tests/test_ctps.py:56–88  ·  view source on GitHub ↗

Test basic ctps functionality.

()

Source from the content-addressed store, hash-verified

54
55
56def test_ctps():
57 """Test basic ctps functionality."""
58 for ii, (n_trials, j_extent, pk_max) in iter_test_ctps:
59 data = get_data(n_trials, j_extent)
60 ks_dyn, pk_dyn, phase_trial = ctps(data)
61 data2 = _compute_normalized_phase(data)
62 ks_dyn2, pk_dyn2, _ = ctps(data2, is_raw=False)
63 for a, b in zip([ks_dyn, pk_dyn, phase_trial], [ks_dyn2, pk_dyn2, data2]):
64 assert_array_equal(a, b)
65 assert a.min() >= 0
66 assert a.max() <= 1
67 assert b.min() >= 0
68 assert b.max() <= 1
69
70 # test for normalization
71 assert (pk_dyn.min() > 0.0) or (pk_dyn.max() < 1.0)
72 # test shapes
73 assert phase_trial.shape == data.shape
74 assert pk_dyn.shape == data.shape[1:]
75 # tets ground_truth + random + jittered case
76 assert pk_dyn[0].max() == 1.0
77 assert len(np.unique(pk_dyn[0])) == 1.0
78 assert pk_dyn[1].max() < pk_max
79 assert pk_dyn[2].max() > 0.3
80 if ii < 1:
81 pytest.raises(ValueError, ctps, data[:, :, :, None])
82
83 assert _prob_kuiper(1.0, 400) == 1.0
84 # test vecrosization
85 assert_array_equal(
86 _prob_kuiper(np.array([1.0, 1.0]), 400), _prob_kuiper(np.array([1.0, 1.0]), 400)
87 )
88 assert _prob_kuiper(0.1, 400) < 0.1

Callers

nothing calls this directly

Calls 4

ctpsFunction · 0.90
_prob_kuiperFunction · 0.90
get_dataFunction · 0.70

Tested by

no test coverage detected