psychopy.org | Reference | Downloads | Github

Problem with Conditional Branching in Builder

Dear Oli and others

I have been trying to design a similar experiment. I am using a mouse component.
What I want is

  1. a boarder on the image (‘green’ if clicked on image on left and ‘red’ if clicked on image on the right)
  2. The boarder should appear for 1 second
  3. If the mouse was clicked on image on left, I want ‘routine x’ to be played else I want ‘routine y’ to be played.

I took the code from this chain
#####################################
#Begin Experiment
from psychopy.clock import CountdownTimer

#Begin Routine
border_left = visual.ShapeStim(win, vertices=smiley_happy.verticesPix, units=‘pix’, lineColor=‘green’,lineWidth=5)
border_right = visual.ShapeStim(win, vertices=smiley_sad.verticesPix, units=‘pix’, lineColor=‘red’,lineWidth=5)

clockStart = 0
timer= core.CountdownTimer(1)

#Each Frame
for stimulus in [smiley_happy, smiley_sad]:
if mouse.isPressedIn(stimulus):
thisExp.addData(‘items’, 1)
items=items+1
thisExp.addData(‘RT’, t)
if stimulus.image == corrAns:
thisExp.addData(‘score’, 1)
else:
thisExp.addData(‘score’, 0)
if mouse.isPressedIn(border_left) and clockStart == 0:
a_sound.play()
clockStart = 1
border_left.autoDraw=True
timer.reset(1)
if mouse.isPressedIn(border_right) and clockStart == 0:
b_sound.play()
clockStart = 1
border_right.autoDraw=True
timer.reset(1)
if border_left.autoDraw and timer.getTime()<0:
border_left.autoDraw=False
continueRoutine = False
if border_right.autoDraw and timer.getTime()<0:
border_right.autoDraw=False
continueRoutine = False

############################################

The problem is in stage 2
a) when I click on one of the image, a border is created of desired color for that image and it stays until I make another click. What I want is the routine to end after displaying the frame for just 1 second.
b) It takes another clock to end the routine however. Another click will register only after 1 s. This seems to reflect on the ‘timer.reset(1)’.

It would be nice if you can also suggest how to conditionally play ‘routine x’ or ‘routine y’ based on response.

Looking forward to any help from you guys

kuppu