Randomization of grating

Hi! I’m new in PsychoPy/python. I try to create a match-to-sample task with gratings (horizontal & vertical). I created circular gratings (components > stimuli > grating) and I organized my experiment into two routine: the first with one grating and the second with two gratings (position (x,y): 0,5 and -5,0 respectively). Nevertheless, I am facing two problems:

  1. When I run it, the first grating is displayed and then it stops
  2. How can I randomize the position of two gratings in the second routine? [i.e. I wanna create a block of 6 trials consisting of two routine. The first with one grating (e.g. horizontal grating) and the second with two gratings (one horizontal and one vertical) with random position]
    Do you have any idea? Thank you in advance!

Hello

insert a code-component in top row of the routine in which you display your gratings. In the Begin Experiment tab, insert

xPos = [-0.25,0.25]

to initialize the list (not when running locally)

In the Begin routine tab, insert

xPos = [-0.25,0.25]
shuffle(xPos)
xPosGrat1 = xPos.pop()
xPosGrat2 = xPos.pop()

Chose the Layout tab of the first grating property and specify the location.

(xPosGrat1, 0)

Set this property to set every repeat.

Do the sam for the second grating. This time, however, specify

(xPosGrat2,0)

You might want to save the positions by adding the following two lines to the “Beginn routine” tab.

thisExp.addData("xPosGrat1", xPosGrat1)
thisExp.addData("xPosGrat2", xPosGrat2)

Best wishes Jens

Thank you very much!!!