Skip to content

Commit

Permalink
More tests xpp vs nml2
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Apr 19, 2024
1 parent b6a97c0 commit 9faa191
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 64 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ report.*.txt
/NeuroML2/LEMS_Sim_IClamp_AWCon.xml
/NicollettiEtAl2019.pdf
/NeuroML2/LEMS_Test_RMD_kir.xml
/NeuroML2/LEMS_RMD.xml
/NeuroML2/Test_RMD.ode
/NeuroML2/report.txt
/RMD.model.xml
8 changes: 4 additions & 4 deletions NeuroML2/AWCon.cell.nml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<notes>AWCon cell from Nicoletti et al. 2019</notes>
<morphology id="morphology">
<segment id="0" name="soma">
<proximal x="0.0" y="0.0" z="0.0" diameter="10.0"/>
<distal x="0.0" y="0.0" z="0.0" diameter="10.0"/>
<proximal x="0.0" y="0.0" z="0.0" diameter="17.841242"/>
<distal x="0.0" y="0.0" z="0.0" diameter="17.841242"/>
</segment>
<segmentGroup id="soma_group" neuroLexId="GO:0043025">
<notes>Default soma segment group for the cell</notes>
Expand All @@ -23,8 +23,8 @@
<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"/>
<specificCapacitance value="0.0031000000000000003 F_per_m2"/>
<initMembPotential value="-70mV"/>
</membraneProperties>
<intracellularProperties>
<resistivity value="0.1 kohm_cm"/>
Expand Down
2 changes: 1 addition & 1 deletion NeuroML2/AWCon_kir.channel.nml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</ComponentType>
<ComponentType name="kir_m_tau" extends="baseVoltageDepTime">
<Constant name="VOLT_SCALE" dimension="voltage" value="1 mV"/>
<Constant name="TIME_SCALE" dimension="time" value="1 s"/>
<Constant name="TIME_SCALE" dimension="time" value="1 ms"/>
<Constant name="va_kir" dimension="none" value="-52.0"/>
<Constant name="ka_kir" dimension="none" value="13.0"/>
<Constant name="p1tmkir" dimension="none" value="17.0752"/>
Expand Down
97 changes: 51 additions & 46 deletions NeuroML2/GenerateNeuroML.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

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

c = 1.2


colors = {"AWCon": "0 0 0.8", "RMD": "0 0.8 0", "GenericMuscleCell": "0.8 0 0"}
Expand Down Expand Up @@ -48,7 +47,7 @@ def create_channel_file(chan_id_in_cell, cell_id, xpp, species, gates={}, parame
vscale = component_factory("Constant", name='VOLT_SCALE', dimension="voltage", value="1 mV")
ssct.add(vscale)
tcct.add(vscale)
tscale = component_factory("Constant", name='TIME_SCALE', dimension="time", value="1 s")
tscale = component_factory("Constant", name='TIME_SCALE', dimension="time", value="1 ms")
tcct.add(tscale)


Expand Down Expand Up @@ -122,7 +121,7 @@ def generate_nmllite(cell, duration=700, config="IClamp", parameters=None):
input_source = InputSource(
id="iclamp_0",
neuroml2_input="PulseGenerator",
parameters={"amplitude": "stim_amp", "delay": "100ms", "duration": "500ms"},
parameters={"amplitude": "stim_amp", "delay": "310ms", "duration": "500ms"},
)

else:
Expand Down Expand Up @@ -156,7 +155,7 @@ def generate_nmllite(cell, duration=700, config="IClamp", parameters=None):
return sim, net


def create_cells():
def create_cells(channels_to_include):
for cell_id in ["AWCon", "RMD"]:
# Create the nml file and add the ion channels
cell_doc = NeuroMLDocument(
Expand All @@ -168,7 +167,7 @@ def create_cells():
cell = cell_doc.add(
"Cell", id=cell_id, notes="%s cell from Nicoletti et al. 2019" % cell_id
)
diam = 10
diam = 17.841242 # Gives a convenient surface area of 1000.0 um^2
cell.add_segment(
prox=[0, 0, 0, diam],
dist=[0, 0, 0, diam],
Expand All @@ -178,49 +177,52 @@ def create_cells():
seg_type="soma",
)

# Leak channel
cell.add_channel_density(
cell_doc,
cd_id="leak_chans",
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], species='non_specific'),
)
if 'leak' in channels_to_include:
# Leak channel
cell.add_channel_density(
cell_doc,
cd_id="leak_chans",
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], species='non_specific'),
)

