esdalmaijer / PyGaze

an open-source, cross-platform toolbox for minimal-effort programming of eye tracking experiments
www.pygaze.org
GNU General Public License v3.0
670 stars 211 forks source link

TobiiProTracker instance has no attribute 't0' #142

Open PaulaSchi opened 4 years ago

PaulaSchi commented 4 years ago

Hi!

I am working on an experiment with OpenSesame and a Tobii eyetracker, and I sometimes get the following error message:

item-stack: experiment[run].pygaze_init[run] exception type: AttributeError exception message: TobiiProTracker instance has no attribute 't0'

Is there any way to "program" my way around it?

Also, I'd like to mention this is a follow-up message that one of our team members posted initially on the OpenSesame forum: https://forum.cogsci.nl/index.php?p=/discussion/5312/tobii-150-spectrum-and-pygaze#latest @esdalmaijer @grebdems @pedrotari7

Thanks!

grebdems commented 4 years ago

Hi @PaulaSchi Me and my colleagues have been scratching our heads about this issue. The error message seems to indicate a scenario that I thought wasn't programmatically possible (perhaps just lack of knowledge from my side). Maybe there could be something broken with your installation? Multiple versions of the same file somehow getting mixed up? Really perplexing. Either way, I have some follow up questions that might help track it down:

  1. Judging by the log posted on the OpenSesame forum, it seems like you've been experiencing this since March 2019. How often does this error occur?
  2. What versions are you using of (respectively), Python, PyGaze, OpenSesame, and tobii-research?
  3. Have you tested (and noticed) this issue with multiple computers, or just one?
  4. What's the specs of the computer used?
  5. Have you contacted TobiiPro Support regarding the varying sample rate of the Spectrum eyetracker (reported in the OpenSesame forum)?
  6. Have you tried this with another Tobii eyetracker (and seen the error)?
  7. Are you specifying the serial number of the eyetracker in the settings file for the experiment?

All the best!

PaulaSchi commented 4 years ago

Hi @grebdems Thank you very much for the reply!

Here are my answers:

  1. It occurs quite often. I would estimate around 30-40% of the time. I will start recording exactly how often it occurs.

The "fix" we use is to re-run the experiment file. When that does not work, I turn the eyetracker off, and then turn it on again :-) It's an "easy" fix, but an undesirable while a subject is present...

One thing that seemed to drive the error appearance rate down, was to change the OpenSesame backend from xpyriment (based on Expyriment) to legacy (based on PyGame). This drove the appearance of this error down from about 50%.

  1. Versions: Python: 2.7.13 PyGaze: 0.6.0a25 OpenSesame: 3.2.8 Tobii-research: 1.7.0

  2. We only use one computer. It would be difficult to connect the system to another one...

  3. Specs: Windows 7 Professional Intel Core i7-3770 CPU @ 3.40GHz RAM: 4 GB 64 bits

  4. No, we haven't contacted them about that. More recently, the sampling rate is stable around 59 or 60 Hz.

  5. We just have one eyetracker.

  6. Not that I am aware of. Where would we do that in OpenSesame? We specify the serial number in the "TobiiPro eyetracker Manager" software.

Really appreciate any input that may help solve this error, or at least understand when it occurs.

Best, Paula

grebdems commented 4 years ago

Hi @PaulaSchi Thanks for the swift reply! Let's see if we can get anywhere closer to understanding your problem.

  1. Wow, that's quite often indeed! Does restarting the eyetracker always solve the problem? Have you ever noticed the issue directly after a restart (or does it always happen the 2:nd - n:th time)?
  2. The PyGaze version is relatively old, and listed as a "pre-release". I don't see any obvious fixes since that version that could be related, but it might be an idea to try a newer version, if possible.
  3. Ok. What makes it difficult to use another computer? Are you relying on some other specific hardware?
  4. That sounds like a quite old setup. I don't know anything about the system requirements for OpenSesame, but it might be that lack of RAM and CPU could be holding you back. Have you tried checking the CPU load and RAM usage during an experiment?
  5. Are you only getting 60Hz even when the Spectrum is set to 150Hz? If so, it could also be related to the computer's specs. The eyetracker will always send data at a constant speed, but if the receiving software (in this case PyGaze/OpenSesame) runs too slow to collect the data it might be missed.
  6. & 7. Ok, then there's no need to specify serial number. In PyGaze there's usually a settings file per experiment. Not sure how that is integrated with OpenSesame. But no need to worry about that.

Have nice weekend! (and Valentines Day) /Magnus

PaulaSchi commented 4 years ago

Hi, Thank you very much for the reply!

As you suggest, we will try setting up the eyetracker with a different computer, to see if that fixes the issue, and also try to update PyGaze. We don't use any additional hardware (except for a response box).

I made several changes in libtobii.py, and now get a different error message: "tuple index out of range". :)

The changes made are:

The result is that the experiment either works perfectly, or it sends the error "tuple index out of range" in self.eyetracker = self.eyetrackers[0].

It is very odd, as the experiment may run perfectly to the end, and, just one minute later, when trying to restart the experiment, the error pops up even though the experiment file is the same. After trying to open the experiment a couple more times, the experiment works again.

(Just to be clear: In the last 40 experiments, the error "has no attribute t0" has not appeared at all.)

Is there any way I could just "tell" Python the serial number of the tracker, so it doesn't have to look for it? It looks like that might fix the issue.

Thanks again for your time and insight! Paula

esdalmaijer commented 4 years ago

The tuple index error seems to suggest that sometimes the Tobii tracker cannot be identified. I've actually seen that very issue with a colleague of mine, and it turned out their Tobii TX300 was malfunctioning. I'd recommend getting your hardware checked out by Tobii.

PaulaSchi commented 4 years ago

Thank you for the suggestion and the fast reply @esdalmaijer!

grebdems commented 4 years ago

Hi again! Yes, I agree with @esdalmaijer that the tuple error does seem to indicate that the eyetracker isn't being discovered. Still struggle with understanding how that would have lead to the eyetracking object not being instantiated (and t0 attribute not being there), but I should probably just pass that on to some more Python-savvy colleagues.

One suggestion is to try and add a condition or short loop that repeats the find_all_eyetrackers() call a few times as long as it comes up empty. I know that we've seen cases where eyetrackers (and I think specifically Spectrum) sometimes doesn't get discovered on the first try, but just rerunning the search finds it.

Unfortunately there's no way to find the eyetracker without running a search, even if you supply the serial numbe. (in the C and C# binding there's a function call that appears to do this, but behind the scenes it still does the same search).

PaulaSchi commented 4 years ago

Hi,

We've introduced a loop to repeat the find_all_eyetrackers() function. In the past 30+ experiment runs, we have had no error messages. We can detect that the loop is indeed used in about 30% of cases, as the loop prints a message every time it is accessed (in the OpenSesame debug window). Sometimes the search loop is not accessed, and other times it takes anywhere between 40 seconds - 1 minute to find the eyetracker. However, it seems the loop solved our problem, which is great!

Thank you @grebdems and @esdalmaijer for your help!