File: examples-electrophysiology_compensation_ex2_spikes.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 (45 lines) | stat: -rw-r--r-- 1,188 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
.. currentmodule:: brian

.. index::
   pair: example usage; load
   pair: example usage; plot
   pair: example usage; linspace
   pair: example usage; show

.. _example-electrophysiology_compensation_ex2_spikes:

Example: compensation_ex2_spikes (electrophysiology)
====================================================

Example of spike detection method. Requires binary files 
"current.npy" and "rawtrace.npy".

    Rossant et al., "A calibration-free electrode compensation method"
    J. Neurophysiol 2012

::

    import os
    
    from brian import *
    import numpy as np
    from brian.library.electrophysiology import *
    
    working_dir = os.path.dirname(__file__)
    
    # load data
    dt = 0.1*ms
    current = np.load(os.path.join(working_dir, "current.npy"))  # 10000-long vector, 1s duration
    rawtrace = np.load(os.path.join(working_dir, "trace.npy"))  # 10000-long vector, 1s duration
    t = linspace(0., 1., len(current))
    
    # find spikes and compute score
    spikes, scores = find_spikes(rawtrace, dt=dt, check_quality=True)
    
    # plot trace and spikes
    plot(t, rawtrace, 'k')
    plot(t[spikes], rawtrace[spikes], 'or')
    show()