# 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],
species='k',
gates={'m':[1,'minf_kir','tm_kir']},
parameters=[
"va_kir",
"ka_kir",
"p1tmkir",
"p2tmkir",
"p3tmkir",
"p4tmkir",
"p5tmkir",
"p6tmkir",
],

),
)

cell.set_specific_capacitance("%s uF_per_cm2" % c)
if 'kir' in channels_to_include:
# IRK/Kir 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],
species='k',
gates={'m':[1,'minf_kir','tm_kir']},
parameters=[
"va_kir",
"ka_kir",
"p1tmkir",
"p2tmkir",
"p3tmkir",
"p4tmkir",
"p5tmkir",
"p6tmkir",
],

),
)

cell.set_specific_capacitance("%s F_per_m2" % (float(xpps[cell_id]["parameters"]["c"]) * 1e-3))

cell.add_membrane_property("SpikeThresh", value="0mV")
cell.set_init_memb_potential("-75mV")
cell.set_init_memb_potential("-70mV")

# This value is not really used as it's a single comp cell model
cell.set_resistivity("0.1 kohm_cm")
Expand All @@ -233,7 +235,7 @@ def create_cells():
)

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

################################################################################
Expand All @@ -246,4 +248,7 @@ def create_cells():


if __name__ == "__main__":
create_cells()

