File: examples-misc_cable.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 (67 lines) | stat: -rw-r--r-- 1,576 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
.. currentmodule:: brian

.. index::
   pair: example usage; plot
   pair: example usage; run
   pair: example usage; trace
   pair: example usage; show
   pair: example usage; MembraneEquation
   pair: example usage; Compartments
   pair: example usage; Current
   pair: example usage; connect
   pair: example usage; NeuronGroup
   pair: example usage; append
   pair: example usage; StateMonitor

.. _example-misc_cable:

Example: cable (misc)
=====================

Dendrite with 100 compartments

::

    from brian import *
    from brian.compartments import *
    from brian.library.ionic_currents import *
    
    length = 1 * mm
    nseg = 100
    dx = length / nseg
    Cm = 1 * uF / cm ** 2
    gl = 0.02 * msiemens / cm ** 2
    diam = 1 * um
    area = pi * diam * dx
    El = 0 * mV
    Ri = 100 * ohm * cm
    ra = Ri * 4 / (pi * diam ** 2)
    
    print "Time constant =", Cm / gl
    print "Space constant =", .5 * (diam / (gl * Ri)) ** .5
    
    segments = {}
    for i in range(nseg):
        segments[i] = MembraneEquation(Cm * area) + leak_current(gl * area, El)
    
    segments[0] += Current('I:nA')
    
    cable = Compartments(segments)
    for i in range(nseg - 1):
        cable.connect(i, i + 1, ra * dx)
    
    neuron = NeuronGroup(1, model=cable)
    #neuron.vm_0=10*mV
    neuron.I_0 = .05 * nA
    
    trace = []
    for i in range(10):
        trace.append(StateMonitor(neuron, 'vm_' + str(10 * i), record=True))
    
    run(200 * ms)
    
    for i in range(10):
        plot(trace[i].times / ms, trace[i][0] / mV)
    show()