From 9faa1910118eb557874baf1ab7ea8a9b56dd10ec Mon Sep 17 00:00:00 2001 From: pgleeson Date: Fri, 19 Apr 2024 15:51:44 +0100 Subject: [PATCH] More tests xpp vs nml2 --- .gitignore | 4 ++ NeuroML2/AWCon.cell.nml | 8 +-- NeuroML2/AWCon_kir.channel.nml | 2 +- NeuroML2/GenerateNeuroML.py | 97 +++++++++++++++++--------------- NeuroML2/IClamp_AWCon.json | 2 +- NeuroML2/IClamp_RMD.json | 2 +- NeuroML2/IClamp_RMD.net.nml | 4 +- NeuroML2/LEMS_Sim_IClamp_RMD.xml | 4 +- NeuroML2/RMD.cell.nml | 8 +-- NeuroML2/RMD_kir.channel.nml | 2 +- NeuroML2/Sim_IClamp_AWCon.json | 2 +- NeuroML2/Sim_IClamp_RMD.json | 2 +- NeuroML2/TestXPP.py | 18 ++++++ 13 files changed, 91 insertions(+), 64 deletions(-) create mode 100644 NeuroML2/TestXPP.py diff --git a/.gitignore b/.gitignore index d81cc66..77b69e9 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/NeuroML2/AWCon.cell.nml b/NeuroML2/AWCon.cell.nml index 1105c59..4676cfe 100644 --- a/NeuroML2/AWCon.cell.nml +++ b/NeuroML2/AWCon.cell.nml @@ -6,8 +6,8 @@ AWCon cell from Nicoletti et al. 2019 - - + + Default soma segment group for the cell @@ -23,8 +23,8 @@ - - + + diff --git a/NeuroML2/AWCon_kir.channel.nml b/NeuroML2/AWCon_kir.channel.nml index 7ab07aa..2c89e34 100644 --- a/NeuroML2/AWCon_kir.channel.nml +++ b/NeuroML2/AWCon_kir.channel.nml @@ -24,7 +24,7 @@ - + diff --git a/NeuroML2/GenerateNeuroML.py b/NeuroML2/GenerateNeuroML.py index c6de810..8ef3098 100644 --- a/NeuroML2/GenerateNeuroML.py +++ b/NeuroML2/GenerateNeuroML.py @@ -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"} @@ -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) @@ -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: @@ -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( @@ -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], @@ -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") @@ -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 ) ################################################################################ @@ -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) diff --git a/NeuroML2/IClamp_AWCon.json b/NeuroML2/IClamp_AWCon.json index 647f3f4..0eee7bb 100644 --- a/NeuroML2/IClamp_AWCon.json +++ b/NeuroML2/IClamp_AWCon.json @@ -14,7 +14,7 @@ "iclamp_0": { "parameters": { "amplitude": "stim_amp", - "delay": "100ms", + "delay": "310ms", "duration": "500ms" }, "neuroml2_input": "PulseGenerator" diff --git a/NeuroML2/IClamp_RMD.json b/NeuroML2/IClamp_RMD.json index 9dfd6c8..81aaec9 100644 --- a/NeuroML2/IClamp_RMD.json +++ b/NeuroML2/IClamp_RMD.json @@ -14,7 +14,7 @@ "iclamp_0": { "parameters": { "amplitude": "stim_amp", - "delay": "100ms", + "delay": "310ms", "duration": "500ms" }, "neuroml2_input": "PulseGenerator" diff --git a/NeuroML2/IClamp_RMD.net.nml b/NeuroML2/IClamp_RMD.net.nml index 5ed4045..e290899 100644 --- a/NeuroML2/IClamp_RMD.net.nml +++ b/NeuroML2/IClamp_RMD.net.nml @@ -5,11 +5,11 @@ NeuroMLlite parameters: stim_amp = 10pA - + A network model: IClamp_RMD - + diff --git a/NeuroML2/LEMS_Sim_IClamp_RMD.xml b/NeuroML2/LEMS_Sim_IClamp_RMD.xml index 626224d..b01f2da 100644 --- a/NeuroML2/LEMS_Sim_IClamp_RMD.xml +++ b/NeuroML2/LEMS_Sim_IClamp_RMD.xml @@ -18,8 +18,8 @@ - - + + diff --git a/NeuroML2/RMD.cell.nml b/NeuroML2/RMD.cell.nml index 776a97d..b19f029 100644 --- a/NeuroML2/RMD.cell.nml +++ b/NeuroML2/RMD.cell.nml @@ -6,8 +6,8 @@ RMD cell from Nicoletti et al. 2019 - - + + Default soma segment group for the cell @@ -23,8 +23,8 @@ - - + + diff --git a/NeuroML2/RMD_kir.channel.nml b/NeuroML2/RMD_kir.channel.nml index f09c1bd..d8d122b 100644 --- a/NeuroML2/RMD_kir.channel.nml +++ b/NeuroML2/RMD_kir.channel.nml @@ -24,7 +24,7 @@ - + diff --git a/NeuroML2/Sim_IClamp_AWCon.json b/NeuroML2/Sim_IClamp_AWCon.json index f7ea9da..744414c 100644 --- a/NeuroML2/Sim_IClamp_AWCon.json +++ b/NeuroML2/Sim_IClamp_AWCon.json @@ -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": { diff --git a/NeuroML2/Sim_IClamp_RMD.json b/NeuroML2/Sim_IClamp_RMD.json index 8242730..04a176e 100644 --- a/NeuroML2/Sim_IClamp_RMD.json +++ b/NeuroML2/Sim_IClamp_RMD.json @@ -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": { diff --git a/NeuroML2/TestXPP.py b/NeuroML2/TestXPP.py new file mode 100644 index 0000000..745d894 --- /dev/null +++ b/NeuroML2/TestXPP.py @@ -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)