#!pip install ANNarchy
Hodgkin Huxley neuron
Simple Hodgkin-Huxley neuron.
import numpy as np
import matplotlib.pyplot as plt
import ANNarchy as ann
= ann.Neuron(
HH
= dict(
parameters = 1.0, # Capacitance
C = -59.387, # Leak voltage
VL = -82.0, # Potassium reversal voltage
VK = 45.0, # Sodium reveral voltage
VNa = 36.0, # Maximal Potassium conductance
gK = 120.0, # Maximal Sodium conductance
gNa = 0.3, # Leak conductance
gL = 30.0, # Threshold for spike emission
vt = 0.0, # External current
I
),
= [
equations # Previous membrane potential
'prev_V = V',
# Voltage-dependency parameters
"""
an = 0.01 * (V + 60.0) / (1.0 - exp(-0.1* (V + 60.0) ) )
am = 0.1 * (V + 45.0) / (1.0 - exp (- 0.1 * ( V + 45.0 )))
ah = 0.07 * exp(- 0.05 * ( V + 70.0 ))
bn = 0.125 * exp (- 0.0125 * (V + 70.0))
bm = 4.0 * exp (- (V + 70.0) / 80.0)
bh = 1.0/(1.0 + exp (- 0.1 * ( V + 40.0 )) )
""",
# Alpha/Beta functions
'dn/dt = an * (1.0 - n) - bn * n', init = 0.3, method='midpoint'),
ann.Variable('dm/dt = am * (1.0 - m) - bm * m', init = 0.0, method='midpoint'),
ann.Variable('dh/dt = ah * (1.0 - h) - bh * h', init = 0.6, method='midpoint'),
ann.Variable(
# Membrane equation
'C * dV/dt = gL * (VL - V ) + gK * n**4 * (VK - V) + gNa * m**3 * h * (VNa - V) + I', method='midpoint'),
ann.Variable(
],
= """
spike # Spike is emitted when the membrane potential crosses the threshold from below
(V > vt) and (prev_V <= vt)
""",
= """
reset # Nothing to do, it is built-in...
"""
)
= ann.Network(dt=0.01)
net
= net.create(neuron=HH, geometry=1)
pop = -50.0
pop.V
compile()
net.
= net.monitor(pop, ['spike', 'V', 'n', 'm', 'h'])
m
# Preparation
100.0)
net.simulate(# Current impulse for 1 ms
= 200.0
pop.I 1.0)
net.simulate(# Reset
= 0.0
pop.I 100.0)
net.simulate(
= m.get()
data
= int(90.0/net.dt)
tstart = int(120.0/net.dt)
tstop
=(15, 10))
plt.figure(figsize2,2,1)
plt.subplot(90.0 + net.dt*np.arange(tstop-tstart), data['V'][tstart:tstop, 0])
plt.plot('V')
plt.title(2,2,2)
plt.subplot(90.0 + net.dt*np.arange(tstop-tstart), data['n'][tstart:tstop, 0])
plt.plot('n')
plt.title(0.0, 1.0))
plt.ylim((2,2,3)
plt.subplot(90.0 + net.dt*np.arange(tstop-tstart), data['m'][tstart:tstop, 0])
plt.plot('m')
plt.title(0.0, 1.0))
plt.ylim((2,2,4)
plt.subplot(90.0 + net.dt*np.arange(tstop-tstart), data['h'][tstart:tstop, 0])
plt.plot('h')
plt.title(0.0, 1.0))
plt.ylim(( plt.show()
ANNarchy 5.0 (5.0.0) on darwin (posix).
Compiling network 1... OK