We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 18a153a commit 6644cdeCopy full SHA for 6644cde
frites/simulations/sim_distant_mi.py
@@ -141,4 +141,4 @@ def sim_gauss_fit(stim_type='cont_linear', n_epochs=400, n_sti=4, n_pts=400,
141
# add random noise to remove equal values for gcmi
142
x = x + rnd_x.rand(*x.shape) / 100.
143
y = y + rnd_y.rand(*x.shape) / 100.
144
- return x.T, y.T, stim
+ return x.T, y.T, stim.squeeze()
frites/simulations/tests/test_sim_distant_mi.py
@@ -0,0 +1,29 @@
1
+"""Test simulating distant MI."""
2
+import numpy as np
3
+
4
+from frites.simulations import (sim_gauss_fit, sim_distant_cc_ms,
5
+ sim_distant_cc_ss)
6
7
8
+class TestDistantMI(object):
9
10
+ def test_sim_gauss_fit(self):
11
+ for stim_type in ['discrete_stim', 'cont_linear', 'cont_flat']:
12
+ x, y, stim = sim_gauss_fit(stim_type=stim_type, n_epochs=20)
13
+ assert x.shape == y.shape
14
+ if stim_type is not 'discrete_stim':
15
+ assert len(stim) == x.shape[0]
16
17
+ def test_sim_distant_cc_ss(self):
18
+ n_epochs = 20
19
+ x, y, roi = sim_distant_cc_ss(n_epochs=n_epochs)
20
+ assert x.shape == (len(y), len(roi), 400)
21
22
+ def test_sim_distant_cc_ms(self):
23
+ n_subjects = 3
24
+ x, y, roi, times = sim_distant_cc_ms(n_subjects)
25
+ assert len(x) == len(y) == len(roi) == n_subjects
26
+ assert [k.shape == x[0].shape for k in x]
27
+ assert [k.shape == y[0].shape for k in y]
28
+ assert [k.shape == roi[0].shape for k in roi]
29
+ assert x[0].shape == (len(y[0]), len(roi[0]), len(times))
frites/stats/stats_param.py
@@ -54,7 +54,7 @@ def rfx_ttest(mi, mi_p, center=False, zscore=False, ttested=False):
54
mi_p : array_like
55
A list of array of permuted mutual information of shape
56
(n_perm, n_suj, n_times). If `ttested` is True, n_suj shoud be 1.
57
- center : {'mean', "median", "trimmed"} | False
+ center : {'mean', 'median', 'trimmed'} | False
58
If True, substract the mean of the surrogates to the true and permuted
59
mi. The median or the 20% trimmed mean can also be removed
60
:cite:`wilcox2018guide`
frites/stats/tests/test_stats_param.py
@@ -24,9 +24,10 @@ def test_rfx_ttest(self):
assert tv.shape == (n_roi, n_times)
assert tv_p.shape == (n_perm, n_roi, n_times)
# center
- tv, tv_p = rfx_ttest(x, x_p, center=True)
- assert tv.shape == (n_roi, n_times)
- assert tv_p.shape == (n_perm, n_roi, n_times)
+ for center in [False, 'mean', 'median', 'trimmed']:
+ tv, tv_p = rfx_ttest(x, x_p, center=center)
+ assert tv.shape == (n_roi, n_times)
30
+ assert tv_p.shape == (n_perm, n_roi, n_times)
31
# zscore
32
tv, tv_p = rfx_ttest(x, x_p, zscore=True)
33
frites/utils/tests/test_perf.py
@@ -0,0 +1,27 @@
+"""Test performance tools."""
+from time import sleep
+from frites.utils.perf import timeit, id, get_data_base, arrays_share_data
+class TestPerfTools(object):
+ def test_timeit(self):
+ @timeit
+ def fcn(sec): return sleep(sec) # noqa
+ def test_id(self):
+ x = np.random.rand(1000)
+ assert id(x) != id(x.copy())
+ assert id(x) == id(x)
+ def test_get_data_base(self):
+ np.testing.assert_array_almost_equal(x, get_data_base(x))
+ def test_arrays_share_data(self):
+ y = np.random.rand(1000)
+ assert not arrays_share_data(x, y)
+ assert arrays_share_data(x, x)
frites/workflow/tests/test_wf_mi.py
@@ -30,7 +30,11 @@ class TestWfMi(object): # noqa
def test_definition(self):
"""Test workflow definition."""
- WfMi(mi_type='cc', inference='rfx')
+ y, gt = sim_mi_cc(x, snr=1.)
34
+ dt = DatasetEphy(x, y, roi, times=time)
35
+ wf = WfMi(mi_type='cc', inference='rfx')
36
+ wf.fit(dt, **kw_mi)
37
+ wf.tvalues
38
39
def test_mi_cc(self):
40
"""Test method fit."""
@@ -93,3 +97,13 @@ def test_no_stat(self):
93
97
wf.fit(dt, mcp='maxstat', **kw_mi)
94
98
t_end_2 = tst()
95
99
assert t_end_1 - t_start_1 > t_end_2 - t_start_2
100
101
+ def test_conjunction_analysis(self):
102
+ """Test the conjunction analysis."""
103
104
105
106
+ mi, pv = wf.fit(dt, **kw_mi)
107
+ cj_ss, cj = wf.conjunction_analysis(dt)
108
+ assert cj_ss.shape == (n_subjects, n_times, n_roi)
109
+ assert cj.shape == (n_times, n_roi)
0 commit comments