Ejemplo n.º 1
0
"""
labels = ['A', 'B']
for ii, label in enumerate(labels):
    ax = panel_factory.new_panel(ii, 0, '' + labels[ii], label_position='leftleft')
    ax.yaxis.set_ticks_position('none')
    ax.xaxis.set_ticks_position('bottom')

    data = utils.load_iteration(ii + 1)
    (par_transition, r_low, r_high,
     minima_low, minima_high) = utils.determine_velocity_minima(time, data)

    unstable_low = r_low[:, minima_low[1]]

    matrix = np.zeros((len(area_list), 8))
    for i, area in enumerate(area_list):
        mask = create_vector_mask(M_base.structure, areas=[area])
        m = unstable_low[mask]
        if area == 'TH':
            m = np.insert(m, 2, 0.0)
            m = np.insert(m, 2, 0.0)
        matrix[i, :] = m[::-1]
    matrix = np.transpose(matrix)

    if ii == 0:
        rate_matrix_plot(panel_factory.figure, ax, matrix, position='left')
    else:
        rate_matrix_plot(panel_factory.figure, ax, matrix, position='right')

"""
Save figure
"""
for i in range(254):
    Npre[i] = num_vector
    Npost[:, i] = num_vector

C = 1. - (1. - 1. / (Npre * Npost))**(M.K_matrix[:, :-1] * Npost)
Nsyn = M.K_matrix[:, :-1] * Npost
outdegree = Nsyn / Npre
indegree = M.K_matrix[:, :-1]

plot_areas = ['V1', 'V2']
mask = create_mask(M.structure,
                   target_areas=plot_areas,
                   source_areas=plot_areas,
                   extern=False)[:, :-1]
vmask = create_vector_mask(M.structure, areas=plot_areas)
new_size = np.where(vmask)[0].size

Nsyn_plot = Nsyn[mask].reshape((new_size, new_size))
C_plot = C[mask].reshape((new_size, new_size))
indegree_plot = indegree[mask].reshape((new_size, new_size))
outdegree_plot = outdegree[mask].reshape((new_size, new_size))

t_index = 0
ticks = []
ticks_r = []
for area in plot_areas:
    ticks.append(t_index + 0.5 * len(M.structure[area]))
    ticks_r.append(new_size - (t_index + 0.5 * len(M.structure[area])))
    for pop in M.structure[area]:
        t_index += 1
print("Iteration 4: {}".format(np.sum(K_prime4 - K_prime3) / np.sum(K_prime3)))
print("In total: {}".format(np.sum(K_prime4 - K_default) / np.sum(K_default)))

data = {}
for iteration in [1, 2, 3, 4, 5]:
    data[iteration] = utils.load_iteration(iteration)
"""
Panel A
"""
ax = panel_factory.new_panel(0, 0, 'A', label_position='leftleft')
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.yaxis.set_ticks_position("left")
ax.xaxis.set_ticks_position("bottom")

mask = create_vector_mask(M_base.structure, pops=['5E', '6E'])
for ii, iteration in enumerate([1, 2, 3, 4, 5]):
    pl.plot(data[iteration]['parameters'],
            np.mean(data[iteration]['results'][:, mask, -1], axis=1),
            '.-',
            color=str(ii / 6.))

ax.set_yscale('Log')
ax.yaxis.set_minor_locator(pl.NullLocator())
ax.set_yticks(10**np.arange(-1., 3., 1.))
ax.yaxis.set_label_coords(-0.13, 0.55)
ax.set_ylabel(r'$\langle \nu_{\{\mathrm{5E,6E}\}} \rangle$')
ax.set_xlabel(r'$\kappa$', labelpad=-0.1)

ax.set_xlim((1., 1.23))
"""
"""
ax = axes['F']
pos = ax.get_position()
divider = make_axes_locatable(ax)
ax_cb = pl.axes([pos.x1, pos.y0, 0.02, pos.y1 - pos.y0])

ax_cb.set_frame_on(False)
ax_cb.set_xticks([])
ax_cb.set_yticks([])

critical_eigenvector = np.real(EV[1][:, np.argsort(np.real(EV[0]))[-1]])
r = vector_to_dict(critical_eigenvector, area_list, M.structure)

ev_matrix = np.zeros((8, 32))
for i, area in enumerate(area_list):
    vm = create_vector_mask(M.structure, areas=[area])
    r = critical_eigenvector[vm]
    if area == 'TH':
        r = np.insert(r, 2, np.zeros(2))
    ev_matrix[:, i] = r

ind = [list(area_list).index(area) for area in hierarchical_areas[::-1]]

im = ax.pcolormesh(np.abs(ev_matrix[::-1][:, ind]),
                   cmap=pl.get_cmap('inferno'),
                   norm=LogNorm(vmin=1e-3, vmax=1e0))

area_string_F = area_list[ind][0]
for area in area_list[ind][1:]:
    area_string_F += ' '
    area_string_F += area