Debian Codegraph @

examples/compartmental/bipolar_with_inputs2.py

raw
1 """
2 A pseudo MSO neuron, with two dendrites (fake geometry).
3 There are synaptic inputs.
4
5 Second method.
6 """
7 from brian2 import *
8
9 # Morphology
10 morpho = Soma(30*um)
11 morpho.L = Cylinder(diameter=1*um, length=100*um, n=50)
12 morpho.R = Cylinder(diameter=1*um, length=100*um, n=50)
13
14 # Passive channels
15 gL = 1e-4*siemens/cm**2
16 EL = -70*mV
17 Es = 0*mV
18 taus = 1*ms
19 eqs='''
20 Im = gL*(EL-v) : amp/meter**2
21 Is = gs*(Es-v) : amp (point current)
22 dgs/dt = -gs/taus : siemens
23 '''
24
25 neuron = SpatialNeuron(morphology=morpho, model=eqs,
26 Cm=1*uF/cm**2, Ri=100*ohm*cm, method='exponential_euler')
27 neuron.v = EL
28
29 # Regular inputs
30 stimulation = NeuronGroup(2, 'dx/dt = 300*Hz : 1', threshold='x>1', reset='x=0',
31 method='euler')
32 stimulation.x = [0, 0.5] # Asynchronous
33
34 # Synapses
35 w = 20*nS
36 S = Synapses(stimulation, neuron, on_pre='gs += w')
37 S.connect(i=0, j=morpho.L[99.9*um])
38 S.connect(i=1, j=morpho.R[99.9*um])
39
40 # Monitors
41 mon_soma = StateMonitor(neuron, 'v', record=[0])
42 mon_L = StateMonitor(neuron.L, 'v', record=True)
43 mon_R = StateMonitor(neuron, 'v', record=morpho.R[99.9*um])
44
45 run(50*ms, report='text')
46
47 subplot(211)
48 plot(mon_L.t/ms, mon_soma[0].v/mV, 'k')
49 plot(mon_L.t/ms, mon_L[morpho.L[99.9*um]].v/mV, 'r')
50 plot(mon_L.t/ms, mon_R[morpho.R[99.9*um]].v/mV, 'b')
51 ylabel('v (mV)')
52 subplot(212)
53 for i in [0, 5, 10, 15, 20, 25, 30, 35, 40, 45]:
54 plot(mon_L.t/ms, mon_L.v[i, :]/mV)
55 xlabel('Time (ms)')
56 ylabel('v (mV)')
57 show()