comparison toolboxes/MIRtoolbox1.3.2/MIRToolbox/@mirpattern/mirpattern.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 = mirpattern(orig,varargin)
2 % p = mirpattern(a)
3
4 period.key = 'Period';
5 period.type = 'Boolean';
6 period.when = 'After';
7 period.default = 0;
8 option.period = period;
9
10 specif.option = option;
11
12 varargout = mirfunction(@mirpattern,orig,varargin,nargout,specif,@init,@main);
13
14
15 function [x type] = init(x,option)
16 if not(isamir(x,'mirpattern'))
17 x = mirsimatrix(x);
18 end
19 type = 'mirpattern';
20
21
22 function p = main(orig,option,postoption)
23 if not(isamir(orig,'mirpattern'))
24 b = get(orig,'Branch');
25 fp = get(orig,'FramePos');
26 pp = get(orig,'PeakPos');
27 for i = 1:length(b)
28 bi = b{i}{1}{1};
29 pi1 = sort(pp{i}{1}{bi(1,1)});
30 pi2 = sort(pp{i}{1}{bi(end,1)});
31 p.pattern{1}.occurrence{1}.start = ...
32 fp{i}{1}(1,bi(1,1)) - mean(fp{i}{1}(1:2,pi1(bi(1,2))));
33 p.pattern{end}.occurrence{2}.start = ...
34 fp{i}{1}(1,bi(1,1));
35 p.pattern{end}.occurrence{1}.end = ...
36 fp{i}{1}(1,bi(end,1)) - mean(fp{i}{1}(1:2,pi2(bi(end,2))));
37 p.pattern{end}.occurrence{2}.end = ...
38 fp{i}{1}(1,bi(end,1));
39 end
40 p = class(p,'mirpattern',mirdata(orig));
41 end
42 if postoption.period
43 for i = 1:length(p.pattern)
44 poi = p.pattern{i}.occurrence;
45 if poi{1}.end > poi{2}.start
46 poi{1}.end = poi{2}.start;
47 cycle = poi{1}.end - poi{1}.start;
48 ncycles = floor((poi{2}.end-poi{2}.start)/cycle)+2;
49 poi{ncycles}.end = poi{2}.end;
50 poi{2}.end = poi{2}.start + cycle;
51 for j = 2:ncycles-1
52 poi{j}.end = poi{j}.start + cycle;
53 poi{j+1}.start = poi{j}.end;
54 end
55 end
56 p.pattern{i}.occurrence = poi;
57 end
58 end