Hodgkin-Huxley Neuron

In this notebook we will use Python to simulate the Hodgkin-Huxley (HH) neuron model. This model is arguably the most important computational model in neuroscience. We’ll focus here on simulating this model and understanding its pieces.

1 Preliminaries

Before beginning, let’s load in the Python packages we’ll need:

In addition, let’s import the functions we’ll need to simulate the HH model, which are available on this repository:

2 The Hodgkin-Huxley (HH) equation code.

To start, let’s examine the code for the HH model. To do so, visit the raw code avaiable here.

Q: Examine this code. Can you make sense of it? Can you identify the gating variables? The rate functions? The equations that define the dynamics? We’ll answer these questions in this in notebook, but try so on your own first.

Whenever examining code, it’s useful to consider the inputs to the code, and the outputs produced by the code. There are two inputs to HH0:

  • I0 = the current we inject to the neuron.
  • T0 = the total time of the simulation in [ms].

And there are five outputs:

  • V = the voltage of neuron.
  • m = activation variable for Na-current.
  • h = inactivation variable for Na-current.
  • n = activation variable for K-current.
  • t = the time axis of the simulation (useful for plotting).

3 At low input current (I0), examine the HH dynamics.

To understand how the HH model works, we’ll start by focusing on the case when I0 is small. Let’s fix the input current to zero,

and let’s simulate the model for 100 ms,

We’ve now defined both inputs to the HH function, and can execute it, as follows,

Notice that the function returns five outputs, which we assign to the variables V, m, h, n, and t.

Q: What are the dynamics of the voltage (variable V) resulting from this simulation?
HINT: Plot V vs t.

Q: What are the dynamics of the gating variables (m, h, n) resulting from this simulation?
HINT: Plot them!

Q: What are the final values (after the 100 ms of simulation) of V, m, h, and n?

4 At high input current (I0), examine the HH dynamics of a spike.

Let’s now increase the input current to the HH model and get this model to generate repeated spiking activity. To do so, let’s set,

We can now simulate this model,

Q: What happens to the dynamics?
HINT: Plot V vs t.

Observations: You should have found that, at this value of input current, the model generates repeated spikes.


Let’s now explore how the combined gates and dynamics evolve. To do so, let’s start by focusing our plot on a single spike. As a first step, let’s plot the voltage, and choose the time axis to focus on a single spike,

We’ve now plotted the voltage dynamics for a single spike (and colored the curve black).

Let’s now plot the three gating variables. To do so, we’ll make another plot.

Let’s start by displaying the gating variable m over the same x-limits,

Notice that, in the call to plot we included the input label. This will be useful when we create a legend.

Within this subplot, we can also simultaneously show the gating variables h and n, with the x-axis labeled.

Let’s also add a legend to help us keep track of the different curves:

Q: Using the figure you created above, describe how the gates swing open and closed during a spike.

ASIDE: Here’s a nice plotting trick, to link the x-axes of our two subfigures. Linking the axes is useful so that, when we zoom or move one subfigure, the other subfigure will match the x-axis.

Now, in the figure, you may use the pan/zoom tool to adjust the linked subplots.

5 At high input current (I0), describe the dynamics of the conductances.

We have so far explored how the three gates m, h, and n evolve during a spike. By combining these terms, we can visualize how the conductances evolve during a spike. To do so, let’s stick with the simulation results we generated in the previous section, and focus our plot on a single spike,

Now, to plot the conductances, let’s define three new variables,

Q: Where do these terms come from?

Then, let’s plot these conductances,

Q: How do the conductances evolve during a spike?

At high input current (I0), describe the dynamics of the currents. In the previous section, we explored how the three conductances (gNa, gK, gL) evolve during a spike.

Let’s now visualize how the ionic currents evolve during a spike.

To do so, let’s stick with the same settings used in the previous section and examine the same simulation result. Again, we’ll focus our plot on a single spike.

Now, to plot the current, let’s define the new variables,

Q: How do the conductances evolve during a spike?

Q: You may notice a small, transient decrease in the sodium current INa near 47 ms. What causes this?

6 Discussion

  1. How is the HH model different from / similar to the IF and LIF models?
  2. What are the ion species simulated in the HH model?
  3. Which ion species is fastest / slowest?
  4. How many variables are in the HH model? Define each.
  5. Sketch the model equations, in schematic form, to capture the “essence” of the behavior (don’t worry about the detailed values for parameters).
  6. Which gating variables are depolarization activated / depolarization inactivated?
  7. Sketch the steady-state curves for the gating variables.
  8. Consider the current: I_K=g_K n^4 (E_K-V)
    1. Define each term.
    2. How does this current behave for different values of V?
  9. Consider the current: I_Na=g_Na m^3 h (E_Na-V)
    1. Define each term.
    2. How does this current behave for different values of V?

7 Challenges

  1. Describe the dynamics during an action potential in the HH model. How does the voltage change? How do the gates open and close? How do the ions flow?
  2. Determine how the firing rate of the HH model varies with input current I. Plot the firing rate versus I (i.e., plot the “f-I curve”).
  3. How does the firing rate of the HH model change as you increase the potassium conductance? Provide a “simulation” explanation and a “physical” explanation.
  4. How does the firing rate of the HH model change as you increase sodium conductance? Provide a “simulation” explanation and a “physical” explanation.
  5. BONUS: Use the forward and backward rate functions (\(\alpha\) and \(\beta\)) in the HH model (see code) to plot the steady state function and time constant for each channel (\(m\), \(h\), \(n\)) versus voltage. In other words, create Figure 1 in the Hodgkin-Huxley Cheat Sheet.