Hi
Sorry, as Michael commented my code was not correctly displayed. Thanks for the advice!
(Hopefully) here it goes now correctly with backticks.
I am programming a very simple “tracking” experiment were participants are instructed to follow a moving circle (movingC) with a cursor circle (cursorC - moved with a joystick/foot pedal) down to a “target” circle (targetC)
If they manage to reach the target circle “without much delay” (e.g. 2 seconds), I want to send a trigger to an EEG record (let’s leave the issue of the trigger for now - in the code below I am only giving a verbal feedback instead - e.g. “Well done!”).
At the moment I have 2 problems:
Problem 1. When using the following code (see full code below) to define the final position of the moving circle (movingC), I am getting the following error message:
Code:
while movingC.pos==(0,-7):
core.wait(2)
if cursorC.pos==(0,-7):
Error message:
while movingC.pos==(0,-7):
The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I am struggling to use a.all() to sort this out. Can anyone help?
Problem 2:
Requiring the cursorC.pos to be exactly in the position (0,-7) is probably too stringent. Is it possible to define an interval of positions with this type of command “.pos”?
Many thanks!!
Tiago
# Experiment section
trials = data.TrialHandler(trialList=[], nReps=50)
for thisTrial in trials:
# define pox_x, pox_y, speed
pos_y = 7
speed = 0.1
# mouse
myMouse = event.Mouse() # will use win by default
event.Mouse(visible=False)
#create circles
targetC = visual.Circle(win=mywin, radius=2.2, edges=32, fillColor="green", lineColor="green", pos=(0,-7))
cursorC = visual.Circle(win=mywin, radius=1.4, edges=32, fillColor="red", lineColor="red", pos=(0,7))
movingC = visual.Circle(win=mywin, radius=1.8, edges=32, fillColor="white", lineColor="white", pos=(0,7))
# draw circles
movingC.draw()
cursorC.draw()
targetC.draw()
mywin.flip()
core.wait(1)
#put moving circle in motion
for x in range(140):
pos_y = pos_y - speed
movingC.pos= (0,pos_y)
x,y=myMouse.getPos()
myMouse.setPos((0,y))
cursorC.setPos(myMouse.getPos())
event.clearEvents()
targetC.draw()
movingC.draw()
cursorC.draw()
while movingC.pos==(0,-7):
core.wait(3)
if cursorC.pos==(0,-7):
message = visual.TextStim(win=mywin, text="Well done!", alignHoriz="center", alignVert="center", bold=True)
message.draw()
mywin.flip()
else:
message = visual.TextStim(win=mywin, text="Missed it!", alignHoriz="center", alignVert="center", bold=True)
message.draw()
mywin.flip()
Thanks!!