Repository navigation
Expand file tree
/
Copy pathsum.m
More file actions
65 lines (52 loc) · 1.31 KB
/
Copy pathsum.m
File metadata and controls
65 lines (52 loc) · 1.31 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
% SIG.SUM
% sums the channels together
%
% Copyright (C) 2014, 2017 Olivier Lartillot
%
% All rights reserved.
% License: New BSD License. See full text of the license in LICENSE.txt in
% the main folder of the MiningSuite distribution.
function varargout = sum(varargin)
if varargin{1}.istype('sig.signal')
chunk = 'concat';
else
chunk = 'no';
end
varargout = sig.operate('sig','sum',options,@init,@main,@after,...
varargin,chunk);
end
function options = options
options = sig.signal.signaloptions();
mean.key = 'Mean';
mean.type = 'Boolean';
mean.default = 0;
options.mean = mean;
type.key = 'Type';
type.type = 'String';
type.choice = {'channel','freqband'};
type.default = 'freqband';
options.type = type;
end
%%
function [x type] = init(x,option,frame)
type = 'sig.signal';
end
function out = main(x,option)
x = x{1};
if option.mean
norm = x.Ydata.size('freqband');
else
norm = 1;
end
x.Ydata = sig.compute(@routine,x.Ydata,norm,option.type);
x.fbchannels = 1;
out = {x};
end
function out = routine(in,norm,type)
out = in.sum(type);
if norm ~= 1
out.content = out.content / norm;
end
end
function x = after(x,option)
end