コード例 #1
0
ファイル: test_stats.py プロジェクト: SherazKhan/pyRiemann
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()
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()
コード例 #3
0
ファイル: oneWay_Manova.py プロジェクト: kingjr/pyRiemann
# strip channel names
raw.info['ch_names'] = [chn.strip('.') for chn in raw.info['ch_names']]

# Apply band-pass filter
raw.filter(7., 35., method='iir')

events = find_events(raw, shortest_event=0, stim_channel='STI 014')
picks = pick_types(raw.info, meg=False, eeg=True, stim=False, eog=False,
                   exclude='bads')

# Read epochs (train will be done only between 1 and 2s)
# Testing will be done with a running classifier
epochs = Epochs(raw, events, event_id, tmin, tmax, proj=True, picks=picks,
                baseline=None, preload=True, add_eeg_ref=False,verbose=False)
labels = epochs.events[:, -1] - 2

# get epochs
epochs_data = epochs.get_data()

# compute covariance matrices
covmats = Covariances().fit_transform(epochs_data) 

p_test = PermutationTest(5000)
p,F = p_test.test(covmats,labels)
p_test.plot()
print p_test.summary()

plt.show()


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()
コード例 #5
0
# compute cospectral covariance matrices
fmin = 2.0
fmax = 40.0
cosp = CospCovariances(window=128, overlap=0.98, fmin=fmin, fmax=fmax,
                       fs=160.0)
covmats = cosp.fit_transform(epochs_data[:, ::4, :])

fr = np.fft.fftfreq(128)[0:64]*160
fr = fr[(fr >= fmin) & (fr <= fmax)]

pv = []
Fv = []
# For each frequency bin, estimate the stats
for i in range(covmats.shape[3]):
    p_test = PermutationTest(5000)
    p, F = p_test.test(covmats[:, :, :, i], labels)
    print(p_test.summary())
    pv.append(p)
    Fv.append(F[0])

plot(fr, Fv, lw=2)
plt.xlabel('Frequency')
plt.ylabel('F-value')

significant = np.array(pv) < 0.001
plot(fr, significant, 'r', lw=2)
plt.legend(['F-value', 'p<0.001'])
plt.grid()
plt.show()
コード例 #6
0
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()
コード例 #7
0
ファイル: test_stats.py プロジェクト: medic20/pyRiemann
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)