def synapse_group_test(env, presyn_name, gid, cell, syn_ids, syn_mech_dict, group_size, v_init, tstart=200.): syn_attrs = env.synapse_attributes vv = h.Vector() vv.append(0, 0, 0, 0, 0, 0) ranstream = np.random.RandomState(0) if len(syn_ids) == 0: return selected = ranstream.choice(np.arange(0, len(syn_ids)), size=group_size, replace=False) selected_ids = [syn_ids[i] for i in selected] for syn_name in syn_mech_dict: nclst = [] print('synapse_group_test: %s %s synapses: %i out of %i' % (presyn_name, syn_name, len(selected_ids), len(syn_ids))) ns = h.NetStim() ns.interval = 1000 ns.number = 1 ns.start = 200 ns.noise = 0 nclst = [] first_syn_id = None for syn_id in selected_ids: if syn_attrs.has_netcon(gid, syn_id, syn_name): syn_index = syn_attrs.syn_name_index_dict[syn_name] del (syn_attrs.pps_dict[gid][syn_id].netcon[syn_index]) syn = syn_attrs.get_pps(gid, syn_id, syn_name) this_nc = h.NetCon(ns, syn) syn_attrs.add_netcon(gid, syn_id, syn_name, this_nc) synapses.config_syn(syn_name=syn_name, rules=syn_attrs.syn_param_rules, mech_names=syn_attrs.syn_mech_names, nc=this_nc, **syn_mech_dict[syn_name]) nclst.append(this_nc) if first_syn_id is None: first_syn_id = syn_id print("%s netcon: %s" % (syn_name, str([ this_nc.weight[i] for i in range(int(this_nc.wcnt())) ]))) for sec in list(cell.all): h.psection(sec=sec) v_holding_exc = -75 v_holding_inh = -45 if syn_name in ['NMDA', 'SatAMPA', 'AMPA']: v_holding = v_holding_exc v = cell.syntest_exc( tstart, v_holding, v_init, "MossyCell_%s_%s_synapse_trace_%i.dat" % (presyn_name, syn_name, group_size)) elif syn_name in [ 'SatGABA', 'GABA', 'SatGABA_A', 'GABA_A', 'SatGABA_B', 'GABA_B' ]: v_holding = v_holding_inh v = cell.syntest_inh( tstart, v_holding, v_init, "MossyCell_%s_%s_synapse_trace_%i.dat" % (presyn_name, syn_name, group_size)) else: raise RuntimeError('Unknown synapse mechanism type %s' % syn_name) vv = vv.add(v) amp = vv.x[0] t_10_90 = vv.x[1] t_20_80 = vv.x[2] t_all = vv.x[3] t_50 = vv.x[4] t_decay = vv.x[5] f = open( "MossyCell_%s_%s_synapse_results_%i.dat" % (presyn_name, syn_name, group_size), 'w') f.write("%s synapses: \n" % syn_name) f.write(" Amplitude %f\n" % amp) f.write(" 10-90 Rise Time %f\n" % t_10_90) f.write(" 20-80 Rise Time %f\n" % t_20_80) f.write(" Decay Time Constant %f\n" % t_decay) f.close()
def synapse_group_rate_test(env, presyn_name, gid, cell, syn_obj_dict, syn_params_dict, group_size, rate, tstart=200.): syn_attrs = env.synapse_attributes ranstream = np.random.RandomState(0) syn_ids = list(syn_obj_dict.keys()) if group_size > len(syn_ids): return selected = ranstream.choice(np.arange(0, len(syn_ids)), size=group_size, replace=False) selected_ids = [syn_ids[i] for i in selected] for section_name, sec_syn_params_dict in utils.viewitems(syn_params_dict): for syn_name in sec_syn_params_dict: synlst = [] for syn_id in selected_ids: synlst.append(syn_attrs.get_pps(gid, syn_id, syn_name)) print('synapse_group_rate_test: %s %s synapses: %i out of %i ' % (presyn_name, syn_name, len(synlst), len(syn_ids))) ns = h.NetStim() ns.interval = 1000. / rate ns.number = rate ns.start = 200 ns.noise = 0 nclst = [] for syn_id, syn in zip(selected_ids, synlst): syn_attrs.del_netcon(gid, syn_id, syn_name, throw_error=False) this_nc = h.NetCon(ns, syn) syn_attrs.add_netcon(gid, syn_id, syn_name, this_nc) synapses.config_syn(syn_name=syn_name, rules=syn_attrs.syn_param_rules, mech_names=syn_attrs.syn_mech_names, nc=this_nc, **sec_syn_params_dict[syn_name]) nclst.append(this_nc) if syn_name == 'SatAMPA': v_init = -65 elif syn_name == 'AMPA': v_init = -65 elif syn_name == 'SatGABA': v_init = 0 elif syn_name == 'GABA': v_init = 0 elif syn_name == 'SatGABA_A': v_init = 0 elif syn_name == 'GABA_A': v_init = 0 elif syn_name == 'SatGABA_B': v_init = 0 elif syn_name == 'GABA_B': v_init = 0 else: raise RuntimeError('Unknown synapse mechanism type %s' % syn_name) hoc_cell = cell.hoc_cell res = hoc_cell.syntest_rate(tstart, rate, v_init) tlog = res.o(0) vlog = res.o(1) f = open( "HIPPCell_%s_%s_synapse_rate_%i.dat" % (presyn_name, syn_name, group_size), 'w') for i in range(0, int(tlog.size())): f.write('%g %g\n' % (tlog.x[i], vlog.x[i])) f.close()
def synapse_group_rate_test(env, presyn_name, gid, cell, syn_ids, syn_mech_dict, group_size, rate, tstart=200.): syn_attrs = env.synapse_attributes syn_attrs = env.synapse_attributes ranstream = np.random.RandomState(0) if len(syn_ids) == 0: return selected = ranstream.choice(np.arange(0, len(syn_ids)), size=group_size, replace=False) selected_ids = [syn_ids[i] for i in selected] for syn_name in syn_mech_dict: print('synapse_group_rate_test: %s %s synapses: %i out of %i ' % (presyn_name, syn_name, len(selected_ids), len(syn_ids))) ns = h.NetStim() ns.interval = 1000. / rate ns.number = rate ns.start = 200 ns.noise = 0 nclst = [] first_syn_id = None for syn_id in selected_ids: for syn_name in syn_mech_dict: if syn_attrs.has_netcon(gid, syn_id, syn_name): syn_index = syn_attrs.syn_name_index_dict[syn_name] del (syn_attrs.pps_dict[gid][syn_id].netcon[syn_index]) syn = syn_attrs.get_pps(gid, syn_id, syn_name) this_nc = h.NetCon(ns, syn) syn_attrs.add_netcon(gid, syn_id, syn_name, this_nc) synapses.config_syn(syn_name=syn_name, rules=syn_attrs.syn_param_rules, mech_names=syn_attrs.syn_mech_names, nc=this_nc, **syn_mech_dict[syn_name]) nclst.append(this_nc) if first_syn_id is None: print("%s netcon: %s" % (syn_name, str([ this_nc.weight[i] for i in range(int(this_nc.wcnt())) ]))) if first_syn_id is None: first_syn_id = syn_id for sec in list(cell.all): h.psection(sec=sec) print('synapse_group_rate_test: %s %s synapses: %i netcons ' % (presyn_name, syn_name, len(nclst))) v_init_exc = -75 v_init_inh = 0 if syn_name in ['NMDA', 'SatAMPA', 'AMPA']: v_init = v_init_exc elif syn_name in [ 'SatGABA', 'GABA', 'SatGABA_A', 'GABA_A', 'SatGABA_B', 'GABA_B' ]: v_init = v_init_inh else: raise RuntimeError('Unknown synapse mechanism type %s' % syn_name) res = cell.syntest_rate(tstart, rate, v_init) tlog = res.o(0) vlog = res.o(1) f = open( "MossyCell_%s_%s_synapse_rate_%i.dat" % (presyn_name, syn_name, group_size), 'w') for i in range(0, int(tlog.size())): f.write('%g %g\n' % (tlog.x[i], vlog.x[i])) f.close()
def synapse_group_test(env, presyn_name, gid, cell, syn_obj_dict, syn_params_dict, group_size, v_holding, v_init, tstart=200.): syn_attrs = env.synapse_attributes vv = h.Vector() vv.append(0, 0, 0, 0, 0, 0) ranstream = np.random.RandomState(0) syn_ids = list(syn_obj_dict.keys()) if group_size > len(syn_ids): print( "synapse_group_test: gid %d: group size %d is greater than number of synapses %d" % (gid, group_size, len(syn_ids))) return selected = ranstream.choice(np.arange(0, len(syn_ids)), size=group_size, replace=False) selected_ids = [syn_ids[i] for i in selected] for section_name, sec_syn_params_dict in utils.viewitems(syn_params_dict): for syn_name in sec_syn_params_dict: synlst = [] for syn_id in selected_ids: synlst.append(syn_attrs.get_pps(gid, syn_id, syn_name)) print('synapse_group_test: %s %s synapses: %i out of %i' % (presyn_name, syn_name, len(synlst), len(syn_ids))) ns = h.NetStim() ns.interval = 1000 ns.number = 1 ns.start = 200 ns.noise = 0 nclst = [] for syn_id, syn in zip(selected_ids, synlst): syn_attrs.del_netcon(gid, syn_id, syn_name, throw_error=False) this_nc = h.NetCon(ns, syn) syn_attrs.add_netcon(gid, syn_id, syn_name, this_nc) synapses.config_syn(syn_name=syn_name, rules=syn_attrs.syn_param_rules, mech_names=syn_attrs.syn_mech_names, nc=this_nc, **sec_syn_params_dict[syn_name]) nclst.append(this_nc) hoc_cell = cell.hoc_cell if syn_name == 'SatAMPA': v = hoc_cell.syntest_exc( tstart, v_holding, v_init, "HIPPCell_%s_%s_synapse_trace_%i.dat" % (presyn_name, syn_name, group_size)) elif syn_name == 'AMPA': v = hoc_cell.syntest_exc( tstart, v_holding, v_init, "HIPPCell_%s_%s_synapse_trace_%i.dat" % (presyn_name, syn_name, group_size)) elif syn_name == 'SatGABA': v = hoc_cell.syntest_inh( tstart, v_holding, v_init, "HIPPCell_%s_%s_synapse_trace_%i.dat" % (presyn_name, syn_name, group_size)) elif syn_name == 'GABA': v = hoc_cell.syntest_inh( tstart, v_holding, v_init, "HIPPCell_%s_%s_synapse_trace_%i.dat" % (presyn_name, syn_name, group_size)) elif syn_name == 'SatGABA_A': v = hoc_cell.syntest_inh( tstart, v_holding, v_init, "HIPPCell_%s_%s_synapse_trace_%i.dat" % (presyn_name, syn_name, group_size)) elif syn_name == 'GABA_A': v = hoc_cell.syntest_inh( tstart, v_holding, v_init, "HIPPCell_%s_%s_synapse_trace_%i.dat" % (presyn_name, syn_name, group_size)) elif syn_name == 'SatGABA_B': v = hoc_cell.syntest_inh( tstart, v_holding, v_init, "HIPPCell_%s_%s_synapse_trace_%i.dat" % (presyn_name, syn_name, group_size)) elif syn_name == 'GABA_B': v = hoc_cell.syntest_inh( tstart, v_holding, v_init, "HIPPCell_%s_%s_synapse_trace_%i.dat" % (presyn_name, syn_name, group_size)) else: raise RuntimeError('Unknown synapse mechanism type %s' % syn_name) vv = vv.add(v) amp = vv.x[0] t_10_90 = vv.x[1] t_20_80 = vv.x[2] t_all = vv.x[3] t_50 = vv.x[4] t_decay = vv.x[5] f = open( "HIPPCell_%s_%s_synapse_results_%i.dat" % (presyn_name, syn_name, group_size), 'w') f.write("%s synapses: \n" % syn_name) f.write(" Amplitude %f\n" % amp) f.write(" 10-90 Rise Time %f\n" % t_10_90) f.write(" 20-80 Rise Time %f\n" % t_20_80) f.write(" Decay Time Constant %f\n" % t_decay) f.close()