%script to visualize the data of the manuscript "Altered causal inference in credit assignment in high autistic traits." 

% 5 .m files:  
% File 1:  exp 1 outward displacement 
% File 2: exp 1 inward displacement
% File 3: exp 1 serial dependences 
% File 4: exp 2 localization under fixation (not shown as a fig in the ms)
% File 5: exp 2 localization post saccade
%%
%figure 1 outward displacement 
load('DataExp1Out.mat')
%% 
% example saccades amplitudes
figure(1);clf; hold on; title('Figure 1C')
plot(exp1Out.sacampl_out, 'o','MarkerSize',8,'MarkerEdgeColor',[0 0 0],'MarkerFaceColor','none'); hold on;
plot(xlim, ylim*0+13, '--k')
plot(xlim*0+20, ylim, '--k'); text(10,18,sprintf('baseline'),'verticalAlignment','middle','HorizontalAlignment','center')
plot(xlim*0+100, ylim, '--k'); text(120,18,sprintf('de-adapt'),'verticalAlignment','middle','HorizontalAlignment','center')
text(80,18,sprintf('Adapt'),'verticalAlignment','middle','HorizontalAlignment','center')
ylim([10 18])
xlabel('Trials'); ylabel('Saccade amplitude [deg]')

% adaptation magnitude vs AQ (saccade)
figure(2); clf; hold on; suptitle('Figure 1G-H')
subplot(2,2,1); hold on
plot(exp1Out.AQtotal, exp1Out.AdaMagnitude_saccadeOut, 'o', 'MarkerSize',10,'MarkerEdgeColor',[0 0 0],'MarkerFaceColor','none'); hold on;
axis tight
xlabel('AQ score')
ylabel('Adaptation magnitude [deg]')
ylim([-2 3])
xlim([9 30]) 
go = isfinite(exp1Out.AQtotal + exp1Out.AdaMagnitude_saccadeOut);
[pp,S] = polyfit(exp1Out.AQtotal(go),exp1Out.AdaMagnitude_saccadeOut(go),1);
plot(xlim,xlim*pp(1)+pp(2),'-k','linewidth',1)

subplot(2,2,2); hold on; 
err = nanstd(exp1Out.EffSacOutLowAQ)./sqrt(length(exp1Out.EffSacOutLowAQ-1));
bar(1, nanmean(exp1Out.EffSacOutLowAQ), 'k'); hold on; errorbar(1,nanmean(exp1Out.EffSacOutLowAQ), err,'k');
err_1 = nanstd(exp1Out.EffSacOutHighAQ)./sqrt(length(exp1Out.EffSacOutHighAQ-1));
bar(2, nanmean(exp1Out.EffSacOutHighAQ), 'g'); hold on; errorbar(2,nanmean(exp1Out.EffSacOutHighAQ), err_1,'g');
axis tight
xlim([0.5 2.5])
xticks([1 2])
ylim([-1 2])
xticklabels({'low AQ', 'high AQ'})
set(gca,'xticklabels')
ylabel('Mean Adaptation effect')
% gaze deviations 
figure(3); clf; hold on; suptitle('Figure1E')
subplot(2,2,1); hold on
plot(exp1Out.Hgazefix_lowAQ, exp1Out.Vgazefix_lowAQ, '-k'); hold on
plot(exp1Out.Hgazefix_highAQ, exp1Out.Vgazefix_highAQ, '-b'); hold on
legend('lowAQ', 'high AQ')
xlabel(sprintf('\n Horizontal gaze position (%% deviations)'))
ylabel(sprintf('Vertical gaze position (%% deviations)\n '))
subplot(2,2,2); hold on
plot(exp1Out.Hgazeresp_lowAQ, exp1Out.Vgazeresp_lowAQ, '-k'); hold on
plot(exp1Out.Hgazeresp_highAQ, exp1Out.Vgazeresp_highAQ, '-b'); hold on
legend('lowAQ', 'high AQ')
xlabel(sprintf('\n Horizontal gaze position (%% deviations)'))
ylabel(sprintf('Vertical gaze position (%% deviations)\n '))

