comparison toolboxes/MIRtoolbox1.3.2/MIRToolbox/mirmode.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function varargout = mirmode(x,varargin)
2 % m = mirmode(a) estimates the mode. A value of 0 indicates a complete
3 % incertainty, whereas a positive value indicates a dominance of
4 % major mode and a negative value indicates a dominance of minor mode.
5 % Optional arguments:
6 % mirmode(a,s) specifies a strategy.
7 % Possible values for s: 'Sum', 'Best'(default)
8
9 stra.type = 'String';
10 stra.default = 'Best';
11 stra.choice = {'Best','Sum'};
12 option.stra = stra;
13
14 specif.option = option;
15 specif.defaultframelength = 1;
16 specif.defaultframehop = .5;
17
18 varargout = mirfunction(@mirmode,x,varargin,nargout,specif,@init,@main);
19
20
21 function [x type] = init(x,option)
22 if not(isamir(x,'mirkeystrength'))
23 x = mirkeystrength(x);
24 end
25 type = 'mirscalar';
26
27
28 function o = main(s,option,postoption)
29 if iscell(s)
30 s = s{1};
31 end
32 m = get(s,'Data');
33 if strcmpi(option.stra,'sum')
34 v = mircompute(@algosum,m);
35 elseif strcmpi(option.stra,'best')
36 v = mircompute(@algobest,m);
37 end
38 b = mirscalar(s,'Data',v,'Title','Mode');
39 o = {b,s};
40
41
42 function v = algosum(m)
43 v = sum(abs(m(:,:,:,1))) - sum(abs(m(:,:,:,2)));
44
45
46 function v = algobest(m)
47 v = max(m(:,:,:,1)) - max(m(:,:,:,2));