function [] = figure6(expNum);

%
% function [] = figure6(expNum);
%
% plots parts of figure 6 of the paper
%
% Stoll, J., Thrun, M., Nuthmann, A., & Einhäuser, W. (2015). Overt
% attention in natural scenes: Objects dominate features. Vision
% Research, 107, 36-48. doi: 10.1016/j.visres.2014.11.006 
%
% for experiment number given as parameter expNum
%
%

if (expNum~=2)&(expNum~=3)
  error('Experiment number must be 2 or 3');
end

load(sprintf('exp%d_fixations',expNum));

AUCaws = nan(72,1);
AUCpvl = nan(72,1);

for imIdx = 1 : 72
  
  % complement
  otherImages = 1:72;
  otherImages(imIdx)=[];
  
  % positive set (all images)
  xPositive = ceil(xFixByImage(:,imIdx,2:end));
  yPositive = ceil(yFixByImage(:,imIdx,2:end));
  
  % negative set (all other images)
  xNegative = ceil(xFixByImage(:,otherImages,2:end));
  yNegative = ceil(yFixByImage(:,otherImages,2:end));

 
  load(sprintf('./maps_%2.2d',imIdx),'PVL','AWS2');

  % AWS (of modified scenes)
  valPos = computeValsAtFixation(xPositive(:),yPositive(:),AWS2);
  valNeg = computeValsAtFixation(xNegative(:),yNegative(:),AWS2);
  AUCaws(imIdx) = computeROC(valNeg,valPos);

  % PVL
  valPos = computeValsAtFixation(xPositive(:),yPositive(:),PVL);
  valNeg = computeValsAtFixation(xNegative(:),yNegative(:),PVL);
  AUCpvl(imIdx) = computeROC(valNeg,valPos);

  
end

figure(6);
clf;

M = mean([AUCaws,AUCpvl]);
S = std([AUCaws,AUCpvl])/sqrt(72);

bar([1:2],M-.5);
hold on;
errorbar([1:2],M-.5,S,'ko');
  
ylabel('AUC');
set(gca,'XTick',[1:2]);
set(gca,'XTickLabel',{'AWS','PVL'});
ylim([0 0.2]);
set(gca,'YTick',[0 0.2]);
set(gca,'YTickLabel',[0.5 0.7]);

function [valsAtFixation]=computeValsAtFixation(x,y,map);

ixBad = find(isnan(x)|isnan(y));
x(ixBad)=[];
y(ixBad)=[];

[yS,xS] = size(map);

ixBad = find((x<1)|(x>xS)|(y<1)|(y>yS));
x(ixBad)=[];
y(ixBad)=[];

valsAtFixation = nan(1,length(x));


for k = 1 : length(x)
  
  valsAtFixation(k)=map(y(k),x(k));
  
end