% example Localization amplitudes
figure(4);clf; hold on; title('Figure 1F')
plot(exp1Out.locampl_out, 'o','MarkerSize',8,'MarkerEdgeColor',[0 0 0],'MarkerFaceColor','none'); hold on;
plot(xlim, ylim*0+13, '--k')
plot(xlim*0+20, ylim, '--k'); text(10,18,sprintf('baseline'),'verticalAlignment','middle','HorizontalAlignment','center')
text(80,18,sprintf('Adapt'),'verticalAlignment','middle','HorizontalAlignment','center')
ylim([10 18])
xlabel('Trials'); ylabel('Saccade amplitude [deg]')

% adaptation magnitude vs AQ (localization)
figure(5); clf; hold on; suptitle('Figure 1I-L')
subplot(2,2,1); hold on
plot(exp1Out.AQtotal, exp1Out.AdaMagnitude_localizOut, 'o', 'MarkerSize',10,'MarkerEdgeColor',[0 0 0],'MarkerFaceColor','none'); hold on;
axis tight
xlabel('AQ score')
ylabel('Adaptation magnitude [deg]')
ylim([-2 3])
xlim([9 30]) 
go = isfinite(exp1Out.AQtotal + exp1Out.AdaMagnitude_localizOut);
[pp,S] = polyfit(exp1Out.AQtotal(go),exp1Out.AdaMagnitude_localizOut(go),1);
plot(xlim,xlim*pp(1)+pp(2),'-k','linewidth',1)

subplot(2,2,2); hold on
err = nanstd(exp1Out.EffLocOutLowAQ)./sqrt(length(exp1Out.EffLocOutLowAQ-1));
bar(1, nanmean(exp1Out.EffLocOutLowAQ), 'k'); hold on; errorbar(1,nanmean(exp1Out.EffLocOutLowAQ), err,'k');
err_1 = nanstd(exp1Out.EffLocOutHighAQ)./sqrt(length(exp1Out.EffLocOutHighAQ-1));
bar(2, nanmean(exp1Out.EffLocOutHighAQ), 'g'); hold on; errorbar(2,nanmean(exp1Out.EffLocOutHighAQ), err_1,'g');
axis tight
xlim([0.5 2.5])
xticks([1 2])
ylim([-1 2])
xticklabels({'low AQ', 'high AQ'})
set(gca,'xticklabels')
ylabel('Mean Adaptation effect')

%% Figure 2 Inward displacement 
load('DataExp1In.mat')
%%
% example saccades amplitudes
figure(6);clf; hold on; title('Figure 2C')
plot(exp1In.sacampl_in, 'o','MarkerSize',8,'MarkerEdgeColor',[0 0 0],'MarkerFaceColor','none'); hold on;
plot(xlim, ylim*0+13, '--k')
plot(xlim*0+20, ylim, '--k'); text(10,18,sprintf('baseline'),'verticalAlignment','middle','HorizontalAlignment','center')
plot(xlim*0+100, ylim, '--k'); text(120,18,sprintf('de-adapt'),'verticalAlignment','middle','HorizontalAlignment','center')
text(80,18,sprintf('Adapt'),'verticalAlignment','middle','HorizontalAlignment','center')
ylim([9 18])
xlabel('Trials'); ylabel('Saccade amplitude [deg]')

% adaptation magnitude vs AQ (saccade)
figure(7); clf; hold on; suptitle('Figure 2G-H')
subplot(2,2,1); hold on
plot(exp1Out.AQtotal, exp1In.AdaMagnitude_saccadeIn, 'o', 'MarkerSize',10,'MarkerEdgeColor',[0 0 0],'MarkerFaceColor','none'); hold on;
axis tight
xlabel('AQ score')
ylabel('Adaptation magnitude [?]')
ylim([-2 1])
xlim([9 30]) 
go = isfinite(exp1Out.AQtotal + exp1In.AdaMagnitude_saccadeIn);
[pp,S] = polyfit(exp1Out.AQtotal(go),exp1In.AdaMagnitude_saccadeIn(go),1);
plot(xlim,xlim*pp(1)+pp(2),'-k','linewidth',1)

