| 1 |
import sys |
| 2 |
import os |
| 3 |
import pandas as pd |
| 4 |
import matplotlib.pyplot as plt |
| 5 |
|
| 6 |
from bmtk.simulator import popnet |
| 7 |
|
| 8 |
|
| 9 |
fig_size = (5.0, 5.7) |
| 10 |
legend_loc = 'upper right' |
| 11 |
legend_alpha = 0.95 |
| 12 |
|
| 13 |
def plot_rates(schema, zoom=True): |
| 14 |
spikes_df = pd.read_csv('output_{}/spike_rates.txt'.format(schema), sep=' ', |
| 15 |
names=['population', 'times', 'rates']) |
| 16 |
|
| 17 |
spikes_df['times'] *= 1000.0 |
| 18 |
|
| 19 |
plt.figure(figsize=fig_size) |
| 20 |
if zoom: |
| 21 |
spikes_df = spikes_df[(spikes_df['times'] >= 1000.0) & (spikes_df['times'] <= 1200.0)] |
| 22 |
|
| 23 |
rates_exc = spikes_df[spikes_df['population'] == 100] |
| 24 |
rates_inh = spikes_df[spikes_df['population'] == 101] |
| 25 |
|
| 26 |
plt.plot(rates_exc['times'], rates_exc['rates'], color='blue', label='excitatory') |
| 27 |
plt.plot(rates_inh['times'], rates_inh['rates'], color='red', label='inhibitory') |
| 28 |
plt.xlabel('time (ms)', fontsize=18, weight='normal') |
| 29 |
plt.ylabel('firing rate (Hz)', fontsize=18, weight='normal') |
| 30 |
plt.legend(loc=legend_loc, framealpha=legend_alpha, prop={'size': 12}) |
| 31 |
plt.xlim([1000, 1200]) |
| 32 |
plt.gca().spines['right'].set_visible(False) |
| 33 |
plt.gca().spines['top'].set_visible(False) |
| 34 |
|
| 35 |
plt.tick_params(which='major', labelsize=12) |
| 36 |
plt.tight_layout() |
| 37 |
|
| 38 |
#plt.savefig('brunel_{}_popnet.png'.format(schema)) |
| 39 |
#plt.savefig('brunel_{}_popnet.eps'.format(schema), format='eps', dpi=1000) |
| 40 |
plt.show() |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
def main(config_file): |
| 45 |
config_file = 'config.json' |
| 46 |
# config_file = 'config_' + sim+ '.json' |
| 47 |
configure = popnet.config.from_json(config_file) |
| 48 |
network = popnet.PopNetwork.from_config(configure) |
| 49 |
sim = popnet.PopSimulator.from_config(configure, network) |
| 50 |
sim.run() |
| 51 |
|
| 52 |
# cells_file = 'network/brunel_node_types.csv' |
| 53 |
# rates_file = configure['output']['rates_file'] |
| 54 |
# plot_rates(schema='D_v2') |
| 55 |
# plot_rates_popnet(cells_file, rates_file, model_keys='pop_name') |
| 56 |
|
| 57 |
|
| 58 |
if __name__ == '__main__': |
| 59 |
if __file__ != sys.argv[-1]: |
| 60 |
main(sys.argv[-1]) |
| 61 |
else: |
| 62 |
print('Please give A,B,C or D') |