annotate toolboxes/MIRtoolbox1.3.2/MIRToolbox/combinepeaks.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function c = combinepeaks(p,v,thr)
wolffd@0 2 % dedicated function for (Klapuri, 99) that creates a curve made of burst
wolffd@0 3 % at position of peaks p and with amplitude related to peaks v.
wolffd@0 4
wolffd@0 5 dp = get(p,'Data');
wolffd@0 6 dv = get(v,'Data');
wolffd@0 7 pp = get(p,'PeakPos');
wolffd@0 8 pv = get(v,'PeakPos');
wolffd@0 9 sr = get(v,'Sampling');
wolffd@0 10 l = length(dp);
wolffd@0 11 empty = cell(1,l);
wolffd@0 12 for i = 1:l
wolffd@0 13 thr = round(thr*sr{i});
wolffd@0 14 empty{i} = cell(1,length(dp{i}));
wolffd@0 15 for h = 1:length(dp{i})
wolffd@0 16 dih = zeros(size(dp{i}{h}));
wolffd@0 17 for l = 1:size(pp{i}{h},3)
wolffd@0 18 for k = 1:size(pp{i}{h},2)
wolffd@0 19 j = 1;
wolffd@0 20 ppkl = pp{i}{h}{1,k,l};
wolffd@0 21 pvkl = pv{i}{h}{1,k,l};
wolffd@0 22 while j < length(ppkl)
wolffd@0 23 if ppkl(j+1)-ppkl(j) < thr
wolffd@0 24 decreas = dv{i}{h}(pvkl(j+1),k,l) ...
wolffd@0 25 < dv{i}{h}(pvkl(j),k,l);
wolffd@0 26 ppkl(j+decreas) = [];
wolffd@0 27 pvkl(j+decreas) = [];
wolffd@0 28 else
wolffd@0 29 j = j+1;
wolffd@0 30 end
wolffd@0 31 end
wolffd@0 32 dih(ppkl,k,l) = dv{i}{h}(pvkl,k,l);
wolffd@0 33 end
wolffd@0 34 end
wolffd@0 35 dv{i}{h} = dih;
wolffd@0 36 end
wolffd@0 37 end
wolffd@0 38 c = set(p,'Data',dv,'PeakPos',empty,'PeakVal',empty,...
wolffd@0 39 'PeakPrecisePos',{},'PeakPreciseVal',{},'PeakMode',empty,...
wolffd@0 40 'InterChunk',[]);