File: examples-misc_heterogeneous_delays.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 (60 lines) | stat: -rw-r--r-- 2,229 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
.. currentmodule:: brian

.. index::
   pair: example usage; subplot
   pair: example usage; plot
   pair: example usage; run
   pair: example usage; title
   pair: example usage; imshow
   pair: example usage; Connection
   pair: example usage; xlabel
   pair: example usage; ylabel
   pair: example usage; show
   pair: example usage; NeuronGroup
   pair: example usage; StateMonitor

.. _example-misc_heterogeneous_delays:

Example: heterogeneous_delays (misc)
====================================

Script demonstrating use of a :class:`Connection` with homogenenous delays

The network consists of a 'starter' neuron which fires a single spike at time
t=0, connected to 100 leaky integrate and fire neurons with different delays
for each target neuron, with the delays forming a quadratic curve centred at
neuron 50. The longest delay is 10ms, and the network is run for 40ms. At
the end, the delays are plotted above a colour plot of the membrane potential
of each of the target neurons as a function of time (demonstrating the
delays).

::

    from brian import *
    # Starter neuron, threshold is below 0 so it fires immediately, reset is below
    # threshold so it fires only once.
    G = NeuronGroup(1, model='V:1', threshold= -1.0, reset= -2.0)
    # 100 LIF neurons, no reset or threshold so they will not spike
    H = NeuronGroup(100, model='dV/dt=-V/(10*ms):volt')
    # Connection with delays, here the delays are specified as a function of (i,j)
    # giving the delay from neuron i to neuron j. In this case there is only one
    # presynaptic neuron so i will be 0.
    C = Connection(G, H, weight=5 * mV, max_delay=10 * ms,
                   delay=lambda i, j:10 * ms * (j / 50. - 1) ** 2)
    M = StateMonitor(H, 'V', record=True)
    run(40 * ms)
    subplot(211)
    # These are the delays from neuron 0 to neuron i in ms
    plot([C.delay[0, i] / ms for i in range(100)])
    ylabel('Delay (ms)')
    title('Delays')
    subplot(212)
    # M.values is an array of all the recorded values, here transposed to make
    # it fit with the plot above.
    imshow(M.values.T, aspect='auto', extent=(0, 100, 40, 0))
    xlabel('Neuron number')
    ylabel('Time (ms)')
    title('Potential')
    show()