Coding adaptive staircase procedure for a stop signal task

Hi everyone. I’m currently working on a Stop Signal Task to test the inhibition time of my participants. I’m really new to the coding components of Psychopy so I’m facing a few problems.

OS : Mac OS 10.15
PsychoPy version: 2020.2.5
Standard Standalone? Yes
What are you trying to achieve?:
I want to create an adaptive staircase procedure for measuring the reaction inhibition response during a Stop signal task by using Python in Psychopy. I have built an experiment in Psychopy for a Stop Signal Task. First, I have a Routine which contains a Textcomponent for the fixdot and two image components. One is named ‘gosignal’ and another image component is named ‘stopsignal’. Also, I implemented a key response with the allowed keys ‘n’, ‘m’, ‘None’. I have a Loop around the Routine which refers to the condition file ‘conditions.xlsx’. It has 120 conditions, with 4 parameters [arrows, ssig, ssigImg, corrAns]. The column ‘ssig’ determines if a trial is a trial where the Stopsignal should appear (for this the content in the column is ‘1’). The Image component ‘gosignal’ has $arrows as its image. The image component ‘stopsignal’ has $ssigImg as its image. Now I want to add a code component which determines the stopsignal Properties and creates an adaptive staircase.
So, for the first trial where a Stopsignal appears is should start after a delay of 600ms, the duration should be for this case 900ms (The presentation of the stopsignal should always end by 1500ms regardless of the delay but has to be adjusted because the delay will differ). Now I want to increase or decrease the Stopsignal delay whether the answer was correct or incorrect in an Stopsignal trial. The code should only refer to the Stopsignal Trials and also only changes the Delay for the next Stop Signal Trial. I want to check if a key was pressed when an stopsignal was presented. If something was pressed, the next trial where a ssigImg is presented, the stopsignal delay should be 100ms longer than the last trial where the stopsignal was present. Repeat this until the participant presses something during a Stopsignal Trial. Now decrease in 100 ms steps until there is no response from the participant during a Stopsignal trial.
I have wrote a Python code, which is not working correctly. When running the experiment it will only show the first gosignal ‘arrows’ and then won’t set a new one for the new frame.
This is my code:

from psychopy import core, data
import numpy as np
import random

startDelay = 0.6 # starting delay for the stop signal
stepSize = 0.1 # size of the step for adjusting delay
minDelay = 0.6 # minimum delay for the stop signal
maxDelay = 1.4 # maximum delay for the stop signal
reversalCriterion = 3 # number of reversals before stopping the staircase

myStaircase = data.StairHandler(startVal=startDelay, stepSizes=stepSize,
nTrials=120, minVal=minDelay, maxVal=maxDelay,
nUp=1, nDown=1, stepType=‘lin’, # linear step size
extraInfo={‘Reversals’: , ‘Response’: },
name=‘myStaircase’)
if ssig == 1: # this is a stop signal trial
currentDelay = myStaircase.next()
stopsignal.duration = 1.5 - currentDelay
if key_resp.keys in [‘m’, ‘n’]: # participant responded to the stop signal
response = 1 if key_resp.keys == corrAns else -1 # correct or incorrect response
myStaircase.addResponse(response) # update the staircase object
if response == 1: # decrease the delay by 100 ms
myStaircase.stepSize = -0.1
else: # increase the delay by 100 ms
myStaircase.stepSize = 0.1
myStaircase.extraInfo[‘Response’].append(response) # save the response in the extra info

if len(myStaircase.reversalIntensities) >= reversalCriterion:
myStaircase.finished = True
print(‘Final staircase results:’)
print(’ Final delay: %.3f’ % myStaircase.intensities[-1])
print(’ Reversals: %s’ % myStaircase.reversalIntensities)
print(’ Responses: %s’ % myStaircase.extraInfo[‘Response’])

I really don’t understand what the issue is here and I would be so glad if anyone could help. For better understanding I will put the .xlsx and the .psyexp file here.

conditions.xlsx (19.7 KB)

SST.psyexp (39.3 KB)

Hey Lara,

did you solve the problem?

I’m also trying to program a similar stop signal task.
I just tried a litte bit and the problem you have is with the StopSignal time and duration. I have entered in the builder at start time e.g. 0.6s and stop duration 1s and now the change of the images works.

greetings, Hannah