Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

plot_comparisons_choice_prob_cellwise.m 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. function [binary_nngt_comp,nnmd_diff_comp,nnmn_diff_comp,Zlengths] = plot_comparisons_choice_prob_cellwise(...
  2. Zstruct_trwise,save_folder_path,filename_suffix)
  3. addpath(genpath('../../../../my-tools'));
  4. Nys=1000;
  5. Nccs=size(Zstruct_trwise.Z_b1_LL_trwise,2);
  6. sidestr={'Left','Right'};
  7. casestr={'_b1_LL','_b1_LR','_b2_LL','_b2_LR'};
  8. ttlab={'SV_L delay2 LookL','SV_L delay2 LookR','SV_R delay2 LookL','SV_R delay2 LookR'};
  9. binary_nngt_comp=nan(4,Nccs); nnmd_diff_comp=nan(4,Nccs); nnmn_diff_comp=nan(4,Nccs);
  10. Zlengths=nan(4,Nccs,4);
  11. FPR1_mat=nan(4,Nccs,Nys); TPR1_mat=nan(4,Nccs,Nys); AUC1_mat=nan(4,Nccs,1);
  12. FPR2_mat=nan(4,Nccs,Nys); TPR2_mat=nan(4,Nccs,Nys); AUC2_mat=nan(4,Nccs,1);
  13. FPR_mat=nan(4,Nccs,Nys); TPR_mat=nan(4,Nccs,Nys); AUC_mat=nan(4,Nccs,1);
  14. for cases=1:4
  15. Z1rnm=nanmean(eval(['Zstruct_trwise.Z' casestr{cases} '_trwise(:,:,:,1)']),3);
  16. Z2rnm=nanmean(eval(['Zstruct_trwise.Z' casestr{cases} '_trwise(:,:,:,2)']),3);
  17. Z3rnm=nanmean(eval(['Zstruct_trwise.Z' casestr{cases} '_trwise(:,:,:,3)']),3);
  18. Z4rnm=nanmean(eval(['Zstruct_trwise.Z' casestr{cases} '_trwise(:,:,:,4)']),3);
  19. parfor cc=1:Nccs
  20. Z1rnm_cc=rmnans(Z1rnm(:,cc)); Z2rnm_cc=rmnans(Z2rnm(:,cc));
  21. Z3rnm_cc=rmnans(Z3rnm(:,cc)); Z4rnm_cc=rmnans(Z4rnm(:,cc));
  22. ZD11=nan; ZD21=nan; ZD31=nan;
  23. ZD12=nan; ZD22=nan; ZD32=nan;
  24. csw=(cases<=2)-(cases>2); % switches LookL>LookR in SVL to LookR>LookL in SVR
  25. Zlengths(cases,cc,:)=[length(Z1rnm_cc) length(Z2rnm_cc) length(Z3rnm_cc) length(Z4rnm_cc)];
  26. if ~isempty(Z1rnm_cc) && ~isempty(Z3rnm) % beta1 is positive: increasing p(chL), hence chL > chR
  27. yd=linspace(min([Z1rnm_cc(:); Z3rnm_cc(:)]),max([Z1rnm_cc(:); Z3rnm_cc(:)]),Nys);
  28. if cases<=2
  29. [FPR1_mat(cases,cc,:),TPR1_mat(cases,cc,:),AUC1_mat(cases,cc)]=get_fpr_tpr_auc(Z1rnm_cc,Z3rnm_cc,yd);
  30. [ZD11,ZD21,ZD31]=vecdiffsubsamp(Z1rnm_cc,Z3rnm_cc,100);
  31. else
  32. [FPR1_mat(cases,cc,:),TPR1_mat(cases,cc,:),AUC1_mat(cases,cc)]=get_fpr_tpr_auc(Z3rnm_cc,Z1rnm_cc,yd);
  33. [ZD11,ZD21,ZD31]=vecdiffsubsamp(Z3rnm_cc,Z1rnm_cc,100);
  34. end
  35. end
  36. if ~isempty(Z2rnm_cc) && ~isempty(Z4rnm_cc) % beta1 is negative: increasing p(chR), hence chL < chR
  37. yd=linspace(min([Z4rnm_cc(:); Z2rnm_cc(:)]),max([Z4rnm_cc(:); Z3rnm_cc(:)]),Nys);
  38. if cases<=2
  39. [FPR2_mat(cases,cc,:),TPR2_mat(cases,cc,:),AUC2_mat(cases,cc)]=get_fpr_tpr_auc(Z4rnm_cc,Z2rnm_cc,yd);
  40. [ZD12,ZD22,ZD32]=vecdiffsubsamp(Z4rnm_cc,Z2rnm_cc,100);
  41. else
  42. [FPR2_mat(cases,cc,:),TPR2_mat(cases,cc,:),AUC2_mat(cases,cc)]=get_fpr_tpr_auc(Z2rnm_cc,Z4rnm_cc,yd);
  43. [ZD12,ZD22,ZD32]=vecdiffsubsamp(Z2rnm_cc,Z4rnm_cc,100);
  44. end
  45. end
  46. if cases==1 || cases==4
  47. binary_nngt_comp(cases,cc)=nanmax([ZD11 ZD12]);%nanmean(ZDiff>0,'all');
  48. if ~isnan(ZD11) && ~isnan(ZD12)
  49. if ZD11>ZD12
  50. FPR_mat(cases,cc,:)=FPR1_mat(cases,cc,:);
  51. TPR_mat(cases,cc,:)=TPR1_mat(cases,cc,:);
  52. AUC_mat(cases,cc)=AUC1_mat(cases,cc);
  53. else
  54. FPR_mat(cases,cc,:)=FPR2_mat(cases,cc,:);
  55. TPR_mat(cases,cc,:)=TPR2_mat(cases,cc,:);
  56. AUC_mat(cases,cc)=AUC2_mat(cases,cc);
  57. end
  58. elseif ~isnan(ZD11)
  59. FPR_mat(cases,cc,:)=FPR1_mat(cases,cc,:);
  60. TPR_mat(cases,cc,:)=TPR1_mat(cases,cc,:);
  61. AUC_mat(cases,cc)=AUC1_mat(cases,cc);
  62. elseif ~isnan(ZD12)
  63. FPR_mat(cases,cc,:)=FPR2_mat(cases,cc,:);
  64. TPR_mat(cases,cc,:)=TPR2_mat(cases,cc,:);
  65. AUC_mat(cases,cc)=AUC2_mat(cases,cc);
  66. end
  67. else
  68. binary_nngt_comp(cases,cc)=nanmin([ZD11 ZD12]);%nanmean(ZDiff>0,'all');
  69. if ~isnan(ZD11) && ~isnan(ZD12)
  70. if ZD11>ZD12
  71. FPR_mat(cases,cc,:)=FPR2_mat(cases,cc,:);
  72. TPR_mat(cases,cc,:)=TPR2_mat(cases,cc,:);
  73. AUC_mat(cases,cc)=AUC2_mat(cases,cc);
  74. else
  75. FPR_mat(cases,cc,:)=FPR1_mat(cases,cc,:);
  76. TPR_mat(cases,cc,:)=TPR1_mat(cases,cc,:);
  77. AUC_mat(cases,cc)=AUC1_mat(cases,cc);
  78. end
  79. elseif ~isnan(ZD11)
  80. FPR_mat(cases,cc,:)=FPR1_mat(cases,cc,:);
  81. TPR_mat(cases,cc,:)=TPR1_mat(cases,cc,:);
  82. AUC_mat(cases,cc)=AUC1_mat(cases,cc);
  83. elseif ~isnan(ZD12)
  84. FPR_mat(cases,cc,:)=FPR2_mat(cases,cc,:);
  85. TPR_mat(cases,cc,:)=TPR2_mat(cases,cc,:);
  86. AUC_mat(cases,cc)=AUC2_mat(cases,cc);
  87. end
  88. end
  89. nnmd_diff_comp(cases,cc)=nanmean([ZD21 ZD22]);%nanmedian(ZDiff,'all');
  90. nnmn_diff_comp(cases,cc)=nanmean([ZD31 ZD32]);%nanmedian(ZDiff,'all');
  91. end
  92. fprintf('computing case:%d/4 %s\n',cases,ttlab{cases})
  93. end
  94. %% Quick safety checks
  95. %save('FTPN.mat','TP','FP','TN','FN')
  96. %FPR=nansum(FP,2)./(nansum(TN,2)+nansum(FP,2))
  97. %TPR=nansum(TP,2)./(nansum(FN,2)+nansum(TP,2))
  98. %nanmean(AUC1)
  99. %nanmean(FPR1)
  100. %nanmean(TPR1)
  101. %plot(nanmean(FPR1),nanmean(TPR1),'k','linewidth',1.5); hold on
  102. %plot([0 1],[0 1]); hold on
  103. %error
  104. %% Plot zone
  105. close all
  106. hff=fullfig([0 0 .5 .5]); clo=colororder();
  107. for cs=1:4
  108. subplot(2,2,cs); hold on
  109. if cs==2
  110. subplot(2,2,3);
  111. elseif cs==3
  112. subplot(2,2,2);
  113. end
  114. if cs==1 || cs==4; pvtail='right'; else pvtail='left'; end
  115. xvnm=(nnmn_diff_comp(cs,:)); pvnm=ranksum(xvnm,zeros(size(xvnm)),'tail',pvtail);
  116. xvnd=(nnmd_diff_comp(cs,:)); pvnd=ranksum(xvnd,zeros(size(xvnd)),'tail',pvtail);
  117. histogram(xvnm,-1e-3:2e-5:1e-3,'edgecolor','none','normalization','count'); hold on;
  118. histogram(xvnd,-1e-3:2e-5:1e-3,'edgecolor',[.5 .5 .5],'normalization','count','facecolor','none'); hold on; % ylim([0 20]);
  119. plot(nanmedian(xvnm),max(get(gca,'YLim')),'v','markeredgecolor',clo(1,:)); plotvline(0,'k-');
  120. plot(nanmedian(xvnd),max(get(gca,'YLim')),'v','markeredgecolor',[.5 .5 .5]); plotvline(0,'k-');
  121. text(min(get(gca,'XLim')).*.9,max(get(gca,'YLim')).*.9,sprintf('p=%.2i %s',pvnm,getpstars(pvnm)),'color',clo(1,:));
  122. text(min(get(gca,'XLim')).*.9,max(get(gca,'YLim')).*.8,sprintf('p=%.2i %s',pvnd,getpstars(pvnd)),'color',[.5 .5 .5]);
  123. xlabel('resudials difference'); ylabel('cell count'); box off;
  124. title(ttlab{cs}); legend({'mean','median'},'box','off')
  125. end
  126. saveas(hff,[save_folder_path 'ChoiceProb-SV-Look-4p' filename_suffix '.fig']);
  127. saveas(hff,[save_folder_path 'ChoiceProb-SV-Look-4p' filename_suffix '.svg']);
  128. saveas(hff,[save_folder_path 'ChoiceProb-SV-Look-4p' filename_suffix '.png']);
  129. hff=fullfig([.5 .25 .5 .25]);
  130. for cs=1:2
  131. subplot(1,2,cs); hold on
  132. xvnm=(nnmn_diff_comp(2*(cs-1)+1,:))-(nnmn_diff_comp(2*(cs-1)+2,:));
  133. if cs==2; xvnm=-xvnm; end
  134. pvnm=ranksum(xvnm,zeros(size(xvnm)),'tail','right');
  135. histogram(xvnm,-2e-3:5e-5:2e-3,'facecolor',clo(1,:),'edgecolor','none','normalization','count'); hold on; ylim([0 28]);
  136. plot(nanmedian(xvnm),max(get(gca,'YLim')),'rv','markeredgecolor',clo(1,:)); plotvline(0,'k-');
  137. xvnd=nnmd_diff_comp(2*(cs-1)+1,:)-nnmd_diff_comp(2*(cs-1)+2,:);
  138. if cs==2; xvnd=-xvnd; end
  139. pvnd=ranksum(xvnd,zeros(size(xvnd)),'tail','right');
  140. histogram(xvnd,-2e-3:5e-5:2e-3,'facecolor','none','edgecolor',[.3 .3 .3],'normalization','count'); hold on; ylim([0 28]);
  141. plot(nanmedian(xvnd),max(get(gca,'YLim')),'rv','markeredgecolor',[.3 .3 .3]); plotvline(0,'k-');
  142. text(-1.8e-3,max(get(gca,'YLim')).*.9,sprintf('p=%.2i %s',pvnm,getpstars(pvnm)),'color',clo(1,:));
  143. text(-1.8e-3,max(get(gca,'YLim')).*.8,sprintf('p=%.2i %s',pvnd,getpstars(pvnd)),'color',[.3 .3 .3]);
  144. xlabel('resudials difference'); ylabel('cell count');
  145. if cs==1
  146. title([ttlab{2*(cs-1)+1}(1:end-5) '(LookL - LookR)']);
  147. else
  148. title([ttlab{2*(cs-1)+1}(1:end-5) '(LookR - LookL)']);
  149. end
  150. end
  151. saveas(hff,[save_folder_path 'ChoiceProb-SV-Look-2p' filename_suffix '.fig']);
  152. saveas(hff,[save_folder_path 'ChoiceProb-SV-Look-2p' filename_suffix '.svg']);
  153. saveas(hff,[save_folder_path 'ChoiceProb-SV-Look-2p' filename_suffix '.png']);
  154. hff=fullfig([.5 0 .5 .25]); comb=[1 4; 2 3];
  155. for cs=1:2
  156. subplot(1,2,cs); hold on
  157. xvnm=[nnmn_diff_comp(comb(cs,1),:) nnmn_diff_comp(comb(cs,2),:)];
  158. %if cs==2; xvnm=-xvnm; end
  159. histogram(xvnm,-2e-3:2e-5:2e-3,'facecolor',[.5 .5 .5],'edgecolor','none','normalization','count'); hold on; ylim([0 38]);
  160. plot(nanmedian(xvnm),max(get(gca,'YLim')),'rv','markeredgecolor',[.5 .5 .5]); plotvline(0,'k-');
  161. xvnd=[nnmd_diff_comp(comb(cs,1),:) nnmd_diff_comp(comb(cs,2),:)];
  162. %if cs==2; xvnd=-xvnd; end
  163. histogram(xvnd,-2e-3:2e-5:2e-3,'facecolor',clo(1,:),'edgecolor','none','normalization','count'); hold on; ylim([0 38]);
  164. plot(nanmedian(xvnd),max(get(gca,'YLim')),'rv','markeredgecolor',clo(1,:)); plotvline(0,'k-');
  165. if cs==1
  166. pvnm=ranksum(xvnm,zeros(size(xvnm)),'tail','right');
  167. pvnd=ranksum(xvnd,zeros(size(xvnd)),'tail','right');
  168. else
  169. pvnm=ranksum(xvnm,zeros(size(xvnm)),'tail','left');
  170. pvnd=ranksum(xvnd,zeros(size(xvnd)),'tail','left');
  171. end
  172. xlim([-1.5e-3 1.5e-3]);
  173. text(min(get(gca,'XLim'))*.9,max(get(gca,'YLim')).*.9,sprintf('p=%.2i %s',pvnm,getpstars(pvnm)),'color',[.5 .5 .5]);
  174. text(min(get(gca,'XLim'))*.9,max(get(gca,'YLim')).*.8,sprintf('p=%.2i %s',pvnd,getpstars(pvnd)),'color',clo(1,:));
  175. xlabel('resudials difference (ch. ipsil. - ch. contral.)'); ylabel('cell count');
  176. if cs==1
  177. title('delay2 encoding (SV_L LookL, SV_R LookR)');
  178. else
  179. title('delay2 encoding (SV_L LookR, SV_R LookL)');
  180. end
  181. end
  182. saveas(hff,[save_folder_path 'ChoiceProb-SV-Look-2p-sides-' filename_suffix '.fig']);
  183. saveas(hff,[save_folder_path 'ChoiceProb-SV-Look-2p-sides-' filename_suffix '.svg']);
  184. saveas(hff,[save_folder_path 'ChoiceProb-SV-Look-2p-sides-' filename_suffix '.png']);
  185. hff=fullfig([0 .5 .5 .5]); clo=colororder(); clo(1:2,:)=flipud(clo(1:2,:));
  186. for cs=1:4
  187. subplot(2,2,cs);
  188. if cs==2; subplot(2,2,3); elseif cs==3; subplot(2,2,2); end
  189. xv=binary_nngt_comp(cs,:);
  190. if mod(cs,3)==1
  191. pv=ranksum(xv,.5*ones(size(xv)),'tail','right');
  192. text(0,14,sprintf('>.5 p=%.2i %s',pv,getpstars(pv)));
  193. else
  194. pv=ranksum(xv,.5*ones(size(xv)),'tail','left');
  195. text(0,14,sprintf('<.5 p=%.2i %s',pv,getpstars(pv)));
  196. end
  197. text(.25,25,sprintf('n=%2.0d',sum(xv<.5)),'color',clo(1,:)); hold on
  198. text(.75,25,sprintf('n=%2.0d',sum(xv>=.5)),'color',clo(2,:));
  199. histogram(xv(xv<.5),0:.01:1,'edgecolor','none','normalization','count','facecolor',clo(1,:)); hold on
  200. histogram(xv(xv>=.5),0:.01:1,'edgecolor','none','normalization','count','facecolor',clo(2,:)); hold on
  201. ylim([0 30]); plotvline(0.5,'k-'); ylim([0 30]);
  202. title(ttlab{cs}); xlabel([sidestr{ceil(cs/2)} ' choice probability']); ylabel('cell count'); box off
  203. end
  204. saveas(hff,[save_folder_path 'ChoicePref-SV-Look' filename_suffix '.fig']);
  205. saveas(hff,[save_folder_path 'ChoicePref-SV-Look' filename_suffix '.svg']);
  206. saveas(hff,[save_folder_path 'ChoicePref-SV-Look' filename_suffix '.png']);
  207. hff=fullfig([.5 0 .5 .25]); clo=colororder(); clo(1:2,:)=flipud(clo(1:2,:));
  208. for cs=1:2
  209. subplot(1,2,cs); hold on; plotcmapdots(clo);
  210. histogram(binary_nngt_comp(2*(cs-1)+1,:),0:7e-3:1,'edgecolor','none','normalization','count','facecolor',clo(1,:)); hold on
  211. histogram(binary_nngt_comp(2*(cs-1)+2,:),0:7e-3:1,'edgecolor','none','normalization','count','facecolor',clo(2,:)); hold on
  212. ylim([0 20]);
  213. nm1=nanmean(binary_nngt_comp(2*(cs-1)+1,:)); nsd1=nanstd(binary_nngt_comp(2*(cs-1)+1,:));
  214. nm2=nanmean(binary_nngt_comp(2*(cs-1)+2,:)); nsd2=nanstd(binary_nngt_comp(2*(cs-1)+2,:));
  215. plot(0:7e-3:1,Nccs*normpdf(0:7e-3:1,nm1,nsd1)*7e-3,'color',clo(1,:));
  216. plot(0:7e-3:1,Nccs*normpdf(0:7e-3:1,nm2,nsd2)*7e-3,'color',clo(2,:));
  217. plot(nanmedian(binary_nngt_comp(2*(cs-1)+1,:)),max(get(gca,'YLim')),'v','markeredgecolor','none','markerfacecolor',clo(1,:));
  218. plot([1 1].*nanmedian(binary_nngt_comp(2*(cs-1)+1,:)),get(gca,'YLim'),':','color',clo(1,:));
  219. plot(nanmedian(binary_nngt_comp(2*(cs-1)+2,:)),max(get(gca,'YLim')),'v','markeredgecolor','none','markerfacecolor',clo(2,:));
  220. plot([1 1].*nanmedian(binary_nngt_comp(2*(cs-1)+2,:)),get(gca,'YLim'),':','color',clo(2,:)); plotvline(.5,'k:')
  221. if cs==1
  222. pv=ranksum(binary_nngt_comp(2*(cs-1)+1,:),binary_nngt_comp(2*(cs-1)+2,:),'tail','right');
  223. else
  224. pv=ranksum(binary_nngt_comp(2*(cs-1)+1,:),binary_nngt_comp(2*(cs-1)+2,:),'tail','left');
  225. end
  226. text(0,14,sprintf('p=%.2i %s',pv,getpstars(pv)));
  227. title(ttlab{2*(cs-1)+1}(1:end-6)); xlabel([sidestr{cs} ' choice probability']); ylabel('cell count'); box off
  228. legend({'LookL','LookR'},'Location','northeast','box','off')
  229. end
  230. saveas(hff,[save_folder_path 'ChoicePref-SV-Look-comparison' filename_suffix '.fig']);
  231. saveas(hff,[save_folder_path 'ChoicePref-SV-Look-comparison' filename_suffix '.svg']);
  232. saveas(hff,[save_folder_path 'ChoicePref-SV-Look-comparison' filename_suffix '.png']);
  233. hff=fullfig([.5 .25 .5 .25]); xorder=[1 2 4 3];
  234. for cs=1:2
  235. subplot(1,2,cs);
  236. X1=binary_nngt_comp(xorder((cs-1)*2+1),:);
  237. X2=binary_nngt_comp(xorder((cs-1)*2+2),:);
  238. [FPR,TPR,AUC]=get_fpr_tpr_auc(X1,X2,0:.001:1,0);
  239. plot(FPR,TPR); hold on; plot([0 1],[0 1]); daspect([1 1 1]);
  240. xlabel('False positive rate'); ylabel('True positive rate');
  241. text(.3,.1,sprintf('AUC = %.3f',AUC));
  242. title(['ROC ch=' sidestr{cs}(1) ', ' ttlab{xorder((cs-1)*2+1)} ' vs ' ttlab{xorder((cs-1)*2+2)}(end-4:end)]);
  243. end
  244. saveas(hff,[save_folder_path 'ChoicePref-SV-Look-comparison-ROC' filename_suffix '.fig']);
  245. saveas(hff,[save_folder_path 'ChoicePref-SV-Look-comparison-ROC' filename_suffix '.svg']);
  246. saveas(hff,[save_folder_path 'ChoicePref-SV-Look-comparison-ROC' filename_suffix '.png']);
  247. hff=fullfig([0 0 .7 .5]);
  248. for cs=1:4
  249. subplot(2,2,cs);
  250. plot(squeeze(FPR_mat(cs,:,:))',squeeze(TPR_mat(cs,:,:))','-','color',[.8 .8 .8]);hold on
  251. plot([0 1],[0 1],'k:')
  252. plot(squeeze(nanmean(FPR_mat(cs,:,:),2)),squeeze(nanmean(TPR_mat(cs,:,:),2)),'k:','linewidth',2)
  253. plot(squeeze(nanmedian(FPR_mat(cs,:,:),2)),squeeze(nanmedian(TPR_mat(cs,:,:),2)),'k','linewidth',2)
  254. nm=nanmedian(binary_nngt_comp(cs,:));
  255. title(sprintf('%s AUC md:%.3f mn:%.3f - CP md:%.3f',ttlab{cs},nanmedian(AUC_mat(cs,:)),nanmean(AUC_mat(cs,:)),nm));
  256. daspect([1 1 1])
  257. end
  258. saveas(hff,[save_folder_path 'ChoicePref-SV-Look-comparison-ROC-cellwise' filename_suffix '.fig']);
  259. saveas(hff,[save_folder_path 'ChoicePref-SV-Look-comparison-ROC-cellwise' filename_suffix '.svg']);
  260. saveas(hff,[save_folder_path 'ChoicePref-SV-Look-comparison-ROC-cellwise' filename_suffix '.png']);
  261. hff=fullfig([.5 0 .5 .25]); clo=colororder(); clo(1:2,:)=flipud(clo(1:2,:));
  262. for cs=1:2
  263. subplot(1,2,cs); hold on; plotcmapdots(clo);
  264. histogram(AUC_mat(2*(cs-1)+1,:),0:7e-3:1,'edgecolor','none','normalization','count','facecolor',clo(1,:)); hold on
  265. histogram(AUC_mat(2*(cs-1)+2,:),0:7e-3:1,'edgecolor','none','normalization','count','facecolor',clo(2,:)); hold on
  266. ylim([0 20]);
  267. nm1=nanmean(AUC_mat(2*(cs-1)+1,:)); nsd1=nanstd(AUC_mat(2*(cs-1)+1,:));
  268. nm2=nanmean(AUC_mat(2*(cs-1)+2,:)); nsd2=nanstd(AUC_mat(2*(cs-1)+2,:));
  269. plot(0:7e-3:1,sum(~isnan(AUC_mat(2*(cs-1)+1,:)))*normpdf(0:7e-3:1,nm1,nsd1)*7e-3,'color',clo(1,:));
  270. plot(0:7e-3:1,sum(~isnan(AUC_mat(2*(cs-1)+2,:)))*normpdf(0:7e-3:1,nm2,nsd2)*7e-3,'color',clo(2,:));
  271. plot(nanmedian(AUC_mat(2*(cs-1)+1,:)),max(get(gca,'YLim')),'v','markeredgecolor','none','markerfacecolor',clo(1,:));
  272. plot([1 1].*nanmedian(AUC_mat(2*(cs-1)+1,:)),get(gca,'YLim'),':','color',clo(1,:));
  273. plot(nanmedian(AUC_mat(2*(cs-1)+2,:)),max(get(gca,'YLim')),'v','markeredgecolor','none','markerfacecolor',clo(2,:));
  274. plot([1 1].*nanmedian(AUC_mat(2*(cs-1)+2,:)),get(gca,'YLim'),':','color',clo(2,:)); plotvline(.5,'k:')
  275. if cs==1
  276. pv=ranksum(AUC_mat(2*(cs-1)+1,:),AUC_mat(2*(cs-1)+2,:),'tail','right');
  277. else
  278. pv=ranksum(AUC_mat(2*(cs-1)+1,:),AUC_mat(2*(cs-1)+2,:),'tail','left');
  279. end
  280. text(0,14,sprintf('p=%.2i %s',pv,getpstars(pv)));
  281. title(ttlab{2*(cs-1)+1}(1:end-6)); xlabel([sidestr{cs} ' AUC']); ylabel('cell count'); box off
  282. legend({'LookL','LookR'},'Location','northeast','box','off')
  283. end
  284. saveas(hff,[save_folder_path 'ChoicePref-SV-Look-comparison-AUC' filename_suffix '.fig']);
  285. saveas(hff,[save_folder_path 'ChoicePref-SV-Look-comparison-AUC' filename_suffix '.svg']);
  286. saveas(hff,[save_folder_path 'ChoicePref-SV-Look-comparison-AUC' filename_suffix '.png']);
  287. end