Mercurial > hg > silvet
comparison testdata/scripts/matlab/computeNoteLevelAccuracy.m @ 231:d9b688700819 norm eval-norm-todate
Merge from default branch
author | Chris Cannam |
---|---|
date | Wed, 16 Jul 2014 17:46:15 +0100 |
parents | 51c18a17404a |
children |
comparison
equal
deleted
inserted
replaced
215:5ba328aae5be | 231:d9b688700819 |
---|---|
1 function [Pre,Rec,F,Acc,PreOff,RecOff,FOff,AccOff] = computeNoteLevelAccuracy(nmat1,nmat2) | |
2 | |
3 % Compute note-level onset-only and onset-offset accuracy (Bay09) | |
4 | |
5 | |
6 % Initialize | |
7 if (isempty(nmat1)) Pre=0; Rec=0; F=0; Acc=0; return; end; | |
8 | |
9 % Total number of transcribed notes | |
10 Ntot = size(nmat1,1); | |
11 | |
12 % Number of reference notes | |
13 Nref = size(nmat2,1); | |
14 | |
15 % Number of correctly transcribed notes, onset within a +/-50 ms range | |
16 Ncorr = 0; | |
17 NcorrOff = 0; | |
18 for j=1:size(nmat2,1) | |
19 for i=1:size(nmat1,1) | |
20 if( (nmat1(i,3) == nmat2(j,3)) && (abs(nmat2(j,1)-nmat1(i,1))<=0.05) ) | |
21 Ncorr = Ncorr+1; | |
22 | |
23 % If offset within a +/-50 ms range or within 20% of ground-truth note's duration | |
24 if abs(nmat2(j,2) - nmat1(i,2)) <= max(0.05, 0.2 * (nmat2(j,2) - nmat2(j,1))) | |
25 NcorrOff = NcorrOff +1; | |
26 end; | |
27 | |
28 break; % In order to consider duplicates as false alarms | |
29 | |
30 end; | |
31 end; | |
32 end; | |
33 | |
34 % Number of onset-only P-R-F-Acc | |
35 Nfp = Ntot-Ncorr; | |
36 Nfn = Nref-Ncorr; | |
37 Rec = Ncorr/Nref; | |
38 Pre = Ncorr/Ntot; | |
39 F = 2*((Pre*Rec)/(Pre+Rec)); | |
40 Acc= Ncorr/(Ncorr+Nfp+Nfn); | |
41 | |
42 % Number of onset-offset P-R-F-Acc | |
43 NfpOff = Ntot-NcorrOff; | |
44 NfnOff = Nref-NcorrOff; | |
45 RecOff = NcorrOff/Nref; | |
46 PreOff = NcorrOff/Ntot; | |
47 FOff = 2*((PreOff*RecOff)/(PreOff+RecOff)); | |
48 AccOff= NcorrOff/(NcorrOff+NfpOff+NfnOff); |