3. Numerical integration of the HH model of the squid axon

Book chapters

See Chapter 2 Section 2 on general information about the Hodgkin-Huxley equations and models.

Python classes

The hodgkin_huxley.HH module contains all code required for this exercise. At the beginning of your exercise solutions, import the contained functions by running

from neurodynex.hodgkin_huxley.HH import *

You can then simply run the exercise functions by executing

HH_Step()  # example Step-current injection
HH_Sinus()  # example Sinus-current injection
HH_Ramp()  # example Ramp-current injection

3.1. Exercise

Use the function HH_Step() to simulate a HH neuron stimulated by a current step of a given amplitude. The goal of this exercise is to modify the provided python functions and use the numpy and matplotlib packages to answer the following questions.

3.1.1. Question

What is the lowest step current amplitude for generating at least one spike? Hint: use binary search on I_amp, with a \(0.1\mu A\) resolution.

3.1.2. Question

What is the lowest step current amplitude to generate repetitive firing?

3.1.3. Question

Look at HH_Step() for I_amp = -5 and I_amp = -1. What is happening here? To which gating variable do you attribute this rebound spike?

3.2. Exercise

Use the function HH_Ramp() to simulate a HH neuron stimulated by a ramping curent.

3.2.1. Question

What is the minimum current required to make a spike when the current is slowly increased (ramp current waveform) instead of being increased suddenly?

3.3. Exercise

To solve this exercise, you will need to change the actual implementation of the model. Download directly the source file HH.py. When starting Python in the directory containing the downloaded file, you run functions from it directly as follows:

import HH  # import the HH module, i.e. the HH.py file
HH.HH_Step()  # access the LIF_Step function in HH.py

Then use any text editor to make changes in the HH.py file.


You might have to reload the module for changes to become active - quitting and restarting the python interpreter reloads all modules. Alternatively, you can also force a reload by typing


For automatic reloading you can also run ipython instead of python and set the autoreload flag. For this, make sure you have ipython installed - if you have followed the setup instructions for anaconda/miniconda this should already work.

3.3.1. Question

What is the current threshold for repetitive spiking if the density of sodium channels is increased by a factor of 1.5? To solve this, change the maximum conductance of sodium channel in HH_Neuron().