channels_to_include = ['leak']
channels_to_include = ['leak','kir']
create_cells(channels_to_include)
2 changes: 1 addition & 1 deletion NeuroML2/IClamp_AWCon.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"iclamp_0": {
"parameters": {
"amplitude": "stim_amp",
"delay": "100ms",
"delay": "310ms",
"duration": "500ms"
},
"neuroml2_input": "PulseGenerator"
Expand Down
2 changes: 1 addition & 1 deletion NeuroML2/IClamp_RMD.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"iclamp_0": {
"parameters": {
"amplitude": "stim_amp",
"delay": "100ms",
"delay": "310ms",
"duration": "500ms"
},
"neuroml2_input": "PulseGenerator"
Expand Down
4 changes: 2 additions & 2 deletions NeuroML2/IClamp_RMD.net.nml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
NeuroMLlite parameters:
stim_amp = 10pA</notes>
<include href="RMD.cell.nml"/>
<pulseGenerator id="iclamp_0" delay="100ms" duration="500ms" amplitude="10pA"/>
<pulseGenerator id="iclamp_0" delay="310ms" duration="500ms" amplitude="10pA"/>
<network id="IClamp_RMD" type="networkWithTemperature" temperature="34.0degC">
<notes>A network model: IClamp_RMD</notes>
<property tag="recommended_dt_ms" value="0.025"/>
<property tag="recommended_duration_ms" value="700.0"/>
<property tag="recommended_duration_ms" value="400.0"/>
<population id="pop_RMD" component="RMD" size="1" type="populationList">
<property tag="color" value="0 0.8 0"/>
<property tag="region" value="Worm"/>
Expand Down
4 changes: 2 additions & 2 deletions NeuroML2/LEMS_Sim_IClamp_RMD.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<Include file="IClamp_RMD.net.nml"/>
<Include file="RMD.cell.nml"/>

<Simulation id="Sim_IClamp_RMD" length="700.0ms" step="0.025ms" target="IClamp_RMD" seed="12345"> <!-- Note seed: ensures same random numbers used every run -->
<Display id="pop_RMD_v" title="Plots of pop_RMD_v" timeScale="1ms" xmin="-70.0" xmax="770.0000000000001" ymin="-80" ymax="40">
<Simulation id="Sim_IClamp_RMD" length="400.0ms" step="0.025ms" target="IClamp_RMD" seed="12345"> <!-- Note seed: ensures same random numbers used every run -->
<Display id="pop_RMD_v" title="Plots of pop_RMD_v" timeScale="1ms" xmin="-40.0" xmax="440.00000000000006" ymin="-80" ymax="40">
<Line id="pop_RMD_0_RMD_v" quantity="pop_RMD/0/RMD/v" scale="1mV" color="#d54f33" timeScale="1ms"/>
</Display>

Expand Down
8 changes: 4 additions & 4 deletions NeuroML2/RMD.cell.nml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<notes>RMD cell from Nicoletti et al. 2019</notes>
<morphology id="morphology">
<segment id="0" name="soma">
<proximal x="0.0" y="0.0" z="0.0" diameter="10.0"/>
<distal x="0.0" y="0.0" z="0.0" diameter="10.0"/>
<proximal x="0.0" y="0.0" z="0.0" diameter="17.841242"/>
<distal x="0.0" y="0.0" z="0.0" diameter="17.841242"/>
</segment>
<segmentGroup id="soma_group" neuroLexId="GO:0043025">
<notes>Default soma segment group for the cell</notes>
Expand All @@ -23,8 +23,8 @@
<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"/>
<specificCapacitance value="0.0012 F_per_m2"/>
<initMembPotential value="-70mV"/>
</membraneProperties>
<intracellularProperties>
<resistivity value="0.1 kohm_cm"/>
Expand Down
2 changes: 1 addition & 1 deletion NeuroML2/RMD_kir.channel.nml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</ComponentType>
<ComponentType name="kir_m_tau" extends="baseVoltageDepTime">
<Constant name="VOLT_SCALE" dimension="voltage" value="1 mV"/>
<Constant name="TIME_SCALE" dimension="time" value="1 s"/>
<Constant name="TIME_SCALE" dimension="time" value="1 ms"/>
<Constant name="va_kir" dimension="none" value="-52.0"/>
<Constant name="ka_kir" dimension="none" value="13.0"/>
<Constant name="p1tmkir" dimension="none" value="17.0752"/>
Expand Down
2 changes: 1 addition & 1 deletion NeuroML2/Sim_IClamp_AWCon.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Sim_IClamp_AWCon": {
"version": "NeuroMLlite v0.5.9",
"network": "IClamp_AWCon.json",
"duration": 700.0,
"duration": 400.0,
"dt": 0.025,
"seed": 12345,
"record_traces": {
Expand Down
2 changes: 1 addition & 1 deletion NeuroML2/Sim_IClamp_RMD.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Sim_IClamp_RMD": {
"version": "NeuroMLlite v0.5.9",
"network": "IClamp_RMD.json",
"duration": 700.0,
"duration": 400.0,
"dt": 0.025,
"seed": 12345,
"record_traces": {
Expand Down
18 changes: 18 additions & 0 deletions NeuroML2/TestXPP.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

from pyneuroml.xppaut import parse_script, to_lems, to_xpp, run_xpp_file


parsed_data = parse_script("../RMD.ode")

all_g = ['gshal','gkir','gshak','gegl36','gunc2','gegl19','gcca1','gslo1','gbk','gbk2','gslo2','gca','gsc','gnca']

all_g.remove('gkir')

for p in all_g:
parsed_data['parameters'][p] = 0

new_ode_file = 'Test_RMD.ode'
new_ode = to_xpp(parsed_data, new_ode_file)


run_xpp_file(new_ode_file, plot=True)

0 comments on commit 9faa191

Please sign in to comment.