If this template helps then use it. If not then just delete and start from scratch.
OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 3.2.4
What are you trying to achieve?:
I’m trying to generate array of dots (up to 150)
What did you try to make it work?:
I generate the trial parameters in the beginning of experiment code component and initialize black and white dots.
totdots = [50, 100, 150]
dot1_stim = []
for tt in totdots:
#loop creating stimuli, number of black and white dots
dot1_stim.append([nb_dots1,nb_dots2,ratio])
random.shuffle(dot1_stim)
white_dot_stim = psychopy.visual.ElementArrayStim(
win=win, units="pix",
elementTex=None,
elementMask="circle",
sizes=5,
colorSpace='rgb',
colors='white'
)
black_dot_stim = psychopy.visual.ElementArrayStim(
win=win, units="pix",
elementTex=None,
elementMask="circle",
sizes=5,
colorSpace='rgb',
colors='black'
)
And then I would generate the array in the beginning routine using:
n_white_dots = dot1_stim[trialcounter][1]
n_black_dots = dot1_stim[trialcounter][0]
white_dot_xys = []
black_dot_xys = []
for dot in range(n_black_dots):
dot_x = random.uniform(-70, 70)
dot_y = random.uniform(5, 145)
black_dot_xys.append([dot_x, dot_y])
for dot in range(n_white_dots):
dot_x = random.uniform(-70, 70)
dot_y = random.uniform(-145, -5)
white_dot_xys.append([dot_x, dot_y])
white_dot_stim.xys = white_dot_xys
white_dot_stim.nElements = n_white_dots
black_dot_stim.xys = black_dot_xys
black_dot_stim.nElements = n_black_dots
white_dot_stim.setAutoDraw(True)
black_dot_stim.setAutoDraw(True)
I also have two rectangles components in this routine. This is the intended final product:
I looked at the crib sheet and this method was proposed for other types of stimuli, but I’m having trouble implementing it with static dots. This is the error I’m getting:
Any ideas on how to make this work?