function analyse_results_maskerLoc(bPrintPDF, experiments)

if nargin < 2
    experiments = analyse_results_rmse;
end
if nargin < 1
    bPrintPDF = false;
end

plotFile = './graphics/kopco_rmse_maskerLoc';
open(strcat(plotFile,'.fig'));

addpath ../tools/common

nExperiments = numel(experiments);
nMaskerPatterns = size(experiments(1).rmseIncMixed, 3);
nAzimuths = numel(experiments(1).azimuths);
plotHandles = zeros(nExperiments,1);
titleStrings = {'Dry Condition', 'Reverb Condition'};
for ii = 1:nExperiments
    
    % rmseIncMixed: [7x11x5]
    rmseOnMasker_mixed = [];
    rmseOffMasker_mixed = [];
    rmseOnMasker_fixed = [];
    rmseOffMasker_fixed = [];
    
    for mPat = 1:nMaskerPatterns
        switch (mPat)
            case 1
                maskerPositions = [1 2 3 4];
            case 2
                maskerPositions = [8 9 10 11];
            case 3
                maskerPositions = [4 5 7 8];
            case 4
                maskerPositions = [1 2 10 11];
            case 5
                maskerPositions = [2 5 7 10];
            otherwise
                maskerPositions = [];
        end
        mIdx = zeros(nAzimuths,1);
        mIdx(maskerPositions) = 1;
        rmse = experiments(ii).rmseIncMixed(:,mIdx==1,mPat);
        rmseOnMasker_mixed = [rmseOnMasker_mixed; rmse(:)];
        rmse = experiments(ii).rmseIncMixed(:,mIdx==0,mPat);
        rmseOffMasker_mixed = [rmseOffMasker_mixed; rmse(:)];
        rmse = experiments(ii).rmseIncFixed(:,mIdx==1,mPat);
        rmseOnMasker_fixed = [rmseOnMasker_fixed; rmse(:)];
        rmse = experiments(ii).rmseIncFixed(:,mIdx==0,mPat);
        rmseOffMasker_fixed = [rmseOffMasker_fixed; rmse(:)];
    end
    
    % [All, Off Masker, On Masker] x [Mixed, Fixed]
    [rmseAVG, rmseSEM] = deal(zeros(3,2));
    
    nOnMasker_mixed = length(rmseOnMasker_mixed);
    nOffMasker_mixed = length(rmseOffMasker_mixed);
    nOnMasker_fixed = length(rmseOnMasker_fixed);
    nOffMasker_fixed = length(rmseOffMasker_fixed);
    % All average
    rmseAVG(1,1) = nanmean([rmseOnMasker_mixed; rmseOffMasker_mixed]);
    rmseSEM(1,1) = nanstd([rmseOnMasker_mixed; rmseOffMasker_mixed]) ...
        ./ sqrt(nOnMasker_mixed+nOffMasker_mixed);
    rmseAVG(1,2) = nanmean([rmseOnMasker_fixed; rmseOffMasker_fixed]);
    rmseSEM(1,2) = nanstd([rmseOnMasker_fixed; rmseOffMasker_fixed]) ...
        ./ sqrt(nOnMasker_fixed+nOffMasker_fixed);
    
    % On masker average
    rmseAVG(2,1) = nanmean(rmseOnMasker_mixed);
    rmseSEM(2,1) = nanstd(rmseOnMasker_mixed) ./ sqrt(nOnMasker_mixed);
    rmseAVG(2,2) = nanmean(rmseOnMasker_fixed);
    rmseSEM(2,2) = nanstd(rmseOnMasker_fixed) ./ sqrt(nOnMasker_fixed);
    
    % Off masker average
    rmseAVG(3,1) = nanmean(rmseOffMasker_mixed);
    rmseSEM(3,1) = nanstd(rmseOffMasker_mixed) ./ sqrt(nOffMasker_mixed);
    rmseAVG(3,2) = nanmean(rmseOffMasker_fixed);
    rmseSEM(3,2) = nanstd(rmseOffMasker_fixed) ./ sqrt(nOffMasker_fixed);
    
    plotHandles(ii) = subplot(1,2,ii);
    offset = 0.14;
    % Plot mixed error bar
    hold off
    errorbar((1:3)-offset, rmseAVG(:,1), rmseSEM(:,1), 'k.');
    hold on
    % Plot fixed error bar
    errorbar((1:3)+offset, rmseAVG(:,2), rmseSEM(:,2), 'k.');
    b = bar(rmseAVG, .9, 'grouped');
    set(b(1), 'FaceColor', [1 1 1]);
    set(b(2), 'FaceColor', [1 1 1]);
    axis([0.5 3.5 -1.5 4.8]);
    for n=1:3
        h = text(n-offset, -1.3, 'Mixed', 'FontSize', 14);
        set(h, 'rotation', 90);
        h = text(n+offset, -1.3, 'Fixed', 'FontSize', 14);
        set(h, 'rotation', 90);
    end
    set(gca, 'XTick',1:3, 'XTickLabel', {'All', 'On Masker', 'Off Masker'}, 'FontSize', 14);
    set(gca, 'YTick',1:4,'FontSize', 14);
    xlabel('Target Locations', 'FontSize', 14);
    ylabel('RMS Error re. Control [\circ]', 'FontSize', 14);
    title(titleStrings{ii}, 'FontSize', 14, 'FontWeight', 'Normal');
    
    % Significance test
    fprintf('-- %s\n', titleStrings{ii});
    [p,t] = anova_rm([[rmseOnMasker_mixed;rmseOffMasker_mixed] [rmseOnMasker_fixed;rmseOffMasker_fixed]],'off');
    fprintf('All: mixed avg = %.1f deg, fixed avg = %.1f deg, p = %.4f, F = %.2f\n', rmseAVG(1,1), rmseAVG(1,2), p(1), cell2mat(t(2,5)));
    [p,t] = anova_rm([rmseOnMasker_mixed rmseOnMasker_fixed],'off');
    fprintf('On-masker: mixed avg = %.1f deg, fixed avg = %.1f deg,p = %.4f, F = %.2f\n', rmseAVG(2,1), rmseAVG(2,2), p(1), cell2mat(t(2,5)));
    [p,t] = anova_rm([rmseOffMasker_mixed rmseOffMasker_fixed],'off');
    fprintf('Off-masker: mixed avg = %.1f deg, fixed avg = %.1f deg,p = %.4f, F = %.2f\n', rmseAVG(3,1), rmseAVG(3,2), p(1), cell2mat(t(2,5)));
end

% Resize figure
%set(gcf, 'Position', [0.4167    4.6944    8.9444    3.8333]);
pause(1);
for n = 1:length(plotHandles)
    pos = get(plotHandles(n), 'Position');
    pos(3) = pos(3) * 1.1;
    set(plotHandles(n), 'Position', pos);
end
if bPrintPDF
    set(gcf,'Units','inches');
    pos = get(gcf,'Position');
    set(gcf, 'PaperPosition',[0 0 pos(3:4)],'PaperSize', pos(3:4));
    print('-dpdf', strcat(plotFile,'.pdf'));
end

