Skip to content

Commit

Permalink
Add initial kir, black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Apr 19, 2024
1 parent c323cb1 commit d1034b0
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 75 deletions.
4 changes: 3 additions & 1 deletion NeuroML2/AWCon.cell.nml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<neuroml xmlns="http://www.neuroml.org/schema/neuroml2" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.neuroml.org/schema/neuroml2 https://raw.github.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2.3.xsd" id="AWCon">
<notes>A cell from Nicoletti et al. 2019</notes>
<include href="AWCon_leak.channel.nml"/>
<include href="AWCon_kir.channel.nml"/>
<cell id="AWCon">
<notes>AWCon cell from Nicoletti et al. 2019</notes>
<morphology id="morphology">
Expand All @@ -19,7 +20,8 @@
</morphology>
<biophysicalProperties id="biophys">
<membraneProperties>
<channelDensity id="leak_chans" ionChannel="AWCon_leak" condDensity="3.0 S_per_m2" erev="-80mV" ion="non_specific"/>
<channelDensity id="leak_chans" ionChannel="AWCon_leak" condDensity="0.27 S_per_m2" erev="-80.0mV" ion="non_specific"/>
<channelDensity id="kir_chans" ionChannel="AWCon_kir" condDensity="0.65 S_per_m2" erev="-80.0mV" ion="k"/>
<spikeThresh value="0mV"/>
<specificCapacitance value="1.2 uF_per_cm2"/>
<initMembPotential value="-75mV"/>
Expand Down
6 changes: 6 additions & 0 deletions NeuroML2/AWCon_kir.channel.nml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<neuroml xmlns="http://www.neuroml.org/schema/neuroml2" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.neuroml.org/schema/neuroml2 https://raw.github.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2.3.xsd" id="AWCon_kir">
<notes>An ion channel from cell AWCon from Nicoletti et al. 2019</notes>
<ionChannelHH id="AWCon_kir" conductance="10pS">
<notes>AWCon_kir channel from Nicoletti et al. 2019</notes>
</ionChannelHH>
</neuroml>
158 changes: 85 additions & 73 deletions NeuroML2/GenerateNeuroML.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,127 +5,139 @@
from pyneuroml.xppaut import parse_script


xpps = {'RMD':parse_script('../RMD.ode'),'AWCon':parse_script('../AWC.ode')}
xpps = {"RMD": parse_script("../RMD.ode"), "AWCon": parse_script("../AWC.ode")}

c=1.2
c = 1.2

ek=-80
eca=60
eleak=-80
ena=30

colors = {'AWCon':'0 0 0.8', 'RMD':'0 0.8 0', 'GenericMuscleCell':'0.8 0 0'}

colors = {"AWCon": "0 0 0.8", "RMD": "0 0.8 0", "GenericMuscleCell": "0.8 0 0"}


def create_channel_file(chan_id_in_cell, cell_id, xpp):
chan_id = "%s_%s" % (cell_id, chan_id_in_cell)
chan_doc = NeuroMLDocument(
id=chan_id,
notes="An ion channel from cell %s from Nicoletti et al. 2019" % cell_id,
)

chan_id = '%s_%s'%(cell_id, chan_id_in_cell)
chan_doc = NeuroMLDocument(id=chan_id, notes="An ion channel from cell %s from Nicoletti et al. 2019"%cell_id)

chan_fn = "%s.channel.nml"%(chan_id)
chan_fn = "%s.channel.nml" % (chan_id)

channel = component_factory(
"IonChannelHH", id=chan_id, conductance="10pS", notes="%s channel from Nicoletti et al. 2019"%chan_id
"IonChannelHH",
id=chan_id,
conductance="10pS",
notes="%s channel from Nicoletti et al. 2019" % chan_id,
)

chan_doc.add(channel)
chan_doc.validate(recursive=True)

pynml.write_neuroml2_file(
nml2_doc=chan_doc, nml2_file_name=chan_fn, validate=True
)
pynml.write_neuroml2_file(nml2_doc=chan_doc, nml2_file_name=chan_fn, validate=True)

return chan_fn


def generate_nmllite(cell, duration=700, config='IClamp',parameters = None):

def generate_nmllite(cell, duration=700, config="IClamp", parameters=None):
from neuromllite import Cell, InputSource
#from neuromllite.NetworkGenerator import *

# from neuromllite.NetworkGenerator import *
from neuromllite.utils import create_new_model

reference = "%s_%s"%(config, cell)

cell_id = '%s'%cell
cell_nmll = Cell(id=cell_id, neuroml2_source_file='%s.cell.nml'%(cell))

reference = "%s_%s" % (config, cell)

cell_id = "%s" % cell
cell_nmll = Cell(id=cell_id, neuroml2_source_file="%s.cell.nml" % (cell))

################################################################################
### Add some inputs

if 'IClamp' in config:


if "IClamp" in config:
if not parameters:
parameters = {}
parameters['stim_amp'] = '10pA'

input_source = InputSource(id='iclamp_0',
neuroml2_input='PulseGenerator',
parameters={'amplitude':'stim_amp', 'delay':'100ms', 'duration':'500ms'})


else:
parameters["stim_amp"] = "10pA"

input_source = InputSource(
id="iclamp_0",
neuroml2_input="PulseGenerator",
parameters={"amplitude": "stim_amp", "delay": "100ms", "duration": "500ms"},
)

else:
if not parameters:
parameters = {}
parameters['average_rate'] = '100 Hz'
parameters['number_per_cell'] = '10'

input_source = InputSource(id='pfs0',
neuroml2_input='PoissonFiringSynapse',
parameters={'average_rate':'average_rate',
'synapse':syn_exc.id,
'spike_target':"./%s"%syn_exc.id})

