psychopy.org | Reference | Downloads | Github

Tell Psychopy to find Variable in Excel Sheet

Hello everyone,

I am very new to this and am currently using PsychoPy for the first time. For an experiment I have to make a Code, that makes the mouse appear in a certain position on the screen depending on a variable in my Excel file.

Up to now I have the following code:

starting_position1 = [-75, -40]
starting_position2 = [75, -40]
if (‘mouse’) == 1:
mouse.setPos = starting_position1
else :
mouse.setPos = starting_position2

and the following error message in PsychoPy:

mouse.setPos = starting_position2
AttributeError: ‘int’ object has no attribute ‘setPos’

I guess it might be cause PsychoPy can’t find the “mouse” variable. How do I tell PsychoPy to look for the variable in the Excel file?

Hi there,

try having one column for the mouse x position and a seperate column for the y position.

Then in your experiment add a mouse component (e.g. called mouse)

then add a code component and in the begin routine tab use:

mouse.setPos(myX myY) (where myX and myY correspond to your column headers

Hope this helps.
Becca

I don’t know if I did it right, but if I put your code, I also get the following message:

mouse.setPos(myx,myy)
AttributeError: ‘int’ object has no attribute ‘setPos’

Experiment ended.

Even though I defined myx and myy in the Excel sheet.

what is the name of your mouse component? replace mouse with the name of the component

The component is called “mouse”.