clear all
close all
figure('pos',[239   337   818   341])

for jjj=1:2
    if jjj==1
        load DisparityDistrib_flesh_rth_xi15_HVSD10_DSD3_xlim1_ylim0.05.mat
    else       
        load DisparityDistrib_flesh_rth_xi15_HVSD20_DSD8_xlim1_ylim0.05.mat
    end
    
    ax(jjj) = subplot(1,2,jjj);
    imagesc(dx,dy,prob);
    colormap(1-gray)
    hold on
    mn = 1/sqrt(2*pi)/SD *exp(-0.5);
    [c,h]=contour(dx,dy,prob,[0 mn],'k:');
    set(h,'linew',2);
    areaelement = min(diff(dx))*min(diff(dy));
    volshown = sum(sum(prob))*areaelement; % this will not in general be the same as vol, because this program is for the situation where the axis range is not large enough to include the whole probability distribution
    z=prctile2dPDF(prob,areaelement,volshown,50)
    [c,h]=contour(dx,dy,prob,[0 z],'k');
    set(h,'linew',2);
    sum(sum(prob(prob>z)))*min(diff(dx))*min(diff(dy))/vol
    sum(sum(prob))*min(diff(dx))*min(diff(dy))/vol
    set(gca,'ydir','normal','fonts',18,'linew',2)
    ylabel('vertical disparity (deg)','fontsize',18)
    xlabel('horizontal disparity (deg)','fontsize',18)
    
    set(gca,'ytick',[-0.05:0.025:0.05])
    set(gca,'pos',[0.17+(jjj-1)*0.5 0.18 0.3 0.65])
    
    if jjj==1
        title('small range in eye position ','fonts',21)
        text(-0.4,1.15,'A','fontweight','bold','fonts',30,'units','norm')
    else
        title('large range in eye position     ','fonts',21)
        text(-0.4,1.15,'B','fontweight','bold','fonts',30,'units','norm')
    end
    
end
set(gcf,'paperpositionmode','auto')