Skip to content

vis.oridir.fit.doublegaussian

  DOUBLEGAUSSIAN - perform a double gaussian fit for stimulus direction

   [P, FITCURVE, MSSE, R2] = DOUBLEGAUSSIAN(ANGLES, RESPONSES)

  Given ANGLES and RESPONSES, produce a least-squares fit to the function

  R=Rsp+Rp*EXP(-(ANGLES-Op)^2)/(2*sigm^2))+Rn*EXP(-(ANGLES-Op+180)^2/(2*sigm^2))

  ANGLES should be in degrees.

  where 
    Rsp = P(1)
    Rp = P(2)
    Op = P(3)
    sigm = P(4)
    Rn = P(5)

  Rsp is constrained to be within -span and + span, where span is max(responses)-min(responses).
  Rp is constrained to be between 0 and 3 times the peak response.
  Rn is constrained to be between 0 and Rp
  Op is between 0 and 2*pi, excluding 2*pi
  sigm must be larger than the median difference between angles divided by 2 and 90.

  Example:
     angles = 0:30:360-30;
     P = [ -0.5 20 10 55 39];
     responses = vlt.neuro.vision.oridir.doublegaussianfunc(angles,P);
     [P_fit,fitcurve,msse,R2] = vis.oridir.fit.doublegaussian(angles,responses);
     figure;
     plot(angles,responses,'o');
     hold on
     plot(fitcurve(1,:),fitcurve(2,:),'b-');
     box off;