def sum_up_fig(args): fig, ax = plt.subplots(1, figsize=(2, 2)) plt.subplots_adjust(left=.4, bottom=.2) ## SAS SAS = [] for i in range(1, 6): args.filename = 'sas' + str(i) + '.zip' args2, DATA = get_scan(args) mean, std = get_spike_train_similarity(DATA,\ args.t0, args.time_span, args.N_target) SAS.append(100 * mean) ax.bar([0], [np.array(SAS).mean()], yerr=[np.array(SAS).std()]) ## BS BS = [] for i in range(1, 6): args.filename = 'bs' + str(i) + '.zip' args2, DATA = get_scan(args) mean, std = get_spike_train_similarity(DATA,\ args.t0, args.time_span, args.N_target) BS.append(100 * mean) ax.bar([1], [np.array(BS).mean()], yerr=[np.array(BS).std()]) set_plot(ax, xticks=[0, 1.], xticks_labels=['SAS', 'BS'], ylabel='spike pattern \n similarity (%)') fig.savefig('fig.svg') ntwk.show()
def plot_sim(filename, ge, omf_data=None, Umodel_data=None, mf_data=None): ## load file data = ntwk.load_dict_from_hdf5(filename) # ## plot fig, AX = ntwk.activity_plots(data, smooth_population_activity=10, COLORS=COLORS, pop_act_log_scale=True) if Umodel_data is not None: AX[2].plot(Umodel_data['t'], Umodel_data['desired_Vm'], '-', lw=2, color='dimgrey', label='mean-field') if mf_data is None: mf = ntwk.FastMeanField(data, tstop=6., dt=2.5e-3, tau=20e-3) mf.build_TF_func(tf_sim_file='neural_network_dynamics/theory/tf_sim_points.npz') X, mVm, sVm = mf.run_single_connectivity_sim(mf.ecMatrix, verbose=True) t = np.linspace(0, data['tstop'], X.shape[1]) for i, label in enumerate(data['REC_POPS']): AX[-1].plot(t, 1e-2+X[i,:], '--', lw=1, color=COLORS[i]) ge.plot(t, 1e3*mVm[i,:], sy=1e3*sVm[i,:], color='k', lw=1, label='mean-field', ax=AX[2+i]) AX[2+i].plot(t, 1e3*(mVm[i,:]-sVm[i,:]), 'k-', lw=0.5) AX[2+i].plot(t, 1e3*(mVm[i,:]+sVm[i,:]), 'k-', lw=0.5) # AX[2].plot(mf_data['t'], mf_data['desired_Vm'], 'k--', lw=2, label='U-model') # AX[2].legend(frameon=False, loc='best') if omf_data is None: try: omf_data = load_dict(filename.replace('ntwk.h5', 'mf.npz')) except FileNotFoundError: pass if omf_data is not None: t = np.linspace(0, data['tstop'], len(omf_data['pyrExc'])) for i, label in enumerate(data['REC_POPS']): AX[-1].plot(t, 1e-2+omf_data[label], '-', lw=4, color=COLORS[i], alpha=.5) # AX[-1].plot(t, omf_data[label], 'k--') figM, _, _ = plot_matrix(data) ntwk.show()
parser.add_argument('-df', '--data_folder', help='Folder for data', default='sparse_vs_balanced/data/') parser.add_argument("--filename", '-f', help="filename", type=str, default='data.zip') parser.add_argument("-a", "--analyze", help="perform analysis of params space", action="store_true") parser.add_argument("-c", "--compare_regimes", help="perform analysis of params space", action="store_true") args = parser.parse_args() Model = vars(args) if args.analyze: analyze_scan(Model) ntwk.show() elif args.compare_regimes: compare_two_regimes(Model) ntwk.show() else: run_scan(Model)
def analyze_scan(args, smooth=10): PATTERNS, seeds, Model, DATA = get_scan({}, filename=args.filename) fig1, ax1 = plt.subplots(1, figsize=(4, 2.5)) plt.subplots_adjust(bottom=.3, right=.95) fig2, ax2 = plt.subplots(1, figsize=(4, 2.5)) plt.subplots_adjust(bottom=.3, right=.95) COLORS = [Brown, Cyan, Pink, Purple, Pink, Grey, Kaki] # COLORS = [Cyan, Pink, Brown, Purple, Pink, Grey, Kaki] MARKERS = ['o', 'd', 'x'] SIZES = [5, 3, 6] nmax_pre = min([args.Nvis_pre, args.N_aff_stim]) ax1.fill_between([0, args.time_span], [0, 0], [nmax_pre, nmax_pre], color='k', alpha=.1) nmax_post = min([args.Nvis_post, args.N_target]) ax2.fill_between([0, args.time_span], [0, 0], [nmax_post, nmax_post], color='k', alpha=.1) for i, data in enumerate(DATA): ii, j = 0, 0 ## AFFERENT SPIKES cond = (data['tRASTER_PRE_in_terms_of_Pre_Pop'][j]>args.t0-args.pre_window) &\ (data['tRASTER_PRE_in_terms_of_Pre_Pop'][j]<args.t0+args.time_span+args.pre_window) &\ (data['iRASTER_PRE_in_terms_of_Pre_Pop'][j]<nmax_pre) if j == 0: ax1.plot(data['tRASTER_PRE_in_terms_of_Pre_Pop'][j][cond] - args.t0, data['iRASTER_PRE_in_terms_of_Pre_Pop'][j][cond] + ii, MARKERS[i], ms=SIZES[i], color=COLORS[i], label='trial ' + str(i + 1)) else: ax1.plot(data['tRASTER_PRE_in_terms_of_Pre_Pop'][j][cond] - args.t0, data['iRASTER_PRE_in_terms_of_Pre_Pop'][j][cond] + ii, MARKERS[i], ms=SIZES[i], color=COLORS[i]) ## EXCITATORY SPIKES cond = (data['tRASTER_RecExc']>args.t0-args.pre_window) & (data['iRASTER_RecExc']<nmax_post) &\ (data['tRASTER_RecExc']<args.t0+args.time_span+args.pre_window) if j == 0: ax2.plot(data['tRASTER_RecExc'][cond] - args.t0, data['iRASTER_RecExc'][cond] + ii, MARKERS[i], ms=SIZES[i], color=COLORS[i]) else: ax2.plot(data['tRASTER_RecExc'][cond] - args.t0, data['iRASTER_RecExc'][cond] + ii, MARKERS[i], ms=SIZES[i], color=COLORS[i]) ax1.plot((-args.pre_window) * np.ones(2), [0, int(nmax_pre / 4) - 1], 'k-', lw=3) fig1.text(0.05, 0.5, str(int(nmax_pre / 4)) + ' neurons', rotation=90, fontsize=14) ax2.plot((-args.pre_window) * np.ones(2), [0, int(nmax_post / 4) - 1], 'k-', lw=3) fig2.text(0.05, 0.5, str(int(nmax_post / 4)) + ' neurons', rotation=90, fontsize=14) ax1.legend() set_plot(ax1, ['bottom'], xlabel='time from stim. onset (ms)', xlim=[ax1.get_xlim()[0], args.time_span + args.pre_window], yticks=[]) ax1.xaxis.label.set_size(13) set_plot(ax2, ['bottom'], xlabel='time from stim. onset (ms)', xlim=[ax2.get_xlim()[0], args.time_span + args.pre_window], yticks=[]) ax2.xaxis.label.set_size(13) put_list_of_figs_to_svg_fig([fig1, fig2], fig_name=args.filename.replace('.zip', '.svg')) ntwk.show()