plot_residuals_comparison_distributions.m 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. function plot_residuals_comparison_distributions(Zstruct_trwise,save_folder_path,filename_suffix)
  2. Z_b1_LL_trwise=Zstruct_trwise.Z_b1_LL_trwise;
  3. Z_b1_LR_trwise=Zstruct_trwise.Z_b1_LR_trwise;
  4. Z_b2_LL_trwise=Zstruct_trwise.Z_b2_LL_trwise;
  5. Z_b2_LR_trwise=Zstruct_trwise.Z_b2_LR_trwise;
  6. Z1_b1LL=(((Z_b1_LL_trwise(:,:,:,1)))); Z1_b1LR=(((Z_b1_LR_trwise(:,:,:,1)))); % z_bpcL
  7. Z2_b1LL=(((Z_b1_LL_trwise(:,:,:,2)))); Z2_b1LR=(((Z_b1_LR_trwise(:,:,:,2)))); % z_bncR
  8. Z3_b1LL=(((Z_b1_LL_trwise(:,:,:,3)))); Z3_b1LR=(((Z_b1_LR_trwise(:,:,:,3)))); % z_bpcR
  9. Z4_b1LL=(((Z_b1_LL_trwise(:,:,:,4)))); Z4_b1LR=(((Z_b1_LR_trwise(:,:,:,4)))); % z_bncL
  10. Z1_b2LL=(((Z_b2_LL_trwise(:,:,:,1)))); Z1_b2LR=(((Z_b2_LR_trwise(:,:,:,1)))); % z_bpcL
  11. Z2_b2LL=(((Z_b2_LL_trwise(:,:,:,2)))); Z2_b2LR=(((Z_b2_LR_trwise(:,:,:,2)))); % z_bncR
  12. Z3_b2LL=(((Z_b2_LL_trwise(:,:,:,3)))); Z3_b2LR=(((Z_b2_LR_trwise(:,:,:,3)))); % z_bpcR
  13. Z4_b2LL=(((Z_b2_LL_trwise(:,:,:,4)))); Z4_b2LR=(((Z_b2_LR_trwise(:,:,:,4)))); % z_bncL
  14. legitems={'\beta_{1}>0, ch=L','\beta_{1}<0, ch=R','\beta_{1}>0, ch=R','\beta_{1}<0, ch=L',...
  15. '\beta_{2}>0, ch=L','\beta_{2}<0, ch=R','\beta_{2}>0, ch=R','\beta_{2}<0, ch=L'};
  16. ttlab={'SV_L delay2 LookL','SV_L delay2 LookR','SV_R delay2 LookL','SV_R delay2 LookR'};
  17. casestr={'_b1LL','_b1LR','_b2LL','_b2LR'};
  18. for ccs=1:4
  19. close all
  20. h0=fullfig([0 .5 .5 .5]); clo=colororder(); clo(1:2,:)=flipud(clo(1:2,:));
  21. for ss=1:2
  22. subplot(2,2,ss); hold on; plotcmapdots(clo(1:2,:));
  23. histogram(rmnans(vectorisen(eval(['Z' num2str(2*(ss-1)+1) casestr{ccs}]))),-10e-3:1e-4:10e-3,'edgecolor','none','normalization','probability','facecolor',clo(1,:));
  24. histogram(rmnans(vectorisen(eval(['Z' num2str(2*(ss-1)+2) casestr{ccs}]))),-10e-3:1e-4:10e-3,'edgecolor','none','normalization','probability','facecolor',clo(2,:));
  25. legend([sprintf('Z%d ',2*(ss-1)+1) legitems{(ceil(ccs/2)-1)*4+2*(ss-1)+1} ],[sprintf('Z%d ',2*(ss-1)+2) legitems{(ceil(ccs/2)-1)*4+2*(ss-1)+2}],'box','off');
  26. subplot(2,2,ss+2); hold on; plotcmapdots(clo(1:2,:));
  27. histogram(rmnans(vectorisen(eval(['Z' num2str(ss) casestr{ccs}]))),-10e-3:1e-4:10e-3,'edgecolor','none','normalization','probability','facecolor',clo(1,:));
  28. histogram(rmnans(vectorisen(eval(['Z' num2str(ss+2) casestr{ccs}]))),-10e-3:1e-4:10e-3,'edgecolor','none','normalization','probability','facecolor',clo(2,:));
  29. legend([sprintf('Z%d ',ss) legitems{(ceil(ccs/2)-1)*4+ss}],[sprintf('Z%d ',ss+2) legitems{(ceil(ccs/2)-1)*4+ss+2}],'box','off');
  30. ylim([0 .1]);
  31. end
  32. supertitle(ttlab{ccs});
  33. saveas(h0,[save_folder_path ttlab{ccs} ' Z_tr_time_distrib' filename_suffix '.png']);
  34. %end
  35. %for ccs=1:4
  36. %close all;
  37. h1=fullfig([.5 .5 .5 .5]);
  38. for ss=1:2
  39. subplot(2,2,ss); hold on; plotcmapdots(clo(1:2,:));
  40. histogram((nanmean(eval(['Z' num2str(2*(ss-1)+1) casestr{ccs}]),[1 3])),-1e-3:2.5e-5:1e-3,'edgecolor','none','normalization','probability','facecolor',clo(1,:));
  41. histogram((nanmean(eval(['Z' num2str(2*(ss-1)+2) casestr{ccs}]),[1 3])),-1e-3:2.5e-5:1e-3,'edgecolor','none','normalization','probability','facecolor',clo(2,:));
  42. ylim([0 .2]); legend([sprintf('Z%d ',2*(ss-1)+1) legitems{(ceil(ccs/2)-1)*4+2*(ss-1)+1}],[sprintf('Z%d ',2*(ss-1)+2) legitems{(ceil(ccs/2)-1)*4+2*(ss-1)+2}],'box','off');
  43. subplot(2,2,ss+2); hold on; plotcmapdots(clo(1:2,:));
  44. histogram((nanmean(eval(['Z' num2str(ss) casestr{ccs}]),[1 3])),-1e-3:2.5e-5:1e-3,'edgecolor','none','normalization','probability','facecolor',clo(1,:));
  45. histogram((nanmean(eval(['Z' num2str(ss+2) casestr{ccs}]),[1 3])),-1e-3:2.5e-5:1e-3,'edgecolor','none','normalization','probability','facecolor',clo(2,:));
  46. ylim([0 .2]); legend([sprintf('Z%d ',ss) legitems{(ceil(ccs/2)-1)*4+ss}],[sprintf('Z%d ',ss+2) legitems{(ceil(ccs/2)-1)*4+ss+2}],'box','off');
  47. end
  48. supertitle(ttlab{ccs});
  49. saveas(h1,[save_folder_path ttlab{ccs} ' Z_tr_time_avg_distrib' filename_suffix '.png']);
  50. %close all;
  51. h2=fullfig([.5 .25 .5 .25]);
  52. subplot(1,2,1); hold on; plotcmapdots(clo(1:2,:));
  53. x1=(nanmean(cat(2,eval(['Z1' casestr{ccs}]),eval(['Z2' casestr{ccs}])),[1 3]));
  54. x2=(nanmean(cat(2,eval(['Z3' casestr{ccs}]),eval(['Z4' casestr{ccs}])),[1 3]));
  55. histogram(x1,-5e-4:1e-5:5e-4,'edgecolor','none','normalization','probability','facecolor',clo(1,:));
  56. histogram(x2,-5e-4:1e-5:5e-4,'edgecolor','none','normalization','probability','facecolor',clo(2,:));
  57. legend({['Z1 ' legitems{(ceil(ccs/2)-1)*4+1} ',' 10 'Z2 ' legitems{(ceil(ccs/2)-1)*4+2}],...
  58. ['Z3 ' legitems{(ceil(ccs/2)-1)*4+3} ',' 10 'Z4 ' legitems{(ceil(ccs/2)-1)*4+4}]},'box','off');
  59. if ccs<3; p=signrank(x1,x2,'tail','right'); else; p=signrank(x1,x2,'tail','left'); end
  60. ylim([0 .07]); text(0, max(get(gca,'YLim')),sprintf('p=%.2i %s',p,getpstars(p)));
  61. subplot(1,2,2); hold on; plotcmapdots(clo(1:2,:));
  62. x1=(nanmean(cat(2,eval(['Z1' casestr{ccs}]),eval(['Z3' casestr{ccs}])),[1 3]));
  63. x2=(nanmean(cat(2,eval(['Z2' casestr{ccs}]),eval(['Z4' casestr{ccs}])),[1 3]));
  64. histogram(x1,-5e-4:1e-5:5e-4,'edgecolor','none','normalization','probability','facecolor',clo(1,:));
  65. histogram(x2,-5e-4:1e-5:5e-4,'edgecolor','none','normalization','probability','facecolor',clo(2,:));
  66. legend({['Z1 ' legitems{(ceil(ccs/2)-1)*4+1} ',' 10 'Z3 ' legitems{(ceil(ccs/2)-1)*4+3}],...
  67. ['Z2 ' legitems{(ceil(ccs/2)-1)*4+2} ',' 10 'Z4 ' legitems{(ceil(ccs/2)-1)*4+4}]},'box','off');
  68. if ccs<3; p=ranksum(x1,x2,'tail','right'); else; p=ranksum(x1,x2,'tail','left'); end
  69. ylim([0 .07]); text(0, max(get(gca,'YLim')),sprintf('p=%.2i %s',p,getpstars(p)));
  70. supertitle(ttlab{ccs});
  71. saveas(h2,[save_folder_path ttlab{ccs} ' Z_tr_time_avg_distrib_comparison' filename_suffix '.png']);
  72. end
  73. end