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.

isosum_psycho.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. % [X Y E]= isosum_psycho(x1,x2,wr,varargin)
  2. % A function to plot psychometrics with isosum lines.
  3. function [X Y E bfit bci]= isosum_psycho(x1,x2,wr,varargin)
  4. nsumbins=5;
  5. sum_bin_e=[];
  6. x_bin_e=[];
  7. nxbins=6;
  8. ax=[];
  9. plot_it=true;
  10. clrs=[.85 0 0;
  11. 0 .1 .8;
  12. 0 .8 .1;
  13. .8 0 1;
  14. 1 .5 0;
  15. 0 0 0;
  16. ];
  17. fit=false;
  18. mod=@erf3;
  19. beta=[0 1 0.5];
  20. model_marker_size=0.3;
  21. data_marker_size=2;
  22. utils.overridedefaults(who,varargin);
  23. if isempty(ax) && plot_it
  24. ax=axes;
  25. end
  26. if isempty(clrs)
  27. clrs=clrs(1:nsumbins,:) ;
  28. end
  29. sumx=x1+x2;
  30. diffx=x2-x1;
  31. if isempty(sum_bin_e)
  32. pbins=linspace(0,100,nsumbins+1);
  33. sum_bin_e=prctile(sumx,pbins);
  34. end
  35. if isempty(x_bin_e)
  36. pbins=linspace(0,100,nxbins+1);
  37. x_bin_e=prctile(diffx,pbins);
  38. end
  39. Y=nan(nsumbins,nxbins);
  40. E=Y;
  41. X=Y;
  42. set(ax,'NextPlot','add');
  43. if fit
  44. [bfit,resid,J,Sigma]=nlinfit([x1 x2],wr,mod,beta);
  45. bci=nlparci(bfit,resid,'covar',Sigma);
  46. [ll,bb]=loglikelihood(mod(bfit,[x1 x2]),wr,numel(beta));
  47. fprintf('The BIC is %0.2f\n',bb);
  48. fprintf('The -LL is %0.2f\n',-ll);
  49. else
  50. bfit=0;
  51. bci=[0 0];
  52. end
  53. for sx=1:nsumbins
  54. gt=sumx>=sum_bin_e(sx) & sumx<sum_bin_e(sx+1);
  55. dc=diffx(gt);
  56. x_bin_e=prctile(dc,pbins);
  57. [X(sx,:) Y(sx,:) E(sx,:)]=binned(dc,wr(gt),'bin_e',x_bin_e);
  58. if plot_it
  59. if fit
  60. mp=plot(ax,dc,mod(bfit,[x1(gt) x2(gt)]),'.','Color',(clrs(sx,:)+1)/2);
  61. set(mp,'MarkerSize',model_marker_size);
  62. end
  63. he=draw.errorplot(ax,X(sx,:)+0.2*sx,Y(sx,:), E(sx,:),'Color',clrs(sx,:),'Marker','o');
  64. set(he(2),'MarkerFaceColor',clrs(sx,:),'MarkerSize',data_marker_size);
  65. end
  66. end
  67. if fit
  68. ch=get(ax,'Children');
  69. mch=findobj(ch,'Marker','.');
  70. cdh=setdiff(ch,mch);
  71. set(ax,'Children',[cdh; mch]);
  72. end
  73. function y=erf2(b,x)
  74. lapse=b(1);
  75. gain=b(2);
  76. ipsC=x(:,1);
  77. conC=x(:,2);
  78. inp=gain*(conC-ipsC)./(ipsC+conC).^0.5;
  79. y=lapse + (1-2*lapse)*(0.5*(erf(inp)+1));
  80. function y=erf3(b,x)
  81. lapse=b(1);
  82. gain=b(2);
  83. noise=b(3);
  84. ipsC=x(:,1);
  85. conC=x(:,2);
  86. inp=gain*(conC-ipsC)./(ipsC+conC).^noise;
  87. y=lapse + (1-2*lapse)*(0.5*(erf(inp)+1));