subplot(2,2,2); hold on
err = nanstd(exp1In.EffSacInLowAQ)./sqrt(length(exp1In.EffSacInLowAQ-1));
bar(1, nanmean(exp1In.EffSacInLowAQ), 'k'); hold on; errorbar(1,nanmean(exp1In.EffSacInLowAQ), err,'k');
err_1 = nanstd(exp1In.EffSacInHighAQ)./sqrt(length(exp1In.EffSacInHighAQ-1));
bar(2, nanmean(exp1In.EffSacInHighAQ), 'g'); hold on; errorbar(2,nanmean(exp1In.EffSacInHighAQ), err_1,'g');
axis tight
xlim([0.5 2.5])
xticks([1 2])
ylim([-1.6 0.8])
xticklabels({'low AQ', 'high AQ'})
set(gca,'xticklabels')
ylabel('Mean Adaptation effect')

% gaze deviations 
figure(8); clf; hold on; suptitle('Figure2E')
subplot(2,2,1); hold on
plot(exp1In.Hgazefix_lowAQ, exp1In.Vgazefix_lowAQ, '-k'); hold on
plot(exp1In.Hgazefix_highAQ, exp1In.Vgazefix_highAQ, '-b'); hold on
legend('lowAQ', 'high AQ')
xlabel(sprintf('\n Horizontal gaze position (%% deviations)'))
ylabel(sprintf('Vertical gaze position (%% deviations)\n '))
subplot(2,2,2); hold on
plot(exp1In.Hgazeresp_lowAQ, exp1In.Vgazeresp_lowAQ, '-k'); hold on
plot(exp1In.Hgazeresp_highAQ, exp1In.Vgazeresp_highAQ, '-b'); hold on
legend('lowAQ', 'high AQ')
xlabel(sprintf('\n Horizontal gaze position (%% deviations)'))
ylabel(sprintf('Vertical gaze position (%% deviations)\n '))

% example Localization amplitudes
figure(9);clf; hold on; title('Figure 2F')
plot(exp1In.locampl_in, 'o','MarkerSize',8,'MarkerEdgeColor',[0 0 0],'MarkerFaceColor','none'); hold on;
plot(xlim, ylim*0+13, '--k')
plot(xlim*0+20, ylim, '--k'); text(10,18,sprintf('baseline'),'verticalAlignment','middle','HorizontalAlignment','center')
text(80,18,sprintf('Adapt'),'verticalAlignment','middle','HorizontalAlignment','center')
ylim([10 18])
xlabel('Trials'); ylabel('Saccade amplitude [deg]')


% adaptation magnitude vs AQ (localization)
figure(10); clf; hold on; suptitle('Figure 2I-L')
subplot(2,2,1); hold on
plot(exp1Out.AQtotal, exp1In.AdaMagnitude_localizIn, 'o', 'MarkerSize',10,'MarkerEdgeColor',[0 0 0],'MarkerFaceColor','none'); hold on;
axis tight
xlabel('AQ score')
ylabel('Adaptation magnitude [?]')
ylim([-2 3])
xlim([9 30]) 
go = isfinite(exp1Out.AQtotal + exp1In.AdaMagnitude_localizIn);
[pp,S] = polyfit(exp1Out.AQtotal(go),exp1In.AdaMagnitude_localizIn(go),1);
plot(xlim,xlim*pp(1)+pp(2),'-k','linewidth',1)

subplot(2,2,2); hold on
err = nanstd(exp1In.EffLocInLowAQ)./sqrt(length(exp1In.EffLocInLowAQ-1));
bar(1, nanmean(exp1In.EffLocInLowAQ), 'k'); hold on; errorbar(1,nanmean(exp1In.EffLocInLowAQ), err,'k');
err_1 = nanstd(exp1In.EffLocInHighAQ)./sqrt(length(exp1In.EffLocInHighAQ-1));
bar(2, nanmean(exp1In.EffLocInHighAQ), 'g'); hold on; errorbar(2,nanmean(exp1In.EffLocInHighAQ), err_1,'g');
axis tight
xlim([0.5 2.5])
xticks([1 2])
ylim([-1 2])
xticklabels({'low AQ', 'high AQ'})
set(gca,'xticklabels')
ylabel('Mean Adaptation effect')

