-
Notifications
You must be signed in to change notification settings - Fork 3
/
Segment.m
37 lines (36 loc) · 1.38 KB
/
Segment.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
classdef Segment < Signal
% Segment Basically a continuous subset of a signal
methods
function self = Segment(time,unit,recording)
self = self@Signal(time,unit,recording);
end
function labeledself = label(self,lab)
labeledself = LabeledSegment(self.time,self.Units,self.quantity,lab);
end
% Extract a set of features
function features=features(self)
[activity,mobility,complexity] = self.hjorthparameters;
fs = struct( ...
'Mean',mean(self.quantity) ...
,'Variance',activity ...
,'Skewness',skewness(self.quantity) ...
,'Kurtosis',kurtosis(self.quantity) ...
,'HjorthMobility',mobility ...
,'HjorthComplexity',complexity ...
,'Amplitude',abs(max(self.quantity)-min(self.quantity)) ...
);
features = Featurevector(fs);
end
function [activity,mobility,complexity] = hjorthparameters(self)
x = self.time;
y = self.quantity;
y1 = diff(y)./diff(x);
x1 = cumsum(diff(x))-diff(x);
y2 = diff(y1)./diff(x1);
x2 = cumsum(diff(x1))-diff(x1);
activity = var(y);
mobility = sqrt(var(y1)/var(y));
complexity = sqrt(var(y)*var(y2)/(var(y)^2));
end
end
end