Example #1
0
def get_condition(rng, dt, context={}):
    #-------------------------------------------------------------------------------------
    # Epochs
    #-------------------------------------------------------------------------------------

    durations = {
        'fixation': (0, fixation),
        'stimulus': (fixation, fixation + stimulus),
        '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
    }
Example #2
0
File: romo.py Project: frsong/pyrl
def get_condition(rng, dt, context={}):
    #-------------------------------------------------------------------------------------
    # Epochs
    #-------------------------------------------------------------------------------------

    delay = context.get('delay')
    if delay is None:
        delay = tasktools.uniform(rng, dt, delay_min, delay_max)

    durations = {
        'fixation':   (0, fixation),
        'f1':         (fixation, fixation + f1),
        'delay':      (fixation + f1, fixation + f1 + delay),
        'f2':         (fixation + f1 + delay, fixation + f1 + delay + f2),
        'decision':   (fixation + f1 + delay + f2, tmax),
        'tmax':       tmax
        }
    time, epochs = tasktools.get_epochs_idx(dt, durations)

    gt_lt = context.get('gt_lt')
    if gt_lt is None:
        gt_lt = tasktools.choice(rng, gt_lts)

    fpair = context.get('fpair')
    if fpair is None:
        fpair = tasktools.choice(rng, fpairs)

    return {
        'durations': durations,
        'time':      time,
        'epochs':    epochs,
        'gt_lt':     gt_lt,
        'fpair':     fpair
        }
Example #3
0
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
        }
Example #4
0
File: romo.py Project: yulkang/pyrl
def get_condition(rng, dt, context={}):
    #-------------------------------------------------------------------------------------
    # Epochs
    #-------------------------------------------------------------------------------------

    delay = context.get('delay')
    if delay is None:
        delay = tasktools.uniform(rng, dt, delay_min, delay_max)

    durations = {
        'fixation': (0, fixation),
        'f1': (fixation, fixation + f1),
        'delay': (fixation + f1, fixation + f1 + delay),
        'f2': (fixation + f1 + delay, fixation + f1 + delay + f2),
        'decision': (fixation + f1 + delay + f2, tmax),
        'tmax': tmax
    }
    time, epochs = tasktools.get_epochs_idx(dt, durations)

    gt_lt = context.get('gt_lt')
    if gt_lt is None:
        gt_lt = tasktools.choice(rng, gt_lts)

    fpair = context.get('fpair')
    if fpair is None:
        fpair = tasktools.choice(rng, fpairs)

    return {
        'durations': durations,
        'time': time,
        'epochs': epochs,
        'gt_lt': gt_lt,
        'fpair': fpair
    }
Example #5
0
def get_condition(rng, dt, context={}):
    #-------------------------------------------------------------------------------------
    # Epochs
    #-------------------------------------------------------------------------------------

    durations = {
        'fixation': (0, fixation),
        'stimulus': (fixation, fixation + stimulus),
        'decision': (fixation + stimulus, tmax),
        'tmax': tmax
    }
    time, epochs = tasktools.get_epochs_idx(dt, durations)

    #-------------------------------------------------------------------------------------

    mod = context.get('mod')
    if mod is None:
        mod = rng.choice(mods)

    freq = context.get('freq')
    if freq is None:
        freq = rng.choice(freqs)

    return {
        'durations': durations,
        'time': time,
        'epochs': epochs,
        'mod': mod,
        'freq': freq
    }
Example #6
0
def get_condition(rng, dt, context={}):
    #-------------------------------------------------------------------------------------
    # Epochs
    #-------------------------------------------------------------------------------------

    durations = {
        'fixation': (0, fixation),
        'stimulus': (fixation, fixation + stimulus),
        '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
        }
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
        }
Example #8
0
def get_condition(rng, dt, context={}):
    #-------------------------------------------------------------------------------------
    # Epochs
    #-------------------------------------------------------------------------------------

    durations = {
        'fixation': (0, fixation),
        'stimulus': (fixation, fixation + stimulus),
        'decision': (fixation + stimulus, tmax),
        'tmax':     tmax
        }
    time, epochs = tasktools.get_epochs_idx(dt, durations)

    #-------------------------------------------------------------------------------------

    mod = context.get('mod')
    if mod is None:
        mod = rng.choice(mods)

    freq = context.get('freq')
    if freq is None:
        freq = rng.choice(freqs)

    return {
        'durations': durations,
        'time':      time,
        'epochs':    epochs,
        'mod':       mod,
        'freq':      freq
        }
Example #9
0
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
    }
Example #10
0
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
    }
Example #11
0
File: mante.py Project: frsong/pyrl
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
        }
Example #12
0
def get_condition(rng, dt, context={}):
    #-------------------------------------------------------------------------------------
    # Epochs
    #-------------------------------------------------------------------------------------

    offer_on = context.get('offer-on')
    if offer_on is None:
        offer_on = tasktools.uniform(rng, dt, offer_on_min, offer_on_max)

    durations = {
        'fixation':    (0, fixation),
        'offer-on':    (fixation, fixation + offer_on),
        'decision':    (fixation + offer_on, tmax),
        'tmax':        tmax
        }
    time, epochs = tasktools.get_epochs_idx(dt, durations)

    #-------------------------------------------------------------------------------------
    # Trial
    #-------------------------------------------------------------------------------------

    juice = context.get('juice')
    if juice is None:
        juice = tasktools.choice(rng, juices)

    offer = context.get('offer')
    if offer is None:
        offer = tasktools.choice(rng, offers)

    juiceL, juiceR = juice
    nB, nA = offer

    if juiceL == 'A':
        nL, nR = nA, nB
    else:
        nL, nR = nB, nA

    return {
        'durations': durations,
        'time':      time,
        'epochs':    epochs,
        'juice':     juice,
        'offer':     offer,
        'nL':        nL,
        'nR':        nR
        }
Example #13
0
def get_condition(rng, dt, context={}):
    #-------------------------------------------------------------------------------------
    # Epochs
    #-------------------------------------------------------------------------------------

    offer_on = context.get('offer-on')
    if offer_on is None:
        offer_on = tasktools.uniform(rng, dt, offer_on_min, offer_on_max)

    durations = {
        'fixation':    (0, fixation),
        'offer-on':    (fixation, fixation + offer_on),
        'decision':    (fixation + offer_on, tmax),
        'tmax':        tmax
        }
    time, epochs = tasktools.get_epochs_idx(dt, durations)

    #-------------------------------------------------------------------------------------
    # Trial
    #-------------------------------------------------------------------------------------

    juice = context.get('juice')
    if juice is None:
        juice = tasktools.choice(rng, juices)

    offer = context.get('offer')
    if offer is None:
        offer = tasktools.choice(rng, offers)

    juiceL, juiceR = juice
    nB, nA = offer

    if juiceL == 'A':
        nL, nR = nA, nB
    else:
        nL, nR = nB, nA

    return {
        'durations': durations,
        'time':      time,
        'epochs':    epochs,
        'juice':     juice,
        'offer':     offer,
        'nL':        nL,
        'nR':        nR
        }
Example #14
0
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
    }
Example #15
0
File: rdmfd.py Project: frsong/pyrl
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
        }