comparison toolboxes/MIRtoolbox1.3.2/MIRToolbox/peaksegments.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 y = peaksegments(func,d,p,varargin)
2
3 y = cell(1,length(d));
4 for h = 1:length(d)
5 if not(iscell(d{h})) % for histograms
6 p{h} = {p{h}(:,:,1)'};
7 d{h} = {d{h}'};
8 end
9 for i = 1:length(d{h})
10 %sum(var(p{h}{i},1,2))
11 %p{h}{i} = repmat(p{h}{i}(:,1,1),[1,size(p{h}{i},2),size(p{h}{i},3)]);
12 d{h}{i} = d{h}{i} + repmat(min(d{h}{i}),[size(d{h}{i},1),1,1]);
13 for j = 1:size(d{h}{i},3)
14 for k = 1:size(d{h}{i},2)
15 yk = [];
16 nb = 0;
17 f = find(not(isnan(d{h}{i}(1:end,k,j))));
18 while not(isempty(f))
19 l = f(1);
20 f = find(isnan(d{h}{i}(l:end,k,j)))+l-1;
21 if isempty(f)
22 f = size(d{h}{i},1)+1;
23 end
24 r = l:f(1)-1;
25 if length(r)>1
26 nb = nb+1;
27 if nargin > 3
28 for g = 1:length(varargin)
29 if g == 1
30 v{g} = repmat(varargin{g}{h}{i}{1,k,j}(nb),...
31 [length(r),1,1]);
32 else
33 v{g} = varargin{g}{h}{i}{1,k,j}(nb);
34 end
35 end
36 else
37 v = {};
38 end
39 yk(nb,1) = func(abs(d{h}{i}(r,k,j)),...
40 p{h}{i}(r,k,1),...
41 v{:});
42 end
43 f = find(not(isnan(d{h}{i}(f(1):end,k,j))))+f(1)-1;
44 end
45 y{h}{i}{1,k,j} = yk;
46 end
47 end
48 end
49 end