-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhalfwidth.m
More file actions
34 lines (33 loc) · 1.01 KB
/
halfwidth.m
File metadata and controls
34 lines (33 loc) · 1.01 KB
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
% threshold = peak_amps(i)/2 + bl
% pklocation = peak_times(i)/(si/1000) % need to go back to points
function [halfspikewidth, backward_time, forward_time] = halfwidth(threshold, pklocation,data,si)
forward = [];
counter = 1;
while isempty(forward)
if data(pklocation+counter) <= threshold
forward = pklocation+counter;
end
counter = counter + 1;
if counter >= length(data(pklocation:end))
break
end
end
backward = [];
counter = 1;
while isempty(backward)
if data(pklocation-counter) <= threshold
backward = pklocation-counter;
end
counter = counter + 1;
if counter >= length(data(1:pklocation))
break
end
end
if ~isempty(backward) || ~isempty(forward)
halfspikewidth = (forward - backward)*(si/1000);
else
halfspikewidth = [];
end
backward_time = backward*(si/1000);
forward_time = forward*(si/1000);
end