def create_neuron_to_muscle_syn(self): self.neuron_to_muscle_exc_syn = GradedSynapse( id="neuron_to_muscle_exc_syn", conductance=self.get_bioparameter( "neuron_to_muscle_exc_syn_conductance").value, delta=self.get_bioparameter( "neuron_to_muscle_exc_syn_delta").value, Vth=self.get_bioparameter("neuron_to_muscle_exc_syn_vth").value, erev=self.get_bioparameter("neuron_to_muscle_exc_syn_erev").value, k=self.get_bioparameter("neuron_to_muscle_exc_syn_k").value) self.neuron_to_muscle_inh_syn = GradedSynapse( id="neuron_to_muscle_inh_syn", conductance=self.get_bioparameter( "neuron_to_muscle_inh_syn_conductance").value, delta=self.get_bioparameter( "neuron_to_muscle_inh_syn_delta").value, Vth=self.get_bioparameter("neuron_to_muscle_inh_syn_vth").value, erev=self.get_bioparameter("neuron_to_muscle_inh_syn_erev").value, k=self.get_bioparameter("neuron_to_muscle_inh_syn_k").value) self.neuron_to_muscle_elec_syn = GapJunction( id="neuron_to_muscle_elec_syn", conductance=self.get_bioparameter( "neuron_to_muscle_elec_syn_gbase").value)
def create_models(self): self.generic_cell = IafActivityCell( id="generic_iaf_cell", C=self.get_bioparameter("iaf_C").value, thresh=self.get_bioparameter("iaf_thresh").value, reset=self.get_bioparameter("iaf_reset").value, leak_conductance=self.get_bioparameter("iaf_conductance").value, leak_reversal=self.get_bioparameter("iaf_leak_reversal").value, tau1=self.get_bioparameter("iaf_tau1").value) self.exc_syn = GradedSynapse( id="exc_syn", conductance=self.get_bioparameter("exc_syn_conductance").value, delta=self.get_bioparameter("exc_syn_delta").value, Vth=self.get_bioparameter("exc_syn_vth").value, erev=self.get_bioparameter("exc_syn_erev").value, k=self.get_bioparameter("exc_syn_k").value) self.inh_syn = GradedSynapse( id="inh_syn", conductance=self.get_bioparameter("inh_syn_conductance").value, delta=self.get_bioparameter("inh_syn_delta").value, Vth=self.get_bioparameter("inh_syn_vth").value, erev=self.get_bioparameter("inh_syn_erev").value, k=self.get_bioparameter("inh_syn_k").value) self.elec_syn = GapJunction( id="elec_syn", conductance=self.get_bioparameter("elec_syn_gbase").value) self.offset_current = PulseGenerator( id="offset_current", delay=self.get_bioparameter( "unphysiological_offset_current_del").value, duration=self.get_bioparameter( "unphysiological_offset_current_dur").value, amplitude=self.get_bioparameter( "unphysiological_offset_current").value)
def get_inh_syn(self, pre_cell, post_cell, type): self.found_specific_param = False specific_param_template = '%s_to_%s_inh_syn_%s' if type == 'neuron_to_neuron': conductance = self.get_conn_param(pre_cell, post_cell, specific_param_template, 'neuron_to_neuron_inh_syn_%s', 'conductance') erev = self.get_conn_param(pre_cell, post_cell, specific_param_template, 'inh_syn_%s', 'erev') delta = self.get_conn_param(pre_cell, post_cell, specific_param_template, 'inh_syn_%s', 'delta') vth = self.get_conn_param(pre_cell, post_cell, specific_param_template, 'inh_syn_%s', 'vth') k = self.get_conn_param(pre_cell, post_cell, specific_param_template, 'inh_syn_%s', 'k') conn_id = 'neuron_to_neuron_inh_syn' elif type == 'neuron_to_muscle': conductance = self.get_conn_param(pre_cell, post_cell, specific_param_template, 'neuron_to_muscle_inh_syn_%s', 'conductance') erev = self.get_conn_param(pre_cell, post_cell, specific_param_template, 'inh_syn_%s', 'erev') delta = self.get_conn_param(pre_cell, post_cell, specific_param_template, 'inh_syn_%s', 'delta') vth = self.get_conn_param(pre_cell, post_cell, specific_param_template, 'inh_syn_%s', 'vth') k = self.get_conn_param(pre_cell, post_cell, specific_param_template, 'inh_syn_%s', 'k') conn_id = 'neuron_to_muscle_inh_syn' if self.found_specific_param: conn_id = '%s_to_%s_inh_syn' % (pre_cell, post_cell) return GradedSynapse(id=conn_id, conductance=conductance, delta=delta, Vth=vth, erev=erev, k=k)
def create_n_connection_synapse(prototype_syn, n, nml_doc, existing_synapses): new_id = "%s_%sconns" % (prototype_syn.id, str(n).replace('.', '_')) if isinstance(prototype_syn, ExpTwoSynapse): new_id = "%s" % (prototype_syn.id) if not existing_synapses.has_key(new_id): if isinstance(prototype_syn, ExpTwoSynapse): new_syn = ExpTwoSynapse(id=new_id, gbase=prototype_syn.gbase, erev=prototype_syn.erev, tau_decay=prototype_syn.tau_decay, tau_rise=prototype_syn.tau_rise) existing_synapses[new_id] = new_syn nml_doc.exp_two_synapses.append(new_syn) elif isinstance(prototype_syn, GapJunction): magnitude, unit = bioparameters.split_neuroml_quantity( prototype_syn.conductance) new_syn = GapJunction(id=new_id, conductance="%s%s" % (magnitude * n, unit)) existing_synapses[new_id] = new_syn nml_doc.gap_junctions.append(new_syn) elif isinstance(prototype_syn, GradedSynapse): magnitude, unit = bioparameters.split_neuroml_quantity( prototype_syn.conductance) new_syn = GradedSynapse(id=new_id, conductance="%s%s" % (magnitude * n, unit), delta=prototype_syn.delta, Vth=prototype_syn.Vth, erev=prototype_syn.erev, k=prototype_syn.k) existing_synapses[new_id] = new_syn nml_doc.graded_synapses.append(new_syn) else: new_syn = existing_synapses[new_id] return new_syn
def create_models(self): self.generic_cell = Cell(id = "GenericCell") morphology = Morphology() morphology.id = "morphology_"+self.generic_cell.id self.generic_cell.morphology = morphology prox_point = Point3DWithDiam(x="0", y="0", z="0", diameter=self.get_bioparameter("cell_diameter").value) dist_point = Point3DWithDiam(x="0", y="0", z=self.get_bioparameter("cell_length").value, diameter=self.get_bioparameter("cell_diameter").value) segment = Segment(id="0", name="soma", proximal = prox_point, distal = dist_point) morphology.segments.append(segment) self.generic_cell.biophysical_properties = BiophysicalProperties(id="biophys_"+self.generic_cell.id) mp = MembraneProperties() self.generic_cell.biophysical_properties.membrane_properties = mp mp.init_memb_potentials.append(InitMembPotential(value=self.get_bioparameter("initial_memb_pot").value)) mp.specific_capacitances.append(SpecificCapacitance(value=self.get_bioparameter("specific_capacitance").value)) mp.spike_threshes.append(SpikeThresh(value=self.get_bioparameter("spike_thresh").value)) mp.channel_densities.append(ChannelDensity(cond_density=self.get_bioparameter("leak_cond_density").value, id="Leak_all", ion_channel="Leak", erev=self.get_bioparameter("leak_erev").value, ion="non_specific")) mp.channel_densities.append(ChannelDensity(cond_density=self.get_bioparameter("k_slow_cond_density").value, id="k_slow_all", ion_channel="k_slow", erev=self.get_bioparameter("k_slow_erev").value, ion="k")) mp.channel_densities.append(ChannelDensity(cond_density=self.get_bioparameter("k_fast_cond_density").value, id="k_fast_all", ion_channel="k_fast", erev=self.get_bioparameter("k_fast_erev").value, ion="k")) mp.channel_densities.append(ChannelDensity(cond_density=self.get_bioparameter("ca_boyle_cond_density").value, id="ca_boyle_all", ion_channel="ca_boyle", erev=self.get_bioparameter("ca_boyle_erev").value, ion="ca")) ip = IntracellularProperties() self.generic_cell.biophysical_properties.intracellular_properties = ip # NOTE: resistivity/axial resistance not used for single compartment cell models, so value irrelevant! ip.resistivities.append(Resistivity(value="0.1 kohm_cm")) # NOTE: Ca reversal potential not calculated by Nernst, so initial_ext_concentration value irrelevant! species = Species(id="ca", ion="ca", concentration_model="CaPool", initial_concentration="0 mM", initial_ext_concentration="2E-6 mol_per_cm3") ip.species.append(species) self.exc_syn = GradedSynapse(id="exc_syn", conductance = self.get_bioparameter("exc_syn_conductance").value, delta = self.get_bioparameter("exc_syn_delta").value, Vth = self.get_bioparameter("exc_syn_vth").value, erev = self.get_bioparameter("exc_syn_erev").value, k = self.get_bioparameter("exc_syn_k").value) self.inh_syn = GradedSynapse(id="inh_syn", conductance = self.get_bioparameter("inh_syn_conductance").value, delta = self.get_bioparameter("inh_syn_delta").value, Vth = self.get_bioparameter("inh_syn_vth").value, erev = self.get_bioparameter("inh_syn_erev").value, k = self.get_bioparameter("inh_syn_k").value) self.elec_syn = GapJunction(id="elec_syn", conductance = self.get_bioparameter("elec_syn_gbase").value) self.offset_current = PulseGenerator(id="offset_current", delay=self.get_bioparameter("unphysiological_offset_current_del").value, duration=self.get_bioparameter("unphysiological_offset_current_dur").value, amplitude=self.get_bioparameter("unphysiological_offset_current").value)
erev="0mV", tau_rise="1ms", tau_decay="3ms") nml_doc.exp_two_synapses.append(syn1) gj = GapJunction(id="gj1", conductance="10pS") nml_doc.gap_junctions.append(gj) sil_syn = SilentSynapse(id="silent1") nml_doc.silent_synapses.append(sil_syn) grad_syn = GradedSynapse(id="gs1", conductance="0.5pS", delta="5mV", Vth="-55mV", k="0.025per_ms", erev="0mV") nml_doc.graded_synapses.append(grad_syn) pfs = PoissonFiringSynapse(id='pfs', average_rate='150Hz', synapse=syn0.id, spike_target="./%s" % syn0.id) nml_doc.poisson_firing_synapses.append(pfs) net = Network(id="CompleteNet", type="networkWithTemperature", temperature="6.3 degC")
def generate(reference = "Weights", num_each = 6, connections=True, duration = 1000, format='xml'): nml_doc, network = oc.generate_network(reference) cell_id = 'HH_477127614' cell = oc.include_opencortex_cell(nml_doc, 'AllenInstituteCellTypesDB_HH/%s.cell.nml'%cell_id) xDim = 500 yDim = 500 zDim = 30 pop_pre = oc.add_population_in_rectangular_region(network, 'pop_pre', cell_id, num_each, 0,0,0, xDim,yDim,zDim, color='.8 0 0') pop_post_chem_exc = oc.add_population_in_rectangular_region(network, 'pop_post_chem_exc', cell_id, num_each+1, 0,yDim,0, xDim,yDim,zDim, color='0 0 .8') pop_post_chem_inh = oc.add_population_in_rectangular_region(network, 'pop_post_chem_inh', cell_id, num_each+2, xDim,yDim,0, xDim,yDim,zDim, color='0 .8 .8') pop_post_cont = oc.add_population_in_rectangular_region(network, 'pop_post_cont', cell_id, num_each+3, xDim,0,0, xDim,yDim,zDim, color='0 .8 0') ampa_syn = oc.add_exp_two_syn(nml_doc, id="AMPA_syn", gbase="10nS", erev="0mV", tau_rise="2ms", tau_decay="10ms") gaba_syn = oc.add_exp_two_syn(nml_doc, id="GABA_syn", gbase="10nS", erev="-80mV", tau_rise="3ms", tau_decay="30ms") gj_syn = oc.add_gap_junction_synapse(nml_doc, id="gj0", conductance=".05nS") analog_syn = GradedSynapse(id='analog_syn', conductance="10nS", delta="5mV", Vth="-35mV", k="0.025per_ms", erev="0mV") silent_syn = SilentSynapse(id="silent1") nml_doc.graded_synapses.append(analog_syn) nml_doc.silent_synapses.append(silent_syn) pfs = oc.add_poisson_firing_synapse(nml_doc, id="poissonFiringSyn", average_rate="10 Hz", synapse_id=ampa_syn.id) oc.add_inputs_to_population(network, "Stim0", pop_pre, pfs.id, all_cells=True) if connections: proj_chem_exc = oc.add_probabilistic_projection(network, "proj_chem_exc", pop_pre, pop_post_chem_exc, ampa_syn.id, 0.7, weight=1, delay=5) for conn in proj_chem_exc.connection_wds: if conn.get_pre_cell_id() < 3 and conn.get_post_cell_id() < 3: conn.weight = 0.5 proj_chem_inh = oc.add_probabilistic_projection(network, "proj_chem_inh", pop_pre, pop_post_chem_inh, gaba_syn.id, 0.7, weight=1, delay=5) for conn in proj_chem_inh.connection_wds: if conn.get_pre_cell_id() < 3 and conn.get_post_cell_id() < 3: conn.weight = 2 proj_cont = ContinuousProjection(id='proj_cont', \ presynaptic_population=pop_pre.id, postsynaptic_population=pop_post_cont.id) network.continuous_projections.append(proj_cont) for i in range(pop_pre.get_size()): for j in range(pop_post_cont.get_size()): conn0 = ContinuousConnectionInstanceW(id='%s'%(j+i*pop_pre.get_size()), \ pre_cell='../%s/%s/%s'%(pop_pre.id,i,cell_id), post_cell='../%s/%s/%s'%(pop_post_cont.id,j,cell_id), pre_component=silent_syn.id, post_component=analog_syn.id, weight=(i+j)/10.0) proj_cont.continuous_connection_instance_ws.append(conn0) gj_pops = [pop_pre, pop_post_chem_exc, pop_post_chem_inh, pop_post_cont] for pre in gj_pops: for post in gj_pops: proj_gap = oc.add_targeted_electrical_projection(nml_doc, network, "proj_", pre, post, targeting_mode='convergent', synapse_list=[gj_syn.id], pre_segment_group = 'soma_group', post_segment_group = 'soma_group', number_conns_per_cell=3) for conn in network.electrical_projections[-1].electrical_connection_instance_ws: conn.weight = conn.get_pre_cell_id() + conn.get_post_cell_id() nml_file_name = '%s.net.%s'%(network.id,'nml.h5' if format == 'hdf5' else 'nml') target_dir = 'HDF5/' if format == 'hdf5' else './' oc.save_network(nml_doc, nml_file_name, validate=(format=='xml'), format = format, target_dir=target_dir) if format=='xml': lems_file_name = oc.generate_lems_simulation(nml_doc, network, nml_file_name, duration = duration, dt = 0.025, gen_plots_for_all_v = True, gen_saves_for_all_v = True) else: lems_file_name = None return nml_doc, nml_file_name, lems_file_name