# Hodgkin-Huxley model in R

**mages' blog**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

One of the great research papers of the 20th century celebrates its 60th anniversary in a few weeks time: *A quantitative description of membrane current and its application to conduction and excitation in nerve* by Alan Hodgkin and Andrew Huxley. Only a few weeks after Andrew Huxley died, 30th May 2012, aged 94.

In 1952 Hodgkin and Huxley published a series of papers, describing the basic processes underlying the nervous mechanisms of control and the communication between nerve cells, for wich they received the Nobel prize in physiology and medicine, together with John Eccles in 1963.

Their research was based on electrophysiological experiments carried out in the late 1940s and early 1950 on a giant squid axon to understand how action potentials in neurons are initiated and propagated.

From their experiments they derived a mathematical model which approximates the electrical characteristics of excitable cells such as neurons. Their key idea was to regard the cell membran and the various ion currents as an electrical circuit made up of capacitors, resistors and batteries.

Source: Wikipedia

The capacitive current across the cell membrane can be described as the sum of changes in the membrane voltage \(V_m\) and ion currents caused primarily by sodium (Na) and potassium (K) and other leakages (L), mainly chloride ions. The ion currents are defined by their conductances (\(g\), with the Na and K conductances being voltage depended), their equilibrium potentials (\(E\)) and how the channel gates open and close (\(m, n, h\)):

\[ \begin{aligned}

I_{ext} &= C_m \frac{dV_m}{dt} + I_{ion} \\

& = C_m \frac{dV_m}{dt} + g_{Na} m^3 h(V-E_{Na}) + g _K n^4 (V – E_K) + g_L (V – E_L)

\end{aligned}

\]

The standard Hodgkin-Huxley model expands into a set of four differential equations:

\[ \begin{aligned}

C \frac{dV}{dt} & = I – g_{Na} m^3 h(V-E_{Na}) – g _K n^4 (V – E_K) -g_L (V – E_L)\\

\frac{dm}{dt} & = a_m(V) (1 – m) – b_m(V)m\\

\frac{dh}{dt} & = a_h(V)(1 – h) – b_h(V)h\\

\frac{dn}{dt} & = a_n(V) (1 – n) – b_n(V)n\\

\\

a_m(V) & = 0.1(V+40)/(1 – \exp(-(V+40)/10)) \\

b_m(V) & = 4 \exp(-(V + 65)/18) \\

a_h(V) & = 0.07 \exp(-(V+65)/20) \\

b_h(V) & = 1/(1 + \exp(- (V + 35)/10))\\

a_n(V) & = 0.01 (V + 55)/(1 – \exp(-(V+55)/10))\\

b_n(V) & = 0.125 \exp(-(V + 65)/80)

\end{aligned}

\]

To model and simulate those differential equations in R I use the `simecol`

package. The package comes with a great vignette which gives a good introduction, and you may also find my recent LondonR talk helpful.

`library(simecol)`

## Hodkin-Huxley model

HH

Let’s run and plot the model: `HH `

From the initial state I observe a tiny stimulus which reverts quickly back to the resting state. So let’s increase the external stimulus in steps to observe its impact on the membrane voltage: `times(HH)["to"] `

Now, this is exciting, as I increase the external stimulus an action potential is generated. Increasing the stimulus further results in a constant firing of the neuron, or in other words, the model is going through a Hopf-bifurcation.

I think it is absolutely remarkable what Hodgkin and Huxley achieved 60 years ago. They could demonstrate that numerical integration of their model could reproduce all the key biophysical properties of the action potential. And what seems so easy on a computer with R or other software, such as XPP/XPPAUT today, must have been a lot of work in the late 40s, early 50s of the 20th century.

**leave a comment**for the author, please follow the link and comment on their blog:

**mages' blog**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.