File: examples-modelfitting_modelfitting_groups.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 (51 lines) | stat: -rw-r--r-- 1,490 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
.. currentmodule:: brian

.. index::
   pair: example usage; loadtxt
   pair: example usage; Equations

.. _example-modelfitting_modelfitting_groups:

Example: modelfitting_groups (modelfitting)
===========================================

Example showing how to fit a single model
with different target spike trains (several groups).

::

    from brian import loadtxt, ms, Equations, second
    from brian.library.modelfitting import *
    
    if __name__ == '__main__':
    
        model = Equations('''
            dV/dt=(R*I-V)/tau : 1
            I : 1
            R : 1
            tau : second
        ''')
    
        input = loadtxt('current.txt')
        spikes0 = loadtxt('spikes.txt')
        spikes = []
        for i in xrange(2):
            spikes.extend([(i, spike*second + 5*i*ms) for spike in spikes0])
    
        results = modelfitting( model = model,
                                reset = 0,
                                threshold = 1,
                                data = spikes,
                                input = input,
                                dt = .1*ms,
                                popsize = 1000,
                                maxiter = 3,
                                cpu = 1,
                                delta = 4*ms,
                                R = [1.0e9, 9.0e9],
                                tau = [10*ms, 40*ms],
                                delays = [-10*ms, 10*ms])
        print_table(results)