Esempio n. 1
0
    zi, ei, pi = Bcpnn.compute_traces(pre_trace, tau_dict['tau_zi'], tau_dict['tau_ei'], tau_dict['tau_pi'], eps=dt/tau_dict['tau_pi'])
    pre_id = my_conns[0][0]
    post_id = my_conns[0][1]
    # print the seperately computed traces 
    np.savetxt('debug_zi_trace_%d.dat' % pre_id, zi)
    np.savetxt('debug_ei_trace_%d.dat' % pre_id, ei)
    np.savetxt('debug_pi_trace_%d.dat' % pre_id, pi)

    zj, ej, pj = Bcpnn.compute_traces(post_trace, tau_dict['tau_zj'], tau_dict['tau_ej'], tau_dict['tau_pj'], eps=dt/tau_dict['tau_pj'])
    np.savetxt('debug_zj_trace_%d.dat' % post_id, zj)
    np.savetxt('debug_ej_trace_%d.dat' % post_id, ej)
    np.savetxt('debug_pj_trace_%d.dat' % post_id, pj)

    pij, w_ij, bias = Bcpnn.compute_pij(zi, zj, pi, pj, tau_dict['tau_eij'], tau_dict['tau_pij'])
    print 'debug w_ij', pre_id, post_id, w_ij
    w_ij_trace, bias, pij, eij = Bcpnn.compute_pij(zi, zj, pi, pj, tau_dict['tau_eij'], tau_dict['tau_pij'], get_traces=True)
    print 'debug w_ij_trace[-1]', w_ij_trace[-1]

    print 'debug compare:'
    print 'zi zi_debug', zi[-1], zi_debug[-1], zi[-1] == zi_debug[-1], np.all(zi == zi_debug)
    print 'zj zj_debug', zj[-1], zj_debug[-1], zj[-1] == zj_debug[-1], np.all(zj == zj_debug)
    print 'ei ei_debug', ei[-1], ei_debug[-1], ei[-1] == ei_debug[-1], np.all(ei == ei_debug)
    print 'ej ej_debug', ej[-1], ej_debug[-1], ej[-1] == ej_debug[-1], np.all(ej == ej_debug)
    print 'pi pi_debug', pi[-1], pi_debug[-1], pi[-1] == pi_debug[-1], np.all(pi == pi_debug)
    print 'pj pj_debug', pj[-1], pj_debug[-1], pj[-1] == pj_debug[-1], np.all(pj == pj_debug)
    print 'bias, bias_j_debug[-1]', bias[-1], bias_j_debug[-1]
    assert np.all(bias[-1] == bias_j_debug[-1])

    trace_plotter.plot_all(my_conns[0][0], my_conns[0][1], fig=None, text=text, output_fn=output_fig_fn, show=True)

    output_fn = params["etrace_fn_base"] + "%d.dat" % pre_id
    np.savetxt(output_fn, ei)
    output_fn = params["etrace_fn_base"] + "%d.dat" % post_id
    np.savetxt(output_fn, ej)
    output_fn = params["etrace_fn_base"] + "%d_%d.dat" % (pre_id, post_id)
    np.savetxt(output_fn, eij)

    output_fn = params["ptrace_fn_base"] + "%d.dat" % pre_id
    np.savetxt(output_fn, pi)
    output_fn = params["ptrace_fn_base"] + "%d.dat" % post_id
    np.savetxt(output_fn, pj)
    output_fn = params["ptrace_fn_base"] + "%d_%d.dat" % (pre_id, post_id)
    np.savetxt(output_fn, pij)

    text = ""
    text += "tau_z = %d\n" % tau_z
    text += "tau_e = %d\n" % tau_e
    text += "tau_p = %d\n" % tau_p
    text += "x_stim(t) = (%.1f, %.1f) + (%.1f, %.1f) * t\n" % (mp[0], mp[1], mp[2], mp[3])
    output_fn = params["figures_folder"] + "bcpnn_%d.png" % (i)
    fig = None
    fig = plotter.plot_all(pre_id, post_id, fig, text, show=False, output_fn=output_fn)
    # fig.canvas.draw()

input_fn = params["figures_folder"] + "bcpnn_%d.png"
output_fn = params["movie_folder"] + "bcpnn_traces.avi"
fps = 0.5
import make_movie as mm

mm.avconv(input_fn, output_fn, fps)