Exemple #1
0
def pokes_per_min(session, plot_pos = []):
    setup_axis(plot_pos)
    poke_IDs =  ut.get_IDs(session.IDs, ['low_poke','high_poke', 'left_poke', 'right_poke'])
    poke_times = session.time_stamps[ut.array_contains(poke_IDs, session.event_codes)]/60
    bin_edges = np.arange(0,np.ceil(poke_times.max())+1)
    pokes_per_min = np.histogram(poke_times, bin_edges)[0]
    p.plot(bin_edges[0:-1]+0.5,pokes_per_min)
    p.xlabel('Time (minutes)')
Exemple #2
0
def log_IPI(session, plot_pos = []):
    'Log inter-poke interval distribution.'
    setup_axis(plot_pos)
    poke_IDs =  ut.get_IDs(session.IDs, ['low_poke','high_poke', 'left_poke', 'right_poke'])
    poke_times = session.time_stamps[ut.array_contains(poke_IDs, session.event_codes)]
    log_IPIs = np.log(poke_times[1::]-poke_times[0:-1])
    poke_events = session.event_codes[ut.array_contains(poke_IDs, session.event_codes)]
    repeated_poke_log_IPIs = log_IPIs[poke_events[1::] == poke_events[0:-1]]   
    bin_edges = np.arange(-1.7,7.6,0.1)
    log_IPI_hist = np.histogram(log_IPIs, bin_edges)[0]
    rep_poke_log_IPI_hist = np.histogram(repeated_poke_log_IPIs, bin_edges)[0]
    mode_IPI = np.exp(bin_edges[np.argmax(log_IPI_hist)]+0.05)
    if setup_axis(plot_pos):
        p.plot(bin_edges[0:-1]+0.05,log_IPI_hist)
        p.plot(bin_edges[0:-1]+0.05,rep_poke_log_IPI_hist,'r')
        p.xlim(bin_edges[0],bin_edges[-1])
        p.xticks(np.log([0.25,1,4,16,64,256]),[0.25,1,4,16,64,256])
        p.xlabel('Inter-poke interval (sec)')
    else: return (mode_IPI, log_IPI_hist, bin_edges[0:-1]+0.05)
Exemple #3
0
def poke_poke_corrlations(IDs, event_codes, plot_pos = []):
    'Poke probability as function of previous poke.' 
    poke_IDs =  ut.get_IDs(IDs, ['low_poke','high_poke', 'left_poke', 'right_poke'])
    poke_sequence = event_codes[ut.array_contains(poke_IDs, event_codes)]
    poke_pairs = zip(poke_sequence[0:-1],poke_sequence[1::])
    k = {IDs['high_poke']: 0,IDs['low_poke']: 1, IDs['left_poke']: 2,IDs['right_poke']: 3}
    poke_counts = np.zeros([4,4])
    for poke, next_poke in poke_pairs:
            poke_counts[k[poke],k[next_poke]] += 1
    poke_probs = poke_counts / np.tile(np.sum(poke_counts,1)[np.newaxis].T,(1,4))
    if setup_axis(plot_pos):
        p.imshow(poke_probs,cmap=p.cm.copper,interpolation='nearest')
        p.colorbar()
        p.xticks([0,1,2,3],['High','Low','Left','Right'])
        p.yticks([0,1,2,3],['High','Low','Left','Right'])
        p.xlabel('Poke t + 1')
        p.ylabel('Poke t')
    else: return poke_probs