File: examples-synapses_delayed_stdp.txt

package info (click to toggle)
brian 1.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, stretch
  • size: 23,436 kB
  • sloc: python: 68,707; cpp: 29,040; ansic: 5,182; sh: 111; makefile: 61
file content (74 lines) | stat: -rw-r--r-- 1,867 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
.. currentmodule:: brian

.. index::
   pair: example usage; subplot
   pair: example usage; plot
   pair: example usage; run
   pair: example usage; show
   pair: example usage; PoissonGroup
   pair: example usage; Synapses
   pair: example usage; NeuronGroup
   pair: example usage; StateMonitor

.. _example-synapses_delayed_stdp:

Example: delayed_stdp (synapses)
================================

Delayed STDP

::

    from brian import *
    import time
    
    N = 1
    taum = 10 * ms
    taupre = 20 * ms
    taupost = taupre
    Ee = 0 * mV
    vt = -54 * mV
    vr = -74 * mV
    El = -74 * mV
    taue = 5 * ms
    F = 20 * Hz
    dApre = .1
    dApost = -dApre * taupre / taupost * 2.
    
    eqs_neurons = '''
    dv/dt=(ge*(Ee-vr)+El-v)/taum : volt   # the synaptic current is linearized
    dge/dt=-ge/taue : 1
    '''
    
    input = PoissonGroup(N, rates=F)
    neurons = NeuronGroup(1, model=eqs_neurons, threshold=vt, reset=vr)
    S = Synapses(input, neurons,
                 model='''w:1
                          dApre/dt=-Apre/taupre : 1 #(event-driven)
                          dApost/dt=-Apost/taupost : 1 #(event-driven)''',
                 pre=('ge+=w',
                      '''w=clip(w+Apost,0,inf)
                         Apre+=dApre'''),
                 post='''Apost+=dApost
                         w=clip(w+Apre,0,inf)''')
    neurons.v = vr
    S[:,:]=True
    S.w=10
    S.delay[1][0,0]=3*ms # delayed trace (try 0 ms to see the difference)
    
    M=StateMonitor(S,'w',record=0)
    Mpre=StateMonitor(S,'Apre',record=0)
    Mpost=StateMonitor(S,'Apost',record=0)
    Mv=StateMonitor(neurons,'v',record=0)
    
    run(10*second,report='text')
    
    subplot(211)
    plot(M.times/ms,M[0])
    plot(M.times/ms,Mpre[0],'r')
    plot(M.times/ms,Mpost[0],'k')
    subplot(212)
    plot(Mv.times/ms,Mv[0])
    show()