File: examples-misc_adaptive.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 (47 lines) | stat: -rw-r--r-- 1,108 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
.. currentmodule:: brian

.. index::
   pair: example usage; NeuronGroup
   pair: example usage; run
   pair: example usage; plot
   pair: example usage; show
   pair: example usage; Connection
   pair: example usage; PoissonGroup
   pair: example usage; SpikeMonitor
   pair: example usage; StateMonitor

.. _example-misc_adaptive:

Example: adaptive (misc)
========================

An adaptive neuron model

::

    from brian import *
    
    PG = PoissonGroup(1, 500 * Hz)
    eqs = '''
    dv/dt = (-w-v)/(10*ms) : volt # the membrane equation
    dw/dt = -w/(30*ms) : volt # the adaptation current
    '''
    # The adaptation variable increases with each spike
    IF = NeuronGroup(1, model=eqs, threshold=20 * mV,
                     reset='''v  = 0*mV
                              w += 3*mV ''')
    
    C = Connection(PG, IF, 'v', weight=3 * mV)
    
    MS = SpikeMonitor(PG, True)
    Mv = StateMonitor(IF, 'v', record=True)
    Mw = StateMonitor(IF, 'w', record=True)
    
    run(100 * ms)
    
    plot(Mv.times / ms, Mv[0] / mV)
    plot(Mw.times / ms, Mw[0] / mV)
    
    show()