-
Notifications
You must be signed in to change notification settings - Fork 19
/
analyse.py
34 lines (27 loc) · 1.06 KB
/
analyse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from os import path
from psychopy import misc, gui
import pandas as pd
import scipy
from scipy import stats
#choose some data files to analyse
filenames = gui.fileOpenDlg(allowed="*.csv")
#loop through the files
for thisFilename in filenames:
print thisFilename
thisDat = pd.read_csv(thisFilename)
#filter out bad data
filtered = thisDat[ thisDat['rt']<=1.0 ]
filtered = filtered[ filtered['corr']==1 ]
#separate conflicting from congruent reaction times
conflict = filtered[filtered.description == 'conflict']
congruent = filtered[filtered.description != 'conflict']
#get mean/std.dev
meanConfl = scipy.mean(conflict.rt)
semConfl = scipy.std(conflict.rt, ddof=1)
meanCongr = scipy.mean(congruent.rt)
semCongr = scipy.std(congruent.rt, ddof=1)
print "Conflict = %.3f (std=%.3f)" %(meanConfl, semConfl)
print "Congruent = %.3f (std=%.3f)" %(meanCongr, semCongr)
#run a t-test
t, p = stats.ttest_ind(conflict.rt, congruent.rt)
print "Independent samples t-test: t=%.3f, p=%.4f" %(t, p)