~ubuntu-branches/ubuntu/wily/brian/wily

« back to all changes in this revision

Viewing changes to examples/electrophysiology/compensation_ex2_spikes.py

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2014-07-30 11:29:44 UTC
  • mfrom: (6.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20140730112944-ln0ogbq0kpyyuz47
Tags: 1.4.1-2
* Forgotten upload to unstable
* debian/control
  - policy boost to 3.9.5
  - updated Vcs- fields given migration to anonscm.d.o and provided -b
    debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
"""
 
3
Example of spike detection method. Requires binary files 
 
4
"current.npy" and "rawtrace.npy".
 
5
 
 
6
    Rossant et al., "A calibration-free electrode compensation method"
 
7
    J. Neurophysiol 2012
 
8
"""
 
9
import os
 
10
 
 
11
from brian import *
 
12
import numpy as np
 
13
from brian.library.electrophysiology import *
 
14
 
 
15
working_dir = os.path.dirname(__file__)
 
16
 
 
17
# load data
 
18
dt = 0.1*ms
 
19
current = np.load(os.path.join(working_dir, "current.npy"))  # 10000-long vector, 1s duration
 
20
rawtrace = np.load(os.path.join(working_dir, "trace.npy"))  # 10000-long vector, 1s duration
 
21
t = linspace(0., 1., len(current))
 
22
 
 
23
# find spikes and compute score
 
24
spikes, scores = find_spikes(rawtrace, dt=dt, check_quality=True)
 
25
 
 
26
# plot trace and spikes
 
27
plot(t, rawtrace, 'k')
 
28
plot(t[spikes], rawtrace[spikes], 'or')
 
29
show()
 
30