def main(gid, pop_name, config_file, template_paths, hoc_lib_path, dataset_prefix, config_prefix, mech_file, load_edges, load_weights, correct_for_spines, verbose): """ :param gid: int :param pop_name: str :param config_file: str; model configuration file name :param template_paths: str; colon-separated list of paths to directories containing hoc cell templates :param hoc_lib_path: str; path to directory containing required hoc libraries :param dataset_prefix: str; path to directory containing required neuroh5 data files :param config_prefix: str; path to directory containing network and cell mechanism config files :param mech_file: str; cell mechanism config file name :param load_edges: bool; whether to attempt to load connections from a neuroh5 file :param load_weights: bool; whether to attempt to load connections from a neuroh5 file :param correct_for_spines: bool :param verbose: bool """ utils.config_logging(verbose) logger = utils.get_script_logger(os.path.basename(__file__)) comm = MPI.COMM_WORLD np.seterr(all='raise') env = Env(comm=comm, config_file=config_file, template_paths=template_paths, hoc_lib_path=hoc_lib_path, dataset_prefix=dataset_prefix, config_prefix=config_prefix, verbose=verbose) configure_hoc_env(env) mech_file_path = config_prefix + '/' + mech_file template_name = env.celltypes[pop_name]['template'] if template_name.lower() == 'izhikevich': cell = make_izhikevich_cell(env, pop_name=pop_name, gid=gid, load_synapses=True, load_connections=True, load_edges=load_edges, load_weights=load_weights, mech_file_path=mech_file_path) elif template_name.lower() == 'pr_nrn': cell = make_PR_cell(env, pop_name=pop_name, gid=gid, load_synapses=True, load_connections=True, load_edges=load_edges, load_weights=load_weights, mech_file_path=mech_file_path) else: cell = make_biophys_cell(env, pop_name=pop_name, gid=gid, load_synapses=True, load_connections=True, load_edges=load_edges, load_weights=load_weights, mech_file_path=mech_file_path) context.update(locals()) init_biophysics(cell, reset_cable=True, correct_cm=correct_for_spines, correct_g_pas=correct_for_spines, env=env, verbose=verbose) init_syn_mech_attrs(cell, env) config_biophys_cell_syns(env, gid, pop_name, insert=True, insert_netcons=True, insert_vecstims=True, verbose=verbose) if verbose: for sec in list(cell.hoc_cell.all if hasattr(cell, 'hoc_cell') else cell.all): h.psection(sec=sec) report_topology(cell, env)
def main(gid, pop_name, config_file, template_paths, hoc_lib_path, dataset_prefix, config_prefix, mech_file, load_edges, load_weights, correct_for_spines, verbose): """ :param gid: int :param pop_name: str :param config_file: str; model configuration file name :param template_paths: str; colon-separated list of paths to directories containing hoc cell templates :param hoc_lib_path: str; path to directory containing required hoc libraries :param dataset_prefix: str; path to directory containing required neuroh5 data files :param config_prefix: str; path to directory containing network and cell mechanism config files :param mech_file: str; cell mechanism config file name :param load_edges: bool; whether to attempt to load connections from a neuroh5 file :param load_weights: bool; whether to attempt to load connections from a neuroh5 file :param correct_for_spines: bool :param verbose: bool """ comm = MPI.COMM_WORLD np.seterr(all='raise') env = Env(comm=comm, config_file=config_file, template_paths=template_paths, hoc_lib_path=hoc_lib_path, dataset_prefix=dataset_prefix, config_prefix=config_prefix, verbose=verbose) configure_hoc_env(env) mech_file_path = config_prefix + '/' + mech_file cell = get_biophys_cell(env, pop_name=pop_name, gid=gid, load_edges=load_edges, load_weights=load_weights, mech_file_path=mech_file_path) context.update(locals()) init_biophysics(cell, reset_cable=True, correct_cm=correct_for_spines, correct_g_pas=correct_for_spines, env=env, verbose=verbose) init_syn_mech_attrs(cell, env) config_biophys_cell_syns(env, gid, pop_name, insert=True, insert_netcons=True, insert_vecstims=True, verbose=verbose) if verbose: report_topology(cell, env)
def synapse_test(template_class, gid, tree, synapses_dict, connections, v_init, env, unique=True): postsyn_name = 'HCC' presyn_names = ['MPP', 'LPP', 'GC', 'MC', 'HCC', 'IS', 'NGFC', 'MOPP'] cell = network_clamp.load_cell(env, postsyn_name, gid, \ tree_dict=tree, synapses_dict=synapses_dict, connections=connections, \ correct_for_spines=True, load_connections=False) cells.register_cell(env, postsyn_name, gid, cell) cells.report_topology(cell, env) syn_attrs = env.synapse_attributes syn_count, nc_count = synapses.config_biophys_cell_syns(env, gid, postsyn_name, unique=unique, \ insert=True, insert_netcons=False) for presyn_name in presyn_names: syn_params_dict = env.connection_config[postsyn_name][presyn_name].mechanisms syn_filters = synapses.get_syn_filter_dict(env, {'sources': [presyn_name]}, convert=True) syn_obj_dict = syn_attrs.filter_synapses(gid, **syn_filters) v_holding = -60 synapse_group_test(env, presyn_name, gid, cell, syn_obj_dict, syn_params_dict, 1, v_holding, v_init) synapse_group_test(env, presyn_name, gid, cell, syn_obj_dict, syn_params_dict, 10, v_holding, v_init) synapse_group_test(env, presyn_name, gid, cell, syn_obj_dict, syn_params_dict, 100, v_holding, v_init) rate = 20 synapse_group_rate_test(env, presyn_name, gid, cell, syn_obj_dict, syn_params_dict, 1, rate) synapse_group_rate_test(env, presyn_name, gid, cell, syn_obj_dict, syn_params_dict, 10, rate) synapse_group_rate_test(env, presyn_name, gid, cell, syn_obj_dict, syn_params_dict, 20, rate) synapse_group_rate_test(env, presyn_name, gid, cell, syn_obj_dict, syn_params_dict, 50, rate) synapse_group_rate_test(env, presyn_name, gid, cell, syn_obj_dict, syn_params_dict, 100, rate) synapse_group_rate_test(env, presyn_name, gid, cell, syn_obj_dict, syn_params_dict, 250, rate)
def measure_psp(gid, pop_name, presyn_name, syn_mech_name, swc_type, env, v_init, erev, syn_layer=None, weight=1, syn_count=1, load_weights=False, cell_dict={}): biophys_cell = init_biophys_cell(env, pop_name, gid, register_cell=False, load_weights=load_weights, cell_dict=cell_dict) synapses.config_biophys_cell_syns(env, gid, pop_name, insert=True, insert_netcons=True, insert_vecstims=True) hoc_cell = biophys_cell.hoc_cell h.dt = env.dt prelength = 200.0 mainlength = 50.0 rules = {'sources': [presyn_name]} if swc_type is not None: rules['swc_types'] = [swc_type] if syn_layer is not None: rules['layers'] = [syn_layer] syn_attrs = env.synapse_attributes syn_filters = get_syn_filter_dict(env, rules=rules, convert=True) syns = syn_attrs.filter_synapses(biophys_cell.gid, **syn_filters) print("total number of %s %s synapses: %d" % (presyn_name, swc_type if swc_type is not None else "", len(syns))) stimvec = h.Vector() stimvec.append(prelength + 1.) count = 0 target_syn_pps = None for target_syn_id, target_syn in iter(syns.items()): target_syn_pps = syn_attrs.get_pps(gid, target_syn_id, syn_mech_name) target_syn_nc = syn_attrs.get_netcon(gid, target_syn_id, syn_mech_name) target_syn_nc.weight[0] = weight setattr(target_syn_pps, 'e', erev) vs = target_syn_nc.pre() vs.play(stimvec) if syn_count <= count: break count += 1 if target_syn_pps is None: raise RuntimeError( "measure_psp: Unable to find %s %s synaptic point process" % (presyn_name, swc_type)) sec = target_syn_pps.get_segment().sec v_rec = make_rec('psp', pop_name, gid, biophys_cell.hoc_cell, sec=sec, dt=env.dt, loc=0.5, param='v') h.tstop = mainlength + prelength h('objref nil, tlog, ilog') h.tlog = h.Vector() h.tlog.record(h._ref_t) h.ilog = h.Vector() h.ilog.record(target_syn_pps._ref_i) neuron_utils.simulate(v_init, prelength, mainlength) vec_v = np.asarray(v_rec['vec'].to_python()) vec_i = np.asarray(h.ilog.to_python()) vec_t = np.asarray(h.tlog.to_python()) idx = np.where(vec_t >= prelength)[0] vec_v = vec_v[idx][1:] vec_t = vec_t[idx][1:] vec_i = vec_i[idx][1:] i_peak_index = np.argmax(np.abs(vec_i)) i_peak = vec_i[i_peak_index] v_peak = vec_v[i_peak_index] amp_v = abs(v_peak - vec_v[0]) amp_i = abs(i_peak - vec_i[0]) print("measure_psp: v0 = %f v_peak = %f (at t %f)" % (vec_v[0], v_peak, vec_t[i_peak_index])) print("measure_psp: i_peak = %f (at t %f)" % (i_peak, vec_t[i_peak_index])) print("measure_psp: amp_v = %f amp_i = %f" % (amp_v, amp_i)) results = { '%s %s PSP' % (presyn_name, syn_mech_name): np.asarray([amp_v], dtype=np.float32), '%s %s PSP i' % (presyn_name, syn_mech_name): np.asarray(vec_i, dtype=np.float32), '%s %s PSP v' % (presyn_name, syn_mech_name): np.asarray(vec_v, dtype=np.float32), '%s %s PSP t' % (presyn_name, syn_mech_name): np.asarray(vec_t, dtype=np.float32) } env.synapse_attributes.del_syn_id_attr_dict(gid) if gid in env.biophys_cells[pop_name]: del env.biophys_cells[pop_name][gid] return results