File: examples-misc_van_rossum_metric.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 (70 lines) | stat: -rw-r--r-- 1,865 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
.. currentmodule:: brian

.. index::
   pair: example usage; NeuronGroup
   pair: example usage; run
   pair: example usage; trace
   pair: example usage; figure
   pair: example usage; show
   pair: example usage; raster_plot
   pair: example usage; imshow
   pair: example usage; colorbar
   pair: example usage; SpikeMonitor
   pair: example usage; linspace
   pair: example usage; title
   pair: example usage; VanRossumMetric
   pair: example usage; StateMonitor

.. _example-misc_van_rossum_metric:

Example: van_rossum_metric (misc)
=================================

Example of how to use the van Rossum metric. 

The VanRossumMetric function, which is defined as a monitor and therefore works online, 
computes  the metric between every neuron in a given population. The present example show 
the concept of phase locking:  N neurons  are driven by  sinusoidal inputs with different amplitude.

 Use: output=VanRossumMetric(source, tau=4 * ms)
 
 source is a NeuronGroup of N neurons
 tau is the time constant of the kernel used in the metric
 
 output is a monitor with attribute distance which is the distance matrix between the neurons in source

::

    from brian import *
    from time import time
    
    tau=20*ms
    N=100
    b=1.2 # constant current mean, the modulation varies
    f=10*Hz
    delta =2*ms
    
    eqs='''
    dv/dt=(-v+a*sin(2*pi*f*t)+b)/tau : 1
    a : 1
    '''
    
    neurons=NeuronGroup(N,model=eqs,threshold=1,reset=0)
    neurons.v=rand(N)
    neurons.a=linspace(.05,0.75,N)
    S=SpikeMonitor(neurons)
    trace=StateMonitor(neurons,'v',record=50)
    
    van_rossum_metric=VanRossumMetric(neurons, tau=4 * ms)
    
    run(1000*ms)
    
    raster_plot(S)
    title('Raster plot')
    
    figure()
    title('Distance matrix between spike trains')
    imshow(van_rossum_metric.distance)
    colorbar()
    show()