File: examples-misc_gap_junctions.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,682 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; subplot
   pair: example usage; plot
   pair: example usage; run
   pair: example usage; PopulationRateMonitor
   pair: example usage; trace
   pair: example usage; show
   pair: example usage; raster_plot
   pair: example usage; network_operation
   pair: example usage; rate
   pair: example usage; SpikeMonitor
   pair: example usage; NeuronGroup
   pair: example usage; StateMonitor

.. _example-misc_gap_junctions:

Example: gap_junctions (misc)
=============================

Network of noisy IF neurons with gap junctions

::

    from brian import *
    
    N = 300
    v0 = 5 * mV
    tau = 20 * ms
    sigma = 5 * mV
    vt = 10 * mV
    vr = 0 * mV
    g_gap = 1. / N
    beta = 60 * mV * 2 * ms
    delta = vt - vr
    
    eqs = '''
    dv/dt=(v0-v)/tau+g_gap*(u-N*v)/tau : volt
    du/dt=(N*v0-u)/tau : volt # input from other neurons
    '''
    
    def myreset(P, spikes):
        P.v[spikes] = vr # reset
        P.v += g_gap * beta * len(spikes) # spike effect
        P.u -= delta * len(spikes)
    
    group = NeuronGroup(N, model=eqs, threshold=vt, reset=myreset)
    
    @network_operation
    def noise(cl):
        x = randn(N) * sigma * (cl.dt / tau) ** .5
        group.v += x
        group.u += sum(x)
    
    trace = StateMonitor(group, 'v', record=[0, 1])
    spikes = SpikeMonitor(group)
    rate = PopulationRateMonitor(group)
    
    run(1 * second)
    subplot(311)
    raster_plot(spikes)
    subplot(312)
    plot(trace.times / ms, trace[0] / mV)
    plot(trace.times / ms, trace[1] / mV)
    subplot(313)
    plot(rate.times / ms, rate.smooth_rate(5 * ms) / Hz)
    show()