-
Notifications
You must be signed in to change notification settings - Fork 0
/
event_characteristics.m
88 lines (76 loc) · 2.24 KB
/
event_characteristics.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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
function [x,y,z,w,h,q,l,p,si_mixed,th,PCA_features]=event_specs(si,timeasleep,print_hist,fs)
% Computes main features of events detected
PCA_features=[];
if ~isempty(si)
%% Instantaneous frequency.
x=cellfun(@(equis) mean(instfreq(equis,fs)) ,si,'UniformOutput',false);
x=cell2mat(x);
if print_hist==1
end
PCA_features(:,1)=x;
x=median(x);
%% Average frequency
y=cellfun(@(equis) (meanfreq(equis,fs)) ,si,'UniformOutput',false);
y=cell2mat(y);
th=NaN;
si_mixed.g1=NaN;
si_mixed.i1=NaN;
si_mixed.g2=NaN;
si_mixed.i2=NaN;
if print_hist==1
end
PCA_features(:,2)=y;
y=median(y);
%% Amplitude
z=cellfun(@(equis) max(abs(hilbert(equis))) ,si,'UniformOutput',false);
z=cell2mat(z);
if print_hist==1
end
PCA_features(:,3)=z;
z=median(z);
%% Area under the curve
l=cell2mat(cellfun(@(equis) trapz((1:length(equis))./fs,abs(equis)),si,'UniformOutput',false));
if print_hist==1
end
PCA_features(:,4)=l;
l=median(l);
%% Count
w=length(si);
%% Rate
h=w/(timeasleep*(60));
%% Duration
q=(cellfun('length',si)/fs);
if print_hist==1
end
PCA_features(:,5)=q;
q=median(q);
%% Peak-to-peak distance
p=cellfun(@peak2peak,si);
if print_hist==1
end
PCA_features(:,6)=p;
p=median(p);
%% POWER
PCA_features(:,7)=cellfun(@power_signal,si);
%% Entropy
PCA_features(:,8)=cellfun(@entropy,si);
%% number of peaks
PCA_features(:,9)=cell2mat(cellfun(@(equis) length(findpeaks(equis)),si,'UniformOutput',false));
%% Spectral entropy
PCA_features(:,10)=cell2mat(cellfun(@(equis) spectral_entropy(equis,100,300,fs),si,'UniformOutput',false ));
else
x=NaN;
y=NaN;
z=NaN;
w=NaN;
h=NaN;
q=NaN;
l=NaN;
p=NaN;
th=NaN;
si_mixed.g1=NaN;
si_mixed.i1=NaN;
si_mixed.g2=NaN;
si_mixed.i2=NaN;
end
end