emmanouil@0: function [results] = eventDetectionMetrics_eventBased(outputFile,GTFile) emmanouil@0: emmanouil@0: % Event-based evaluation for event detection task emmanouil@0: % outputFile: the output of the event detection system emmanouil@0: % GTFile: the ground truth list of events emmanouil@0: emmanouil@0: % Load event list from output and ground-truth emmanouil@0: [onset,offset,classNames] = loadEventsList(outputFile); emmanouil@0: [onsetGT,offsetGT,classNamesGT] = loadEventsList(GTFile); emmanouil@0: emmanouil@0: emmanouil@0: % Total number of detected and reference events emmanouil@0: Ntot = length(onset); emmanouil@0: Nref = length(onsetGT); emmanouil@0: emmanouil@0: emmanouil@0: % Number of correctly transcribed events, onset within a +/-100 ms range emmanouil@0: Ncorr = 0; emmanouil@0: NcorrOff = 0; emmanouil@0: for j=1:length(onsetGT) emmanouil@0: for i=1:length(onset) emmanouil@0: emmanouil@0: if( strcmp(classNames{i},classNamesGT{j}) && (abs(onsetGT(j)-onset(i))<=0.1) ) emmanouil@0: Ncorr = Ncorr+1; emmanouil@0: emmanouil@0: % If offset within a +/-100 ms range or within 50% of ground-truth event's duration emmanouil@0: if abs(offsetGT(j) - offset(i)) <= max(0.1, 0.5 * (offsetGT(j) - onsetGT(j))) emmanouil@0: NcorrOff = NcorrOff +1; emmanouil@0: end; emmanouil@0: emmanouil@0: break; % In order to not evaluate duplicates emmanouil@0: emmanouil@0: end; emmanouil@0: end; emmanouil@0: emmanouil@0: end; emmanouil@0: emmanouil@0: emmanouil@0: % Compute onset-only event-based metrics emmanouil@0: Nfp = Ntot-Ncorr; emmanouil@0: Nfn = Nref-Ncorr; emmanouil@0: Nsubs = min(Nfp,Nfn); emmanouil@0: results.Rec = Ncorr/(Nref+eps); emmanouil@0: results.Pre = Ncorr/(Ntot+eps); emmanouil@0: results.F = 2*((results.Pre*results.Rec)/(results.Pre+results.Rec+eps)); emmanouil@0: results.AEER= (Nfn+Nfp+Nsubs)/(Nref+eps); emmanouil@0: emmanouil@0: emmanouil@0: % Compute onset-offset event-based metrics emmanouil@0: NfpOff = Ntot-NcorrOff; emmanouil@0: NfnOff = Nref-NcorrOff; emmanouil@0: NsubsOff = min(NfpOff,NfnOff); emmanouil@0: results.RecOff = NcorrOff/(Nref+eps); emmanouil@0: results.PreOff = NcorrOff/(Ntot+eps); emmanouil@0: results.FOff = 2*((results.PreOff*results.RecOff)/(results.PreOff+results.RecOff+eps)); emmanouil@0: results.AEEROff= (NfnOff+NfpOff+NsubsOff)/(Nref+eps);