def get_condition(rng, dt, context={}): #------------------------------------------------------------------------------------- # Wager or no wager? #------------------------------------------------------------------------------------- wager = context.get('wager') if wager is None: wager = rng.choice(wagers) #------------------------------------------------------------------------------------- # Epochs #------------------------------------------------------------------------------------- stimulus = context.get('stimulus') if stimulus is None: stimulus = stimulus_min + tasktools.truncated_exponential(rng, dt, stimulus_mean, xmax=stimulus_max) delay = context.get('delay') if delay is None: delay = tasktools.truncated_exponential(rng, dt, delay_mean, xmin=delay_min, xmax=delay_max) if wager: sure_onset = context.get('sure_onset') if sure_onset is None: sure_onset = tasktools.truncated_exponential(rng, dt, sure_mean, xmin=sure_min, xmax=sure_max) durations = { 'fixation': (0, fixation), 'stimulus': (fixation, fixation + stimulus), 'delay': (fixation + stimulus, fixation + stimulus + delay), 'decision': (fixation + stimulus + delay, tmax), 'tmax': tmax } if wager: durations['sure'] = (fixation + stimulus + sure_onset, tmax) time, epochs = tasktools.get_epochs_idx(dt, durations) #------------------------------------------------------------------------------------- # Trial #------------------------------------------------------------------------------------- left_right = context.get('left_right') if left_right is None: left_right = rng.choice(left_rights) coh = context.get('coh') if coh is None: coh = rng.choice(cohs) return { 'durations': durations, 'time': time, 'epochs': epochs, 'wager': wager, 'left_right': left_right, 'coh': coh }
def get_condition(rng, dt, context={}, choiceHis=[], rewardHis=[], trial_count=0): #------------------------------------------------------------------------------------- # Epochs #------------------------------------------------------------------------------------- #print "running here" ITI = context.get('ITI') if ITI is None: ITI = tasktools.truncated_exponential(rng, dt, ITI_min, ITI_min, ITI_max) #print ITI durations = { 'go': (0, go), 'decision': (go, go + decision), #'reward': (go + decision, go + decision + reward), 'ITI': (go + decision, go + decision + ITI), 'tmax': tmax } time, epochs = tasktools.get_epochs_idx(dt, durations) #------------------------------------------------------------------------------------- # Trial #------------------------------------------------------------------------------------- juice = context.get('juice') if juice is None: juice = juices offer = context.get('offer') if offer is None: pred_choice = binomial_test(choiceHis, rewardHis, trial_count) #offer = tasktools.choice(rng, offers) offer = offers[pred_choice - 2] #juiceL, juiceR = juice #nB, nA = offer nL, nR = offer #if juiceL == 'A': # nL, nR = nA, nB #else: # nL, nR = nB, nA return { 'durations': durations, 'time': time, 'epochs': epochs, 'juice': juices, 'offer': offer, 'nL': nL, 'nR': nR }
def get_condition(rng, dt, context={}): #------------------------------------------------------------------------------------- # Epochs #------------------------------------------------------------------------------------- delay = context.get('delay') if delay is None: delay = delay_min + tasktools.truncated_exponential( rng, dt, delay_mean, xmax=delay_max) durations = { 'fixation': (0, fixation), 'stimulus': (fixation, fixation + stimulus), 'delay': (fixation + stimulus, fixation + stimulus + delay), 'decision': (fixation + stimulus + delay, tmax), 'tmax': tmax } time, epochs = tasktools.get_epochs_idx(dt, durations) #------------------------------------------------------------------------------------- # Trial #------------------------------------------------------------------------------------- context_ = context.get('context') if context_ is None: context_ = rng.choice(contexts) left_right_m = context.get('left_right_m') if left_right_m is None: left_right_m = rng.choice(left_rights) left_right_c = context.get('left_right_c') if left_right_c is None: left_right_c = rng.choice(left_rights) coh_m = context.get('coh_m') if coh_m is None: coh_m = rng.choice(cohs) coh_c = context.get('coh_c') if coh_c is None: coh_c = rng.choice(cohs) return { 'durations': durations, 'time': time, 'epochs': epochs, 'context': context_, 'left_right_m': left_right_m, 'left_right_c': left_right_c, 'coh_m': coh_m, 'coh_c': coh_c }
def get_condition(rng, dt, context={}): #------------------------------------------------------------------------------------- # Epochs #------------------------------------------------------------------------------------- delay = context.get('delay') if delay is None: delay = delay_min + tasktools.truncated_exponential(rng, dt, delay_mean, xmax=delay_max) durations = { 'fixation': (0, fixation), 'stimulus': (fixation, fixation + stimulus), 'delay': (fixation + stimulus, fixation + stimulus + delay), 'decision': (fixation + stimulus + delay, tmax), 'tmax': tmax } time, epochs = tasktools.get_epochs_idx(dt, durations) #------------------------------------------------------------------------------------- # Trial #------------------------------------------------------------------------------------- context_ = context.get('context') if context_ is None: context_ = rng.choice(contexts) left_right_m = context.get('left_right_m') if left_right_m is None: left_right_m = rng.choice(left_rights) left_right_c = context.get('left_right_c') if left_right_c is None: left_right_c = rng.choice(left_rights) coh_m = context.get('coh_m') if coh_m is None: coh_m = rng.choice(cohs) coh_c = context.get('coh_c') if coh_c is None: coh_c = rng.choice(cohs) return { 'durations': durations, 'time': time, 'epochs': epochs, 'context': context_, 'left_right_m': left_right_m, 'left_right_c': left_right_c, 'coh_m': coh_m, 'coh_c': coh_c }
def get_condition(rng, dt, context={}): #------------------------------------------------------------------------------------- # Epochs #------------------------------------------------------------------------------------- stimulus = context.get('stimulus') if stimulus is None: stimulus = tasktools.truncated_exponential(rng, dt, stimulus_mean, xmin=stimulus_min, xmax=stimulus_max) durations = { 'fixation': (0, fixation), 'stimulus': (fixation, fixation + stimulus), 'decision': (fixation + stimulus, fixation + stimulus + decision), 'tmax': tmax } time, epochs = tasktools.get_epochs_idx(dt, durations) #------------------------------------------------------------------------------------- # Trial #------------------------------------------------------------------------------------- left_right = context.get('left_right') if left_right is None: left_right = rng.choice(left_rights) coh = context.get('coh') if coh is None: coh = rng.choice(cohs) return { 'durations': durations, 'time': time, 'epochs': epochs, 'left_right': left_right, 'coh': coh }