Hodgkin-Huxley model#
In this section you will interact with the famous Hodgkin-Huxley (HH) Neuron Model. This was a mathematical model of a neuron’s membrane potential based on careful experiments that studied the electrical properties of a squid’s giant axon, which is visible to the naked eye.
Image credit: National Institute of Health, USA
The HH Model is more realistic than many commonly used models of neurons. and captures the rich dynamics of a neuron’s membrane as a function of its transmembrane conductances.
!pip install interact --quiet
!pip install interactive --quiet
import matplotlib.pyplot as plt
import numpy as np
import ipywidgets as widgets
from ipywidgets import interact, interactive, fixed, interact_manual
from IPython.display import display
def HH_model(C,Gna,Gk,Gleak,Iin):
dt = 0.5; # all time units in ms
t_end = 1000;
num_timepoints = t_end/dt;
time = int(num_timepoints);
# C = 1; # (muF/cm^2)
# Gna = 2.0; # (2mS/cm^2)
# Gk = 1.44; # (1.44mS/cm^2)
# Gleak = 0.2; # (0.2mS/cm^2)
Ena = 50.0; # 50(mV)
Ek = -80.0; # -77(mV)
Eleak = -65.0; # -54(mV)
kn = 15.0; # (mV)
km = 7.0; # (mV);
tau = 10.0; # (ms)
Vn = -45.0; # (mV)
n = np.zeros((time,1)); # this is our gating parameter
V = Eleak*np.ones((time,1)); # this will store our membrane potential
# Iin = 2.0; # and this is an input current (muA/cm^2)
x = np.arange(1, time, 1, dtype=int);
for t in x:
minf = 1/(1+np.exp((-40.0-V[t-1])/km));
ninf = 1/(1+np.exp((Vn-V[t-1])/kn));
h = 0.89 - 1.1*n[t-1];
dvdt = (1/C)*(-Gna*minf**3*h*(V[t-1]-Ena) - Gk*n[t-1]**4*(V[t-1]-Ek) - Gleak*(V[t-1]-Eleak) + Iin);
dndt = (1/tau)*(ninf - n[t-1]);
V[t] = V[t-1] + dvdt*dt;
n[t] = n[t-1] + dndt*dt;
t = np.arange(0, t_end, 0.5, dtype=float);
plt.plot(t,V)
plt.ylabel('Voltage (mV)');
plt.xlabel('Time (ms)');
plt.ylim(-100,100);
plt.show
interact_manual(HH_model, C = widgets.FloatSlider(
value=1.0,
min=0.1,
max=2.0,
step=0.1,
continuous_update=False,
style = {'description_width': 'initial'},
description='C membrane capacitance'),
Gna = widgets.FloatSlider(
value=2.0,
min=0.0,
max=5.0,
step=0.1,
continuous_update=False,
style = {'description_width': 'initial'},
description='gNa conductance'),
Gk = widgets.FloatSlider(
value=1.44,
min=0.0,
max=5.0,
step=0.1,
continuous_update=False,
style = {'description_width': 'initial'},
description='gK conductance'),
Gleak = widgets.FloatSlider(
value=0.2,
min=0.0,
max=1.0,
step=0.1,
continuous_update=False,
style = {'description_width': 'initial'},
description='gLeak conductance'),
Iin = widgets.FloatSlider(
value=2.0,
min=0.0,
max=10.0,
step=0.1,
continuous_update=False,
description='Input current')
)
<function __main__.HH_model(C, Gna, Gk, Gleak, Iin)>