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
671 stars 211 forks source link

The opensesame plugin pygaze_init needs a prepare phase/function #33

Open wkruijne opened 9 years ago

wkruijne commented 9 years ago

Hey Edwin -- Nice work on pygaze!

I found a small issue in the OS plugins . This minimal example, which is basically:

pygaze_init 
pygaze_drift_correct_ 
pygaze_start_recording, 
pygaze_stop_recording 

...causes a crash, because pygaze_eyetracker is not available in exp.

I think it's because since there is no prepare in pygaze_init, the pygaze_eyetracker hasn't been set yet, which is needed by the other items e.g. line 88 in pygaze_drift_correct.py

The reason you may not have noticed this before is that if you put the items in a loop-item (as people tend to do) initialization is run before any item is prepared. (See here)

The simple solution seems to be that it needs a prepare phase that sets the variables needed. I don't really have time right now to review what parts of the init would have to go in that prepare function -- hence no pull request with a proposed fix from me :) -- but it seems like this could be an easy fix for you

esdalmaijer commented 9 years ago

Thanks for finding this out! You're right, the init plug-in lacks a prepare phase. I'll see whether I can get to it anytime soon. Otherwise maybe @smathot could help?

esdalmaijer commented 9 years ago

I think we can move anything between line 145 and line 198 to a prepare function.

Don't have time to test it now, though, so won't implement directly.

smathot commented 9 years ago

Moving all the code to the prepare phase will break with the idea that, from the user's perspective, nothing happens during the prepare phase. So it's not optimal. I'll take a look at it to see if I can find a better way.