File: examples-frompapers-computing with neural synchrony-duration selectivity_Fig1D_duration_selectivity.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 (124 lines) | stat: -rw-r--r-- 3,794 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
.. currentmodule:: brian

.. index::
   pair: example usage; IdentityConnection
   pair: example usage; plot
   pair: example usage; run
   pair: example usage; xlim
   pair: example usage; show
   pair: example usage; rate
   pair: example usage; subplot
   pair: example usage; xlabel
   pair: example usage; linspace
   pair: example usage; exp
   pair: example usage; ylabel
   pair: example usage; mean
   pair: example usage; NeuronGroup
   pair: example usage; ylim
   pair: example usage; SpikeCounter
   pair: example usage; StateMonitor

.. _example-frompapers-computing with neural synchrony-duration selectivity_Fig1D_duration_selectivity:

Example: Fig1D_duration_selectivity (frompapers/computing with neural synchrony/duration selectivity)
=====================================================================================================

Brette R (2012). Computing with neural synchrony. PLoS Comp Biol. 8(6): e1002561. doi:10.1371/journal.pcbi.1002561
------------------------------------------------------------------------------------------------------------------
Figure 1C,D. Duration selectivity.
(takes about 1 min)

Caption (Fig. 1C,D).
A postsynaptic neuron receives inputs from A and B. It is
more likely to fire when the stimulus in the synchrony receptive field of
A and B.

::

    from brian import *
    
    # Parameters and equations of the rebound neurons
    Vt=-55*mV
    Vr=-70*mV
    El=-35*mV
    EK=-90*mV
    Va=Vr
    ka=5*mV
    gmax2=2
    tau=20*ms
    ginh_max=5.
    tauK2=100*ms
    N=10000 # number of neurons (= different durations)
    rest_time=1*second # initial time
    tmin=rest_time-20*ms #for plots
    tmax=rest_time+600*ms
    
    eqs='''
    dv/dt=(El-v+(gmax*gK+gmax2*gK2+ginh)*(EK-v))/tau : volt
    dgK/dt=(gKinf-gK)/tauK : 1 # IKLT
    dgK2/dt=-gK2/tauK2 : 1 # Delayed rectifier
    gKinf=1./(1+exp((Va-v)/ka)) : 1
    duration : second
    ginh = ginh_max*((t>rest_time) & (t<(rest_time+duration))) : 1
    tauK : ms
    gmax : 1
    theta : volt # threshold
    '''
    
    neurons=NeuronGroup(2*N,model=eqs,threshold='v>theta',reset='v=Vr;gK2=1')
    neurons.v=Vr
    neurons.theta=Vt
    neurons.gK=1./(1+exp((Va-El)/ka))
    # Neuron A, duplicated to simulate multiple input durations simultaneously
    neuronsA=neurons[:N]
    neuronsA.tauK=400*ms
    neuronsA.gmax=1
    neuronsA.theta=-55*mV
    neuronsA.duration=linspace(100*ms,1*second,N)
    # Neuron B, duplicated to simulate multiple input durations simultaneously
    neuronsB=neurons[N:]
    neuronsB.tauK=100*ms
    neuronsB.gmax=1.5
    neuronsB.theta=-54*mV
    neuronsB.duration=linspace(100*ms,1*second,N)
    
    # Noisy coincidence detectors
    tau_cd=5*ms
    tau_n=tau_cd
    sigma=0.2 # noise s.d. in units of the threshold
    eqs_post='''
    dv/dt=(n-v)/tau_cd : 1
    dn/dt=-n/tau_n+sigma*(2/tau_n)**.5*xi : 1
    '''
    postneurons=NeuronGroup(N,model=eqs_post,threshold=1,reset=0)
    CA=IdentityConnection(neuronsA,postneurons,'v',weight=0.5)
    CB=IdentityConnection(neuronsB,postneurons,'v',weight=0.5)
    
    spikes=SpikeCounter(postneurons)
    M=StateMonitor(postneurons,'v',record=N/3)
    
    run(rest_time+1.1*second,report='text')
    
    # Figure
    subplot(121) # Fig. 1C, example trace
    plot(M.times/ms,M[N/3],'k')
    xlim(1350,1500)
    ylim(-.3,1)
    xlabel('Time (ms)')
    ylabel('V')
    
    subplot(122) # Fig. 1D, duration tuning curve
    count=spikes.count
    # Smooth the tuning curve
    window=200
    rate=zeros(len(count)-window)
    for i in range(0,len(count)-window):
        rate[i]=mean(count[i:i+window])
    plot((neuronsA.duration[window/2:-window/2]/ms)[::10],rate[::10],'k')
    xlim(0,1000)
    ylim(0,0.5)
    xlabel('Duration (ms)')
    ylabel('Spiking probability')
    show()