Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeErrors in gazeplotter.draw_heatmap #9

Open
pashultz opened this issue Mar 13, 2017 · 2 comments
Open

TypeErrors in gazeplotter.draw_heatmap #9

pashultz opened this issue Mar 13, 2017 · 2 comments

Comments

@pashultz
Copy link

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.

@JARS29
Copy link

JARS29 commented Oct 5, 2017

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
draw_heatmap(Efix, scrsize,imagefile='lecture.jpg',durationweight=True,alpha=0.5,savefilename=os.path.dirname(file))
File "C:\Users\Inf-CG\Documents\eye-tracker\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

@JARS29
Copy link

JARS29 commented Oct 5, 2017

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!

jfrey-xx added a commit to jfrey-xx/PyGazeAnalyser that referenced this issue Sep 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants