<jupyter_start><jupyter_text>Interactive race model for stop signal taskbased on <NAME>'s interactiverace.m<jupyter_code>import numpy
import matplotlib.pyplot as plt

%matplotlib inline

# original matlab code

#function [meanrtgo,presp] = interactiverace

#rng('shuffle');
params={'mugo':.2,
        'mustop':.5,
        'threshold':60,
        'nondecisiongo':50,
        'nondecisionstop':50,
        'ssds':[100,200,300,400,500,3000],
        'nreps':1000,
        'maxtime':1000}

def interactiverace(params):
    
    meanrtgo = numpy.zeros(len(params['ssds']))
    presp = numpy.zeros(len(params['ssds']));
 
    for irep in range(params['nreps']):
        for j,ssd in enumerate(params['ssds']):
            stopsignaldelay = ssd
            goaccumulator = 0
            stopaccumulator = 0
            rtgo = 0
            itime = 0
            while itime < params['maxtime'] and rtgo == 0: # single trial
                itime = itime + 1
                if itime < stopsignaldelay + params['nondecisionstop']:
                    inhibition = 0
                else:
                    inhibition = 1
                    stopaccumulator = stopaccumulator + params['mustop'] + numpy.random.normal()
                if itime >= params['nondecisiongo']:
                    goaccumulator = goaccumulator + params['mugo'] - inhibition*stopaccumulator + numpy.random.normal()

                if goaccumulator > params['threshold']:
                    if rtgo == 0:
                        rtgo = itime;
            meanrtgo[j] += rtgo;
            if rtgo > 0:
                presp[j] += 1;

    for ssd in range(len(params['ssds'])):
        if presp[ssd] > 0:
            meanrtgo[ssd] = meanrtgo[ssd]/presp[ssd];
        presp[ssd] = presp[ssd]/params['nreps'];
    return(meanrtgo,presp)

meanrtgo,presp=interactiverace(params)
print(meanrtgo)
print(presp)
plt.figure(figsize=(10,5))
plt.subplot(1,2,1)
plt.plot(params['ssds'][:5],meanrtgo[:5] - meanrtgo[5])
plt.plot([params['ssds'][0],params['ssds'][4]],[0,0],'k:')
plt.xlabel('Stop signal delay')
plt.ylabel('Violation (Stop Failure RT - No-Stop RT)')
plt.subplot(1,2,2)
plt.plot(params['ssds'][:4],presp[:4])
plt.xlabel('Stop signal delay')
plt.ylabel('Probability of responding')
plt.axis([params['ssds'][0],params['ssds'][4],0,1])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1509433962264151, 'fraction_numerical': 0.029588336192109776, 'mean_word_length': 2.6003086419753085, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '100106', 'license': 'Apache-2.0', 'n_tokens_mistral': 860, 'n_tokens_neox': 786, 'n_words': 141, 'path': 'interactive_race.ipynb', 'repo_name': 'poldrack/stopping', 'size': '2338'}