| Reference | Downloads | Github

Setting eyetracking ROI with builder and $Size

OS : Windows 10
PsychoPy version : v2021.2.2
Standard Standalone? (y/n) yes
What are you trying to achieve?: I’m trying to do a reading experiment with the eyetracking builder options. More specifically, I’m trying now to use the eye-tracking ROI module. In the place where I can set the size and position of my region of interest, I can write numbers in the format [x,y] and [w,h]. However, the size and position of the ROI that interests me will change for each items.

What did you try to make it work?: I’ve tried to imitate what I do for the text : My loop is linked to a excel file, with rows and columns. I write the name of the column containing the text, preceded by $, and everything works, for the text. I’m trying to do the same thing for the size and the position of the ROI : I write “$Size” and “$Position”, wich are the name of two columns I’ve added to my excel file, containing the parameters I want for each item. (in the format [x,y] and [w,h])

What specifically went wrong when you tried that?:
It gives me “NameError: name ‘Position’ is not defined”, wich is false, i’ve defined it. I then went to search in the code around my textbox stimuli to see what is the magic that allows me to says $Text and it goes in my file looking for the Text column. Sadly, since I’m kind of a Python beginner, I only understood that setText does itself…

Is there a way already in the builder to do what I want that I don’t know about?
If not, where and how in the code can I implement the same kind of options that there is in text and textbox stimuli, e.g. to write $Parameter and it goes look for it in the excel file?

Thank you for the time given to read and respond,


In theory this should work - :roi: ROI is really just a :polygon: Polygon with some extra functions to work with eyetracking, so it should be able to have its position set each frame just like a Polygon component. Is the size input set to set each frame? Leaving it as constant is a common mistake which causes this error - if it’s constant, it’s set at the beginning of the experiment, before the Excel file has been read in and all the variables from your column names have been created.

That was it.

Now I have to collect the data in fixation points, so I’ll continue surfing the forums for clues, and probably write another post if I encounter another problem.

Thank you.

1 Like