Sending triggers to Pupil Invisible tracker using Matlab

Hi all,

We recently purchased a Pupil Labs eye-tracker, the Pupil Invisible. To be able to make sense of the data we record, we want to send triggers to the tracker (i.e., time of trial start, stimulus presentation start). However, we have not yet found a way to do this.
We managed to connect the Pupil Invisible via a WiFi connection to the computer (as in, we can see the camera image on the computer), so there is a connection.

Currently, we are working on a Windows 10 machine (64 bits), with Matlab 2017b, latest Psychtoolbox and zeromq. We found a script that uses zeromq to send triggers, but it is not working. below is some code
zmq_request(‘init’);
requester = zmq_request(‘add_requester’, ‘tcp://100.1.0.3:5004’);
requester = int64(requester); % no problems up to this point
zmq_request(‘send_request’, requester, ‘Connect Pupil’); % this may work, but we do not know
reply = zmq_request(‘receive_reply’, requester, 1000); % reply = NaN, so it did not work

Does anyone have any experience with this and know how to fix it?

Thanks in advance!
Minke

Hi Minke,

I have also recently been working on sending triggers to a Pupil Labs eye tracker. So far I have only tested sending triggers from Octave to the eye tracker running on the same computer (on Ubuntu).

I found the descriptions and code examples from this study particularly helpful for getting started: https://peerj.com/articles/7086/#
https://github.com/behinger/etcomp

I’ve only done minimal testing myself so far. This test code worked for me to send a trigger to start the eye tracker (using Octave on Ubuntu).

requester = zmq_socket (ZMQ_REQ);
zmq_connect (requester, “tcp://127.0.0.1:50020”);

%% send some data -start recording
zmq_send (requester, uint8(“R”), 5, 0);
received = zmq_recv (requester, 10, 0);

%% send some data -stop recording
zmq_send (requester, uint8(“r”), 5, 0);
received = zmq_recv (requester, 10, 0);

zmq_close (requester);

Best,
Celia

Hi Celia,

Thank you for your reply. Actually, we got our current code from the links you included. But, as mentioned, that did not work…
Although I see your test code is slightly different, so we could test that. At the moment we unfortunately do not have access to our Pupil Invisible, but I will let you know if it works nice we do!

Best,
Minke

One thing to look at is if the IP address and port number is right for your setup, e.g., “tcp://127.0.0.1:50020” as in Celias script means to connect to the tracker running on the same computer, on port 50020, whereas your “tcp://100.1.0.3:5004” means to connect to a different machine somewhere on the network with IP address 100.1.0.3, and there expect the tracking software to listen on port 5004. The difference 50020 vs. 5004 is suspicious, as i’d assume that the Pupil Invisible tracker software has some default port number it listens on. According to pupil labs docs, the default port is 50020. The IP address 100.1.0.3 must be determined by you locally for your machine, you would not be able to just take that number from same example code you found. I assume you can also specify the host name of the tracker computer instead of a numeric IP.

-mario

Hi Minke,

Another couple points in addition to Mario’s great explanation about the IP address and port number. I think you should be able to test that your code works without the eye tracker - just having the Pupil Capture software open should be enough, even with no eye tracker plugged in.

I’m also planning to work on a matlab implementation of this same code in the next 2 weeks - I’ll update you with that.

Best,
Celia

I spent yesterday trying to figure out a Matlab implementation – this was much more difficult than in Octave!

For the Octave implementation, I forgot to mention before that it is first necessary to install the zeromq package in octave. The details of that, and how to use it are here: http://wiki.octave.org/Zeromq_package

For a Matlab implementation, Mario found the ‘cosy-zeromq-matlab’ implementation of zeromq in matlab (see the link below), which works for me now. It needs to be compiled though before it’ll run.

Using this method, I could run the code below in Matlab with the ‘pupil capture’ software open on the same PC, with no eye tracker attached.

zmq_request(‘init’);
requester = zmq_request(‘add_requester’, ‘tcp://127.0.0.1:50020’);

% start eye tracker recording (the R button in the pupil capture window should turn red and start recording)
zmq_request(‘send_request’, requester, ‘R’);
reply = zmq_request(‘receive_reply’, requester, 3000)

% stop eye tracker recording (the R button in the pupil capture window should turn off)
zmq_request(‘send_request’, requester, ‘r’);
reply = zmq_request(‘receive_reply’, requester, 3000)

zmq_request(‘close’);

Adding to Celia’s tips that on Ubuntu/Debian Linux, simply typing:

sudo apt install octave-zeromq will install zeromq for Octave, then a pkg load zeromq in Octave will do the trick.

Octave on Windows only needs a pkg load zeromq because Octave 6.1 for Windows already includes the zeromq package. Only macOS users have to do the full installation dance as described on their Wiki.

That https://github.com/UCLouvain-IoNS-CATL Github account has more useful github repos for simplified Pupil labs eyetracking and other stuff btw.

-mario