Beispiel #1
0
def simulate_sacs_compare(pardict, novpres=0, fampres=10000, n=100, nplot=4,
                          ft_ref_dist=sf.observed_lendistrib, bins=100):
    sacs = get_saccaders(pardict)
    for sac in sacs:
        plot_inds = np.random.randint(0, n-1, nplot)
        ts, sals, looks, sac_ts, lookprob = sac.present_many([novpres, 
                                                              fampres],
                                                             n=n, 
                                                             prestime=4000, 
                                                             tstep=1)
        f = plt.figure(figsize=(7, 5.2))
        pref_ax = f.add_subplot(2, 1, 1)
        pts, prefs, xticks = s.plot_avg_preference(looks, ax=pref_ax, show=False)
        pref_ax.set_xticklabels(xticks, visible=False)
        pref_ax.set_xlabel('')
        pref_ax.set_yticks([.2, .4])
        sal_ax = f.add_subplot(2, 1, 2, sharex=pref_ax)
        sal_ax = s.plot_salience(ts, sals[plot_inds[0]], sal_ts=xticks, ax=sal_ax)
        for x in plot_inds:
            s.plot_presentation(ts, sals[x], looks[x], sac_ts[x], lookprob[x],
                                show=False)
        fixtimes = np.concatenate(map(np.diff, sac_ts), axis=0)
        # f2 = plt.figure()
        # ax1 = f2.add_subplot(1, 2, 1)
        # ax1.hist(ft_ref_dist, bins=bins, histtype='step', label='observed', 
        #          normed=True)
        # ax1.hist(fixtimes, bins=bins, histtype='step', label='model', normed=True)
        # ax2 = f2.add_subplot(1, 2, 2)
        # ax2.hist(map(len, sac_ts), bins=bins, histtype='step', 
        #          label='observed', normed=True)        
        lp = sf.compare_fixlens(fixtimes, ft_ref_dist)
        f.tight_layout()
        f.savefig('model_pref_sal.pdf', bbox_inches='tight')
    plt.show(block=False)
    return pts, prefs, lp
Beispiel #2
0
def sample_eyetrace(lt_novpars=lt_novpars, st_novpars=st_novpars, 
                    sal_tc=sal_tc, prob_tc=prob_tc, off_tnov=off_tnov, 
                    sacc_grow=sacc_grow, samebias=samebias, 
                    prob_sp=prob_saccpar):
    print 'getting samp'
    sac = NaiveSaccader(lt_novfunc, lt_novpars, st_novfunc, st_novpars, sal_tc, 
                   off_tnov, prob_tc, prob_sp, sacc_grow, samebias)
    out = sac.present_many([leftviews, rightviews], samp_pres, 
                           prestime=prestime, tstep=tstep)
    ts, sals, looks, saccs, lookprobs = out
    if plot_preses:
        plot_presentation(ts, sals[0], looks[0], saccs[0], lookprobs[0])
    fixes = np.concatenate(map(np.diff, saccs), axis=0)
    fixarr = np.zeros(sacclen)
    fixarr[:] = np.nan
    fixarr[:len(fixes)] = fixes
    return fixarr