File: examples-synapses_STDP1.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 (83 lines) | stat: -rw-r--r-- 2,095 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
75
76
77
78
79
80
81
82
83
.. currentmodule:: brian

.. index::
   pair: example usage; subplot
   pair: example usage; plot
   pair: example usage; run
   pair: example usage; PopulationRateMonitor
   pair: example usage; show
   pair: example usage; rate
   pair: example usage; hist
   pair: example usage; PoissonGroup
   pair: example usage; Synapses
   pair: example usage; NeuronGroup

.. _example-synapses_STDP1:

Example: STDP1 (synapses)
=========================

Spike-timing dependent plasticity
Adapted from Song, Miller and Abbott (2000) and Song and Abbott (2001)

This simulation takes a long time!

::

    from brian import *
    from time import time
    
    N = 1000
    taum = 10 * ms
    taupre = 20 * ms
    taupost = taupre
    Ee = 0 * mV
    vt = -54 * mV
    vr = -60 * mV
    El = -74 * mV
    taue = 5 * ms
    F = 15 * Hz
    gmax = .01
    dApre = .01
    dApost = -dApre * taupre / taupost * 1.05
    dApost *= gmax
    dApre *= gmax
    
    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
                 Apre:1
                 Apost:1''',
                 pre='''ge+=w
                 Apre=Apre*exp((lastupdate-t)/taupre)+dApre
                 Apost=Apost*exp((lastupdate-t)/taupost)
                 w=clip(w+Apost,0,gmax)''',
                 post='''
                 Apre=Apre*exp((lastupdate-t)/taupre)
                 Apost=Apost*exp((lastupdate-t)/taupost)+dApost
                 w=clip(w+Apre,0,gmax)''')
    neurons.v = vr
    S[:,:]=True
    S.w='rand()*gmax'
    
    rate = PopulationRateMonitor(neurons)
    
    start_time = time()
    run(100 * second, report='text')
    print "Simulation time:", time() - start_time
    
    subplot(311)
    plot(rate.times / second, rate.smooth_rate(100 * ms))
    subplot(312)
    plot(S.w[:] / gmax, '.')
    subplot(313)
    hist(S.w[:] / gmax, 20)
    show()