示例#1
0
from pyrates.utility import functional_connectivity, plot_connectivity
from sklearn.decomposition import PCA

# load parametrizations
df = pd.read_excel(
    '/home/rgast/ownCloud/data/stn_gpe_initial_parameters.xlsx').transpose()
df = pd.DataFrame(np.asarray(df.values[1:, :], dtype=np.float),
                  columns=df.iloc[0, :])

# raw data plot
df.plot()

# cross-correlation plot
_, ax = plt.subplots()
fc = functional_connectivity(df, metric='corr')
plot_connectivity(fc, ax=ax, xticklabels=df.columns, yticklabels=df.columns)

# dimensionality reduction plot
pca = PCA(n_components=7)
reduced_data = pca.fit_transform(df.values)
_, ax2 = plt.subplots(ncols=2)
plot_connectivity(
    pca.components_,
    ax=ax2[0],
    xticklabels=df.columns,
    yticklabels=['PC1', 'PC2', 'PC3', 'PC4', 'PC5', 'PC6', 'PC7'])
ax2[1].scatter(reduced_data[:, 0], reduced_data[:, 1])
ax2[1].set_xlabel('PC1'), ax2[1].set_ylabel('PC2')
print('Component eigenvalues: ', pca.singular_values_)
plt.tight_layout()
示例#2
0
                np.abs(ei_ratio - t_e / t_i))
            max_freq[r, c] = freqs[np.argmax(pow)]
            freq_pow[r, c] = np.max(pow)
            plt.close(plt.gcf())

    cm1 = cubehelix_palette(n_colors=int(len(tau_e_scaling) * len(ei_ratio)),
                            as_cmap=True,
                            start=2.5,
                            rot=-0.1)
    cm2 = cubehelix_palette(n_colors=int(len(tau_e_scaling) * len(ei_ratio)),
                            as_cmap=True,
                            start=-2.0,
                            rot=-0.1)
    cax1 = plot_connectivity(max_freq,
                             ax=ax[0, i],
                             yticklabels=list(
                                 np.round(tau_e_scaling, decimals=2)),
                             xticklabels=list(np.round(ei_ratio, decimals=2)),
                             cmap=cm1)
    cax1.set_xlabel('tau_e/tau_i')
    cax1.set_ylabel('tau_e/tau')
    cax1.set_title(f'max freq (tau = {t})')
    cax2 = plot_connectivity(freq_pow,
                             ax=ax[1, i],
                             yticklabels=list(
                                 np.round(tau_e_scaling, decimals=2)),
                             xticklabels=list(np.round(ei_ratio, decimals=2)),
                             cmap=cm2)
    cax2.set_xlabel('tau_e/tau_i')
    cax2.set_ylabel('tau_e/tau')
    cax2.set_title(f'freq power (tau = {t})')
    max_idx1 = np.argmax(power[idx1])
    max_idx2 = np.argmax(power[idx2])
    max_freq1[idx_r, idx_c] = freqs[idx1][max_idx1]
    max_pow1[idx_r, idx_c] = power[idx1][max_idx1]
    max_freq2[idx_r, idx_c] = freqs[idx2][max_idx2]
    max_pow2[idx_r, idx_c] = power[idx2][max_idx2]

# visualization
###############
results.plot()

fig, axes = plt.subplots(ncols=2, nrows=2, figsize=(12, 10))

# plot dominating beta frequency
plot_connectivity(max_freq1,
                  xticklabels=np.round(param_grid['d'], decimals=2),
                  yticklabels=np.round(param_grid['s'], decimals=3),
                  ax=axes[0, 0])
axes[0, 0].set_xlabel('delay mean')
axes[0, 0].set_ylabel('delay std')
axes[0, 0].set_title('Dominant Beta Frequency')

# plot power density of dominating beta frequency
plot_connectivity(max_pow1,
                  xticklabels=np.round(param_grid['d'], decimals=2),
                  yticklabels=np.round(param_grid['s'], decimals=3),
                  ax=axes[0, 1])
