-
Notifications
You must be signed in to change notification settings - Fork 0
/
psc_variability.py
51 lines (29 loc) · 1.23 KB
/
psc_variability.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
def find_average():
peaks = []
for i in stf.get_selected_indices():
trace = stf.get_trace(trace=i)
base = trace[int(stf.get_base_start()):int(stf.get_base_end())]
base = np.median(base)
p = trace[stf.get_peak_start():stf.get_peak_end()] - base
peaks.append(np.min(p))
peak_mean = np.mean(peaks)
peak_error = np.std(peaks)
stf.show_table({'Peak': peak_mean, 'Error': peak_error})
return peak_mean, peak_error
def correct_autapse():
traces = []
fit_time = stf.get_fit_end() - stf.get_fit_start()
x = np.arange(fit_time)
trace_time = stf.get_peak_end() - stf.get_fit_start()
y = np.arange(trace_time)
for i in stf.get_selected_indices():
trace = stf.get_trace(trace=i)
base = np.median(trace[get_base_start():get_base_end()])
trace = trace[stf.get_fit_start():stf.get_peak_end()] - base
fit = np.polyfit(x, trace[:fit_time], 1)
line = fit[0] * y + fit[1]
line[line > 0] = 0
traces.append(trace - line)
traces = np.array(traces)
new_window_matrix(traces)
return traces