Debian Codegraph @

examples/IF_curve_Hodgkin_Huxley.py

raw
1 """
2 Input-Frequency curve of a HH model.
3
4 Network: 100 unconnected Hodgin-Huxley neurons with an input current I.
5 The input is set differently for each neuron.
6
7 This simulation should use exponential Euler integration.
8 """
9 from brian2 import *
10
11 num_neurons = 100
12 duration = 2*second
13
14 # Parameters
15 area = 20000*umetre**2
16 Cm = 1*ufarad*cm**-2 * area
17 gl = 5e-5*siemens*cm**-2 * area
18 El = -65*mV
19 EK = -90*mV
20 ENa = 50*mV
21 g_na = 100*msiemens*cm**-2 * area
22 g_kd = 30*msiemens*cm**-2 * area
23 VT = -63*mV
24
25 # The model
26 eqs = Equations('''
27 dv/dt = (gl*(El-v) - g_na*(m*m*m)*h*(v-ENa) - g_kd*(n*n*n*n)*(v-EK) + I)/Cm : volt
28 dm/dt = 0.32*(mV**-1)*4*mV/exprel((13.*mV-v+VT)/(4*mV))/ms*(1-m)-0.28*(mV**-1)*5*mV/exprel((v-VT-40.*mV)/(5*mV))/ms*m : 1
29 dn/dt = 0.032*(mV**-1)*5*mV/exprel((15.*mV-v+VT)/(5*mV))/ms*(1.-n)-.5*exp((10.*mV-v+VT)/(40.*mV))/ms*n : 1
30 dh/dt = 0.128*exp((17.*mV-v+VT)/(18.*mV))/ms*(1.-h)-4./(1+exp((40.*mV-v+VT)/(5.*mV)))/ms*h : 1
31 I : amp
32 ''')
33 # Threshold and refractoriness are only used for spike counting
34 group = NeuronGroup(num_neurons, eqs,
35 threshold='v > -40*mV',
36 refractory='v > -40*mV',
37 method='exponential_euler')
38 group.v = El
39 group.I = '0.7*nA * i / num_neurons'
40
41 monitor = SpikeMonitor(group)
42
43 run(duration)
44
45 plot(group.I/nA, monitor.count / duration)
46 xlabel('I (nA)')
47 ylabel('Firing rate (sp/s)')
48 show()