opensourcebrain/HodgkinHuxleyTutorial
0
1Implementation of HH Model in Python and NeuroML 2
2==================================================
3
4In this section, we make line-by-line comparisons of the contents of the `HodgkinHuxley.py <Hodgkin%20Huxley.html>`_ python script and
5the contents of the `NeuroML 2 files <Source.html>`_ and the related `LEMS_HH_Simulation.xml <LEMS_HH_Simulation.html>`_ LEMS file.
6
7
8Installing the code
9-------------------
10
11You can either clone a local copy of this repository from GitHub using::
12
13 git clone https://github.com/openworm/hodgkin_huxley_tutorial.git
14 cd hodgkin_huxley_tutorial/Tutorial/Source
15
16or just download `a zip file of the latest code <https://github.com/openworm/hodgkin_huxley_tutorial/archive/master.zip>`_, extract
17the contents and go to hodgkin_huxley_tutorial-master/Tutorial/Source/.
18
19
20Running the model implementations
21---------------------------------
22
23To run the Python version::
24
25 python HodgkinHuxley.py
26
27To run the NeuroML 2 version on Linux/Mac::
28
29 ./run.sh
30
31or on Windows::
32
33 run.bat
34
35These both use the `bundled jar file <https://github.com/openworm/hodgkin_huxley_tutorial/blob/master/Tutorial/Source/jNeuroML-0.7.2-jar-with-dependencies.jar>`_
36generated from `jNeuroML <https://github.com/NeuroML/jNeuroML>`_. Alternatively, you can install the latest `jNeuroML <https://github.com/NeuroML/jNeuroML>`_
37or `pyNeuroML <https://github.com/NeuroML/pyNeuroML>`_ and use the corresponding command line utilities to run the model::
38
39 jnml LEMS_HH_Simulation.xml
40 pynml LEMS_HH_Simulation.xml
41
42
43
44Membrane Capacitance
45....................
46
47This variable from `HodgkinHuxley.py <Hodgkin%20Huxley.html>`_:
48
49.. literalinclude:: ../Source/HodgkinHuxley.py
50 :language: python
51 :lines: 13-16
52
53Is used in this line in `hhcell.cell.nml <hhcell.html>`_:
54
55.. literalinclude:: ../Source/hhcell.cell.nml
56 :language: xml
57 :lines: 37
58
59You can `read more about the capacitance of a membrane <http://www.scholarpedia.org/article/Electrical_properties_of_cell_membranes#Capacitance>`_.
60
61Sodium (Na) Ion Channel Variables
62.................................
63
64These variables from `HodgkinHuxley.py <Hodgkin%20Huxley.html>`_:
65
66.. literalinclude:: ../Source/HodgkinHuxley.py
67 :language: python
68 :lines: 13-14,18-19
69
70.. literalinclude:: ../Source/HodgkinHuxley.py
71 :language: python
72 :lines: 27-28
73
74Are used in this line in `hhcell.cell.nml <hhcell.html>`_:
75
76.. literalinclude:: ../Source/hhcell.cell.nml
77 :language: xml
78 :lines: 33
79
80You can `read more about the maximum conductance and reversal potential (zero-current potential) of an ion channel <http://www.scholarpedia.org/article/Ion_channels#Bioelectricity_results_from_currents_in_ion_channels>`_.
81
82
83Potassium (K) Ion Channel Variables
84...................................
85
86These variables from `HodgkinHuxley.py <Hodgkin%20Huxley.html>`_:
87
88.. literalinclude:: ../Source/HodgkinHuxley.py
89 :language: python
90 :lines: 13-14,21-22
91
92.. literalinclude:: ../Source/HodgkinHuxley.py
93 :language: python
94 :lines: 30-31
95
96Are used in this line in `hhcell.cell.nml <hhcell.html>`_:
97
98.. literalinclude:: ../Source/hhcell.cell.nml
99 :language: xml
100 :lines: 34
101
102You can `read more about the maximum conductance and reversal potential (zero-current potential) of an ion channel <http://www.scholarpedia.org/article/Ion_channels#Bioelectricity_results_from_currents_in_ion_channels>`_.
103
104Passive Leak Channel Variables
105..............................
106
107These variables from `HodgkinHuxley.py <Hodgkin%20Huxley.html>`_:
108
109.. literalinclude:: ../Source/HodgkinHuxley.py
110 :language: python
111 :lines: 13-14,24-25
112
113.. literalinclude:: ../Source/HodgkinHuxley.py
114 :language: python
115 :lines: 33-34
116
117Are used in this line in `hhcell.cell.nml <hhcell.html>`_:
118
119.. literalinclude:: ../Source/hhcell.cell.nml
120 :language: xml
121 :lines: 32
122
123You can `read more about the maximum conductance and reversal potential (zero-current potential) of an ion channel <http://www.scholarpedia.org/article/Ion_channels#Bioelectricity_results_from_currents_in_ion_channels>`_.
124
125Time of Simulation
126..................
127
128This variable from `HodgkinHuxley.py <Hodgkin%20Huxley.html>`_:
129
130.. literalinclude:: ../Source/HodgkinHuxley.py
131 :language: python
132 :lines: 13-14,36-37
133
134Is used in this line in `LEMS_HH_Simulation.xml <LEMS_HH_Simulation.html>`_:
135
136.. literalinclude:: ../Source/LEMS_HH_Simulation.xml
137 :language: xml
138 :lines: 25
139
140This specifies that the simulation should run for 450 milliseconds and use a step size for integration of 0.01 milliseconds.
141
142Input Current / Input Current Density
143.....................................
144
145The method from `HodgkinHuxley.py <Hodgkin%20Huxley.html>`_ takes the input in as a current density in the form of uA/cm^2. NeuroML/LEMS uses an input current in the form of nA, which requires a conversion in the input values.
146
147This method from `HodgkinHuxley.py <Hodgkin%20Huxley.html>`_:
148
149.. literalinclude:: ../Source/HodgkinHuxley.py
150 :language: python
151 :pyobject: HodgkinHuxley.I_inj
152 :linenos:
153
154By using a given surface area of 1000.0 um^2 in the cell, it makes the conversion from uA/cm^2 to nA easier.
155
156.. math::
157
158 Surface Area = 4 * pi * (radius)^2 = 4 * pi * (diameter / 2)^2 = 4 * pi * (17.841242 / 2)^2 = 4 * pi * (8.920621)^2 = 1000 um^2
159
160.. literalinclude:: ../Source/hhcell.cell.nml
161 :language: xml
162 :lines: 17-20
163
164Given a surface area of 1000.0 um^2 in the cell the following equation is used to convert from X uA/cm^2 to Y nA:
165
166.. math::
167
168 (X uA/cm^2) * (1000.0 um^2) * (1000 nA/uA) / (1 * 10^8 um^2/cm^2) = Y nA
169
170Line 11 can then be translated into the delay, duration and amplitude of the two pulseGenerator objects in `HHCellNetwork.net.nml <HHCellNetwork.html>`_:
171
172.. literalinclude:: ../Source/HHCellNetwork.net.nml
173 :language: xml
174 :lines: 13-14
175
176Channel Gating Kinetics for Sodium (Na) Channel m
177.................................................
178
179m is the activation variable for the Sodium (Na) Channel.
180
181The function that governs the activation of this channel is based on the overall
182membrane voltage, because the channel opens and closes based on detecting the membrane potential.
183
184You can `read more about these variables <https://en.wikipedia.org/wiki/Hodgkin%E2%80%93Huxley_model#Voltage-gated_ion_channels>`_.
185
186These methods from `HodgkinHuxley.py <Hodgkin%20Huxley.html>`_:
187
188.. literalinclude:: ../Source/HodgkinHuxley.py
189 :language: python
190 :pyobject: HodgkinHuxley.alpha_m
191 :linenos:
192
193.. literalinclude:: ../Source/HodgkinHuxley.py
194 :language: python
195 :pyobject: HodgkinHuxley.beta_m
196 :linenos:
197
198Are used in these lines in `naChan.channel.nml <naChan.html>`_:
199
200.. literalinclude:: ../Source/naChan.channel.nml
201 :language: xml
202 :lines: 13-16
203
204Channel Gating Kinetics for Sodium (Na) Channel h
205.................................................
206
207h is the inactivation variable for the Sodium (Na) Channel. Inactivation is a
208different state than not being activated, which is called "deactivated". You can
209`read more about how Sodium channel gating works <https://en.wikipedia.org/wiki/Sodium_channel#Gating>`_.
210
211The function that governs the activation of this channel is based on the overall
212membrane voltage, because the channel opens and closes based on detecting the membrane potential.
213
214You can `read more about these variables <https://en.wikipedia.org/wiki/Hodgkin%E2%80%93Huxley_model#Voltage-gated_ion_channels>`_.
215
216These methods from `HodgkinHuxley.py <Hodgkin%20Huxley.html>`_:
217
218.. literalinclude:: ../Source/HodgkinHuxley.py
219 :language: python
220 :pyobject: HodgkinHuxley.alpha_h
221 :linenos:
222
223.. literalinclude:: ../Source/HodgkinHuxley.py
224 :language: python
225 :pyobject: HodgkinHuxley.beta_h
226 :linenos:
227
228Are used in these lines in `naChan.channel.nml <naChan.html>`_:
229
230.. literalinclude:: ../Source/naChan.channel.nml
231 :language: xml
232 :lines: 18-21
233
234Channel Gating Kinetics for Potassium (K) channel n
235...................................................
236
237n is the activation variable for the Potassium (K) Channel. The potassium channel does not inactivate, so there is no inactivation variable.
238
239The function that governs the activation of this channel is based on the overall
240membrane voltage, because the channel opens and closes based on detecting the membrane potential.
241
242You can `read more about these variables <https://en.wikipedia.org/wiki/Hodgkin%E2%80%93Huxley_model#Voltage-gated_ion_channels>`_.
243
244These methods from `HodgkinHuxley.py <Hodgkin%20Huxley.html>`_:
245
246.. literalinclude:: ../Source/HodgkinHuxley.py
247 :language: python
248 :pyobject: HodgkinHuxley.alpha_n
249 :linenos:
250
251.. literalinclude:: ../Source/HodgkinHuxley.py
252 :language: python
253 :pyobject: HodgkinHuxley.beta_n
254 :linenos:
255
256Are used in these lines in `kChan.channel.nml <kChan.html>`_:
257
258.. literalinclude:: ../Source/kChan.channel.nml
259 :language: xml
260 :lines: 13-16
261
262Initial Values
263..............
264
265This line from `HodgkinHuxley.py <Hodgkin%20Huxley.html>`_:
266
267.. literalinclude:: ../Source/HodgkinHuxley.py
268 :language: python
269 :lines: 220
270
271Is used to define the initial values for the model in `hhcell.cell.nml <hhcell.html>`_:
272
273.. literalinclude:: ../Source/hhcell.cell.nml
274 :language: xml
275 :lines: 38
276
277The values for m, h, n at t=0 in LEMS/NML2 are worked out as the steady state values (inf)
278of each activation variable for the given initial membrane potential.
279See `here <http://www.neuroml.org/NeuroML2CoreTypes/Channels.html#gateHHrates>`_
280for the NML2 implementation (see On Start).
281
282You could refactor the script to do this too by introducing tau_m() and inf_m()
283and using alpha_m etc., change the expressions for dmdt etc. (e.g. dm/dt = (inf_m - m) / tau_m) etc. and::
284
285 V_init = -65
286 X = odeint(self.dALLdt, [V_init, m_inf(V_init), h_inf(V_init), n_inf(V_init)], self.t, args=(self,))
287
288
289
290Plots
291.....
292
293This line in `HodgkinHuxley.py <Hodgkin%20Huxley.html>`_:
294
295.. literalinclude:: ../Source/HodgkinHuxley.py
296 :language: python
297 :lines: 262-265
298
299Is used in these lines in `LEMS_HH_Simulation.xml <LEMS_HH_Simulation.html>`_:
300
301.. literalinclude:: ../Source/LEMS_HH_Simulation.xml
302 :language: xml
303 :lines: 27-29
304
305This line in `HodgkinHuxley.py <Hodgkin%20Huxley.html>`_:
306
307.. literalinclude:: ../Source/HodgkinHuxley.py
308 :language: python
309 :lines: 248-252
310
311Is used in these lines in `LEMS_HH_Simulation.xml <LEMS_HH_Simulation.html>`_:
312
313.. literalinclude:: ../Source/LEMS_HH_Simulation.xml
314 :language: xml
315 :lines: 37-41
316
317This line in `HodgkinHuxley.py <Hodgkin%20Huxley.html>`_:
318
319.. literalinclude:: ../Source/HodgkinHuxley.py
320 :language: python
321 :lines: 255-259
322
323Is used in these lines in `LEMS_HH_Simulation.xml <LEMS_HH_Simulation.html>`_:
324
325.. literalinclude:: ../Source/LEMS_HH_Simulation.xml
326 :language: xml
327 :lines: 31-35
328
329This line in `HodgkinHuxley.py <Hodgkin%20Huxley.html>`_:
330
331.. literalinclude:: ../Source/HodgkinHuxley.py
332 :language: python
333 :lines: 244-245
334
335Is used in these lines in `LEMS_HH_Simulation.xml <LEMS_HH_Simulation.html>`_:
336
337.. literalinclude:: ../Source/LEMS_HH_Simulation.xml
338 :language: xml
339 :lines: 43-46
340
341
342Output of simulations
343.....................
344
345After running the scripts the output figures should look like the ones below.
346
347For: *python HodgkinHuxley.py*
348
349.. image:: ../_media/figure_1.png
350
351
352For: *run.sh* (or *run.bat* on Windows)
353
354.. image:: ../_media/jNeuroML.png
355
356
357Check out `the electrophysiology part of this tutorial <Electrophysiology.html#plots>`_
358for an explanation of these plots.
359
360
361 