function [] = figure7(expNum);

%
% function [] = figure7(expNum);
%
% plots parts of figure 7 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));




maxFix = 11;

AUC_AWS = nan(72,maxFix);
AUC_PVL = nan(72,maxFix);

for imIdx = 1 : 72
  
  fprintf('Processing %3.3d\n',imIdx);
  
  % complement
  otherImages = 1:72;
  otherImages(imIdx)=[];
  
  for k =1:maxFix
  
	% positive set (all images)
	xPositive = ceil(xFixByImage(:,imIdx,k));
	yPositive = ceil(yFixByImage(:,imIdx,k));
	
	% negative set (all other images)
	xNegative = ceil(xFixByImage(:,otherImages,k));
	yNegative = ceil(yFixByImage(:,otherImages,k));
	
	load(sprintf('./maps_%2.2d',imIdx),'PVL','AWS2');

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

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

  end
  
end



figure(7);
clf;

errorbar([0:10]+.1,nanmean(AUC_AWS),nanstd(AUC_AWS)./sqrt(sum(isfinite(AUC_AWS))),'k.');
hold on;
errorbar([0:10]-.1,nanmean(AUC_PVL),nanstd(AUC_PVL)./sqrt(sum(isfinite(AUC_PVL))),'r.');

axis([-.5 10.5 .45 .75]);
line([-.5 10.5],[.5 .5]);
set(gca,'YTick',[.45 .75]);
set(gca,'XTick',[0 10]);
xlabel('fixation number');
ylabel('AUC');

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
