-
Notifications
You must be signed in to change notification settings - Fork 0
/
gazeanalyse.py
50 lines (44 loc) · 1.7 KB
/
gazeanalyse.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import sys
sys.path.append("../PyGazeAnalyser")
from pygazeanalyser import eyetribereader, gazeplotter
import os
IMGDIR = os.path.join('/home/akos/Documents/tcsai-saliency/mod_imgs')
IMGNAMES = os.listdir(IMGDIR)
outdir = os.path.join('/home/akos/Documents/tcsai-saliency/gazeviz')
RESOLUTION = (1024, 768)
DATAFILE = 'testdata/subject-5-1.tsv'
# ,stop="stop_trial"
gazedata = eyetribereader.read_eyetribe(DATAFILE,
"start_trial",
stop_time=2995, # first 3 seconds
missing=0.0)
imgs = open("imgorder.txt").read().split('\n')
for i in range(len(gazedata)):
if i < 4:
pass
# print gazedata[i]['events']['msg']
# imgname = gazedata[i]['events']['msg'][69][1].split()[-1]
# imgname = imgname.split('.')[0] + '.jpg'
else:
print i+4
print gazedata[i]['events']['msg']
# imgname = gazedata[i]['events']['msg'][71][1].split()[-1]
imgname = imgs[i+4]
imgname = imgname.split('.')[0] + '.jpg'
imgfile = os.path.join(IMGDIR, imgname)
print imgname, imgfile
# get the fixations
fixations = gazedata[i]['events']['Efix']
# get the saccades
saccades = gazedata[i]['events']['Esac']
# plot a heatmap
gazeplotter.draw_heatmap(fixations, RESOLUTION, imagefile=imgfile,
alpha=0.5, invert_x=True, invert_y=False,
savefilename=os.path.join(outdir, '%s_fix.png' % imgname))
gazeplotter.draw_fixations(fixations, RESOLUTION, imagefile=imgfile,
alpha=0.5, invert_x=True, invert_y=False,
savefilename=os.path.join(outdir,'%s_heatmap.png' % imgname))
# gazeplotter.draw_scanpath(fixations, saccades, RESOLUTION, imagefile=imgfile,
# alpha=0.5, invert_x=True, invert_y=False,
# savefilename=os.path.join(outdir ,'%s_scan.png' % imgname))
print "YEEEEEEEEEEEE"