emmanouil@71
|
1 function [Pre,Rec,F,Acc,PreOff,RecOff,FOff,AccOff] = computeNoteLevelAccuracy(nmat1,nmat2)
|
emmanouil@71
|
2
|
emmanouil@71
|
3 % Compute note-level onset-only and onset-offset accuracy (Bay09)
|
emmanouil@71
|
4
|
emmanouil@71
|
5
|
emmanouil@71
|
6 % Initialize
|
emmanouil@71
|
7 if (isempty(nmat1)) Pre=0; Rec=0; F=0; Acc=0; return; end;
|
emmanouil@71
|
8
|
emmanouil@71
|
9 % Total number of transcribed notes
|
emmanouil@71
|
10 Ntot = size(nmat1,1);
|
emmanouil@71
|
11
|
emmanouil@71
|
12 % Number of reference notes
|
emmanouil@71
|
13 Nref = size(nmat2,1);
|
emmanouil@71
|
14
|
emmanouil@71
|
15 % Number of correctly transcribed notes, onset within a +/-50 ms range
|
emmanouil@71
|
16 Ncorr = 0;
|
emmanouil@71
|
17 NcorrOff = 0;
|
emmanouil@71
|
18 for j=1:size(nmat2,1)
|
emmanouil@71
|
19 for i=1:size(nmat1,1)
|
emmanouil@71
|
20 if( (nmat1(i,3) == nmat2(j,3)) && (abs(nmat2(j,1)-nmat1(i,1))<=0.05) )
|
emmanouil@71
|
21 Ncorr = Ncorr+1;
|
emmanouil@71
|
22
|
emmanouil@71
|
23 % If offset within a +/-50 ms range or within 20% of ground-truth note's duration
|
emmanouil@71
|
24 if abs(nmat2(j,2) - nmat1(i,2)) <= max(0.05, 0.2 * (nmat2(j,2) - nmat2(j,1)))
|
emmanouil@71
|
25 NcorrOff = NcorrOff +1;
|
emmanouil@71
|
26 end;
|
emmanouil@71
|
27
|
emmanouil@71
|
28 break; % In order to consider duplicates as false alarms
|
emmanouil@71
|
29
|
emmanouil@71
|
30 end;
|
emmanouil@71
|
31 end;
|
emmanouil@71
|
32 end;
|
emmanouil@71
|
33
|
emmanouil@71
|
34 % Number of onset-only P-R-F-Acc
|
emmanouil@71
|
35 Nfp = Ntot-Ncorr;
|
emmanouil@71
|
36 Nfn = Nref-Ncorr;
|
emmanouil@71
|
37 Rec = Ncorr/Nref;
|
emmanouil@71
|
38 Pre = Ncorr/Ntot;
|
emmanouil@71
|
39 F = 2*((Pre*Rec)/(Pre+Rec));
|
emmanouil@71
|
40 Acc= Ncorr/(Ncorr+Nfp+Nfn);
|
emmanouil@71
|
41
|
emmanouil@71
|
42 % Number of onset-offset P-R-F-Acc
|
emmanouil@71
|
43 NfpOff = Ntot-NcorrOff;
|
emmanouil@71
|
44 NfnOff = Nref-NcorrOff;
|
emmanouil@71
|
45 RecOff = NcorrOff/Nref;
|
emmanouil@71
|
46 PreOff = NcorrOff/Ntot;
|
emmanouil@71
|
47 FOff = 2*((PreOff*RecOff)/(PreOff+RecOff));
|
emmanouil@71
|
48 AccOff= NcorrOff/(NcorrOff+NfpOff+NfnOff); |