File: examples-misc_linked_var.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 (73 lines) | stat: -rw-r--r-- 1,970 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
.. currentmodule:: brian

.. index::
   pair: example usage; subplot
   pair: example usage; plot
   pair: example usage; run
   pair: example usage; linked_var
   pair: example usage; show
   pair: example usage; linspace
   pair: example usage; ylabel
   pair: example usage; MultiStateMonitor
   pair: example usage; NeuronGroup

.. _example-misc_linked_var:

Example: linked_var (misc)
==========================

Example showing :func:`linked_var`, connecting two different :class:`NeuronGroup`
variables. Here we show something like a simplified haircell and auditory nerve
fibre model where the hair cells and ANFs are implemented as two separate
:class:`NeuronGroup` objects. The hair cells filter their inputs via a 
differential equation, and then emit graded amounts of neurotransmitter
(variable 'y') to the auditory nerve fibres input current (variable 'I').

::

    from brian import *
    
    N = 5
    f = 50 * Hz
    a_min = 1.0
    a_max = 100.0
    tau_haircell = 50 * ms
    tau = 10 * ms
    duration = 100 * ms
    
    eqs_haircells = '''
    input = a*sin(2*pi*f*t) : 1
    x = clip(input, 0, Inf)**(1.0/3.0) : 1
    a : 1
    dy/dt = (x-y)/tau_haircell : 1 
    '''
    
    haircells = NeuronGroup(N, eqs_haircells)
    haircells.a = linspace(a_min, a_max, N)
    M_haircells = MultiStateMonitor(haircells, vars=('input', 'y'), record=True)
    
    eqs_nervefibres = '''
    dV/dt = (I-V)/tau : 1
    I : 1
    '''
    nervefibres = NeuronGroup(N, eqs_nervefibres, reset=0, threshold=1)
    nervefibres.I = linked_var(haircells, 'y')
    M_nervefibres = MultiStateMonitor(nervefibres, record=True)
    
    run(duration)
    
    subplot(221)
    M_haircells['input'].plot()
    ylabel('haircell.input')
    subplot(222)
    M_haircells['y'].plot()
    ylabel('haircell.y')
    subplot(223)
    M_nervefibres['I'].plot()
    ylabel('nervefibres.I')
    subplot(224)
    M_nervefibres['V'].plot()
    ylabel('nervefibres.V')
    show()