File: examples-electrophysiology_compensation_ex3_quality.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 (50 lines) | stat: -rw-r--r-- 1,609 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
.. currentmodule:: brian

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

.. _example-electrophysiology_compensation_ex3_quality:

Example: compensation_ex3_quality (electrophysiology)
=====================================================

Example of quality check 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
    compensatedtrace = np.load(os.path.join(working_dir, "compensatedtrace.npy"))  # obtained with example1
    t = linspace(0., 1., len(current))
    
    # get trace quality of both raw and compensated traces
    r = get_trace_quality(rawtrace, current, full=True)
    rcomp = get_trace_quality(compensatedtrace, current, full=True)
    spikes = r["spikes"]
    print "Quality coefficient for raw: %.3f and for compensated trace: %.3f" % \
          (r["correlation"], rcomp["correlation"])
    
    # plot trace and spikes
    plot(t, rawtrace, 'k')
    plot(t, compensatedtrace, 'g')
    plot(t[spikes], rawtrace[spikes], 'ok')
    plot(t[spikes], compensatedtrace[spikes], 'og')
    show()