%% Figure 3 Serial dependencies 
load('DataExp1SerialDep.mat')
%%
% outward
figure(11); clf; hold on; suptitle('Figure 3A-B-C')
subplot(2,2,1);
plot(exp1SD.sacerrOut_lowAQ, exp1SD.locerrOut_lowAQ, 'ok'); errorbar(exp1SD.sacerrOut_lowAQ, exp1SD.locerrOut_lowAQ, exp1SD.semOut_lowAQ, 'ok')
hold on; go = isfinite(exp1SD.sacerrOut_lowAQ + exp1SD.locerrOut_lowAQ);
[pp,S] = polyfit(exp1SD.sacerrOut_lowAQ(go),exp1SD.locerrOut_lowAQ(go),1);
plot(xlim,xlim*pp(1)+pp(2),'-k','linewidth',1)
xlim([-1 2])
ylim([-1.5 1])
xlabel('N-1:saccade error deg')
ylabel('N:localization error deg')
subplot(2,2,2);
plot(exp1SD.sacerrOut_highAQ, exp1SD.locerrOut_highAQ, 'ok'); errorbar(exp1SD.sacerrOut_highAQ, exp1SD.locerrOut_highAQ, exp1SD.semOut_highAQ, 'ok')
hold on; go = isfinite(exp1SD.sacerrOut_highAQ + exp1SD.locerrOut_highAQ);
[pp,S] = polyfit(exp1SD.sacerrOut_highAQ(go),exp1SD.locerrOut_highAQ(go),1);
plot(xlim,xlim*pp(1)+pp(2),'-k','linewidth',1)
xlim([-1 2])
ylim([-1.5 1])
xlabel('N-1:saccade error deg')
ylabel('N:localization error deg')

% slopes vs AQ (outward)
subplot(2,2,3); hold on
plot(exp1SD.AQtot, exp1SD.slopesAllOut, 'o', 'MarkerSize',10,'MarkerEdgeColor',[0 0 0],'MarkerFaceColor','none'); hold on;
axis tight
xlabel('AQ score')
ylabel('slopes')
ylim([-1 1])
xlim([9 30]) 
go = isfinite(exp1SD.AQtot + exp1SD.slopesAllOut);
[pp,S] = polyfit(exp1SD.AQtot(go),exp1SD.slopesAllOut(go),1);
plot(xlim,xlim*pp(1)+pp(2),'-k','linewidth',1)


subplot(2,2,4); hold on
err = nanstd(exp1SD.slopesOut_lowAQ)./sqrt(length(exp1SD.slopesOut_lowAQ-1));
bar(1, nanmean(exp1SD.slopesOut_lowAQ), 'k'); hold on; errorbar(1,nanmean(exp1SD.slopesOut_lowAQ), err,'k');
err_1 = nanstd(exp1SD.slopesOut_highAQ)./sqrt(length(exp1SD.slopesOut_highAQ-1));
bar(2, nanmean(exp1SD.slopesOut_highAQ), 'g'); hold on; errorbar(2,nanmean(exp1SD.slopesOut_highAQ), err_1,'g');
axis tight
xlim([0.5 2.5])
xticks([1 2])
ylim([-.4 .4])
xticklabels({'low AQ', 'high AQ'})
set(gca,'xticklabels')
ylabel('Mean Adaptation effect')

