squircleBehave2.m 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. %% Probably better version that directly mixes radians
  2. function [AccuMix, BiasMix]=squircleBehave2(s,A,CardPrez,makefig,makefigonlybias)
  3. %% Settings/prep
  4. n=16; % number of equidistant rotations
  5. testd=6.43; % +/- displacement of test stims in deg (ask Juan)?
  6. % % developer settings:
  7. % s=0.2; % noise (in memory/decision-making)
  8. % A=0.2; % Key Parameter (squircle) 0: all circle; 1: all square
  9. % CardPrez=0.6; % Reduce noise near cardinal by this factor (1: off)
  10. % makefig=1;
  11. %% Get ori vectors (where oriC is "Circle")
  12. [oriC, oriP, oriN]=orivectors(n,testd);
  13. %% Also prepare categorical vector (where oriS is "Square")
  14. oriS1=[repmat(45,1,4) repmat(3*45,1,4) repmat(5*45,1,4) repmat(7*45,1,4)]; % cat
  15. oriS1=deg2rad(oriS1);
  16. oriS2=[0 0 repmat(90,1,4) repmat(2*90,1,4) repmat(3*90,1,4) 360 360]; % anti-cat
  17. oriS2=deg2rad(oriS2);
  18. % mix oris directly
  19. if A>=0
  20. oriM=A*oriS1+(1-A)*oriC;
  21. elseif A<0
  22. fA=-A; % need to flip since its negative
  23. oriM=fA*oriS2+(1-fA)*oriC;
  24. end
  25. %% Calculate angular distances
  26. % between mixed ori and test ori:
  27. dTp=angdiff(oriM,oriP);
  28. dTn=angdiff(oriM,oriN);
  29. %% (optional) better precision at cardinal
  30. sW=repmat([CardPrez 1 1 CardPrez],1,4);
  31. sW=sW/mean(sW); % ensure that the mean of the vector is 1
  32. s=s*sW;
  33. % (this could be decomposed further into horizontal and vertical,
  34. % but probably better to keep it simple for now)
  35. %% Predict choices under either model
  36. CP_P=sigmoid(dTp,s,0); % p of sensing "ccw" when test was "ccw" (correct)
  37. CP_N=sigmoid(dTn,s,0); % p of sensing "ccw" when test was "cw" (error)
  38. %% Accuracy (by objective measures as used in analysis) should be
  39. AccuMix=(CP_P+(1-CP_N))/2; % for circle this is symmetric
  40. %% Bias should simply be the average of CPs (CW/CCW)
  41. BiasMix=(CP_P+CP_N)/2;
  42. %% Plots
  43. % note: I'll put 0° at the right (standard circle)
  44. if makefig
  45. subplot(2,2,1); quickplot(oriC,AccuMix,AccuMix,'Accuracy');
  46. subplot(2,2,2); quickplot(oriC,BiasMix,BiasMix,'Bias');
  47. plotori=[oriM oriM(1)]; % to draw complete squircle
  48. subplot(2,2,[3 4]); polarplot(plotori,ones(1,n+1),'o-');
  49. title(['Squircle A=' num2str(A)]); rlim([0 1.5]);
  50. elseif makefigonlybias
  51. quickplot_onlybias(oriC,BiasMix,BiasMix,'Bias');
  52. end
  53. end