Using eye tracker by Expyriment

161 views
Skip to first unread message

Oliver Lindemann

unread,
Oct 16, 2015, 11:12:49 AM10/16/15
to expyrime...@googlegroups.com



-------- Forwarded Message --------
Subject: Re: 【Inquiry】Using eye tracker by Expyriment
Date: Fri, 16 Oct 2015 16:58:37 +0200
From: Oliver Lindemann <oliver.l...@uni-potsdam.de>
To: Ryo TACHIBANA <ryotachi...@gmail.com>



Does this help?
https://www.reddit.com/r/expyriment/comments/3j8dbr/expyriment_and_eyetracking/

Oliver


On 16.10.2015 14:55, Ryo TACHIBANA wrote:
> Dear Mr. Oliver,
>
> Sorry for the sudden email.
> I am Ryo Tachibana, a Ph.D student at Tohoku university in japan.
>
> I would like to ask you a question about using eye tracker by Expyriment.
> Please see the forwarded mail below.
>
> I sent Mr. Florian the same inquiry about two weeks ago, but have not
> heard from him.
> Probably he is very busy now, so he does not have time to reply.
>
> I would appreciate it if you have any ideas about my question.
>
> Beat regards,
>
> Ryo
>
> ---------- Forwarded message ----------
> From: *Ryo TACHIBANA* <ryotachi...@gmail.com
> <mailto:ryotachi...@gmail.com>>
> Date: 2015-10-04 18:40 GMT+09:00
> Subject: Using eye tracker
> To: Florian Krause <flo...@expyriment.org
> <mailto:flo...@expyriment.org>>
>
>
> Dear Florian,
>
> Thank you for your great help.
>
> The question is about using eye tracker by Expyriment.
>
> I try to use an eye tracker (EyeLink) by Expyriment.
>
> Controlling the experiment by Expyriment, I try to send some trigger
> (time, trial, stimuli onset/offset...) by Pygaze
> (http://www.pygaze.org/) to my eye tracker for the data analysis of
> eye movements.
>
> But, a display problem occurs.
> Pygaze has also its display setting (libscreen), so my program doesn't
> work.
> When I asked this problem to the developers of Pygaze, he answered it
> is possible to do a bit of hacking as below.
>
>
> import pygaze
> from pygaze import EyeTracker
> from expyriment import control
>
> # EXAMPLE initialisation of expyriment
> exp = control.initialize()
>
> # get the active PyGame Surface
> window = exp.screen._surface
>
> # define a custom Display class
> # the parent is the actual Display class,
> # but we're going to overwrite the initialisation function
> class Display(pygaze.display):
>
> def __init__(self, pygamewindow):
>
> # use the passed handle to the active surface
> pygaze.expdisplay = window
> self.dispsize = window.get_size()
> self.fgc = (0, 0, 0)
> self.bgc = (128, 128, 128)
> self.mousevis = False
>
> # now initialise a dummy Display,
> # and pass the active PyGame window
> disp = Display(window)
>
> # and initialise an EyeTracker object
> tracker = EyeTracker(disp)
>
> # REST OF YOUR SCRIPT
>
>
> This script causes an error,
> class Display(pygaze.display): TypeError: Error when calling the
> metaclass bases module.init() takes at most 2 arguments (3 given)
>
> Do you have any ideas?
>
> All the best,
>
> Ryo
>
> *―――――――――――――――――――――――*
> *Ryo TACHIBANA*
>
> Ph.D Student
>
> Department of Psychology,
> Graduate School of Arts and Letters, Tohoku University
> 27-1 Kawauchi, Aobaku, Sendai, 980-8576, JAPAN
> Tel: +81-(0)22-795-6048 <tel:%2B81-%280%2922-795-6048>
> Email-1: ryo...@dc.tohoku.ac.jp <mailto:ryo...@dc.tohoku.ac.jp>
> Email-2: ryotachi...@gmail.com <mailto:ryotachi...@gmail.com>
> *―――――――――――――――――――――――*
>
>

--
/*Dr. Oliver Lindemann*
Division of Cognitive Science
University of Potsdam/

Karl - Liebknecht Str. 24/25, Building 14, 14476 Potsdam, Germany
Tel: +49 - 331 - 977 2915, Fax: +49 - 331 - 977 2794
Room: 6.24, Building 14, http://www.cognitive-psychology.eu/lindemann



Ryo TACHIBANA

unread,
Oct 27, 2015, 11:47:28 AM10/27/15
to expyriment-users, oliver.l...@uni-potsdam.de
Dear Oliver,

Thank you very much for your suggestion.

I was able to connect Expyriment to an Eyelink by modifying 'eyelink_fnctns.py' a bit.
But I and a specialist of SR Research Support found a screen problem of Expyriment.

When I run my program as below, the screen keeps a gray blank after the calibration.
After a while, the end message is showed correctly.
According to the specialist, it seems that Expyriment doesn't present stimuli during the trial while the recording of eye movements actually done.

How can I present stimuli during the trial?

import pylink
from expyriment import design, control, stimuli, io, misc
from eyelink_fnctns import init_eyelink, end_eyelink, end_recording, do_drift, getEYELINK, start_recording, GazeDetector

control.initialize(exp)
...

control.start()
tracker = init_eyelink(exp)
edfFileName = init_eyelink(exp)
pylink.doTrackerSetup()
start_recording()
...
end_recording()
end_eyelink()

control.end()


Best regards,

2015年10月17日土曜日 0時12分49秒 UTC+9 Oliver Lindemann:

Oliver Lindemann

unread,
Oct 27, 2015, 1:44:11 PM10/27/15
to Ryo TACHIBANA, expyriment-users
Sorry, I have no idea. I do not have a eyelink and I never used
Expyriment together with eyelink.

What is the function pylink.doTrackerSetup() doing? Why is that needed?
In the code below I do not see what kind of stimulus you want to present?

Oliver
> > Email-1: ryo...@dc.tohoku.ac.jp <javascript:>
> <mailto:ryo...@dc.tohoku.ac.jp <javascript:>>
> > Email-2: ryotachi...@gmail.com <javascript:>
> <mailto:ryotachi...@gmail.com <javascript:>>
> > *―――――――――――――――――――――――*
> >
> >
>
> --
> /*Dr. Oliver Lindemann*
> Division of Cognitive Science
> University of Potsdam/
>
> Karl - Liebknecht Str. 24/25, Building 14, 14476 Potsdam, Germany
> Tel: +49 - 331 - 977 2915, Fax: +49 - 331 - 977 2794
> Room: 6.24, Building 14,
> http://www.cognitive-psychology.eu/lindemann
> <http://www.cognitive-psychology.eu/lindemann>

Ryo TACHIBANA

unread,
Oct 27, 2015, 2:09:27 PM10/27/15
to expyriment-users, ryotachi...@gmail.com, oliver.l...@uni-potsdam.de
Dear Oliver,

The pylink.doTrackerSetup() is the function to conduct the calibration and validation of eye movements. This is necessary for eye tracking, and should be done before the trial. The SR Research specialist have already confirmed that we were able to do it from Expyriment.

The stimuli are images.
I run the program as a test that just present fixation and images a few times.

Best,



2015年10月28日水曜日 2時44分11秒 UTC+9 Oliver Lindemann:

Oliver Lindemann

unread,
Oct 27, 2015, 2:25:18 PM10/27/15
to expyrime...@googlegroups.com
Without the full code it is hard to give any feedback.

Oliver
> <http://www.cognitive-psychology.eu/lindemann>
>
> --
> You received this message because you are subscribed to the Google
> Groups "expyriment-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to expyriment-use...@googlegroups.com
> <mailto:expyriment-use...@googlegroups.com>.
> To post to this group, send email to expyrime...@googlegroups.com
> <mailto:expyrime...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/expyriment-users.
> For more options, visit https://groups.google.com/d/optout.

Ryo TACHIBANA

unread,
Oct 27, 2015, 2:47:42 PM10/27/15
to expyriment-users, oliver.l...@uni-potsdam.de
Dear Oliver,

Sorry, please look at the attached files.

Best,


2015年10月28日水曜日 3時25分18秒 UTC+9 Oliver Lindemann:
eyelink_fnctns_r.py
test_eyelink1.py

Oliver Lindemann

unread,
Oct 28, 2015, 5:56:30 AM10/28/15
to expyrime...@googlegroups.com
The script should run withpout problems. If so, it seems to be an issue
of pylink. Or the compatibility of pylink and Expyriment.

* Does it run without the eyelink stuff (lines 36-40 & 51-52)?

* Does the eyelink_fnctns, but without line 39?


Oliver
> > an email to expyriment-use...@googlegroups.com <javascript:>
> > <mailto:expyriment-use...@googlegroups.com
> <javascript:>>.
> > To post to this group, send email to
> expyrime...@googlegroups.com <javascript:>
> > <mailto:expyrime...@googlegroups.com <javascript:>>.
> <http://groups.google.com/group/expyriment-users>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> /*Dr. Oliver Lindemann*
> Division of Cognitive Science
> University of Potsdam/
>
> Karl - Liebknecht Str. 24/25, Building 14, 14476 Potsdam, Germany
> Tel: +49 - 331 - 977 2915, Fax: +49 - 331 - 977 2794
> Room: 6.24, Building 14,
> http://www.cognitive-psychology.eu/lindemann
> <http://www.cognitive-psychology.eu/lindemann>
>
> --
> You received this message because you are subscribed to the Google
> Groups "expyriment-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to expyriment-use...@googlegroups.com
> <mailto:expyriment-use...@googlegroups.com>.

Sebastiaan Mathôt

unread,
Oct 29, 2015, 4:51:30 AM10/29/15
to expyriment-users, oliver.l...@uni-potsdam.de
Hi guys,

I haven't looked at the experiment, but a general comment that may clear things up. pylink requires a 'custom graphics class', which handles all the drawing operations (like showing the camera image and drawing the calibration dots) in a way that is compatible with the software that you're using--expyriment in this case. If you don't have this, you'll get weird interference/ crashes.

The only custom-graphics class for Expyriment that I know of is the one from OpenSesame. That doesn't mean you have to use the OpenSesame interface much though (if you're a coding guy), you can just copy-paste your expyriment script in an OpenSesame inline_script, or use the external_script plug-in.

See:


Cheers!
Sebastiaan

Oliver Lindemann

unread,
Oct 29, 2015, 6:37:49 AM10/29/15
to expyrime...@googlegroups.com
Thanks Sebastiaan for the feedback.

Oliver

Ryo TACHIBANA

unread,
Jan 22, 2016, 5:12:10 AM1/22/16
to expyriment-users, oliver.l...@uni-potsdam.de
Dear Oliver,

Sorry for the long delay.

Does it run without the eyelink stuff (lines 36-40 & 51-52)? 
Does the eyelink_fnctns, but without line 39? 
It doesn't work. Without the lines 36-40 & 51-52, it gets a forced termination of program.
Yes it works. 'exp.experiment_info[0]'  in line 39-40 doesn't seem to exist, resultig 'IndexError: list index out of range'.

Eventually, I succeeded to use the eyetracker by using Expyriment with Opensesame and Pygaze on MacOS!
>Thank you Sebastiaan.

I hope this help.



2015年10月29日木曜日 19時37分49秒 UTC+9 Oliver Lindemann:
Reply all
Reply to author
Forward
0 new messages