annotate toolboxes/MIRtoolbox1.3.2/MIRToolbox/mirmode.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function varargout = mirmode(x,varargin)
Daniel@0 2 % m = mirmode(a) estimates the mode. A value of 0 indicates a complete
Daniel@0 3 % incertainty, whereas a positive value indicates a dominance of
Daniel@0 4 % major mode and a negative value indicates a dominance of minor mode.
Daniel@0 5 % Optional arguments:
Daniel@0 6 % mirmode(a,s) specifies a strategy.
Daniel@0 7 % Possible values for s: 'Sum', 'Best'(default)
Daniel@0 8
Daniel@0 9 stra.type = 'String';
Daniel@0 10 stra.default = 'Best';
Daniel@0 11 stra.choice = {'Best','Sum'};
Daniel@0 12 option.stra = stra;
Daniel@0 13
Daniel@0 14 specif.option = option;
Daniel@0 15 specif.defaultframelength = 1;
Daniel@0 16 specif.defaultframehop = .5;
Daniel@0 17
Daniel@0 18 varargout = mirfunction(@mirmode,x,varargin,nargout,specif,@init,@main);
Daniel@0 19
Daniel@0 20
Daniel@0 21 function [x type] = init(x,option)
Daniel@0 22 if not(isamir(x,'mirkeystrength'))
Daniel@0 23 x = mirkeystrength(x);
Daniel@0 24 end
Daniel@0 25 type = 'mirscalar';
Daniel@0 26
Daniel@0 27
Daniel@0 28 function o = main(s,option,postoption)
Daniel@0 29 if iscell(s)
Daniel@0 30 s = s{1};
Daniel@0 31 end
Daniel@0 32 m = get(s,'Data');
Daniel@0 33 if strcmpi(option.stra,'sum')
Daniel@0 34 v = mircompute(@algosum,m);
Daniel@0 35 elseif strcmpi(option.stra,'best')
Daniel@0 36 v = mircompute(@algobest,m);
Daniel@0 37 end
Daniel@0 38 b = mirscalar(s,'Data',v,'Title','Mode');
Daniel@0 39 o = {b,s};
Daniel@0 40
Daniel@0 41
Daniel@0 42 function v = algosum(m)
Daniel@0 43 v = sum(abs(m(:,:,:,1))) - sum(abs(m(:,:,:,2)));
Daniel@0 44
Daniel@0 45
Daniel@0 46 function v = algobest(m)
Daniel@0 47 v = max(m(:,:,:,1)) - max(m(:,:,:,2));