# Staircase reaches the minValue or maxValue then the subsequent trial will be one step up or down

Hello,

I’m building a motion detection task using the staircase procedure to detect the lowest speed necessary to detect motion. The study involves two gratings shown simultaneously in the left and right visual fields. In each trial, one of the two gratings will be randomly selected to move upwards or downwards while the other remains stationary. The speed of the motion varies according to an adaptive staircase procedure. For the first trial of every run, the grating will have a speed of 0.566 degrees/second. For each correct response, the speed will decrease by 0.0472 degrees/second. For each incorrect answer, the speed will increase by 0.142 degrees/second.

I’ve managed to get all of the above components to work fine. I’ve attached screenshots at the bottom outlining how I’ve included these conditions in builder.

I need help adding code so that once the staircase reaches the minValue (0) or maxValue (0.660) then the subsequent trial will be on step up or down, respectively.

I would appreciate any help/feedback!

My current code for Begin Routine is as follow:

#Psychopy decides if left grating moves up or down
if random() > 0.5:
Left_Grat = level # Positive, so direction upward

else:
Left_Grat = - level # Negative, so direction downward

#Psychopy decides if right grating moves up or down
if random() > 0.5:
Right_Grat = level # Positive, so direction upward
else:
Right_Grat = - level # Negative, so direction downward

#Psychopy decides which grating remains stationary
if random() >0.5:
Left_Grat = 0 # so left grating doesn't move
CorrectAns = 'right' # correct answer would be right

else:
Right_Grat = 0 # so right grating doesn't move
CorrectAns = 'left' # correct answer would be left