Пример #1
0
def show_connectivity_profile(x_probed, conn, ax, fit, true_model=None, ymax=None, fit_label=None):
    # where to bin connections for measuring connection probability
    x_bins = np.arange(0, 500e-6, 40e-6)

    # where to sample models
    #x_vals = 0.5 * (x_bins[1:] + x_bins[:-1])
    x_vals = np.linspace(x_bins[0], x_bins[-1], 200)
   
    _, cprop, lower, upper = connectivity_profile(conn, x_probed, x_bins)
    # plot the connectivity profile with confidence intervals (black line / grey area)
    show_distance_binned_cp(x_bins, cprop, ax, ci_lower=lower, ci_upper=upper)

    if ymax is None:
        ymax = upper.max()
    
    show_connectivity_fit(x_vals, fit, ax, true_model=true_model, label=fit_label)

    tickheight = ymax / 10
    show_connectivity_raster(x_probed, conn, tickheight, ax)

    # err = 0 if not hasattr(fit, 'fit_result') else fit.fit_result.fun
    # label = "Fit pmax=%0.2f\nsize=%0.2f µm\nerr=%f" % (fit.pmax, fit.size*1e6, err)
    # ax.text(0.99, 0.85, label, transform=ax.transAxes, color=(0.5, 0, 0), horizontalalignment='right')
    
    # if true_model is not None:
    #     label = "True pmax=%0.2f\nsize=%0.2f µm" % (true_model.pmax, true_model.size*1e6)
    #     ax.text(0.99, 0.95, label, transform=ax.transAxes, color=(0, 0.5, 0), horizontalalignment='right')
    
    ax.axhline(0, color=(0, 0, 0))
    set_distance_xticks(x_vals, ax)

    y_vals = np.arange(0, ymax + 0.1, 0.1)
    ax.set_yticks([-tickheight*2, -tickheight] + list(y_vals))
    ax.set_yticklabels(['probed', 'connected'] + ['%0.1f'%x for x in y_vals])
    ax.set_ylim(-tickheight*2.6, ymax)
Пример #2
0
    fit = test_model_class.fit(x_probed, conn)
    fit_p[i] = fit.pdf(x_vals)

# plot last generated connectivity histogram (light grey)
conn_x = x_probed[conn]
x_conn_hist = np.histogram(conn_x, bins=x_bins)
p = plt.plot(x_conn_hist[1],
             x_conn_hist[0] / x_hist[0].max(),
             stepMode=True,
             pen=None,
             fillLevel=0,
             fillBrush=0.3)
p.setZValue(-20)

# plot the last generated connectivity profile with confidence intervals (white/grey lines)
_, cprop, lower, upper = connectivity_profile(conn, x_probed, x_bins)
plt.plot(x_vals, cprop, pen={'width': 2, 'color': 'w'})
plt.plot(x_vals, lower, pen=0.5)
plt.plot(x_vals, upper, pen=0.5)

# plot the last fit result (thick red)
print(fit.fit_result)
plt.plot(x_vals, fit.pdf(x_vals), pen={'width': 2, 'color': (255, 0, 0, 200)})

# plot true confidence intervals on the fit (thin red)
#  -> this show us how wrong our fit is likely to be
lower = scipy.stats.scoreatpercentile(fit_p, 5, axis=0)
upper = scipy.stats.scoreatpercentile(fit_p, 95, axis=0)
plt.plot(x_vals, lower, pen=(255, 0, 0, 100))
plt.plot(x_vals, upper, pen=(255, 0, 0, 100))