def get_sim_3d(match_pars): ''' get simulation object corresponding to (g,eta,inh2_ratio) match_pars is a dictionary, e.g. {'g':5.6,'eta':7.6, 'inh2_ratio':0.5} CAUTION: check order of keys''' #batch_pars ={'pg_rate_exc':ext_rate,'extra_inh':add_inh_rate,'exc2_ratio':exc_range,'inh2_ratio':inh_range } batch_pars = { 'pg_rate_exc': ext_rate, 'pg_rate_inh': add_inh_rate, 'exc2_ratio': exc_range, 'inh2_ratio': inh_range } comb_pars = [[value for (key, value) in zip(batch_pars, values)] for values in itertools.product(*batch_pars.values())] sim_id = -1 keys_sort = batch_pars.keys() match_pars_lis = [match_pars[k] for k in keys_sort] for ii, pars in enumerate(comb_pars): if match_pars_lis == np.array(pars).round(2).tolist(): sim_id = ii #print pars if sim_id > -1: res = adata.analyze_data(prefix0 + '_%d' % sim_id, path1) #print 'sim_id is: ',sim_id return res else: print 'No %s found' % match_pars.keys() return comb_pars, batch_pars.keys()
import matplotlib.cm as cm import plotly.plotly as py from plotly.graph_objs import * import random #prefix1 = 'beta_oscil-2' path1 = '/media/DISK_B/results/basal/' fil_name = 'test' fig = pl.figure(1,(12,8)) ad1 = adata.analyze_data(fil_name,path1) ad1.load_spikes() spikes = ad1.events['spikes'] labelsize = 18. ax1 = fig.add_axes([0.075, 0.075, 0.225,0.375]) stn_spikes = spikes[spikes[:,0] < 1000.] gpe_spikes = spikes[spikes[:,0] > 1000.] stn_spikes_smp = random.sample(np.unique(stn_spikes[:,0]), 100) hh = [] for ii in stn_spikes_smp: hh.append(stn_spikes[stn_spikes[:,0]==ii]) stn_spikes_new = np.array([item for sublist in hh for item in sublist]) gpe_spikes_smp = random.sample(np.unique(gpe_spikes[:,0]), 300) hh = [] for ii in gpe_spikes_smp:
prefix = 'test' pars = dict() pars['model_type'] = 'psdb' pars['add_spikes'] = 0 pars['T_sim'] = 1000. #pars['delay'] = 5.0 #pars['g'] = 9.0 pars['inh2_ratio'] = 0.7 pars['exc2_ratio'] = 0. pars['pg_rate_exc'] = 5000. #3.6 pars['pg_rate_inh'] = 2100. pars['num_spikes_burst_stn'] = 4. pars['num_spikes_burst_gpe'] = 4. pars['add_spikes'] = 0 pars['extra_spk'] = 'inh' pars['st_val'] = 700. pars['num_gen'] = 300 pars['ex_width'] = 8. pars['rnd_seeds'] = 1 pars['change_type'] = 1 pars['num_chg'] = 500 net1 = simd.Simulation(prefix, pars) net1.sim() ad2 = adata.analyze_data(prefix) #pl.figure() ad2.plot_raster(4000)
nr = 0 max_state_var_stn = 4. state_var_stn = 0. state_var_gpe = 0.5 ff = ff_max chk_val = 0 #while ff <= ff_max: while state_var_gpe <= max_spb + 1: #while state_var >= 0: if nr == 0: #pars['add_input'] = -200. net1 = simd.Simulation(prefix, pars) net1.sim() ad1 = adata.analyze_data(prefix) ff = ad1.comp_ff(pop_id='pops_exc', time_range=[200., 1000.]) ff_lis.append(ff) print ff else: #pars['add_input'] = -200. if ff >= ff_max - 3: pars['exc2_ratio'] = 0.8 pars['state_var_stn'] = max_state_var_stn print 'critical point' chk_val += 1 state_var_stn = max_state_var_stn pars['state_var_gpe'] = state_var_gpe net1 = simd.Simulation(prefix, pars) net1.sim() ad1 = adata.analyze_data(prefix)
import sys sys.path.append('/users/padmanabhan/simulations/basal/scripts/common/') import analyze_data_psd as ad reload(ad) results_path = '/media/DISK_B/results/basal/' labelsize = 16 ticksize = 16 col_add = '#A6842A' col_base = '#246742' col_control = '#2358B8' fig = pl.figure(1, figsize=(8, 12)) ax1 = fig.add_axes([0.11, 0.35, 0.4, 0.2]) ad1 = ad.analyze_data('test_add_spikes', results_path) ad1.comp_psth(form='-', plot_fl=1, pop_id='pops_inh', label='Add. spikes outside cycle', color=col_add) ad1 = ad.analyze_data('test_add_spikes-control', results_path) ad1.comp_psth(form='-', plot_fl=1, pop_id='pops_inh', label='Add. spikes within cycle', color=col_control) ad1 = ad.analyze_data('test', results_path) ad1.comp_psth(form='-',
import numpy as np import matplotlib.pyplot as pl import sys sys.path.append('/users/padmanabhan/simulations/basal/scripts/common/') import analyze_data_psd as ad reload(ad) results_path = '/media/DISK_B/results/basal/' labelsize = 14 ticksize = 14 col_base = '#7E89FF' col_add = '#3242FF' col_control = '#3F447F' fig = pl.figure(1, figsize=(8, 8)) ax1 = fig.add_axes([0.09, 0.5, 0.4, 0.3]) ad1 = ad.analyze_data('add_inh_spikes_dest_osc', results_path) ad1.comp_psth(form='-', plot_fl=1, pop_id='pops_inh', label='Add. spikes outside cycle', color=col_add) ad1 = ad.analyze_data('add_inh_spikes_dest_osc-control', results_path) ad1.comp_psth(form='-', plot_fl=1, pop_id='pops_inh', label='Add. spikes within cycle', color=col_control) ad1 = ad.analyze_data('test', results_path) ad1.comp_psth(form='-',