def get_volts(mtype, etype, param_ind, nsamples): all_volts = [] my_model = get_model('BBP', log, m_type=mtype, e_type=etype, cell_i=0) param_set = make_paramset(my_model, param_ind, nsamples) #param_name = my_model.PARAM_NAMES[param_ind] for i in range(nsamples): params = param_set[i] my_model = get_model('BBP', log, mtype, etype, 0, *params) my_model.DEFAULT_PARAMS = False volts = my_model.simulate(stim, 0.02) all_volts.append(volts) return all_volts
def main(): NTHREADS = 128 m_type = sys.argv[1] e_type = sys.argv[2] nsamples = int(sys.argv[3]) try: procid = int(os.environ['SLURM_PROCID']) print("in cori") except: print("not in cori") procid = 0 my_model = get_model('BBP', log, m_type=m_type, e_type=e_type, cell_i=1) def_vals = my_model.DEFAULT_PARAMS pnames = [ my_model.PARAM_NAMES[i] for i in range(len(def_vals)) if def_vals[i] > 0 ] threads_per_param = int(NTHREADS / len(pnames)) samples_per_thread = int(nsamples / threads_per_param) + 1 p_ind = procid % (len(pnames)) adjusted_param = my_model.PARAM_NAMES[p_ind] print("working on " + adjusted_param + "will be sampled " + str(samples_per_thread * threads_per_param)) all_volts = get_volts(m_type, e_type, p_ind, samples_per_thread) pkl_fn = m_type + '_' + e_type + adjusted_param + '_' + str( procid) + '.pkl' with open(pkl_fn, 'wb') as output: pkl.dump(all_volts, output)
def get_volts(mtype, etype, param_ind, nsamples): all_volts = [] my_model = get_model('BBP', log, m_type=mtype, e_type=etype, cell_i=1) param_set = make_paramset(my_model, param_ind, nsamples) #param_name = my_model.PARAM_NAMES[param_ind] for i in range(nsamples): s_time = time.time() print("working on param_ind" + str(param_ind) + " sample" + str(i)) params = param_set[i] my_model = get_model('BBP', log, mtype, etype, 1, *params) my_model.DEFAULT_PARAMS = False volts = my_model.simulate(stim, 0.025) all_volts.append(volts) end_time = time.time() etime = end_time - s_time print("done param_ind" + str(param_ind) + " sample" + str(i) + str(etime)) return all_volts
def main(m_type,e_type): nsamples = 2 try: procid = int(os.environ['SLURM_PROCID']) print("in cori") nsamples = 20 except: print("not in cori") procid = 0 nsamples = 2 my_model = get_model('BBP',log,m_type=m_type,e_type=e_type,cell_i=1) adjusted_param = my_model.PARAM_NAMES[procid] print("working on " + adjusted_param) all_volts = get_volts(m_type,e_type,procid,nsamples) pkl_fn=m_type + e_type + adjusted_param +'.pkl' with open(pkl_fn, 'wb') as output: pkl.dump(all_volts,output)
def main(): short_name = None m_type = sys.argv[1] e_type = sys.argv[2] try: short_name = sys.argv[3] except: print('no short name') short_name = None files_loc = './output/' + m_type + '_' + e_type + '/' my_model = get_model('BBP', log, m_type=m_type, e_type=e_type, cell_i=0) def_vals = my_model.DEFAULT_PARAMS ECDS = test_sensitivity(files_loc, my_model) #if short_name is not None: if short_name is not None: ml_results = get_ml_results(short_name, list(ECDS.keys())) analyze_ecds(ECDS, def_vals, files_loc, ml_results) else: analyze_ecds_no_ML(ECDS, def_vals, files_loc)
def test_sensitivity(mtype, etype): my_model = get_model('BBP', log, m_type=mtype, e_type=etype, cell_i=0) def_volts = my_model.simulate(stim, 0.02) param_names = my_model.PARAM_NAMES all_ECDS = {} for i in range(len(param_names)): adjusted_param = my_model.PARAM_NAMES[i] all_volts = get_volts(mtype, etype, i, 5) curr_errs = check_param_sensitivity(all_volts, def_volts, adjusted_param) curr_ECDs = [ls[-1] for ls in curr_errs] all_ECDS[adjusted_param] = curr_ECDs pkl_fn = mtype + etype + adjusted_param + '.pkl' with open(pkl_fn, 'wb') as output: pkl.dump(def_volts, output) pkl.dump(all_volts, output) pkl_fn = mtype + etype + 'sensitivity.pkl' with open(pkl_fn, 'wb') as output: pkl.dump(all_ECDS, output) pkl.dump(param_names)
import logging as log from neuron import h from run import get_model from get_rec_points import get_rec_points import sys # model = get_model('BBP', log, 'L4_BTC', 'cNAC', 0) m_type = sys.argv[1] e_type = sys.argv[2] model = get_model('BBP', log, m_type, e_type, 0) x = get_rec_points(model.entire_cell) y = get_rec_points(model.entire_cell) print("First time: {}".format(x)) print("Second time: {}".format(y)) print("First time: {} rec points".format(len(x))) print("Second time: {} rec points".format(len(y))) h("segcount=0") h('forall {segcount+=1}') print("total number of segments") h("print segcount")
ax_dend.axhline(threshold_dend, color='red') ax_dend.grid() ax_soma.grid() ax_soma.title.set_text('Somatic Parameters') means_soma = np.clip(means_soma, 0, ymx_soma) STDs_soma = np.clip(STDs_soma, 0, ymx_soma / 2) ax_soma.errorbar(range(len(pnames_soma)), means_soma, STDs_soma, linestyle='None', marker='s') ax_soma.set_xticks(range(len(pnames_soma))) ax_soma.set_xticklabels(pnames_soma) ax_soma.axhline(threshold_soma, color='red') fig_name = mtype + etype + str(nsamples) + 'Analysis.pdf' fig.savefig(fig_name) plt.show() return params_sensitivity_dict nsamples = 50 mtype = 'L1_DAC' etype = 'bNAC' my_model = get_model('BBP', log, m_type=mtype, e_type=etype, cell_i=1) #def_volts = my_model.simulate(stim,0.02) def_volts = None def_vals = my_model.DEFAULT_PARAMS ECDS = test_sensitivity(mtype, etype, def_volts, nsamples) analyze_ecds(ECDS, def_vals)
def get_cur(): user = raw_input('Please input user_name: ') database = raw_input('Please input a name of the database: ') table_name = raw_input('Please input a name of the data table: ') return get_model(user, database, table_name)