示例#1
0
def default_analysis_figure(idx):

    global fname, ftitle

    tr = load_trajectory(fname)
    tr.v_idx = idx
    crun = tr.v_crun

    pl.close()
    fig = pl.figure()

    # ----- 3x4 -----
    s = 150
    fig.set_size_inches(1920 / s * 5 / 4, 1080 / s * 7 / 3)

    ax_lines, ax_cols = 7, 5
    axs = {}
    for x, y in itertools.product(range(ax_lines), range(ax_cols)):
        axs['%d,%d' % (x + 1, y + 1)] = pl.subplot2grid((ax_lines, ax_cols),
                                                        (x, y))

    midT = int(tr.T / tr.dt / 2)

    if tr.T / second > 2:
        raster_plot(axs['1,1'], tr, crun, tmin=0 * second, tmax=2 * second)
        raster_plot(axs['1,2'],
                    tr,
                    crun,
                    tmin=tr.T / 2 - 1 * second,
                    tmax=tr.T / 2 + 1 * second)
        raster_plot(axs['1,3'], tr, crun, tmin=tr.T - 2 * second, tmax=tr.T)

        voltage_traces(axs['2,1'],
                       tr,
                       crun,
                       tmin=0 * second,
                       tmax=0.5 * second)
        voltage_traces(axs['2,2'],
                       tr,
                       crun,
                       tmin=tr.T / 2 - 0.25 * second,
                       tmax=tr.T / 2 + 0.25 * second)
        voltage_traces(axs['2,3'],
                       tr,
                       crun,
                       tmin=tr.T - 0.25 * second,
                       tmax=tr.T)
    else:
        raster_plot(axs['1,1'], tr, crun)
        voltage_traces(axs['2,1'], tr, crun)

    firing_rate_distribution_exc(axs['1,4'], tr, crun, steps=10)
    firing_rate_distribution_inh(axs['2,4'], tr, crun, steps=15)

    print_netw_params(axs['2,5'], tr, crun)

    isi_distribution(axs['1,5'], tr, crun, bins=50)

    conductance_mult_trace(axs['3,1'], tr, crun, tmin=0, tmax=2000)

    conductance_mult_trace(axs['3,2'], tr, crun, tmin=midT, tmax=midT + 2000)
    conductance_mult_trace(axs['3,3'], tr, crun, tmin=-2001, tmax=-1)

    print_stdp_params(axs['3,5'], tr, crun)

    synapse_weight_distribution_t(axs['4,1'], tr, crun, tstep=0)
    synapse_weight_distribution_t(axs['4,2'], tr, crun, tstep=-1)
    synapse_weight_distribution_log_t(axs['4,3'], tr, crun, bins=30, tstep=-1)
    synapse_weight_distribution_log_t(axs['4,4'],
                                      tr,
                                      crun,
                                      bins=30,
                                      a_min=tr.a_insert,
                                      tstep=-1)
    synapse_weight_distribution_log_t_faulty(axs['4,5'], tr, crun, bins=30)

    synapse_active_trace(axs['5,1'], tr, crun)
    synapse_deathtime_distribution(axs['5,2'], tr, crun)
    synapse_lifetime_distribution(axs['5,3'], tr, crun)
    synapse_lifetime_distribution_loglog_linbin(axs['5,4'], tr, crun)
    synapse_lifetime_distribution_loglog(axs['5,5'], tr, crun)

    synapse_weight_traces(axs['6,1'], tr, crun)
    synapse_weight_traces(axs['7,1'],
                          tr,
                          crun,
                          tmin=tr.T - 1 * second,
                          tmax=tr.T)
    synapse_weight_change_on_spike(axs['6,2'], tr, crun)
    synapse_weight_change_on_spike_log(axs['6,3'], tr, crun)
    synapse_weight_change_on_spike_loglog(axs['6,4'], tr, crun)

    synapse_lifetime_distribution_loglin(axs['6,5'], tr, crun)

    # Apre_traces(axs['6,4'], tr, crun, tmin=-2001, tmax=-1)
    # Apost_traces(axs['6,5'], tr, crun, tmin=-2001, tmax=-1)

    membrane_threshold_distribution_t(axs['7,2'], tr, crun, tstep=0)
    membrane_threshold_distribution_t(axs['7,3'], tr, crun, tstep=-1)
    membrane_threshold_traces(axs['7,4'], tr, crun)
    print_membrane_params(axs['7,5'], tr, crun)

    pl.tight_layout()

    directory = "figures/default_analysis".format(ftitle)
    if not os.path.exists(directory):
        os.makedirs(directory)

    pl.savefig(directory + "/{:s}_{:s}.png".format(ftitle, crun),
               dpi=100,
               bbox_inches='tight')
