annotate util/AMT_analysis.m @ 8:33850553b702

(none)
author idamnjanovic
date Mon, 22 Mar 2010 10:56:54 +0000
parents
children fc395272d53e
rev   line source
idamnjanovic@8 1 function AMT_res = AMT_analysis(Problem, solver)
idamnjanovic@8 2 %%% Automatic Music Transcription results analysis
idamnjanovic@8 3 % Ivan Damnjanovic 2009
idamnjanovic@8 4 %
idamnjanovic@8 5 % If wav file that is transcribed is generated from midi file (i.e. if
idamnjanovic@8 6 % groundtruth exists) transcription is comapred to the original notes and
idamnjanovic@8 7 % AMT_res structure is generated. It contains following fields:
idamnjanovic@8 8 % - tp_notes - true positive notes (notes corectly transcribed)
idamnjanovic@8 9 % - oe_notes - octave errors (erroes due to imperfect pitch estimation)
idamnjanovic@8 10 % - fn_notes_wo_oe - false negative notes without octave errors
idamnjanovic@8 11 % (notes that were not detected)
idamnjanovic@8 12 % - fp_notes_wo_oe - false positive notes without octave erors
idamnjanovic@8 13 % - TP - number of true positives
idamnjanovic@8 14 % - FN - number of false negatives
idamnjanovic@8 15 % - FP - number of false positives
idamnjanovic@8 16
idamnjanovic@8 17 timeOr=Problem.notesOriginal(:,5);
idamnjanovic@8 18 noteOr=Problem.notesOriginal(:,3);
idamnjanovic@8 19 timeTr=solver.reconstructed.notes(:,5);
idamnjanovic@8 20 noteTr=solver.reconstructed.notes(:,3);
idamnjanovic@8 21 n=size(timeOr,1);
idamnjanovic@8 22 m=size(timeTr,1);
idamnjanovic@8 23
idamnjanovic@8 24 % tolerance (ts) is set to one window before and after the reference offset
idamnjanovic@8 25 % time
idamnjanovic@8 26
idamnjanovic@8 27 ts=(Problem.windowSize)/Problem.fs;
idamnjanovic@8 28
idamnjanovic@8 29 Hits=[];
idamnjanovic@8 30 OE=[];
idamnjanovic@8 31
idamnjanovic@8 32 for i=1:n
idamnjanovic@8 33 Hit= find((noteTr(:)==noteOr(i))&(abs(timeOr(i)-timeTr(:))<ts));
idamnjanovic@8 34 if size(Hit,1)>1 Hit=Hit(1); end
idamnjanovic@8 35 if ~isempty(Hit) Hits=[Hits; i , Hit];
idamnjanovic@8 36 else
idamnjanovic@8 37 OctErr=find(((noteTr(:)==noteOr(i)-12)|(noteTr(:)==noteOr(i)-24))&(abs(timeOr(i)-timeTr(:))<ts), 1);
idamnjanovic@8 38 if ~isempty(OctErr) OE=[OE; i , OctErr]; end
idamnjanovic@8 39 end
idamnjanovic@8 40 end
idamnjanovic@8 41
idamnjanovic@8 42 AMT_res.tp_notes = [Problem.notesOriginal(Hits(:,1),[3 5]) solver.reconstructed.notes(Hits(:,2),[3 5])];
idamnjanovic@8 43 AMT_res.oe_notes = [Problem.notesOriginal(OE(:,1),[3 5]) solver.reconstructed.notes(OE(:,2),[3 5])];
idamnjanovic@8 44 AMT_res.fn_notes_wo_oe = Problem.notesOriginal(setdiff([1:n],union(Hits(:,1),OE(:,1))),[3 5]);
idamnjanovic@8 45 AMT_res.fp_notes_wo_oe = solver.reconstructed.notes(setdiff([1:m],union(Hits(:,2),OE(:,2))),[3 5]);
idamnjanovic@8 46 AMT_res.TP=size(Hits,1);
idamnjanovic@8 47 AMT_res.FN=n-AMT_res.TP;
idamnjanovic@8 48 AMT_res.FP=m-AMT_res.TP;
idamnjanovic@8 49 end