jordan@1: function [mir2pub pub2mir pwf] = match_mirex_to_public_data_macro(mir2pub, pub2mir, pwf, miranns, pubanns, rel_mir, rel_pub, length_thresh, quality_thresh) jordan@1: jordan@1: tic jordan@1: unmatched_mirdata = find(max(transpose(pwf))<.99); jordan@1: unmatched_pubdata = find(max(pwf)<.99); jordan@1: % This is how many more songs we have to match. jordan@4: jordan@4: fprintf('FYI: there are %i songs in this dataset that have not yet been matched.\n',length(unmatched_mirdata)) jordan@1: if ~isempty(unmatched_mirdata) & ~isempty(unmatched_pubdata), jordan@1: jordan@1: for i=row(unmatched_mirdata), jordan@1: dothese = find(max(pwf)<.99 & pwf(i,:)==0); jordan@1: for j=dothese, jordan@1: if (abs(miranns(rel_mir(i)).tim(end)-pubanns(rel_pub(j)).tim(end)) < length_thresh), jordan@1: res = boundary_grader(miranns(rel_mir(i)).tim, pubanns(rel_pub(j)).tim, 1, 3); jordan@1: pwf(i,j) = res(1); jordan@1: end jordan@1: end jordan@4: % toc jordan@1: end jordan@1: end jordan@1: jordan@1: % After running that, we can update our matches. jordan@1: % We will choose, for each MIREX song, the best matching public annotation as long as it has a pwf value of at least 0.99. jordan@1: % (If we just picked the best one, it obviously might be a non-match.) jordan@1: % We will also choose the best-matching MIREX song for each public annotation in the same manner. This means that the best jordan@1: % match from mir2pub and from pub2mir could be different! This is expected, since any song by the Beatles will show up jordan@1: % only once in MIREX, but could show up several times in the public data. jordan@1: jordan@1: % Recall: jordan@1: % rel_mir lists the indices (in miranns) of the mir songs we are looking at. jordan@1: % rel_pub lists the indices (in pubanns) of the pub songs we are looking at. jordan@1: % We want to find, for each miranns index, which pubanns index matches it. jordan@1: jordan@1: % Pick best public match for each MIREX annotation: jordan@1: for i=1:length(rel_mir), jordan@1: miranns_id = rel_mir(i); jordan@1: [value rel_pub_id] = max(pwf(i,:)); jordan@1: if value>=quality_thresh, jordan@1: pubanns_id = rel_pub(rel_pub_id); jordan@1: mir2pub(miranns_id) = pubanns_id; jordan@1: pub2mir(pubanns_id) = miranns_id; jordan@1: end jordan@1: end jordan@1: jordan@1: % Pick best MIREX match for each public annotation: jordan@1: for i=1:length(rel_pub), jordan@1: pubanns_id = rel_pub(i); jordan@1: [value rel_mir_id] = max(pwf(:,i)); jordan@1: if value>=quality_thresh, jordan@1: miranns_id = rel_mir(rel_mir_id); jordan@1: pub2mir(pubanns_id) = miranns_id; jordan@1: mir2pub(miranns_id) = pubanns_id; jordan@1: end jordan@1: end