% inward
figure(12); clf; hold on; suptitle('Figure 3D-E-F')
subplot(2,2,1);
plot(exp1SD.sacerrIn_lowAQ, exp1SD.locerrIn_lowAQ, 'ok'); errorbar(exp1SD.sacerrIn_lowAQ, exp1SD.locerrIn_lowAQ, exp1SD.semIn_lowAQ, 'ok')
hold on; go = isfinite(exp1SD.sacerrIn_lowAQ + exp1SD.locerrIn_lowAQ);
[pp,S] = polyfit(exp1SD.sacerrIn_lowAQ(go),exp1SD.locerrIn_lowAQ(go),1);
plot(xlim,xlim*pp(1)+pp(2),'-k','linewidth',1)
xlim([-2 0])
ylim([-1.5 1])
xlabel('N-1:saccade error deg')
ylabel('N:localization error deg')
subplot(2,2,2);
plot(exp1SD.sacerrIn_highAQ, exp1SD.locerrIn_highAQ, 'ok'); errorbar(exp1SD.sacerrIn_highAQ, exp1SD.locerrIn_highAQ, exp1SD.semIn_highAQ, 'ok')
hold on; go = isfinite(exp1SD.sacerrIn_highAQ + exp1SD.locerrIn_highAQ);
[pp,S] = polyfit(exp1SD.sacerrIn_highAQ(go),exp1SD.locerrIn_highAQ(go),1);
plot(xlim,xlim*pp(1)+pp(2),'-k','linewidth',1)
xlim([-2 0])
ylim([-1.5 1])
xlabel('N-1:saccade error deg')
ylabel('N:localization error deg')

% slopes vs AQ (inward)
subplot(2,2,3); hold on
plot(exp1SD.AQtot, exp1SD.slopesAllIn, 'o', 'MarkerSize',10,'MarkerEdgeColor',[0 0 0],'MarkerFaceColor','none'); hold on;
axis tight
xlabel('AQ score')
ylabel('slopes')
ylim([-1 1])
xlim([9 30]) 
go = isfinite(exp1SD.AQtot + exp1SD.slopesAllIn);
[pp,S] = polyfit(exp1SD.AQtot(go),exp1SD.slopesAllIn(go),1);
plot(xlim,xlim*pp(1)+pp(2),'-k','linewidth',1)

subplot(2,2,4); hold on
err = nanstd(exp1SD.slopesIn_lowAQ)./sqrt(length(exp1SD.slopesIn_lowAQ-1));
bar(1, nanmean(exp1SD.slopesIn_lowAQ), 'k'); hold on; errorbar(1,nanmean(exp1SD.slopesIn_lowAQ), err,'k');
err_1 = nanstd(exp1SD.slopesIn_highAQ)./sqrt(length(exp1SD.slopesIn_highAQ-1));
bar(2, nanmean(exp1SD.slopesIn_highAQ), 'g'); hold on; errorbar(2,nanmean(exp1SD.slopesIn_highAQ), err_1,'g');
axis tight
xlim([0.5 2.5])
xticks([1 2])
ylim([-.4 .6])
xticklabels({'low AQ', 'high AQ'})
set(gca,'xticklabels')
ylabel('Mean Adaptation effect')

%% exp 2 localization under fixation (not shown as a figure)
load('DataExp2LocUnderFix.mat')

%%
figure(12); clf; hold on; 
subplot(2,2,1); hold on; title('saccade') 
bar(1,nanmean(exp2LocFix.lowAQ(:,1)), 'k');hold on; bar(2,nanmean(exp2LocFix.highAQ(:,1)), 'g');
errlowAQ = nanstd(exp2LocFix.lowAQ(:,1))./sqrt(length(exp2LocFix.lowAQ(:,1))-1); errhighAQ = nanstd(exp2LocFix.highAQ(:,1))./sqrt(length(exp2LocFix.highAQ(:,1)-1)); 
errorbar(1,nanmean(exp2LocFix.lowAQ(:,1)),errlowAQ,'k'); errorbar(2,nanmean(exp2LocFix.highAQ(:,1)),errhighAQ,'g');
axis tight
xticks([1 2])
xticklabels({'low AQ', 'high AQ'})
set(gca,'xticklabels')  
ylabel('Adaptation magnitude deg')
xlim([0 3])
ylim([-0.6 1])

