comparison functions/challange/eventDetectionMetrics_eventBased.m @ 0:2fadb31a9d55 tip

Import code by Vuegen et al
author Dan Stowell <dan.stowell@elec.qmul.ac.uk>
date Fri, 11 Oct 2013 12:02:43 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:2fadb31a9d55
1 function [results] = eventDetectionMetrics_eventBased(outputFile,GTFile)
2
3 % Event-based evaluation for event detection task
4 % outputFile: the output of the event detection system
5 % GTFile: the ground truth list of events
6
7 % Load event list from output and ground-truth
8 [onset,offset,classNames] = loadEventsList(outputFile);
9 [onsetGT,offsetGT,classNamesGT] = loadEventsList(GTFile);
10
11
12 % Total number of detected and reference events
13 Ntot = length(onset);
14 Nref = length(onsetGT);
15
16
17 % Number of correctly transcribed events, onset within a +/-100 ms range
18 Ncorr = 0;
19 NcorrOff = 0;
20 for j=1:length(onsetGT)
21 for i=1:length(onset)
22
23 if( strcmp(classNames{i},classNamesGT{j}) && (abs(onsetGT(j)-onset(i))<=0.1) )
24 Ncorr = Ncorr+1;
25
26 % If offset within a +/-100 ms range or within 50% of ground-truth event's duration
27 if abs(offsetGT(j) - offset(i)) <= max(0.1, 0.5 * (offsetGT(j) - onsetGT(j)))
28 NcorrOff = NcorrOff +1;
29 end;
30
31 break; % In order to not evaluate duplicates
32
33 end;
34 end;
35
36 end;
37
38
39 % Compute onset-only event-based metrics
40 Nfp = Ntot-Ncorr;
41 Nfn = Nref-Ncorr;
42 Nsubs = min(Nfp,Nfn);
43 results.Rec = Ncorr/(Nref+eps);
44 results.Pre = Ncorr/(Ntot+eps);
45 results.F = 2*((results.Pre*results.Rec)/(results.Pre+results.Rec+eps));
46 results.AEER= (Nfn+Nfp+Nsubs)/(Nref+eps);
47
48
49 % Compute onset-offset event-based metrics
50 NfpOff = Ntot-NcorrOff;
51 NfnOff = Nref-NcorrOff;
52 NsubsOff = min(NfpOff,NfnOff);
53 results.RecOff = NcorrOff/(Nref+eps);
54 results.PreOff = NcorrOff/(Ntot+eps);
55 results.FOff = 2*((results.PreOff*results.RecOff)/(results.PreOff+results.RecOff+eps));
56 results.AEEROff= (NfnOff+NfpOff+NsubsOff)/(Nref+eps);