forked from ModelDBRepository/262670
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from sanjayankur31/neuroml-ankur
Setup for NeuroML conversion
- Loading branch information
Showing
101 changed files
with
441,528 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added
BIN
+46.7 KB
NEURON/mb/mod/Steady_state(s)_of_activation_variables_in_nas_at_6.3_degC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.9 KB
NEURON/mb/mod/Time_course(s)_of_activation_variables_in_nas_at_6.3_degC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# NeuroML2 | ||
|
||
NeuroML conversion of model: WIP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
<neuroml xmlns="http://www.neuroml.org/schema/neuroml2" 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_v2beta4.xsd" id="NeuroML_ionChannel"> | ||
|
||
<notes>NeuroML file containing a single ion channel</notes> | ||
|
||
<ionChannel id="Navp" conductance="1pS" type="ionChannelHH" species="na"> | ||
|
||
<notes> | ||
Implementation of slow Na+ channel ( NAS ) from Wustenberg DG, Boytcheva M, Grunewald B, Byrne JH, Menzel R, Baxter DA | ||
|
||
This is slow Na+ channel in Apis mellifera Kenyon cells :(cultured). | ||
</notes> | ||
|
||
<gate id="m" type="gateHHratesTau" instances="3"> | ||
<forwardRate type="HHExpLinearRate" rate="1per_ms" midpoint="-30.1mV" scale="6.65mV"/> | ||
<timeCourse type="Ray_nas_taum"/> | ||
</gate> | ||
|
||
<gate id="h" type="gateHHratesTau" instances="1"> | ||
<forwardRate type="HHExpLinearRate" rate="1per_ms" midpoint="-51.4mV" scale="5.9mV"/> | ||
<timeCourse type="Ray_nas_tauh"/> | ||
</gate> | ||
|
||
</ionChannel> | ||
|
||
<ComponentType name="Ray_nas_taum" | ||
extends="baseVoltageDepTime" | ||
description="Tau parameter to describe Navp"> | ||
|
||
<Constant name="TIME_SCALE" dimension="time" value="1 ms"/> | ||
<Constant name="VOLT_SCALE" dimension="voltage" value="1 mV"/> | ||
<Constant name="max_tau" dimension="per_time" value="0.83 per_time"/> | ||
<Constant name="min_tau" dimension="per_time" value="0.093 per_time"/> | ||
<Dynamics> | ||
<DerivedVariable name="V" dimension="none" value="v / VOLT_SCALE"/> | ||
<ConditionalDerivedVariable name="t" dimension="time" exposure="t"> | ||
<Case condition="(ALPHA + BETA) .eq. 0" value="( 0 ) * TIME_SCALE"/> | ||
<Case condition="1/( (ALPHA + BETA) * rateScale ) .lt. ( 0.02 )" value="( (0.02 * rateScale) ) * TIME_SCALE"/> | ||
<Case value="( 1/(ALPHA + BETA) ) * TIME_SCALE"/> | ||
</ConditionalDerivedVariable> | ||
|
||
</Dynamics> | ||
|
||
</ComponentType> | ||
|
||
<ComponentType name="Ray_nas_tauh" | ||
extends="baseVoltageDepTime" | ||
description="Tau parameter to describe Navp"> | ||
|
||
<Constant name="TIME_SCALE" dimension="time" value="1 ms"/> | ||
<Constant name="VOLT_SCALE" dimension="voltage" value="1 mV"/> | ||
|
||
<Requirement name="alpha" dimension="per_time"/> | ||
<Requirement name="beta" dimension="per_time"/> | ||
<Requirement name="rateScale" dimension="none"/> | ||
|
||
<Dynamics> | ||
<DerivedVariable name="V" dimension="none" value="v / VOLT_SCALE"/> | ||
<DerivedVariable name="ALPHA" dimension="none" value="alpha * TIME_SCALE"/> | ||
<DerivedVariable name="BETA" dimension="none" value="beta * TIME_SCALE"/> | ||
|
||
<ConditionalDerivedVariable name="t" exposure="t" dimension="time"> | ||
<Case condition="(ALPHA + BETA) .eq. 0" value="( 0 ) * TIME_SCALE"/> | ||
<Case condition="1/( (ALPHA + BETA) * rateScale ) .lt. ( 0.5 )" value="( (0.5 * rateScale) ) * TIME_SCALE"/> | ||
<Case value="( 1/(ALPHA + BETA) ) * TIME_SCALE"/> | ||
</ConditionalDerivedVariable> | ||
|
||
</Dynamics> | ||
|
||
</ComponentType> | ||
|
||
<ComponentType name="Ray_nas_taus" | ||
extends="baseVoltageDepTime" | ||
description="Tau parameter to describe Navp"> | ||
|
||
<Constant name="TIME_SCALE" dimension="time" value="1 ms"/> | ||
<Constant name="VOLT_SCALE" dimension="voltage" value="1 mV"/> | ||
<Constant name="TEMP_SCALE" dimension="temperature" value="1 K"/> | ||
<Constant name="R" dimension="none" value="8.315"/> | ||
<Constant name="F" dimension="none" value="96480"/> | ||
|
||
<Requirement name="rateScale" dimension="none"/> | ||
<Requirement name="temperature" dimension="temperature"/> | ||
|
||
<Dynamics> | ||
<DerivedVariable name="V" dimension="none" value="v / VOLT_SCALE"/> | ||
<DerivedVariable name="T" dimension="none" value="temperature / TEMP_SCALE"/> | ||
|
||
<DerivedVariable name="alpha" dimension="none" value="exp((1e-3*12*(V+45)*F) / (R*(T+0.01)))"/> <!-- NEURON code: 273.16 + celsius--> | ||
<DerivedVariable name="beta" dimension="none" value="exp((1e-3*12*0.2*(V+45)*F) / (R*(T+0.01)))"/> <!-- NEURON code: 273.16 + celsius--> | ||
|
||
<DerivedVariable name="tmp" value="beta / (3e-4*(1 + alpha))" dimension="none"/> | ||
<ConditionalDerivedVariable name="t" dimension="time" exposure="t" > | ||
<Case condition="(tmp / rateScale) .lt. 10" value="10 * rateScale * TIME_SCALE"/> | ||
<Case value="tmp * TIME_SCALE"/> | ||
</ConditionalDerivedVariable> | ||
|
||
</Dynamics> | ||
|
||
</ComponentType> | ||
|
||
<ComponentType name="Ray_nas_sss_ar2_1" | ||
extends="baseVoltageDepVariable" | ||
description="steadyState parameter to describe Navp"> | ||
|
||
<Constant name="no_inact" dimension="none" value="1"/> <!-- 1: no inact, 0: max inact--> | ||
<Constant name="VOLT_SCALE" dimension="voltage" value="1 mV"/> | ||
|
||
<Dynamics> | ||
<DerivedVariable name="V" dimension="none" value="v / VOLT_SCALE"/> | ||
|
||
<DerivedVariable name="alpha" dimension="none" value="1 / (1 + exp((V+43)/2))"/> | ||
|
||
<DerivedVariable name="x" exposure="x" dimension="none" value="alpha + no_inact*(1 - alpha)"/> | ||
</Dynamics> | ||
|
||
</ComponentType> | ||
|
||
|
||
<ComponentType name="Ray_nas_sss_ar2_0_8" | ||
extends="baseVoltageDepVariable" | ||
description="steadyState parameter to describe Navp"> | ||
|
||
<Constant name="no_inact" dimension="none" value="0.8"/> <!-- 1: no inact, 0: max inact--> | ||
<Constant name="VOLT_SCALE" dimension="voltage" value="1 mV"/> | ||
|
||
<Dynamics> | ||
<DerivedVariable name="V" dimension="none" value="v / VOLT_SCALE"/> | ||
|
||
<DerivedVariable name="alpha" dimension="none" value="1 / (1 + exp((V+43)/2))"/> | ||
|
||
<DerivedVariable name="x" exposure="x" dimension="none" value="alpha + no_inact*(1 - alpha)"/> | ||
</Dynamics> | ||
|
||
</ComponentType> | ||
|
||
</neuroml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
<neuroml xmlns="http://www.neuroml.org/schema/neuroml2" 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_v2beta4.xsd" id="pas"> | ||
|
||
<notes>NeuroML file containing a single Channel description</notes> | ||
|
||
<ionChannel id="pas" conductance="10pS" type="ionChannelPassive"> | ||
|
||
<notes>Simple example of a leak/passive conductance. Note: for GENESIS cells with a single leak conductance, | ||
it is better to use the Rm and Em variables for a passive current.</notes> | ||
|
||
</ionChannel> | ||
|
||
</neuroml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
Post process and add biophysics to cells. | ||
We make any updates to the morphology, and add biophysics. | ||
File: NeuroML2/postprocess_cells.py | ||
Copyright 2022 Ankur Sinha | ||
Author: Ankur Sinha <sanjay DOT ankur AT gmail DOT com> | ||
""" | ||
|
||
|
||
import random | ||
|
||
import neuroml | ||
from neuroml.loaders import read_neuroml2_file | ||
from pyneuroml.pynml import write_neuroml2_file | ||
from neuroml.utils import component_factory | ||
|
||
random.seed(1412) | ||
|
||
|
||
def load_and_setup_cell(cellname: str): | ||
"""Load a cell, and clean it to prepare it for further modifications. | ||
These operations are common for all cells. | ||
:param cellname: name of cell. | ||
the file containing the cell should then be <cell>.morph.cell.nml | ||
:returns: document with cell | ||
:rtype: neuroml.NeuroMLDocument | ||
""" | ||
celldoc = read_neuroml2_file( | ||
f"{cellname}.morph.cell.nml" | ||
) # type: neuroml.NeuroMLDocument | ||
cell = celldoc.cells[0] # type: neuroml.Cell | ||
celldoc.networks = [] | ||
cell.id = cellname | ||
cell.notes = cell.notes.replace("GGN_20170309_sc_0_0", cellname) | ||
cell.notes += ". Reference: Subhasis Ray, Zane N Aldworth, Mark A Stopfer (2020) Feedback inhibition and its control in an insect olfactory circuit eLife 9:e53281." | ||
|
||
[ | ||
default_all_group, | ||
default_soma_group, | ||
default_dendrite_group, | ||
default_axon_group, | ||
] = cell.setup_default_segment_groups( | ||
use_convention=True, | ||
default_groups=["all", "soma_group", "dendrite_group", "axon_group"], | ||
) | ||
|
||
# populate default groups | ||
for sg in cell.morphology.segment_groups: | ||
if "soma" in sg.id and sg.id != "soma_group": | ||
default_soma_group.add(neuroml.Include(segment_groups=sg.id)) | ||
if "axon" in sg.id and sg.id != "axon_group": | ||
default_axon_group.add(neuroml.Include(segment_groups=sg.id)) | ||
if "dend" in sg.id and sg.id != "dendrite_group": | ||
default_dendrite_group.add(neuroml.Include(segment_groups=sg.id)) | ||
|
||
cell.optimise_segment_groups() | ||
|
||
return celldoc | ||
|
||
|
||
def postprocess_GGN(): | ||
"""Post process GGN and add biophysics.""" | ||
cellname = "GGN" | ||
celldoc = load_and_setup_cell(cellname) | ||
cell = celldoc.cells[0] # type: neuroml.Cell | ||
|
||
# biophysics | ||
# all | ||
cell.add_channel_density( | ||
nml_cell_doc=celldoc, | ||
cd_id="pas", | ||
ion_channel="pas", | ||
cond_density="0.00003 S_per_cm2", | ||
erev="-51 mV", | ||
group_id="all", | ||
ion="non_specific", | ||
ion_chan_def_file="channels/pas.channel.nml", | ||
) | ||
cell.set_resistivity("0.1 kohm_cm", group_id="all") | ||
cell.set_specific_capacitance("1 uF_per_cm2", group_id="all") | ||
cell.set_init_memb_potential("-80mV") | ||
|
||
# L1 validation | ||
# cell.validate(recursive=True) | ||
cell.summary(morph=False, biophys=True) | ||
# use pynml writer to also run L2 validation | ||
write_neuroml2_file(celldoc, f"{cellname}.cell.nml") | ||
|
||
|
||
def postprocess_KC(): | ||
"""Manually create KC and add biophysics.""" | ||
celldoc = component_factory("NeuroMLDocument", id="KC_doc") # type: neuroml.NeuroMLDocument | ||
cell = celldoc.add("Cell", id="KC", validate=False) # type: neuroml.Cell | ||
cell.setup_nml_cell() | ||
cell.add_segment([0, 0, 0, 20], [0, 0, 6.366, 20], seg_type="soma") | ||
|
||
# biophysics | ||
# all | ||
cell.add_channel_density( | ||
nml_cell_doc=celldoc, | ||
cd_id="pas", | ||
ion_channel="pas", | ||
cond_density=".0000975 S_per_cm2", | ||
erev="-70 mV", | ||
group_id="all", | ||
ion="non_specific", | ||
ion_chan_def_file="channels/pas.channel.nml", | ||
) | ||
cell.set_resistivity("35.4 ohm_cm", group_id="all") | ||
cell.set_specific_capacitance("1 uF_per_cm2", group_id="all") | ||
cell.set_init_memb_potential("-80mV") | ||
|
||
# L1 validation | ||
# cell.validate(recursive=True) | ||
cell.summary(morph=False, biophys=True) | ||
# use pynml writer to also run L2 validation | ||
write_neuroml2_file(celldoc, "KC.cell.nml") | ||
|
||
|
||
def KC_create_na_channel(): | ||
"""Create the Na channel. | ||
This will create the Na channel and save it to a file. | ||
It will also validate this file. | ||
returns: name of the created file | ||
""" | ||
na_channel = component_factory( | ||
"IonChannelHH", | ||
id="na_channel", | ||
notes="Sodium channel for HH cell", | ||
conductance="10pS", | ||
species="na", | ||
validate=False, | ||
) | ||
gate_m = component_factory( | ||
"GateHHRates", | ||
id="m", | ||
instances="3", | ||
notes="m gate for na channel", | ||
validate=False, | ||
) | ||
m_forward_rate = component_factory( | ||
"HHRate", type="HHExpLinearRate", rate="1per_ms", midpoint="-40mV", scale="10mV" | ||
) | ||
m_reverse_rate = component_factory( | ||
"HHRate", type="HHExpRate", rate="4per_ms", midpoint="-65mV", scale="-18mV" | ||
) | ||
|
||
gate_m.add(m_forward_rate, hint="forward_rate", validate=False) | ||
gate_m.add(m_reverse_rate, hint="reverse_rate") | ||
na_channel.add(gate_m) | ||
|
||
gate_h = component_factory( | ||
"GateHHRates", | ||
id="h", | ||
instances="1", | ||
notes="h gate for na channel", | ||
validate=False, | ||
) | ||
h_forward_rate = component_factory( | ||
"HHRate", type="HHExpRate", rate="0.07per_ms", midpoint="-65mV", scale="-20mV" | ||
) | ||
h_reverse_rate = component_factory( | ||
"HHRate", type="HHSigmoidRate", rate="1per_ms", midpoint="-35mV", scale="10mV" | ||
) | ||
gate_h.add(h_forward_rate, hint="forward_rate", validate=False) | ||
gate_h.add(h_reverse_rate, hint="reverse_rate") | ||
na_channel.add(gate_h) | ||
|
||
na_channel_doc = component_factory( | ||
"NeuroMLDocument", id="na_channel", notes="Na channel for HH neuron" | ||
) | ||
na_channel_fn = "HH_example_na_channel.nml" | ||
na_channel_doc.add(na_channel) | ||
na_channel_doc.validate(recursive=True) | ||
|
||
write_neuroml2_file( | ||
nml2_doc=na_channel_doc, nml2_file_name=na_channel_fn, validate=True | ||
) | ||
|
||
return na_channel_fn | ||
|
||
|
||
if __name__ == "__main__": | ||
postprocess_GGN() |
Oops, something went wrong.