ck_2dPRF_ephys.m 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. function out = ck_2dPRF_ephys(xc,yc,sd, settings)
  2. % creates a 3d array of 2d pRF heatmaps
  3. % xc : x-coordinate(s) in degrees (Nx1 vector)
  4. % yc : y-coordinate(s) in degrees (Nx1 vector)
  5. % sd : sima(s) in degrees (Nx1 vector)
  6. % settings.PixPerDeg : pixels per dva
  7. % settings.meshsize : 1000
  8. if nargin < 4
  9. settings.PixPerDeg = 29.5032;
  10. settings.meshsize = 2000;
  11. else
  12. if ~isfield(settings,'PixPerDeg')
  13. settings.PixPerDeg = 29.5032;
  14. end
  15. if ~isfield(settings,'meshsize')
  16. settings.meshsize = 2000;
  17. end
  18. end
  19. xmesh = ((1:settings.meshsize)-settings.meshsize/2)./settings.PixPerDeg;
  20. ymesh = ((settings.meshsize:-1:1)-settings.meshsize/2)./settings.PixPerDeg;
  21. % [x y sd]
  22. gdets = [xc,yc,sd];
  23. ngauss = size(gdets,1);
  24. ZZ=[];
  25. for gz = 1:ngauss
  26. %Read in Gaussian parameters
  27. a = gdets(gz,1);
  28. b = gdets(gz,2);
  29. c = gdets(gz,3);
  30. %Make Gaussian
  31. gw = normpdf(xmesh,a,c);
  32. gv = normpdf(ymesh,b,c);
  33. Z = gv'*gw;
  34. %Z = Z./sum(Z(:)); %Could normalise by sum (surface under Gauss = 1)
  35. Z = Z./max(Z(:)); %Could normalise by max (peak = 1)
  36. if gz == 1
  37. ZZ = zeros(size(Z,1),size(Z,2),ngauss,'single');
  38. end
  39. ZZ(:,:,gz) = single(Z);
  40. end
  41. out.img = ZZ;
  42. out.xmesh = xmesh;
  43. out.ymesh = ymesh;
  44. out.xr = [xmesh(1) xmesh(end)];
  45. out.yr = [ymesh(end) ymesh(1)];