psychopy.org | Reference | Downloads | Github

Eyetracking in py3.x

Hi all,

Is it possible to run an eyetracking experiment in python 3.x? I’ve seen pylink/ pylinkwrapper, and got it somewhat working in py2.7, but have generally switched over to py3.x. I know pylink itself is still a python 2.x package - does that prevent psychopy3 from being able to successfully interface with eyelink? ioHub doesn’t make reference to this specific limitation, though I’ve found it difficult figuring out how ioHub works from the documentation.

Thanks for your help!

The best thing to do is probably to try it and see. It’s likely that any Python 2 vs 3 incompatibilities can be solved.

Hi!

Just to report that we have been successful in making a set of experiments using python 3 + psychopy + eyelink1000 and only that libraries. This was installed on a MacOs machine with a dual LED display (one for control, one in the setup room). This involved the use of different parts of code found in the pylink wrapper but also thanks to the excellent work of the pygaze team (in particular the edfreader.py script).

Most of the code for it is available @ https://github.com/chloepasturel/AnticipatorySPEM and in particular in https://github.com/chloepasturel/AnticipatorySPEM/blob/master/EyeTracking.py for the eye tracking part. Sorry that it is not 100% bullet-proof, that most comments are in french, but it is a workable solution. We are now in the process of separating that specific part into a proper package, any feedback is welcome.

Cheers,
Laurent

3 Likes

How did you import pylink and which pylink version did you use for it to work in python 3?

When running

import pylink as pl

in either PsychoPy2PY3 or PsychoPy3 (Python 3) I receive the error message:
ModuleNotFoundError: No module named ‘pylink’

I also tried to paste the pylink folder into ‘C:\Program Files (x86)\PsychoPy3\Lib\site-packages’, but then I receive the error:
bad magic number in ‘pylink’: b’l\x0c\r\n’

I also tried to add the pylink folder to the paths (under Preferences), but then I get:
DLL load failed: %1 is not a valid Win32 application.

I am using a Windows PC and with Python 2.7 the pylink import worked just fine.

Any help would be appreciated!
Corinna

Hi Corinna,

I have no experience with windows boxes. The import just works using a MacOs with the provided executables… See the screenshot with a minimal import. Do you have any to use a different OS, like a dual boot on your windows box?

cheers,
Laurent

31

Thanks for your reply!
Unfortunately using a different OS in that setup would not be easy right now.
I have contacted SR research now, as I have found out that they have not released any official pylink versions for Python 3.6 (at least not for Windows), but have some internal builds.
Hopefully my script runs with that, I will have to see.

Hi laurent.perrinet! thanks for this code, it is amazing. I’m wondering (since this was a few years ago) what version of python 3.X were you using? I think pylink has a 3.4 but I’m not sure if that’s still in beta / you were able to have it work. thanks for any tips!

Hello,

Thanks for the interest! We got it to work and had no problem using it. We collected the data and the work was publihed last year, see

Pasturel C, Montagnini A, Perrinet LU. Humans adapt their anticipatory eye movements to the volatility of visual motion properties. PLoS Comput Biol. 2020 Apr 13;16(4):e1007438. doi: 10.1371/journal.pcbi.1007438. Erratum in: PLoS Comput Biol. 2020 Oct 21;16(10):e1008385. PMID: 32282790; PMCID: PMC7179935.

Actually, I do not remember what version of python we used, but certainly > 3.4… The whole code is available at

(with most comments and some variable names still in French :grinning:)

do not hesitate to comment if you need more info

Laurent

1 Like