Hello everyone
I need a help with setting up an experiment. Basically, I need to set up a random sequence of 20 trials in two different conditions, stimulus A and stimulus B, established in lines 86 and 97.
The sequence would be: point of fixation, display of one of the the stimulus and the task of reproduction, in line 110. Then, a new attempt begins at the point of fixation.
The problem is that I do not know how to randomize the display of the stimuli.
I thought of generating a sequence of odd and even numbers and put an" if ", for example, if it is an even number choose the sequence for gray clock (lines 87 to 97), if it is an odd number choose the sequence for red clock(lines 100 to 106), but I do not know if that is the best choice, and I also do not know how to insert this "if " with the two for commands.
Thanks from Brazil!!!
import math, numpy, random # to have handy system and math functions
from psychopy import core, event, visual, gui # these are the PsychoPy modules
# creates a window
myWin = visual.Window(color='white',
units='pix',
size=[800, 800],
allowGUI=False,
fullscr=False
)
#setup participants
gui = gui.Dlg()
gui.addField("Subject ID:")
gui.addField("Condition Num:")
gui.show()
subj_id = gui.data[0]
cond_num = int(gui.data[1])
print (subj_id)
print (cond_num)
#Instructions
text = visual.TextStim(myWin,
text="Test",
color=[-1,-1,-1]
)
fixation = visual.TextStim(myWin,
text="+",
color=[-1,-1,-1]
)
# gray
disk1 = visual.Circle(myWin,
radius=80,
fillColor='gray',
lineColor=None,
edges=128
)
# Red
disk2 = visual.Circle(myWin,
radius=80,
fillColor='red',
lineColor=None,
edges=128
)
# Clockhand
clock_hand = visual.Line(myWin,
start=[0, 0],
end=[-80, 0],
lineColor='black',
lineWidth=3,
ori=0
)
#Text
text.draw()
myWin.flip()
event.waitKeys()
#Start_text
text2 = visual.TextStim(myWin,
text="Start with A",
color=[-1,-1,-1]
)
#Stop_text
text3 = visual.TextStim(myWin,
text="Stop with L",
color=[-1,-1,-1]
)
#Fixation
fixation.draw()
myWin.flip()
core.wait(5)
#Stimuli_A
current_angle = 0.0
for i in range(10):
disk1.draw()
clock_hand.ori = current_angle
clock_hand.draw()
myWin.flip()
core.wait(1)
current_angle += 45.0
#Stimuli_B
current_angle = 0.0
for i in range(10):
disk2.draw()
clock_hand.ori = current_angle
clock_hand.draw()
myWin.flip()
core.wait(2)
current_angle += 45.0
#ReproductionTask
#Start
text2.draw()
myWin.flip()
start = event.waitKeys(keyList=["a"])
#Stop
clock = core.Clock()
text3.draw()
myWin.flip()
stop = event.waitKeys(keyList=["l"],timeStamped=clock)
print(start)
print(stop)
myWin.close() #closes the window