sacAdapt = [exp2LocFix.lowAQ(:,1);exp2LocFix.highAQ(:,1)];
AQtot = [exp2LocFix.lowAQ(:,3) ;exp2LocFix.highAQ(:,3)];
subplot(2,2,2); hold on
plot(AQtot, sacAdapt, 'o','MarkerSize',8,'MarkerEdgeColor','k','MarkerFaceColor','none');
go = isfinite(AQtot + sacAdapt);
[pp,S] = polyfit(AQtot(go),sacAdapt(go),1);
plot(xlim,xlim*pp(1)+pp(2),'-k','linewidth',1)
ylim([-1 1.2])
xlabel('AQ scores')
ylabel('Magnitude adaptation deg')


subplot(2,2,3); hold on; title('localiz') 
bar(1,nanmean(exp2LocFix.lowAQ(:,2)), 'k');hold on; bar(2,nanmean(exp2LocFix.highAQ(:,2)), 'g');
errlowAQ = nanstd(exp2LocFix.lowAQ(:,2))./sqrt(length(exp2LocFix.lowAQ(:,2))-1); errhighAQ = nanstd(exp2LocFix.highAQ(:,2))./sqrt(length(exp2LocFix.highAQ(:,2)-1)); 
errorbar(1,nanmean(exp2LocFix.lowAQ(:,2)),errlowAQ,'k'); errorbar(2,nanmean(exp2LocFix.highAQ(:,2)),errhighAQ,'g');
axis tight
xticks([1 2])
xticklabels({'low AQ', 'high AQ'})
set(gca,'xticklabels')  
ylabel('Adaptation magnitude deg')
xlim([0 3])
ylim([-0.6 1])

subplot(2,2,4); hold on
locAdapt = [exp2LocFix.lowAQ(:,2);exp2LocFix.highAQ(:,2)];
plot(AQtot, locAdapt, 'o','MarkerSize',8,'MarkerEdgeColor','k','MarkerFaceColor','none');
go = isfinite(AQtot + locAdapt);
[pp,S] = polyfit(AQtot(go),locAdapt(go),1);
plot(xlim,xlim*pp(1)+pp(2),'-k','linewidth',1)
[R,P,RL,RU] = corrcoef(AQtot(go),locAdapt(go));
ylim([-1 1.2])
xlabel('AQ scores')
ylabel('Magnitude adaptation deg')


%% exp 2 localization post saccade
load('DataExp2LocPostSac.mat')

%%
figure(14);clf;hold on; suptitle('Figure 4C-D')
subplot(5,1,1);hold on; title('saccade baseline')
bsl_sacloc_low = exp2LocSac.lowAQ(:,4);
bsl_sacloc_high = exp2LocSac.highAQ(:,4);
plot(bsl_sacloc_low,1:19,'ko','MarkerSize',10, 'MarkerFaceColor','none' );
plot(bsl_sacloc_high,1:19,'go','MarkerSize', 10,'MarkerFaceColor','none' );
x_mean = nanmean(bsl_sacloc_low); x_mean_err = nanstd(bsl_sacloc_low)./sqrt(length(bsl_sacloc_low)-1);
plot(x_mean,13.5,'ko','MarkerSize',15, 'MarkerFaceColor', 'k'); errorbar(x_mean, 13.5,x_mean_err,'k')
y_mean = nanmean(bsl_sacloc_high); y_mean_err = nanstd(bsl_sacloc_high)./sqrt(length(bsl_sacloc_high)-1);
plot(y_mean,13.5,'go','MarkerSize',15, 'MarkerFaceColor', 'g'); errorbar(y_mean, 13.5,y_mean_err,'k')
xlim([10 18])
plot(xlim*0+13,ylim,'--k');
h = gca;
h.YAxis.Visible = 'off';