def lognorm_analysis_figure(idx):

    global fname, ftitle

    tr = load_trajectory(fname)
    tr.v_idx = idx
    crun = tr.v_crun

    pl.close()
    fig = pl.figure()

    ax_lines, ax_cols = 6, 8
    s = 150
    fig.set_size_inches(1920 / s * ax_cols / 4, 1080 / s * ax_lines / 3)

    axs = {}
    for x, y in itertools.product(range(ax_lines), range(ax_cols)):
        axs['%d,%d' % (x + 1, y + 1)] = pl.subplot2grid((ax_lines, ax_cols),
                                                        (x, y))

    midT = int(tr.T / tr.dt / 2)

    fit = True

    synapse_weight_distribution_log_t(axs['1,1'], tr, crun, tstep=1, bins=50)
    synapse_weight_distribution_log_t(axs['1,2'], tr, crun, tstep=2, bins=50)
    synapse_weight_distribution_log_t(axs['1,3'], tr, crun, tstep=3, bins=50)
    synapse_weight_distribution_log_t(axs['1,4'], tr, crun, tstep=4, bins=50)
    synapse_weight_distribution_log_t(axs['1,5'], tr, crun, tstep=5, bins=50)
    synapse_weight_distribution_log_t(axs['1,6'], tr, crun, tstep=6, bins=50)
    synapse_weight_distribution_log_t(axs['1,7'],
                                      tr,
                                      crun,
                                      tstep=-1,
                                      bins=50,
                                      ax_text=True)

    low_bound = 0.00000000000000001 * tr.ATotalMax
    synapse_weight_distribution_log_t(axs['2,1'],
                                      tr,
                                      crun,
                                      tstep=1,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['2,2'],
                                      tr,
                                      crun,
                                      tstep=2,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['2,3'],
                                      tr,
                                      crun,
                                      tstep=3,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['2,4'],
                                      tr,
                                      crun,
                                      tstep=4,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['2,5'],
                                      tr,
                                      crun,
                                      tstep=5,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['2,6'],
                                      tr,
                                      crun,
                                      tstep=6,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['2,7'],
                                      tr,
                                      crun,
                                      tstep=-1,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit,
                                      ax_text=True)

    low_bound = 0.00000000001 * tr.ATotalMax
    synapse_weight_distribution_log_t(axs['3,1'],
                                      tr,
                                      crun,
                                      tstep=1,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['3,2'],
                                      tr,
                                      crun,
                                      tstep=2,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['3,3'],
                                      tr,
                                      crun,
                                      tstep=3,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['3,4'],
                                      tr,
                                      crun,
                                      tstep=4,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['3,5'],
                                      tr,
                                      crun,
                                      tstep=5,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['3,6'],
                                      tr,
                                      crun,
                                      tstep=6,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['3,7'],
                                      tr,
                                      crun,
                                      tstep=-1,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    view_thrshld_ax_text(axs['3,8'], tr, low_bound=low_bound)

    low_bound = 0.00000001 * tr.ATotalMax
    synapse_weight_distribution_log_t(axs['4,1'],
                                      tr,
                                      crun,
                                      tstep=1,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['4,2'],
                                      tr,
                                      crun,
                                      tstep=2,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['4,3'],
                                      tr,
                                      crun,
                                      tstep=3,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['4,4'],
                                      tr,
                                      crun,
                                      tstep=4,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['4,5'],
                                      tr,
                                      crun,
                                      tstep=5,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['4,6'],
                                      tr,
                                      crun,
                                      tstep=6,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['4,7'],
                                      tr,
                                      crun,
                                      tstep=-1,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    view_thrshld_ax_text(axs['4,8'], tr, low_bound=low_bound)

    low_bound = 0.00001 * tr.ATotalMax
    synapse_weight_distribution_log_t(axs['5,1'],
                                      tr,
                                      crun,
                                      tstep=1,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['5,2'],
                                      tr,
                                      crun,
                                      tstep=2,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['5,3'],
                                      tr,
                                      crun,
                                      tstep=3,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['5,4'],
                                      tr,
                                      crun,
                                      tstep=4,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['5,5'],
                                      tr,
                                      crun,
                                      tstep=5,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['5,6'],
                                      tr,
                                      crun,
                                      tstep=6,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['5,7'],
                                      tr,
                                      crun,
                                      tstep=-1,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    view_thrshld_ax_text(axs['5,8'], tr, low_bound=low_bound)

    low_bound = 0.001 * tr.ATotalMax
    synapse_weight_distribution_log_t(axs['6,1'],
                                      tr,
                                      crun,
                                      tstep=1,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['6,2'],
                                      tr,
                                      crun,
                                      tstep=2,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['6,3'],
                                      tr,
                                      crun,
                                      tstep=3,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['6,4'],
                                      tr,
                                      crun,
                                      tstep=4,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['6,5'],
                                      tr,
                                      crun,
                                      tstep=5,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['6,6'],
                                      tr,
                                      crun,
                                      tstep=6,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    synapse_weight_distribution_log_t(axs['6,7'],
                                      tr,
                                      crun,
                                      tstep=-1,
                                      bins=50,
                                      low_bound=low_bound,
                                      fit=fit)
    view_thrshld_ax_text(axs['6,8'], tr, low_bound=low_bound)

    print_netw_params(axs['1,8'], tr, crun)
    print_stdp_params(axs['2,8'], tr, crun)
    ax_off(axs['3,8'])
    ax_off(axs['4,8'])
    ax_off(axs['5,8'])
    ax_off(axs['6,8'])

    pl.tight_layout()

    subdir = "analysis/synaptic_weight_lognorm_t"
    if not os.path.exists(subdir):
        os.makedirs(subdir)

    pl.savefig(subdir + "/syn_lnt_{:s}_{:s}.png".format(ftitle, crun),
               dpi=100,
               bbox_inches='tight')
def lognorm_analysis_figure(idx):

    global fname, ftitle

    tr = load_trajectory(fname)
    tr.v_idx = idx
    crun = tr.v_crun

    pl.close()
    fig = pl.figure()

    ax_lines, ax_cols = 6, 4
    s = 150
    fig.set_size_inches(1920 / s * ax_cols / 4, 1080 / s * ax_lines / 3)

    axs = {}
    for x, y in itertools.product(range(ax_lines), range(ax_cols)):
        axs['%d,%d' % (x + 1, y + 1)] = pl.subplot2grid((ax_lines, ax_cols),
                                                        (x, y))

    midT = int(tr.T / tr.dt / 2)

    synapse_weight_distribution_t(axs['1,1'], tr, crun, tstep=-1, bins=50)
    synapse_weight_distribution_log_t(axs['1,2'], tr, crun, tstep=-1, bins=50)
    synapse_weight_distribution_loglog_t(axs['1,3'],
                                         tr,
                                         crun,
                                         tstep=-1,
                                         bins=50)

    synapse_weight_distribution_t(axs['2,1'],
                                  tr,
                                  crun,
                                  tstep=-1,
                                  bins=50,
                                  low_bound=0.00001 * tr.ATotalMax)
    synapse_weight_distribution_log_t(axs['2,2'],
                                      tr,
                                      crun,
                                      tstep=-1,
                                      bins=50,
                                      low_bound=0.00001 * tr.ATotalMax)
    synapse_weight_distribution_loglog_t(axs['2,3'],
                                         tr,
                                         crun,
                                         tstep=-1,
                                         bins=50,
                                         low_bound=0.00001 * tr.ATotalMax)

    print_netw_params(axs['1,4'], tr, crun)
    print_stdp_params(axs['2,4'], tr, crun)
    ax_off(axs['3,4'])
    ax_off(axs['4,4'])
    ax_off(axs['5,4'])
    ax_off(axs['6,4'])

    synapse_weight_distribution_t(axs['3,1'],
                                  tr,
                                  crun,
                                  tstep=-1,
                                  bins=50,
                                  low_bound=0.0001 * tr.ATotalMax)
    synapse_weight_distribution_log_t(axs['3,2'],
                                      tr,
                                      crun,
                                      tstep=-1,
                                      bins=50,
                                      low_bound=0.0001 * tr.ATotalMax)
    synapse_weight_distribution_loglog_t(axs['3,3'],
                                         tr,
                                         crun,
                                         tstep=-1,
                                         bins=50,
                                         low_bound=0.0001 * tr.ATotalMax)

    synapse_weight_distribution_t(axs['4,1'],
                                  tr,
                                  crun,
                                  tstep=-1,
                                  bins=50,
                                  low_bound=0.001 * tr.ATotalMax)
    synapse_weight_distribution_log_t(axs['4,2'],
                                      tr,
                                      crun,
                                      tstep=-1,
                                      bins=50,
                                      low_bound=0.001 * tr.ATotalMax)
    synapse_weight_distribution_loglog_t(axs['4,3'],
                                         tr,
                                         crun,
                                         tstep=-1,
                                         bins=50,
                                         low_bound=0.001 * tr.ATotalMax)

    synapse_weight_distribution_t(axs['5,1'],
                                  tr,
                                  crun,
                                  tstep=-1,
                                  bins=50,
                                  low_bound=0.01 * tr.ATotalMax)
    synapse_weight_distribution_log_t(axs['5,2'],
                                      tr,
                                      crun,
                                      tstep=-1,
                                      bins=50,
                                      low_bound=0.01 * tr.ATotalMax)
    synapse_weight_distribution_loglog_t(axs['5,3'],
                                         tr,
                                         crun,
                                         tstep=-1,
                                         bins=50,
                                         low_bound=0.01 * tr.ATotalMax)

    synapse_weight_distribution_t(axs['6,1'],
                                  tr,
                                  crun,
                                  tstep=-1,
                                  bins=50,
                                  low_bound=0.05 * tr.ATotalMax)
    synapse_weight_distribution_log_t(axs['6,2'],
                                      tr,
                                      crun,
                                      tstep=-1,
                                      bins=50,
                                      low_bound=0.05 * tr.ATotalMax)
    synapse_weight_distribution_loglog_t(axs['6,3'],
                                         tr,
                                         crun,
                                         tstep=-1,
                                         bins=50,
                                         low_bound=0.05 * tr.ATotalMax)

    # synapse_weight_distribution_t(axs['5,1'], tr, crun, tstep=0)
    # synapse_weight_distribution_t(axs['5,2'], tr, crun, tstep=1)
    # synapse_weight_distribution_t(axs['5,3'], tr, crun, tstep=2)
    # synapse_weight_distribution_t(axs['5,4'], tr, crun, tstep=-1)

    # synapse_weight_distribution_log_t(axs['6,1'], tr, crun, tstep=1)
    # synapse_weight_distribution_log_t(axs['6,2'], tr, crun, tstep=2)
    # synapse_weight_distribution_log_t(axs['6,3'], tr, crun, tstep=3)
    # synapse_weight_distribution_log_t(axs['6,4'], tr, crun, tstep=-1)

    # synapse_weight_distribution_log_t(axs['1,5'], tr, crun, tstep=1, bins=50)
    # synapse_weight_distribution_log_t(axs['1,6'], tr, crun, tstep=2, bins=50)
    # synapse_weight_distribution_log_t(axs['1,7'], tr, crun, tstep=3, bins=50)
    # synapse_weight_distribution_log_t(axs['1,8'], tr, crun, tstep=-1, bins=50)

    # synapse_weight_distribution_log_t(axs['2,5'], tr, crun, tstep=1, bins=100)
    # synapse_weight_distribution_log_t(axs['2,6'], tr, crun, tstep=2, bins=100)
    # synapse_weight_distribution_log_t(axs['2,7'], tr, crun, tstep=3, bins=100)
    # synapse_weight_distribution_log_t(axs['2,8'], tr, crun, tstep=-1, bins=100)

    # synapse_weight_distribution_log_t(axs['3,5'], tr, crun, tstep=1, bins=250)
    # synapse_weight_distribution_log_t(axs['3,6'], tr, crun, tstep=2, bins=250)
    # synapse_weight_distribution_log_t(axs['3,7'], tr, crun, tstep=3, bins=250)
    # synapse_weight_distribution_log_t(axs['3,8'], tr, crun, tstep=-1, bins=250)

    # synapse_weight_distribution_loglog_t(axs['4,5'], tr, crun, tstep=1, bins=50)
    # synapse_weight_distribution_loglog_t(axs['4,6'], tr, crun, tstep=2, bins=50)
    # synapse_weight_distribution_loglog_t(axs['4,7'], tr, crun, tstep=3, bins=50)
    # synapse_weight_distribution_loglog_t(axs['4,8'], tr, crun, tstep=-1, bins=50)

    # synapse_weight_distribution_loglog_t(axs['5,5'], tr, crun, tstep=1, bins=100)
    # synapse_weight_distribution_loglog_t(axs['5,6'], tr, crun, tstep=2, bins=100)
    # synapse_weight_distribution_loglog_t(axs['5,7'], tr, crun, tstep=3, bins=100)
    # synapse_weight_distribution_loglog_t(axs['5,8'], tr, crun, tstep=-1, bins=100)

    # synapse_weight_distribution_loglog_t(axs['6,5'], tr, crun, tstep=1, bins=250)
    # synapse_weight_distribution_loglog_t(axs['6,6'], tr, crun, tstep=2, bins=250)
    # synapse_weight_distribution_loglog_t(axs['6,7'], tr, crun, tstep=3, bins=250)
    # synapse_weight_distribution_loglog_t(axs['6,8'], tr, crun, tstep=-1, bins=250)

    # synapse_weight_distribution_t(axs['4,2'], tr, crun, tstep=-1)
    # synapse_weight_distribution_log_t(axs['4,3'], tr, crun, bins=30,
    #                                  tstep=-1)
    # synapse_weight_distribution_log_t(axs['4,4'], tr, crun, bins=30,
    #                                   a_min=tr.a_insert, tstep=-1)
    # synapse_weight_distribution_log_t_faulty(axs['4,5'], tr, crun, bins=30)

    # synapse_active_trace(axs['5,1'], tr, crun)
    # synapse_deathtime_distribution(axs['5,2'], tr, crun)
    # synapse_lifetime_distribution(axs['5,3'], tr, crun)
    # synapse_lifetime_distribution_loglog_linbin(axs['5,4'], tr, crun)
    # synapse_lifetime_distribution_loglog(axs['5,5'], tr, crun)

    # synapse_weight_traces(axs['6,1'], tr, crun)
    # synapse_weight_traces(axs['7,1'], tr, crun, tmin=tr.T-1*second, tmax=tr.T)
    # synapse_weight_change_on_spike(axs['6,2'], tr, crun)
    # synapse_weight_change_on_spike_log(axs['6,3'], tr, crun)
    # synapse_weight_change_on_spike_loglog(axs['6,4'], tr, crun)

    # synapse_lifetime_distribution_loglin(axs['6,5'], tr, crun)

    # # Apre_traces(axs['6,4'], tr, crun, tmin=-2001, tmax=-1)
    # # Apost_traces(axs['6,5'], tr, crun, tmin=-2001, tmax=-1)

    # membrane_threshold_distribution_t(axs['7,2'], tr, crun, tstep=0)
    # membrane_threshold_distribution_t(axs['7,3'], tr, crun, tstep=-1)
    # membrane_threshold_traces(axs['7,4'], tr, crun)
    # print_membrane_params(axs['7,5'], tr, crun)

    pl.tight_layout()

    subdir = "analysis/synaptic_weight_full".format(ftitle)
    if not os.path.exists(subdir):
        os.makedirs(subdir)

    pl.savefig(subdir + "/synw_full_{:s}_{:s}.png".format(ftitle, crun),
               dpi=100,
               bbox_inches='tight')