annotate collect_all_mirex_algo_output_data.m @ 6:e2337cd691b1 tip

Finishing writing the matlab code to replicate all observations made in the article. Added the article to the repository. Renamed the two main scripts ("1-get_mirex_estimates.rb" and "2-generate_smith2013_ismir.m") to not have dashes (since this was annoying within Matlab) Added new Michael Jackson figure.
author Jordan Smith <jordan.smith@eecs.qmul.ac.uk>
date Wed, 05 Mar 2014 01:02:26 +0000
parents 92b5a46bc67b
children
rev   line source
jordan@1 1 function mrxoutput = collect_all_mirex_algo_output_data(base_directory, dsets, algos)
jordan@1 2 % function mrxoutput = collect_all_mirex_algo_output_data(base_directory, dsets, algos)
jordan@1 3 %
jordan@1 4 % GET ALL THE DATA!
jordan@1 5 % This function collects the output data (predictions of onset locations and segment
jordan@1 6 % labels) of the algorithms in the MIREX evaluation.
jordan@1 7 %
jordan@1 8 % BASE_DIRECTORY should be the "mirex_path" specified in "get_mirex_estimates.rb",
jordan@1 9 % or whatever directory contains all the downloaded MIREX data. For example:
jordan@1 10 % "/Users/jordan/Desktop/MIREX_data"
jordan@1 11 %
jordan@1 12 % DSETS should contain the names of the datasets. The default value is all of them:
jordan@1 13 % {'mrx09','mrx10_1','mrx10_2','sal'}
jordan@1 14 % Keep the DSETS in a consistent order across your work, because the index of the dataset
jordan@1 15 % is important for some of the other functions.
jordan@1 16 %
jordan@1 17 % ALGOS should contain the name of all the algorithms. The default value is all of them:
jordan@1 18 % {'KSP1','KSP2','KSP3','MHRAF1','OYZS1','SBV1','SMGA1','SMGA2','SP1'}
jordan@1 19 % As with the DSETS, keep these names consistent across all work.
jordan@1 20 %
jordan@1 21 % The output structure MRXOUTPUT contains the following fields:
jordan@1 22 %
jordan@1 23 % MRXOUTPUT(k).ALGO(j).SONG(i) gives the structure of the ith song of the kth dataset
jordan@1 24 % as predicted by the jth algorithm.
jordan@1 25 %
jordan@1 26 % SONG(i).TIM = onset times of annotation
jordan@1 27 % SONG(i).LAB = labels of sections
jordan@1 28 % SONG(i).FILE = file from which the above information derives
jordan@1 29 %
jordan@1 30 % Dependencies:
jordan@1 31 % - load_annotation.m
jordan@1 32
jordan@1 33 if nargin<2,
jordan@1 34 dsets = {'mrx09','mrx10_1','mrx10_2','sal'};
jordan@1 35 end
jordan@1 36 if nargin<3,
jordan@1 37 algos = {'KSP1','KSP2','KSP3','MHRAF1','OYZS1','SBV1','SMGA1','SMGA2','SP1'};
jordan@1 38 end
jordan@1 39
jordan@1 40 % Use the CSV files to discover the names of all the songs.
jordan@1 41 csv_files = {};
jordan@1 42 for i=1:length(dsets),
jordan@1 43 csv_files{end+1} = fullfile(base_directory,dsets{i},algos{1},'per_track_results.csv');
jordan@1 44 end
jordan@1 45 fprintf('About to open some CSV files to extract the names of the songs in MIREX. If you see lots of errors, please ensure that the files exist in the correct location.\n')
jordan@1 46 for i=1:length(csv_files),
jordan@1 47 try
jordan@1 48 fid = fopen(csv_files{i});
jordan@1 49 names_tmp = textscan(fid,'%s%s%*[^\n]','Delimiter',',');
jordan@1 50 fclose(fid);
jordan@1 51 year(i).names = names_tmp{2}(2:end);
jordan@1 52 catch
jordan@1 53 fprintf('Error opening or reading the following CSV file:\n %s\n',csv_files{i});
jordan@1 54 end
jordan@1 55 end
jordan@4 56 fprintf('OK, done with that.\n\n')
jordan@1 57
jordan@1 58
jordan@1 59 fprintf('About to go through all the algorithm outputs and load all the predicted song descriptions. If you see lots of errors, please ensure that the files exist in the correct location.\n')
jordan@1 60
jordan@1 61 mrxoutput = {};
jordan@1 62 % For each dataset (DSET), and for each algorith (ALGO), look in turn at each song.
jordan@1 63 for k=1:length(dsets),
jordan@1 64 dset = dsets{k};
jordan@1 65 for j=1:length(algos),
jordan@1 66 algo = algos{j};
jordan@1 67 for i=1:length(year(k).names),
jordan@1 68 % FYI: PRED stands for 'prediction', in contrast to GT for 'ground truth'.
jordan@1 69 pred = fullfile(base_directory,dset,algo,strcat(year(k).names{i},'_pred.txt'));
jordan@1 70 [mrxoutput(k).algo(j).song(i).tim mrxoutput(k).algo(j).song(i).lab] = load_annotation(pred,'two_column');
jordan@1 71 mrxoutput(k).algo(j).song(i).file = pred;
jordan@1 72 if isempty(mrxoutput(k).algo(j).song(i).tim),
jordan@1 73 fprintf('Screw up on %s?\n',mrxoutput(k).algo(j).song(i).file)
jordan@1 74 end
jordan@1 75 end
jordan@1 76 end
jordan@4 77 end
jordan@4 78 fprintf('OK, done with that.\n\n')