diff functions/challange/eventDetectionMetrics_frameBased.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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/functions/challange/eventDetectionMetrics_frameBased.m	Fri Oct 11 12:02:43 2013 +0100
@@ -0,0 +1,34 @@
+function [results] = eventDetectionMetrics_frameBased(outputFile,GTFile)
+
+% Frame-based evaluation for event detection task
+% outputFile: the output of the event detection system
+% GTFile: the ground truth list of events
+
+% Load event list from output and ground-truth
+[onset,offset,classNames] = loadEventsList(outputFile);
+[onsetGT,offsetGT,classNamesGT] = loadEventsList(GTFile);
+
+
+% Convert event list into frame-based representation (10msec resolution)
+[eventRoll] = convertEventListToEventRoll(onset,offset,classNames);
+[eventRollGT] = convertEventListToEventRoll(onsetGT,offsetGT,classNamesGT);
+
+
+% Fix durations of eventRolls
+if (size(eventRollGT,1) > size(eventRoll,1)) eventRoll = [eventRoll; zeros(size(eventRollGT,1)-size(eventRoll,1),16)]; end;
+if (size(eventRoll,1) > size(eventRollGT,1)) eventRollGT = [eventRollGT; zeros(size(eventRoll,1)-size(eventRollGT,1),16)]; end;
+
+
+% Compute frame-based metrics
+Nref = sum(sum(eventRollGT));
+Ntot = sum(sum(eventRoll));
+Ntp = sum(sum(eventRoll+eventRollGT > 1));
+Nfp = sum(sum(eventRoll-eventRollGT > 0));
+Nfn = sum(sum(eventRollGT-eventRoll > 0));
+Nsubs = min(Nfp,Nfn);
+
+
+results.Rec = Ntp/(Nref+eps);
+results.Pre = Ntp/(Ntot+eps);
+results.F = 2*((results.Pre*results.Rec)/(results.Pre+results.Rec+eps));
+results.AEER = (Nfn+Nfp+Nsubs)/(Nref+eps);