How exclude a location after chosed from random.choice(locations)

OS (e.g. Win10):
PsychoPy version (2023.2.3):
What are you trying to achieve?:
Its a simple “ranking stimuli task”.
Eight images will appear on the screen for the participant and then they need to click with the mouse above one of them. After clicking on the mouse, the clicked image will disappear and the rest of them will have their positions randomized and so on… until have none image on the screen.

The objective is to have at the final of the experiment a list of preferable stimuli.
Per exemple, Stimulus7 was the first selected, and then Stimulus6… and so on…

What did you try to make it work?:
Currently, I’m have some issues with the image position.

I set on “Before Experiment”

import random
locations = [(-0.75, 0.36), (-0.27,0.36), (0.27,0.36), (0.75,0.36), (-0.75,-0.36), (-0.27,-0.36), (0.27,-0.36), (0.75,-0.36)]

At the begin routine

stimulus1.pos = random.choice(locations)

stimulus2.pos = random.choice(locations)

stimulus3.pos = random.choice(locations)

stimulus4.pos = random.choice(locations)

stimulus5.pos = random.choice(locations)

stimulus6.pos = random.choice(locations)

stimulus7.pos = random.choice(locations)

stimulus8.pos = random.choice(locations)

What specifically went wrong when you tried that?:
Its seems that the stimulus in getting above on each other. I don’t think random.choice(locations) is excluding the selected location for one of the previous Image (stimulus), but I don’t know how to continue from this…

SMTS.psyexp (158.1 KB)

I never use random.choice (because it doesn’t translate online)

Instead in your circumstances I would

shuffle(locations)
stimulus1.pos = locations.pop()
1 Like

Thanks a lot!
That was really helpful :slight_smile:

I have almost done my experiment here.
But I’d like to add some complexity in here. Can u help me?

The experiment is now running perfectly, but I’d like that after a first response (that is selecting one of the stimuli) a new trial began with the rest of the stimuli, but with their position randomized again. I don’t know if there is a way to to that in a single routine.

SMTS.psyexp (158.4 KB)
D1
B1
Uploading: B2.png…
C1
C2
D2
E1
E2

  1. Add a loop that points to a spreadsheet of stimulus sets
  2. Either move your Before Experiment code to Begin Routine or move it to Begin Experiment and set the positions using location stimulus1.pos = locations[0], stimulus2.pos = locations[1], etc instead of using .pop()
1 Like

Thanks a lot for the help until now :slight_smile:

I don’t think I get the first point “1. Add a loop that points to a spreadsheet of stimulus sets”

Hi, I am trying to make the randomization of the imagens in the same routine, but I tried a lot of stuffs (I was looking here Randomizing position of stim - #8 by wakecarter), but when I insert “set every repeat” on the imagem location, I can’t run the experiment.
SMTS.psyexp (200.3 KB)