Debian Codegraph @

examples/COBAHH.py

raw
1 #!/usr/bin/env python
2 # -*- coding: UTF-8 -*-
3 """
4 This is an implementation of a benchmark described
5 in the following review paper:
6
7 Simulation of networks of spiking neurons: A review of tools and strategies (2006).
8 Brette, Rudolph, Carnevale, Hines, Beeman, Bower, Diesmann, Goodman, Harris, Zirpe,
9 Natschläger, Pecevski, Ermentrout, Djurfeldt, Lansner, Rochel, Vibert, Alvarez, Muller,
10 Davison, El Boustani and Destexhe.
11 Journal of Computational Neuroscience
12
13 Benchmark 3: random network of HH neurons with exponential synaptic conductances
14
15 Clock-driven implementation
16 (no spike time interpolation)
17
18 R. Brette - Dec 2007
19 """
20
21 from brian2 import *
22
23 # Parameters
24 area = 20000*umetre**2
25 Cm = (1*ufarad*cm**-2) * area
26 gl = (5e-5*siemens*cm**-2) * area
27
28 El = -60*mV
29 EK = -90*mV
30 ENa = 50*mV
31 g_na = (100*msiemens*cm**-2) * area
32 g_kd = (30*msiemens*cm**-2) * area
33 VT = -63*mV
34 # Time constants
35 taue = 5*ms
36 taui = 10*ms
37 # Reversal potentials
38 Ee = 0*mV
39 Ei = -80*mV
40 we = 6*nS # excitatory synaptic weight
41 wi = 67*nS # inhibitory synaptic weight
42
43 # The model
44 eqs = Equations('''
45 dv/dt = (gl*(El-v)+ge*(Ee-v)+gi*(Ei-v)-
46 g_na*(m*m*m)*h*(v-ENa)-
47 g_kd*(n*n*n*n)*(v-EK))/Cm : volt
48 dm/dt = alpha_m*(1-m)-beta_m*m : 1
49 dn/dt = alpha_n*(1-n)-beta_n*n : 1
50 dh/dt = alpha_h*(1-h)-beta_h*h : 1
51 dge/dt = -ge*(1./taue) : siemens
52 dgi/dt = -gi*(1./taui) : siemens
53 alpha_m = 0.32*(mV**-1)*4*mV/exprel((13*mV-v+VT)/(4*mV))/ms : Hz
54 beta_m = 0.28*(mV**-1)*5*mV/exprel((v-VT-40*mV)/(5*mV))/ms : Hz
55 alpha_h = 0.128*exp((17*mV-v+VT)/(18*mV))/ms : Hz
56 beta_h = 4./(1+exp((40*mV-v+VT)/(5*mV)))/ms : Hz
57 alpha_n = 0.032*(mV**-1)*5*mV/exprel((15*mV-v+VT)/(5*mV))/ms : Hz
58 beta_n = .5*exp((10*mV-v+VT)/(40*mV))/ms : Hz
59 ''')
60
61 P = NeuronGroup(4000, model=eqs, threshold='v>-20*mV', refractory=3*ms,
62 method='exponential_euler')
63 Pe = P[:3200]
64 Pi = P[3200:]
65 Ce = Synapses(Pe, P, on_pre='ge+=we')
66 Ci = Synapses(Pi, P, on_pre='gi+=wi')
67 Ce.connect(p=0.02)
68 Ci.connect(p=0.02)
69
70 # Initialization
71 P.v = 'El + (randn() * 5 - 5)*mV'
72 P.ge = '(randn() * 1.5 + 4) * 10.*nS'
73 P.gi = '(randn() * 12 + 20) * 10.*nS'
74
75 # Record a few traces
76 trace = StateMonitor(P, 'v', record=[1, 10, 100])
77 run(1 * second, report='text')
78 plot(trace.t/ms, trace[1].v/mV)
79 plot(trace.t/ms, trace[10].v/mV)
80 plot(trace.t/ms, trace[100].v/mV)
81 xlabel('t (ms)')
82 ylabel('v (mV)')
83 show()