-
Notifications
You must be signed in to change notification settings - Fork 1
/
alphas2ths.m
32 lines (27 loc) · 1.21 KB
/
alphas2ths.m
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% alphas2ths.m: Calculates the thresholds for burst detection
% authors: Inkeri A. Välkki, Kerstin Lenk, Jarno E. Mikkonen, Fikret E. Kapucu, Jari A. K. Hyttinen
% date: 2016 - 2019
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [BurstThreshold, TailThreshold] = alphas2ths(CMAcurve, BurstAlpha, TailAlpha)
% [BurstThreshold, TailThreshold] = alphas2ths(CMAcurve, BurstAlpha, TailAlpha)
% in:
% CMAcurve: of ISIinfo, vector
% BurstAlpha, TailAlpha: scalars
% out:
% BurstThreshold, TailThreshold: scalars
MaxCMA = max(CMAcurve);
MaxPointCMA = find(CMAcurve==max(CMAcurve),1, 'last');
if isnan(BurstAlpha) || isempty(CMAcurve)
BurstThreshold = nan;
else
BurstDistants = abs(CMAcurve(MaxPointCMA:end) - (BurstAlpha * max(MaxCMA)));
BurstThreshold = MaxPointCMA + find(BurstDistants==min(BurstDistants), 1, 'last') -1;
end
if isnan(TailAlpha) || isempty(CMAcurve)
TailThreshold = nan;
else
TailDistants = abs(CMAcurve(BurstThreshold:end) - (TailAlpha * max(MaxCMA)));
TailThreshold = BurstThreshold + find(TailDistants==min(TailDistants), 1, 'last') -1;
end
end