subplot(5,1,2);hold on;  title('saccade adaptation')
x =  exp2LocSac.lowAQ(:,6);
y =  exp2LocSac.highAQ(:,6);
plot(x,1:19,'ko','MarkerSize', 10, 'MarkerFaceColor','none' );
plot(y,1:19,'go','MarkerSize', 10, 'MarkerFaceColor','none' );
x_means = nanmean(x); plot(x_means,13.5,'ko','MarkerSize',15, 'MarkerFaceColor', 'k');
y_means = nanmean(y); plot(y_means,13.5,'go','MarkerSize',15, 'MarkerFaceColor', 'g')
xlim([10 18])
plot(xlim*0+13,ylim,'--k');
h = gca;
h.YAxis.Visible = 'off';
xlabel('Saccade amplitudes deg')


subplot(5,1,4);hold on; title('localization baseline')
bsl_loc_low = exp2LocSac.lowAQ(:,3);
bsl_loc_high = exp2LocSac.highAQ(:,3);
plot(bsl_loc_low,1:19,'ko','MarkerSize', 10, 'MarkerFaceColor','none' );
plot(bsl_loc_high,1:19,'bo','MarkerSize', 10, 'MarkerFaceColor','none' );
x_mean = nanmean(bsl_loc_low); x_mean_err = nanstd(bsl_loc_low)./sqrt(length(bsl_loc_low)-1);
plot(x_mean,15.5,'ko','MarkerSize',15, 'MarkerFaceColor', 'k'); errorbar(x_mean, 13.5,x_mean_err,'k')
y_mean = nanmean(bsl_loc_high); y_mean_err = nanstd(bsl_loc_high)./sqrt(length(bsl_loc_high)-1);
plot(y_mean,13.5,'bo','MarkerSize',15, 'MarkerFaceColor', 'b'); errorbar(y_mean, 13.5,y_mean_err,'k')
xlim([10 18])
h = gca;
h.YAxis.Visible = 'off';
plot(xlim*0+13,ylim,'--k');

subplot(5,1,5);hold on; title('localization adaptation')
x =  exp2LocSac.lowAQ(:,5);
y =  exp2LocSac.highAQ(:,5);
plot(x,1:19,'ko','MarkerSize', 10, 'MarkerFaceColor','none' );
plot(y,1:19,'bo','MarkerSize', 10, 'MarkerFaceColor','none' );
x_meanl = nanmean(x); plot(x_meanl,13.5,'ko','MarkerSize',15, 'MarkerFaceColor', 'k');
y_meanl = nanmean(y); plot(y_meanl,13.5,'bo','MarkerSize',15, 'MarkerFaceColor', 'b')
xlim([10 18])
plot(xlim*0+13,ylim,'--k');
h = gca;
h.YAxis.Visible = 'off';
xlabel('Localization amplitudes')


figure(15); clf; hold on; suptitle('Figure 4E-F')
subplot(2,2,1); hold on; title('Saccade adaptation magnitide vs AQ')
AQtot = [exp2LocSac.lowAQ(:,7);exp2LocSac.highAQ(:,7)];
SacAdapt = [exp2LocSac.lowAQ(:,2);exp2LocSac.highAQ(:,2)];
plot(AQtot, SacAdapt, 'o','MarkerSize',8,'MarkerEdgeColor','k','MarkerFaceColor','none');
go = isfinite(AQtot + SacAdapt);
[pp,S] = polyfit(AQtot(go),SacAdapt(go),1);
plot(xlim,xlim*pp(1)+pp(2),'-k','linewidth',1)
ylim([-1 1.2])
xlabel('AQ scores')
ylabel('Magnitude adaptation deg')

subplot(2,2,2); hold on; title('Localization adaptation magnitide vs AQ')
AQtot = [exp2LocSac.lowAQ(:,7);exp2LocSac.highAQ(:,7)];
LocAdapt = [exp2LocSac.lowAQ(:,1);exp2LocSac.highAQ(:,1)];
plot(AQtot, LocAdapt, 'o','MarkerSize',8,'MarkerEdgeColor','k','MarkerFaceColor','none');
go = isfinite(AQtot + LocAdapt);
[pp,S] = polyfit(AQtot(go),LocAdapt(go),1);
plot(xlim,xlim*pp(1)+pp(2),'-k','linewidth',1)
ylim([-1 1.2])
xlabel('AQ scores')
ylabel('Magnitude adaptation deg')

