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