sim, net = create_new_model(reference,
duration,
dt=0.025, # ms
temperature=34, # degC
default_region='Worm',
parameters = parameters,
cell_for_default_population=cell_nmll,
color_for_default_population=colors[cell],
input_for_default_population=input_source)
parameters["average_rate"] = "100 Hz"
parameters["number_per_cell"] = "10"

input_source = InputSource(
id="pfs0",
neuroml2_input="PoissonFiringSynapse",
parameters={
"average_rate": "average_rate",
"synapse": syn_exc.id,
"spike_target": "./%s" % syn_exc.id,
},
)

return sim, net
sim, net = create_new_model(
reference,
duration,
dt=0.025, # ms
temperature=34, # degC
default_region="Worm",
parameters=parameters,
cell_for_default_population=cell_nmll,
color_for_default_population=colors[cell],
input_for_default_population=input_source,
)

return sim, net


def create_cells():

for cell_id in ['AWCon','RMD']:

for cell_id in ["AWCon", "RMD"]:
# Create the nml file and add the ion channels
cell_doc = NeuroMLDocument(id=cell_id, notes="A cell from Nicoletti et al. 2019")
cell_fn = "%s.cell.nml"%cell_id
cell_doc = NeuroMLDocument(
id=cell_id, notes="A cell from Nicoletti et al. 2019"
)
cell_fn = "%s.cell.nml" % cell_id

# Define a cell
cell = cell_doc.add(
"Cell", id=cell_id, notes="%s cell from Nicoletti et al. 2019"%cell_id
)
"Cell", id=cell_id, notes="%s cell from Nicoletti et al. 2019" % cell_id
)
diam = 10
cell.add_segment(
prox=[0, 0, 0, diam],
dist=[0, 0, 0, diam],
name="soma",
parent=None,
fraction_along=1.0,
seg_type='soma'
seg_type="soma",
)


# Leak channel
cell.add_channel_density(
cell_doc,
cd_id="leak_chans",
cond_density="3.0 S_per_m2",
erev="%smV"%eleak,
cond_density="%s S_per_m2" % xpps[cell_id]["parameters"]["gleak"],
erev="%smV" % xpps[cell_id]["parameters"]["eleak"],
ion="non_specific",
ion_channel="%s_leak"%cell_id,
ion_chan_def_file=create_channel_file('leak',cell_id,xpps[cell_id]),
ion_channel="%s_leak" % cell_id,
ion_chan_def_file=create_channel_file("leak", cell_id, xpps[cell_id]),
)

cell.set_specific_capacitance("%s uF_per_cm2"%c)
# IRK channel
cell.add_channel_density(
cell_doc,
cd_id="kir_chans",
cond_density="%s S_per_m2" % xpps[cell_id]["parameters"]["gkir"],
erev="%smV" % xpps[cell_id]["parameters"]["ek"],
ion="k",
ion_channel="%s_kir" % cell_id,
ion_chan_def_file=create_channel_file("kir", cell_id, xpps[cell_id]),
)

cell.set_specific_capacitance("%s uF_per_cm2" % c)

cell.add_membrane_property("SpikeThresh", value="0mV")
cell.set_init_memb_potential("-75mV")
Expand All @@ -140,7 +152,9 @@ def create_cells():
nml2_doc=cell_doc, nml2_file_name=cell_fn, validate=True
)

sim, net = generate_nmllite(cell_id, duration=700, config='IClamp', parameters = None)
sim, net = generate_nmllite(
cell_id, duration=700, config="IClamp", parameters=None
)

################################################################################
### Run in some simulators
Expand All @@ -152,6 +166,4 @@ def create_cells():


if __name__ == "__main__":


create_cells()
create_cells()
4 changes: 3 additions & 1 deletion NeuroML2/RMD.cell.nml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<neuroml xmlns="http://www.neuroml.org/schema/neuroml2" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.neuroml.org/schema/neuroml2 https://raw.github.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2.3.xsd" id="RMD">
<notes>A cell from Nicoletti et al. 2019</notes>
<include href="RMD_leak.channel.nml"/>
<include href="RMD_kir.channel.nml"/>
<cell id="RMD">
<notes>RMD cell from Nicoletti et al. 2019</notes>
<morphology id="morphology">
Expand All @@ -19,7 +20,8 @@
</morphology>
<biophysicalProperties id="biophys">
<membraneProperties>
<channelDensity id="leak_chans" ionChannel="RMD_leak" condDensity="3.0 S_per_m2" erev="-80mV" ion="non_specific"/>
<channelDensity id="leak_chans" ionChannel="RMD_leak" condDensity="0.4 S_per_m2" erev="-80.0mV" ion="non_specific"/>
<channelDensity id="kir_chans" ionChannel="RMD_kir" condDensity="0.2 S_per_m2" erev="-80.0mV" ion="k"/>
<spikeThresh value="0mV"/>
<specificCapacitance value="1.2 uF_per_cm2"/>
<initMembPotential value="-75mV"/>
Expand Down
6 changes: 6 additions & 0 deletions NeuroML2/RMD_kir.channel.nml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<neuroml xmlns="http://www.neuroml.org/schema/neuroml2" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.neuroml.org/schema/neuroml2 https://raw.github.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2.3.xsd" id="RMD_kir">
<notes>An ion channel from cell RMD from Nicoletti et al. 2019</notes>
<ionChannelHH id="RMD_kir" conductance="10pS">
<notes>RMD_kir channel from Nicoletti et al. 2019</notes>
</ionChannelHH>
</neuroml>

0 comments on commit d1034b0

Please sign in to comment.