-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostBurstAHPstart.m
More file actions
67 lines (64 loc) · 3.01 KB
/
PostBurstAHPstart.m
File metadata and controls
67 lines (64 loc) · 3.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
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
function [output] = PostBurstAHPstart(data,si,bl,startsearch)
startsearch = str2double(sprintf('%16.f',startsearch));
numconsec = 50/(si/1000); % 50ms
belowblidx = find(data(startsearch:end) < bl); % find below BL starting from first spike
if ~isempty(belowblidx) % if there are points below BL,
diffbtwn = diff(belowblidx); % if consecutive bins are below threshold, diff should be 1 for each
AHPstart = [];
counter = 1;
if length(diffbtwn) > numconsec % if it's consecutive for 50ms, then find AHP start
while isempty(AHPstart)
if sum(diffbtwn(counter:counter+numconsec-1)) == numconsec
AHPstart = counter;
end
counter = counter + 1;
if counter >= length(diffbtwn)-numconsec
break
end
end
else % if it's not consecutive for 50ms, there is not AHP start
AHPstart = [];
end
if ~isempty(AHPstart) % if there is an AHP start, calculate values
AHPstart_time = startsearch+belowblidx(AHPstart);
AHPstart_amplitude = data(AHPstart_time);
% [AHPpeak_amplitude, C] = min(data(AHPstart_time:end));
% AHPpeak_time = C+AHPstart_time;
% Find 1sAHP
onesec = 1000/(si/1000);
% % % % % % % % % % AHP1s_time = AHPstart_time+onesec;
% % % % % % % % % % AHP1s_meanamplitude = mean(data(AHP1s_time-5:AHP1s_time+5));
output.AHPstart_time = AHPstart_time*(si/1000);
output.AHPstart_idx = AHPstart_time;
output.AHPstart_amplitude = AHPstart_amplitude;
% output.AHPpeak_negative_amplitude = AHPpeak_amplitude;
% output.AHPpeak_negative_amplitude_baseline = AHPpeak_amplitude-bl;
% output.AHPpeak_negative_time = AHPpeak_time*(si/1000);
% output.AHPpeak_negative_idx = AHPpeak_time;
% % % % % % % % % % output.AHP1s_time = AHP1s_time*(si/1000);
% % % % % % % % % % output.AHP1s_mean_amplitude = AHP1s_meanamplitude;
% % % % % % % % % % output.AHP1s_mean_amplitude_baseline = AHP1s_meanamplitude-bl;
else % if there is no AHP start, there are no values
output.AHPstart_time = [];
output.AHPstart_idx = [];
output.AHPstart_amplitude = [];
% output.AHPpeak_negative_amplitude = [];
% output.AHPpeak_negative_amplitude_baseline = [];
% output.AHPpeak_negative_time = [];
% output.AHPpeak_negative_idx = [];
output.AHP1s_time = [];
output.AHP1s_mean_amplitude = [];
output.AHP1s_mean_amplitude_baseline = [];
end
else % there are no points below BL so no AHP start
output.AHPstart_time = [];
output.AHPstart_idx = [];
output.AHPstart_amplitude = [];
output.AHPpeak_negative_amplitude = [];
output.AHPpeak_negative_amplitude_baseline = [];
output.AHPpeak_negative_time = [];
output.AHPpeak_negative_idx = [];
output.AHP1s_time = [];
output.AHP1s_mean_amplitude = [];
output.AHP1s_mean_amplitude_baseline = [];
end