annotate util/AMT_analysis.m @ 192:f1e601cc916d danieleb

removed error check for wLength
author Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk>
date Thu, 01 Mar 2012 16:57:51 +0000
parents dab78a3598b6
children
rev   line source
idamnjanovic@8 1 function AMT_res = AMT_analysis(Problem, solver)
idamnjanovic@8 2 %%% Automatic Music Transcription results analysis
idamnjanovic@24 3 %
idamnjanovic@8 4 % If wav file that is transcribed is generated from midi file (i.e. if
idamnjanovic@8 5 % groundtruth exists) transcription is comapred to the original notes and
idamnjanovic@8 6 % AMT_res structure is generated. It contains following fields:
idamnjanovic@8 7 % - tp_notes - true positive notes (notes corectly transcribed)
idamnjanovic@8 8 % - oe_notes - octave errors (erroes due to imperfect pitch estimation)
idamnjanovic@8 9 % - fn_notes_wo_oe - false negative notes without octave errors
idamnjanovic@8 10 % (notes that were not detected)
idamnjanovic@8 11 % - fp_notes_wo_oe - false positive notes without octave erors
idamnjanovic@8 12 % - TP - number of true positives
idamnjanovic@8 13 % - FN - number of false negatives
idamnjanovic@8 14 % - FP - number of false positives
idamnjanovic@8 15
ivan@107 16 %
ivan@107 17 % Centre for Digital Music, Queen Mary, University of London.
ivan@107 18 % This file copyright 2009 Ivan Damnjanovic.
ivan@107 19 %
ivan@107 20 % This program is free software; you can redistribute it and/or
ivan@107 21 % modify it under the terms of the GNU General Public License as
ivan@107 22 % published by the Free Software Foundation; either version 2 of the
ivan@107 23 % License, or (at your option) any later version. See the file
ivan@107 24 % COPYING included with this distribution for more information.
ivan@107 25 %%
ivan@107 26
idamnjanovic@8 27 timeOr=Problem.notesOriginal(:,5);
idamnjanovic@8 28 noteOr=Problem.notesOriginal(:,3);
idamnjanovic@8 29 timeTr=solver.reconstructed.notes(:,5);
idamnjanovic@8 30 noteTr=solver.reconstructed.notes(:,3);
idamnjanovic@8 31 n=size(timeOr,1);
idamnjanovic@8 32 m=size(timeTr,1);
idamnjanovic@8 33
idamnjanovic@8 34 % tolerance (ts) is set to one window before and after the reference offset
idamnjanovic@8 35 % time
idamnjanovic@8 36
idamnjanovic@8 37 ts=(Problem.windowSize)/Problem.fs;
idamnjanovic@8 38
idamnjanovic@8 39 Hits=[];
idamnjanovic@8 40 OE=[];
idamnjanovic@8 41
idamnjanovic@8 42 for i=1:n
idamnjanovic@8 43 Hit= find((noteTr(:)==noteOr(i))&(abs(timeOr(i)-timeTr(:))<ts));
idamnjanovic@8 44 if size(Hit,1)>1 Hit=Hit(1); end
idamnjanovic@8 45 if ~isempty(Hit) Hits=[Hits; i , Hit];
idamnjanovic@8 46 else
idamnjanovic@8 47 OctErr=find(((noteTr(:)==noteOr(i)-12)|(noteTr(:)==noteOr(i)-24))&(abs(timeOr(i)-timeTr(:))<ts), 1);
idamnjanovic@8 48 if ~isempty(OctErr) OE=[OE; i , OctErr]; end
idamnjanovic@8 49 end
idamnjanovic@8 50 end
idamnjanovic@8 51
idamnjanovic@8 52 AMT_res.tp_notes = [Problem.notesOriginal(Hits(:,1),[3 5]) solver.reconstructed.notes(Hits(:,2),[3 5])];
ivan@107 53 if ~isempty(OE)
ivan@107 54 AMT_res.oe_notes = [Problem.notesOriginal(OE(:,1),[3 5]) solver.reconstructed.notes(OE(:,2),[3 5])];
ivan@107 55 end
ivan@107 56 if isempty(OE)
ivan@107 57 OE=[0 0];
ivan@107 58 end
idamnjanovic@8 59 AMT_res.fn_notes_wo_oe = Problem.notesOriginal(setdiff([1:n],union(Hits(:,1),OE(:,1))),[3 5]);
idamnjanovic@8 60 AMT_res.fp_notes_wo_oe = solver.reconstructed.notes(setdiff([1:m],union(Hits(:,2),OE(:,2))),[3 5]);
idamnjanovic@8 61 AMT_res.TP=size(Hits,1);
idamnjanovic@8 62 AMT_res.FN=n-AMT_res.TP;
idamnjanovic@8 63 AMT_res.FP=m-AMT_res.TP;
idamnjanovic@8 64 end