def add_channel_density(cell, nml_cell_doc, cd_id, cond_density, ion_channel, ion_chan_def_file="", erev="0.0 mV", ion="non_specific", group="all"): # type: (Cell, NeuroMLDocument, str, str, str, str, str, str, str) -> None """Add channel density. :param cell: cell to be modified :type cell: Cell :param nml_cell_doc: cell NeuroML document to which channel density is to be added :type nml_cell_doc: NeuroMLDocument :param cd_id: id for channel density :type cd_id: str :param cond_density: value of conductance density with units :type cond_density: str :param ion_channel: name of ion channel :type ion_channel: str :param ion_chan_def_file: path to NeuroML2 file defining the ion channel, if empty, it assumes the channel is defined in the same file :type ion_chan_def_file: str :param erev: value of reversal potential with units :type erev: str :param ion: name of ion :type ion: str :param group: segment groups to add to :type group: str """ cd = ChannelDensity(id=cd_id, segment_groups=group, ion=ion, ion_channel=ion_channel, erev=erev, cond_density=cond_density) cell.biophysical_properties.membrane_properties.channel_densities.append( cd) if len(ion_chan_def_file) > 0: if IncludeType(ion_chan_def_file) not in nml_cell_doc.includes: nml_cell_doc.includes.append(IncludeType(ion_chan_def_file))
def create_generic_neuron_cell(self): self.generic_neuron_cell = Cell(id="GenericNeuronCell") morphology = Morphology() morphology.id = "morphology_" + self.generic_neuron_cell.id self.generic_neuron_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="0", 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_neuron_cell.biophysical_properties = BiophysicalProperties( id="biophys_" + self.generic_neuron_cell.id) mp = MembraneProperties() self.generic_neuron_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( "neuron_specific_capacitance").value)) mp.spike_threshes.append( SpikeThresh( value=self.get_bioparameter("neuron_spike_thresh").value)) mp.channel_densities.append( ChannelDensity(cond_density=self.get_bioparameter( "neuron_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( "neuron_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("neuron_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( "neuron_ca_simple_cond_density").value, id="ca_simple_all", ion_channel="ca_simple", erev=self.get_bioparameter("ca_simple_erev").value, ion="ca")) ip = IntracellularProperties() self.generic_neuron_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)
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)
def create_cell(): """Create the cell. :returns: name of the cell nml file """ # Create the nml file and add the ion channels hh_cell_doc = NeuroMLDocument(id="cell", notes="HH cell") hh_cell_fn = "HH_example_cell.nml" hh_cell_doc.includes.append(IncludeType(href=create_na_channel())) hh_cell_doc.includes.append(IncludeType(href=create_k_channel())) hh_cell_doc.includes.append(IncludeType(href=create_leak_channel())) # Define a cell hh_cell = Cell(id="hh_cell", notes="A single compartment HH cell") # Define its biophysical properties bio_prop = BiophysicalProperties(id="hh_b_prop") # notes="Biophysical properties for HH cell") # Membrane properties are a type of biophysical properties mem_prop = MembraneProperties() # Add membrane properties to the biophysical properties bio_prop.membrane_properties = mem_prop # Append to cell hh_cell.biophysical_properties = bio_prop # Channel density for Na channel na_channel_density = ChannelDensity(id="na_channels", cond_density="120.0 mS_per_cm2", erev="50.0 mV", ion="na", ion_channel="na_channel") mem_prop.channel_densities.append(na_channel_density) # Channel density for k channel k_channel_density = ChannelDensity(id="k_channels", cond_density="360 S_per_m2", erev="-77mV", ion="k", ion_channel="k_channel") mem_prop.channel_densities.append(k_channel_density) # Leak channel leak_channel_density = ChannelDensity(id="leak_channels", cond_density="3.0 S_per_m2", erev="-54.3mV", ion="non_specific", ion_channel="leak_channel") mem_prop.channel_densities.append(leak_channel_density) # Other membrane properties mem_prop.spike_threshes.append(SpikeThresh(value="-20mV")) mem_prop.specific_capacitances.append(SpecificCapacitance(value="1.0 uF_per_cm2")) mem_prop.init_memb_potentials.append(InitMembPotential(value="-65mV")) intra_prop = IntracellularProperties() intra_prop.resistivities.append(Resistivity(value="0.03 kohm_cm")) # Add to biological properties bio_prop.intracellular_properties = intra_prop # Morphology morph = Morphology(id="hh_cell_morph") # notes="Simple morphology for the HH cell") seg = Segment(id="0", name="soma", notes="Soma segment") # We want a diameter such that area is 1000 micro meter^2 # surface area of a sphere is 4pi r^2 = 4pi diam^2 diam = math.sqrt(1000 / math.pi) proximal = distal = Point3DWithDiam(x="0", y="0", z="0", diameter=str(diam)) seg.proximal = proximal seg.distal = distal morph.segments.append(seg) hh_cell.morphology = morph hh_cell_doc.cells.append(hh_cell) pynml.write_neuroml2_file(nml2_doc=hh_cell_doc, nml2_file_name=hh_cell_fn, validate=True) return hh_cell_fn
def create_neuron_cell(self, cell_name, morphology): cell = Cell(id=cell_name) cell.notes = "Cell model created by c302 with custom electrical parameters" cell.morphology = morphology cell.biophysical_properties = BiophysicalProperties(id="biophys_" + cell.id) mp = MembraneProperties() 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("neuron_spike_thresh").value)) mp.channel_densities.append( ChannelDensity(cond_density=self.get_bioparameter( "neuron_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( "neuron_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( "neuron_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( "neuron_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() 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=self.get_bioparameter("resistivity").value)) # 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) return cell