File: tutorial_1f_recording_spikes.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 (51 lines) | stat: -rw-r--r-- 1,514 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
.. currentmodule:: brian

Tutorial 1f: Recording spikes
*****************************

In the previous part of the tutorial, we defined a network with
not entirely trivial behaviour, and printed the number of spikes.
In this part, we'll record every spike that the network generates
and display a raster plot of them. We start as before:

  ::

    from brian import *
    
    tau = 20 * msecond        # membrane time constant
    Vt = -50 * mvolt          # spike threshold
    Vr = -60 * mvolt          # reset value
    El = -49 * mvolt          # resting potential (same as the reset)
    psp = 0.5 * mvolt         # postsynaptic potential size
    
    G = NeuronGroup(N=40, model='dV/dt = -(V-El)/tau : volt',
                  threshold=Vt, reset=Vr)
    
    C = Connection(G, G)
    C.connect_random(sparseness=0.1, weight=psp)
    
    M = SpikeMonitor(G)
    
    G.V = Vr + rand(40) * (Vt - Vr)
    
    run(1 * second)
    
    print M.nspikes

Having run the network, we simply use the :func:`raster_plot` function
provided by Brian. After creating plots, we have to use the
``show()`` function to display them. This function is from the
PyLab module that Brian uses for its built in plotting
routines.

  ::

    raster_plot()
    show()


.. image:: images/tutorials/1f.jpg

As you can see, despite having introduced some randomness into
our network, the output is very regular indeed. In the next part
we introduce one more way to plot the output of a network.