comparison util/AMT_analysis.m @ 8:33850553b702

(none)
author idamnjanovic
date Mon, 22 Mar 2010 10:56:54 +0000
parents
children fc395272d53e
comparison
equal deleted inserted replaced
7:0151f1ea080d 8:33850553b702
1 function AMT_res = AMT_analysis(Problem, solver)
2 %%% Automatic Music Transcription results analysis
3 % Ivan Damnjanovic 2009
4 %
5 % If wav file that is transcribed is generated from midi file (i.e. if
6 % groundtruth exists) transcription is comapred to the original notes and
7 % AMT_res structure is generated. It contains following fields:
8 % - tp_notes - true positive notes (notes corectly transcribed)
9 % - oe_notes - octave errors (erroes due to imperfect pitch estimation)
10 % - fn_notes_wo_oe - false negative notes without octave errors
11 % (notes that were not detected)
12 % - fp_notes_wo_oe - false positive notes without octave erors
13 % - TP - number of true positives
14 % - FN - number of false negatives
15 % - FP - number of false positives
16
17 timeOr=Problem.notesOriginal(:,5);
18 noteOr=Problem.notesOriginal(:,3);
19 timeTr=solver.reconstructed.notes(:,5);
20 noteTr=solver.reconstructed.notes(:,3);
21 n=size(timeOr,1);
22 m=size(timeTr,1);
23
24 % tolerance (ts) is set to one window before and after the reference offset
25 % time
26
27 ts=(Problem.windowSize)/Problem.fs;
28
29 Hits=[];
30 OE=[];
31
32 for i=1:n
33 Hit= find((noteTr(:)==noteOr(i))&(abs(timeOr(i)-timeTr(:))<ts));
34 if size(Hit,1)>1 Hit=Hit(1); end
35 if ~isempty(Hit) Hits=[Hits; i , Hit];
36 else
37 OctErr=find(((noteTr(:)==noteOr(i)-12)|(noteTr(:)==noteOr(i)-24))&(abs(timeOr(i)-timeTr(:))<ts), 1);
38 if ~isempty(OctErr) OE=[OE; i , OctErr]; end
39 end
40 end
41
42 AMT_res.tp_notes = [Problem.notesOriginal(Hits(:,1),[3 5]) solver.reconstructed.notes(Hits(:,2),[3 5])];
43 AMT_res.oe_notes = [Problem.notesOriginal(OE(:,1),[3 5]) solver.reconstructed.notes(OE(:,2),[3 5])];
44 AMT_res.fn_notes_wo_oe = Problem.notesOriginal(setdiff([1:n],union(Hits(:,1),OE(:,1))),[3 5]);
45 AMT_res.fp_notes_wo_oe = solver.reconstructed.notes(setdiff([1:m],union(Hits(:,2),OE(:,2))),[3 5]);
46 AMT_res.TP=size(Hits,1);
47 AMT_res.FN=n-AMT_res.TP;
48 AMT_res.FP=m-AMT_res.TP;
49 end