squircleBehave3.m 2.3 KB

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