Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Difficulty writing variables to eye tracker logfile with OpenGaze tracker type

Hi all,

I am trying to do custom message logging through the pygaze log, rather than automatically logging all variables (because this adds ~3.5 seconds to each trial). I have done this in the past with the Eye Tribe, but with OpenGaze/Gazepoint, I find that the same code fails. For example, in the log message window for the pygaze log, I have the code:

"time_ITI" [time_ITI]

The variable exists: print(var.time_ITI) returns the value in the debug window after I quit out. But nothing shows up in the user column of the .tsv. If I enter msg(clock.time()) I get MSG(CLOCK.TIME()) in the .tsv.... that is, the text I entered, but not the variable value I asked for.

Finally, when I try to use an inline script instead of pygaze log, a similar failure occurs. For example, eyetracker.log_var("current time", clock.time()) leads to nothing in the .tsv file. The experiment file is attached.

I should note that the variable values do get written to the .tsv when I use the "automatically log all variables" option in the pygaze logger.

Thanks for any advice you have,



  • As a follow-up, I see that the messages are being written to the _log.txt file, not the .tsv file. (The _log.txt file is not outputted when Eye Tribe is the tracker type.) Is it possible to do custom logging to the .tsv with OpenGaze as tracker type, or is "automatically log all variables" the only way to get variable values into the .tsv?

    Thanks again,


  • edited June 2019

    Hi Tom,

    Yeah, I wouldn't ever use the "log all variables" button in the pygaze_log item. Takes a bucketload of time, and writing every single variable that OpenSesame collects generally isn't what you want anyway. Instead, I'd recommend using an inline_script item where you call "eyetracker.log". For example, you could use the following code:

    # Get variables you want to log.
    var_a = exp.get("time_ITI")
    var_b = clock.time()
    # Stick all variables in a list.
    my_variable_list = [var_a, var_b]
    # Add variables together in a comma-separated string.
    message = ",".join(map(str, my_variable_list))
    # Log string.

    The OpenGaze code in PyGaze logs stuff in two places if you use the "eyetracker.log" function. The extra log that you found is one of them, but the log messages should also appear in the "USER" column of the gaze data file. (The USER column only works during recording, so only in between calling "start_recording" and "stop_recording"!)

    This limitation is due to how GazePoint's server works. It streams samples that are earmarked with a timestamp, but those samples asynchronously get processed in the Python thread and written to file. Hence, writing triggers to files directly would cause timing headaches. (When did the trigger come in? When did the last sample? Are they on the same clock?) To circumvent this, the triggers are sent to the GazePoint server, which adds them to the next sample (in the USER field). In this way, triggers will be written to file together with the closest sample, and thus providing a good anchor for cutting out epochs in your data.

    In sum: You should be seeing all logged messages in the extra log file, but you should also see messages that were logged during recording in the USER column of the gaze data file.



Sign In or Register to comment.