psychopy.org | Reference | Downloads | Github

Object position shifting between trials

I’m relatively new to coding in python and new to Psychopy. I’m designing an experiment that involves briefly presenting a set of lines with fixed positions on the screen. I’m trying to make it so that the lines can randomly change their positions from trial to trial by a margin of 0.1 in any direction.

For example, I want to make it so that an object at position (3, 3), depending on the trial, could appear at (3, 3), (2.9, 3), (3, 2.9), (3, 3.1), (3.1, 3.1), (3.1, 3), (3.1, 2.9), (2.9, 2.9), and (2.9, 3.1).

Is there anything I can do in either Psychopy, python, or both to make this happen?

Thank you,
Vlad

The easiest option would be to have the position as $(xPos,yPos)

Add a code component to the top of the routine

The following code in Begin Experiment
xPos = 3
yPos = 3
changePos = [0,.1,-.1]

The following code in Begin Routine

shuffle (changePos)
xPos += changePos[0]
shuffle (changePos)
yPos += changePos[0]

Thank you so much! I added it to my code and it worked perfectly. I then adjusted it so that it could apply to each of the set positions I had!