Skip to content

Commit

Permalink
towards revision
Browse files Browse the repository at this point in the history
  • Loading branch information
matus committed Jul 15, 2015
1 parent 8980f11 commit 2f7a52d
Show file tree
Hide file tree
Showing 87 changed files with 341 additions and 670 deletions.
44 changes: 42 additions & 2 deletions code/Coord.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,49 @@ def createIdealObserver(vpnr=999,N=5000,rseed=10):
g=(D[n,mdp,0,:]+D[n,mdp,1,:])/2.
D[n,:,:,0]-=g[0]
D[n,:,:,1]-=g[1]
np.save(path+'E1/DG.npy',D)

np.save(path+'E1/DG.npy',D)
###########################################################
def codingComparison():
res=[];
for vp in [2,1]:
initVP(vpl=vp,evl=0)
si1=np.load(path+'sicoder1.npy').tolist()
si2=np.load(path+'sicoder2.npy').tolist()
sel=[]
for i in range(len(si1)):
for j in range(i+1,len(si1)):
if si1[i][0]==si1[j][0] and si1[i][-1]==si1[j][-1] and si1[i][-2]==si1[j][-2]:
sel.append(j)
print sel
j=-1
for a in si1:
j+=1
if j in sel: continue
for b in si2:
if a[0]==b[0] and a[-1]==b[-1] and a[-2]==b[-2]: res.append([a[14],b[14]])
print vp,len(res),len(si1),len(si2)
def analyze(dat):
tp=np.logical_and(dat[:,0],dat[:,1]).sum()
fn=np.logical_and(~dat[:,0],dat[:,1]).sum()
tn=np.logical_and(~dat[:,0],~dat[:,1]).sum()
fp=np.logical_and(dat[:,0],~dat[:,1]).sum()
acc=(tn+tp)/float(dat.shape[0])
sens=tp/float(tp+fn)
spec=tn/float(fp+tn)
corr=(tp*tn-fp*fn)/np.sqrt((tp+fp)*(tp+fn)*(tn+fp)*(tn+fn))
return [acc,sens,spec,corr]
#np.save(path+'ress',res)
out=[];res=np.array(res)
for dat in [res>0,res==0,res==1]: out.append(analyze(dat))
res=res[np.logical_or(res[:,1]==0,res[:,1]==1),:]
out.append(analyze(res==1))
np.save(path+'codingComparison',out)
from matustools.matusplotlib import ndarray2latextable
print ndarray2latextable(np.array(out))

if __name__ == '__main__':
codingComparison()
bla
for event in range(0,3)+range(96,100):
for vpl in range(1,5):
initVP(vpl=vpl,evl=event)
Expand Down
7 changes: 4 additions & 3 deletions code/ETData.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ def __init__(self,dat,calib,t0,info,recTime="0:0:0",fs=None,
self.t0=[t0[1]-t0[0],t0[2]-t0[0]]
self.fs=fs
self.msgs=msgs
if self.fs==None or self.fs.size==0: self.fs= self.computeFs()
if self.fs==None or self.fs.size==0:
self.fs= self.computeFs()
#fsa=self.computeFs()
#m=min(self.fs.shape[0],fsa.shape[0])
#print np.round(np.max(np.abs(self.fs[:m,:2]-fsa[:m,:])),1), self.t0[1]-self.t0[0]
Expand Down Expand Up @@ -353,7 +354,7 @@ def computeFs(self):
f.close()
dur=self.t0[1]-self.t0[0]
inc=1000/monhz
N=min(int(round((dur)/inc)), int(Q.trialDur*monhz)+1)
N=min(int(round((dur)/inc)), int(Qexp.trialDur*monhz)+1)
return np.array([range(N),np.linspace(inc/2.0,dur-inc,N)]).T
#######################################################
# helper functions for drift correction and extraction of basic events
Expand Down Expand Up @@ -495,7 +496,7 @@ def extractBasicEvents(self):
dat=self.gaze
# add two columns with binocular gaze point
if self.focus==BINOCULAR:
print self.gaze.shape
#print self.gaze.shape
gazep=np.array([dat[:,[1,4]].mean(1),dat[:,[2,5]].mean(1)]).T
temp=dat[np.isnan(dat[:,1]),:]
if temp.size>0: gazep[np.isnan(dat[:,1]),:]=temp[:,[4,5]]
Expand Down
Loading

0 comments on commit 2f7a52d

Please sign in to comment.