squircleBehave2trials.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. %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. sW=repmat([CardPrez 1 1 CardPrez],1,4);
  32. sW=sW/mean(sW); % ensure that the mean of the vector is 1
  33. s=s*sW;
  34. % (this could be decomposed further into horizontal and vertical,
  35. % but probably better to keep it simple for now)
  36. %% Predict choices under either model
  37. CP_P=sigmoid(dTp,s,0); % p of sensing "ccw" when test was "ccw" (correct)
  38. CP_N=sigmoid(dTn,s,0); % p of sensing "ccw" when test was "cw" (error)
  39. %% Accuracy (by objective measures as used in analysis) should be
  40. AccuMix=(CP_P+(1-CP_N))/2; % for circle this is symmetric
  41. %% Bias should simply be the average of CPs (CW/CCW)
  42. BiasMix=(CP_P+CP_N)/2;
  43. %% Plots
  44. % note: I'll put 0° at the right (standard circle)
  45. if makefig
  46. subplot(2,2,1); quickplot(oriC,AccuMix,AccuMix,'Accuracy');
  47. subplot(2,2,2); quickplot(oriC,BiasMix,BiasMix,'Bias');
  48. plotori=[oriM oriM(1)]; % to draw complete squircle
  49. subplot(2,2,[3 4]); polarplot(plotori,ones(1,n+1),'o-');
  50. title(['Squircle A=' num2str(A)]); rlim([0 1.5]);
  51. elseif makefigonlybias
  52. quickplot_onlybias(oriC,BiasMix,BiasMix,'Bias');
  53. end
  54. end