TypeErrors in gazeplotter.draw_heatmap
Hello! I'm trying to produce a heatmap from an EyeTribe data file. The data seems to load and parse correctly, but gazeplotter.draw_heatmap keeps throwing TypeErrors.
import eyetribereader, gazeplotter, detectors
sub = eyetribereader.read_eyetribe("**********/subject-502.tsv", "start_trial", "stop_trial")
t = sub[15]
fixations = detectors.fixation_detection(t['x'], t['y'], t['time'])
gazeplotter.draw_heatmap(fixations[1], (1280, 1024))
In Python 2.7.13, this results in:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "gazeplotter.py", line 227, in draw_heatmap
heatmap[y:y+gwh,x:x+gwh] += gaus * fix['dur'][i]
TypeError: slice indices must be integers or None or have an __index__ method
And in Python 3.6.0, it gives:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "************/PyGazeAnalyser/pygazeanalyser/gazeplotter.py", line 199, in draw_heatmap
heatmap = numpy.zeros(heatmapsize, dtype=float)
TypeError: 'float' object cannot be interpreted as an integer
Can you tell what I'm doing wrong? I'm on Arch Linux, with matplotlib 2.0.0 and numpy 1.12.0.
I have the same problem with Python 2.7.14, Matplotlib 2.0.2 and Numpy -1.13.3, running on Windows 10.
do you fix it ?
My script perfectly draw scanpath, fixation and raw data from the same package... Only with the heatmap there is problem
Traceback (most recent call last):
File "C:\Users\Inf-CG\Documents\eye-tracker\probe.py", line 38, in
Solved! You need to add int() into the line 227 of gazeplotter.py Instead: heatmap[y:y+gwh,x:x+gwh] += gaus * fix['dur'][i]
You should have: heatmap[int(y):int(y+gwh),int(x):int(x+gwh)] += gaus * fix['dur'][i]
It works for me!