function [ptes, ves, ues, gpes, vpes] = pt_eval_multi(idlist, gtdir, gtext, ptdir, pts)
% [ptes, ves, ues, gpes, vpes] = pt_eval_multi(idlist, gtdir, gtext, ptdir, pts)
%    Run pt_eval over several directories of pitch tracker outputs,
%    and report summary results for each one.  <idlist> is a list
%    of ids to use, finding reference labels in <gtdir>, with
%    extension <gtext>. <pts> is a cell array list of pitch tracker
%    stems, system outputs will be read from 
%    <ptdir>/<pts{i}>/<idlist{j}>-<pts{i}>.txt.
% 2013-02-07 Dan Ellis dpwe@ee.columbia.edu

if gtdir(end) ~= '/'; gtdir = [gtdir, '/']; end
if ptdir(end) ~= '/'; ptdir = [ptdir, '/']; end

% pts can be one string with commas or spaces separating PTs
if ischar(pts)
  % split it into a list on any strings of spaces and/or commas
  pts = regexp(pts, '[ ,]+','split');
end

% Make the list of all ground truth files
gtfiles = addprefixsuffix(idlist, gtdir, gtext);

for i = 1:length(pts)
   % List of system output files for this pitch tracker
   ptfiles = addprefixsuffix(idlist, ...
                             fullfile(ptdir, [pts{i},'/']), ...
                             ['-', pts{i}, '.txt']);
   % Evaluate system output against pseudo-ground-truth
   [pte, ve, ue, gpe, vpe] = pt_eval(gtfiles, ptfiles);
   % print results
   fprintf(1, 'Algo %9s: PTE=%4.1f%% (VE=%4.1f%% (VPE=%4.1f%%, VFR=%4.1f%%) UE=%4.1f%%) GPE=%4.1f%% \n', ...
           pts{i}, 100*mean(pte), 100*mean(ve), 100*mean(vpe), ...
           100*mean(ve-vpe), 100*mean(ue), 100*mean(gpe));
   % save results
   ptes(i) = mean(pte);
   ves(i) = mean(ve);
   ues(i) = mean(ue);
   gpes(i) = mean(gpe);
   vpes(i) = mean(vpe);
end
