#### Howdy, Stranger!

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

Supported by

# pygaze_log plugin iussue with OpenGaze

Hi everybody!

I'm running an experiment using GazePoint eyetracker. My script is actually working, but I saw that the .tsv output file is very long and confusing. Plus, I created a crucial variable in my block loop that specifies each type of trial, and I really need to have this variable in my .tsv file!! So, I could easily identify the condition that each raw refers to.
I thought that this was possible through the setting "Automatically log all variables" in the pygaze_log plugin, that was disabled by default. But unfortunately the experiment stops right at the end of the trial, showing this message:

Unexpected error

item-stack: experiment[run].TRN_loop[run].block_sequence_TRN[run].block_loop_TRN[run].trial_sequence[run].EyeLog[run]
exception type: UnicodeEncodeError
exception message: 'ascii' codec can't encode character u'\xe0' in position 57: ordinal not in range(128)
time: Thu Dec 20 17:46:52 2018

Traceback:
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libqtopensesame\misc\process.py", line 154, in run
exp.run()
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\experiment.py", line 449, in run
self.items.execute(self.var.start)
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 103, in execute
self.run(name)
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 122, in run
self[name].run()
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\sequence.py", line 51, in run
self.experiment.items.run(_item)
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 122, in run
self[name].run()
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\loop.py", line 341, in run
self.experiment.items.execute(self._item)
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 103, in execute
self.run(name)
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 122, in run
self[name].run()
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\sequence.py", line 51, in run
self.experiment.items.run(_item)
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 122, in run
self[name].run()
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\loop.py", line 341, in run
self.experiment.items.execute(self._item)
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 103, in execute
self.run(name)
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 122, in run
self[name].run()
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\sequence.py", line 51, in run
self.experiment.items.run(_item)
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 122, in run
self[name].run()
File "C:\Program Files (x86)\OpenSesame\share\opensesame_plugins\pygaze_log\pygaze_log.py", line 52, in run
info[u'value'])
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\pygaze_eyetracker\baseeyetracker.py", line 319, in log_var
self.log(u"var %s %s" % (safe_decode(var), safe_decode(val)))
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\pygaze_eyetracker\libopengaze.py", line 685, in log
self._elog(msg)
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\pygaze_eyetracker\libopengaze.py", line 167, in _elog
self.extralogfile.write(msg + '\n')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 57: ordinal not in range(128)

I also adopted the method suggested by @eduard in this discussion (http://forum.cogsci.nl/index.php?p=/discussion/2247/pygaze-log-variables-in-edf-dataviewer), namely write the following code in a inline script:
exp.pygaze_eyetracker.log("!V TRIAL_VAR var %s" % var)
...but I saw that this code reports my variable only in .txt file; while I really need it in my .tsv file!

Any possible solution??

Martina

• Hi Martina,

What happens is that you're trying to write a non-ascii character to a file (which might just be in a reference to a file location, and not something you're deliberately trying to log). Allowing this to work is on my TODO list for PyGaze, but unfortunately not yet possible.

You could, instead of logging all variables, simply logging the variable of your choice by including the following in your pygaze_log item:

[var_name]

Where var_name should be replaced by the name of the variable that you need to log.

Make sure to deselect the option to log all variables!

Cheers,
Edwin

• Hi Edwin!

I'm not sure of where to include my variable in the pygaze_log item. I wrote it on the log message (it seemed to be the only editable space) and it appeared on the .txt file. Unfortunately, I need it to be on my .tsv file together with the coordinates of the saccades. Did I miss something?

Thank you!
Martina

• Hi Martina,

The pygaze_log item uses PyGaze's EyeTracker.log function, which should add the variable to both files! Have you checked the right-most column in the TSV file?

If it's not in there, I would be very interested in seeing your experiment script and your TSV file, please. That would greatly help with any further debugging efforts.

Cheers,
Edwin

• Hi Edwin!

My variable is not in the right-most column! So, here are my script and the .tsv file as well.

Thanks a lot for your help!!

Martina

• edited January 15

Hi Martina,

Could you clarify why you think your variable is not in the right-most column? I just opened "subject-00.tsv", and there are definitely logged messages in there. For example, I can see "START_EXPL_0", "STOP_EXPL_0", "START_GRASP_0", "STOP_GRASP_0", and "START_EXPL_1" (and a whole bunch more of those messages, numbering up).

Are other things supposed to be in there, or are you missing things?

Cheers,
Edwin