File: PositionGridMinutesToSfGridCyclesDeg.m

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (28 lines) | stat: -rw-r--r-- 1,267 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function [xSfGridCyclesDeg,ySfGridCyclesDeg] = PositionGridMinutesToSfGridCyclesDeg(xGridMinutes,yGridMinutes)
%PositionGridMinutesToSfGridCyclesDeg  Convert mesh sf coords to mesh position coords
%    xSfGridCyclesDeg,ySfGridCyclesDeg] = PositionGridMinutesToSfGridCyclesDeg(xGridMinutes,yGridMinutes)
%
% Convert passed x,y position mesh grids in minutes to corresponding
% sf mesh grids in cycles/degree.  Useful for psf/lsf/otf calculation


%% Generate spatial frequency grids
%
% Samples are evenly spaced and the same for both x and y (checked above).
% Handle even versus odd dimension properly for fft conventions.
[m,n] = size(xGridMinutes);
if (m ~= n)
    error('Passed grids should be square');
end
centerPosition = floor(n/2) + 1;
spatialXExtentMinutes = xGridMinutes(centerPosition,end)-xGridMinutes(centerPosition,1);
spatialYExtentMinutes = yGridMinutes(end,centerPosition)-yGridMinutes(1,centerPosition);
if (spatialXExtentMinutes ~= spatialYExtentMinutes)
    error('Spatial frequency extent not matched in x and y');
end
if (rem(n,2) == 0)
    sfCyclesDeg = 60*(-n/2:n/2-1)/spatialXExtentMinutes;
else
    sfCyclesDeg = 60*(-floor(n/2):floor(n/2))/spatialXExtentMinutes;
end
[xSfGridCyclesDeg,ySfGridCyclesDeg] = meshgrid(sfCyclesDeg,sfCyclesDeg);