Пример #1
0
def test_permutation_test():
    """Test one way permutation test"""
    covset = generate_cov(10, 30)
    labels = np.array([0, 1]).repeat(5)
    # base
    p = PermutationTest(10)
    p.test(covset, labels)
    # fit perm
    p = PermutationTest(10, fit_perms=True)
    p.test(covset, labels)
    # unique perms
    p = PermutationTest(1000)
    p.test(covset, labels)
    p.summary()
    p.plot(nbins=2)
def test_permutation_test():
    """Test one way permutation test"""
    covset = generate_cov(10, 30)
    labels = np.array([0, 1]).repeat(5)
    p = PermutationTest(10)
    p.test(covset, labels)
    p.summary()
covest = Covariances()

Fs = 160
window = 2 * Fs
Nwindow = 20
Ns = epochs_data.shape[2]
step = int((Ns - window) / Nwindow)
time_bins = range(0, Ns - window, step)

pv = []
Fv = []
# For each frequency bin, estimate the stats
for t in time_bins:
    covmats = covest.fit_transform(epochs_data[:, ::1, t:(t + window)])
    p_test = PermutationTest(5000)
    p, F = p_test.test(covmats, labels)
    print p_test.summary()
    pv.append(p)
    Fv.append(F[0])

time = np.array(time_bins) / float(Fs) + tmin
plot(time, Fv, lw=2)
plt.xlabel('Time')
plt.ylabel('F-value')

significant = np.array(pv) < 0.001
plot(time, significant, 'r', lw=2)
plt.legend(['F-value', 'p<0.001'])
plt.grid()
plt.show()