Skip to content

Commit

Permalink
wip: KC conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayankur31 committed Apr 9, 2024
1 parent af097ee commit 7532ea8
Show file tree
Hide file tree
Showing 7 changed files with 213,436 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
213,217 changes: 213,217 additions & 0 deletions NeuroML2/GGN.cell.nml

Large diffs are not rendered by default.

File renamed without changes.
137 changes: 137 additions & 0 deletions NeuroML2/channels/nas.channel.nml
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>
13 changes: 13 additions & 0 deletions NeuroML2/channels/pas.channel.nml
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>
73 changes: 69 additions & 4 deletions NeuroML2/postprocess_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ def load_and_setup_cell(cellname: str):
return celldoc


def postprocess_GGM():
"""Post process GGM and add biophysics."""
cellname = "GGM"
def postprocess_GGN():
"""Post process GGN and add biophysics."""
cellname = "GGN"
celldoc = load_and_setup_cell(cellname)
cell = celldoc.cells[0] # type: neuroml.Cell

Expand Down Expand Up @@ -124,5 +124,70 @@ def postprocess_KC():
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_GGM()
postprocess_GGN()

0 comments on commit 7532ea8

Please sign in to comment.