axes[0, 1].set_xlabel('delay mean')
axes[0, 1].set_ylabel('delay std')
axes[0, 1].set_title('PSD at Dominant Beta Frequency')

# plot dominating gamma frequency
示例#4
0
# create colormaps
n_colors = 20
cm_red = create_cmap('pyrates_red', as_cmap=True, n_colors=n_colors, reverse=True)
cm_green = create_cmap('pyrates_green', as_cmap=True, n_colors=n_colors, reverse=True)
div_cols = np.linspace(np.min(diff), np.max(diff), n_colors)
n_red = np.sum(div_cols > 1.)
n_blue = n_colors - n_red
cm_div = create_cmap('pyrates_red/pyrates_blue', as_cmap=True, n_colors=(n_blue, n_red),
                     pyrates_blue={'reverse': True}, pyrates_red={'reverse': False}, vmin=(0., 0.), vmax=(1.0, 1.0))

# plot results
dpi = 400
fig, axes = plt.subplots(ncols=3, figsize=(int(5000/dpi), int(2000/dpi)), dpi=400)

# plot simulation times of benchmarks run on the GPU
plot_connectivity(gpu_results[:, :, 0], ax=axes[0], yticklabels=N, xticklabels=p, cmap=cm_red,
                  cbar_kws={'label': 'T in s'})
axes[0].set_yticklabels(axes[0].get_yticklabels(), rotation='horizontal')
axes[0].set_ylabel('number of JRCs', labelpad=15.)
#axes[0].set_xlabel('coupling density', labelpad=15.)
axes[0].set_title('A: Simulation time T', pad=20.)

# plot simulation time differene between GPU and CPU
ax = plot_connectivity(diff, ax=axes[1], yticklabels=N, xticklabels=p, cmap=cm_div,
                       cbar_kws={'label': r'$\mathbf{T_{GPU}} / \mathbf{T_{CPU}}$'})
axes[1].set_yticklabels(axes[1].get_yticklabels(), rotation='horizontal')
#axes[1].set_ylabel('number of JRCs', labelpad=15.)
axes[1].set_xlabel('coupling density', labelpad=15.)
axes[1].set_title('B: GPU vs. CPU', pad=20.)

# plot memory consumption of benchmarks run on the GPU
plot_connectivity(cpu_results[:, :, 1], ax=axes[2], yticklabels=N, xticklabels=p, cmap=cm_green,
示例#5
0
            max_freq[i, j] = freqs[np.argmax(pow)]
            freq_pow[i, j] = np.max(pow)
            plt.close('all')

fig, ax = plt.subplots(ncols=2, figsize=(15, 5), gridspec_kw={})
cm1 = cubehelix_palette(n_colors=int(len(params['H_e']) * len(params['H_i'])),
                        as_cmap=True,
                        start=2.5,
                        rot=-0.1)
cm2 = cubehelix_palette(n_colors=int(len(params['H_e']) * len(params['H_i'])),
                        as_cmap=True,
                        start=-2.0,
                        rot=-0.1)
cax1 = plot_connectivity(max_freq,
                         ax=ax[0],
                         yticklabels=list(np.round(params['H_e'], decimals=2)),
                         xticklabels=list(np.round(params['H_i'], decimals=2)),
                         cmap=cm1)
cax1.set_xlabel('H_i')
cax1.set_ylabel('H_e')
cax1.set_title(f'max freq')
cax2 = plot_connectivity(freq_pow,
                         ax=ax[1],
                         yticklabels=list(np.round(params['H_e'], decimals=2)),
                         xticklabels=list(np.round(params['H_i'], decimals=2)),
                         cmap=cm2)
cax2.set_xlabel('H_i')
cax2.set_ylabel('H_e')
cax2.set_title(f'freq pow')
plt.suptitle('EI-circuit sensitivity to synaptic efficacies (H)')
plt.tight_layout(pad=2.5, rect=(0.01, 0.01, 0.99, 0.96))