annotate 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
rev   line source
dan@0 1 function [results] = eventDetectionMetrics_frameBased(outputFile,GTFile)
dan@0 2
dan@0 3 % Frame-based evaluation for event detection task
dan@0 4 % outputFile: the output of the event detection system
dan@0 5 % GTFile: the ground truth list of events
dan@0 6
dan@0 7 % Load event list from output and ground-truth
dan@0 8 [onset,offset,classNames] = loadEventsList(outputFile);
dan@0 9 [onsetGT,offsetGT,classNamesGT] = loadEventsList(GTFile);
dan@0 10
dan@0 11
dan@0 12 % Convert event list into frame-based representation (10msec resolution)
dan@0 13 [eventRoll] = convertEventListToEventRoll(onset,offset,classNames);
dan@0 14 [eventRollGT] = convertEventListToEventRoll(onsetGT,offsetGT,classNamesGT);
dan@0 15
dan@0 16
dan@0 17 % Fix durations of eventRolls
dan@0 18 if (size(eventRollGT,1) > size(eventRoll,1)) eventRoll = [eventRoll; zeros(size(eventRollGT,1)-size(eventRoll,1),16)]; end;
dan@0 19 if (size(eventRoll,1) > size(eventRollGT,1)) eventRollGT = [eventRollGT; zeros(size(eventRoll,1)-size(eventRollGT,1),16)]; end;
dan@0 20
dan@0 21
dan@0 22 % Compute frame-based metrics
dan@0 23 Nref = sum(sum(eventRollGT));
dan@0 24 Ntot = sum(sum(eventRoll));
dan@0 25 Ntp = sum(sum(eventRoll+eventRollGT > 1));
dan@0 26 Nfp = sum(sum(eventRoll-eventRollGT > 0));
dan@0 27 Nfn = sum(sum(eventRollGT-eventRoll > 0));
dan@0 28 Nsubs = min(Nfp,Nfn);
dan@0 29
dan@0 30
dan@0 31 results.Rec = Ntp/(Nref+eps);
dan@0 32 results.Pre = Ntp/(Ntot+eps);
dan@0 33 results.F = 2*((results.Pre*results.Rec)/(results.Pre+results.Rec+eps));
dan@0 34 results.AEER = (Nfn+Nfp+Nsubs)/(Nref+eps);