-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.py
70 lines (48 loc) · 1.51 KB
/
utils.py
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
68
69
70
from brian2 import *
import numpy as np
def exp2_factor(tau1, tau2):
tp = (tau1 * tau2) / (tau2 - tau1) * np.log(tau2 / tau1)
factor = -np.exp(-tp / tau1) + np.exp(-tp / tau2)
return 1.0 / factor
def density(data, t, Nt, duration):
tt = linspace(0.0, duration / ms, Nt)
dtt = tt[1] - tt[0]
den = zeros([Nt, 1])
ST = size(t)
j = 0
for i in range(Nt):
while logical_and(abs(t[j] / ms - tt[i]) < dtt / 2, j < ST - 1):
den[i, 0] += 1
j += 1
return den, tt # tt dimensionless
def std_spiketime(Sp, duration, range_i):
# Compute the standard deviation of spike time, which indicate the ability of synchrony signal propagation
data0 = Sp.i
t0 = Sp.t
ind1 = np.where(logical_and(range_i[0] <= data0, data0 <= range_i[-1]))
a1 = ind1[0]
data = data0[a1]
t = t0[a1]
den, tt = density(data, t, 200, duration)
ind_center = argmax(den)
t_center = tt[ind_center] * ms
inds_in = np.where(abs((t - t_center) / ms) < 4.0)
a = inds_in[0]
t_in = t[a]
sig = std(t_in)
return sig
def firing_rate(Sp, duration, range_i):
data0 = Sp.i
t0 = Sp.t
ind1 = np.where(logical_and(range_i[0] <= data0, data0 <= range_i[-1]))
a1 = ind1[0]
data = data0[a1]
t = t0[a1]
den, tt = density(data, t, 200, duration)
ind_center = argmax(den)
t_center = tt[ind_center] * ms
inds_in = np.where(abs((t - t_center) / ms) < 4.0)
a = inds_in[0]
t_in = t[a]
fr = size(t_in)
return fr