File: tutorial_1b_counting_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 (63 lines) | stat: -rw-r--r-- 1,751 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
.. currentmodule:: brian

Tutorial 1b: Counting spikes
****************************

In the previous part of the tutorial we looked at the following:

* Importing the Brian module into Python
* Using quantities with units
* Defining a neuron model by its differential equation
* Creating a group of neurons
* Running a network

In this part, we move on to looking at the output of the network.
    
The first part of the code is the same.

  ::

    from brian import *
    
    tau = 20 * msecond        # membrane time constant
    Vt = -50 * mvolt          # spike threshold
    Vr = -60 * mvolt          # reset value
    El = -60 * mvolt          # resting potential (same as the reset)
    
    G = NeuronGroup(N=40, model='dV/dt = -(V-El)/tau : volt',
                  threshold=Vt, reset=Vr)

Counting spikes
~~~~~~~~~~~~~~~

Now we would like to have some idea of what this network is
doing. In Brian, we use monitors to keep track of the behaviour
of the network during the simulation. The simplest monitor of
all is the :class:`SpikeMonitor`, which just records the spikes from a
given :class:`NeuronGroup`.

  ::

    M = SpikeMonitor(G)

Results
~~~~~~~

Now we run the simulation as before:

  ::

    run(1 * second)

And finally, we print out how many spikes there were:

  ::

    print M.nspikes

So what's going on? Why are there 40 spikes? Well, the answer is
that the initial value of the membrane potential for every neuron
is 0 mV, which is above the threshold potential of -50 mV and so there
is an initial spike at t=0 and then it resets to -60 mV and stays there,
below the threshold potential. In the next part of this tutorial, we'll
make sure there are some more spikes to see.