File: SfGridCyclesDegToPositionGridMinutes.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 (29 lines) | stat: -rw-r--r-- 1,429 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
29
function [xGridMinutes,yGridMinutes] = SfGridCyclesDegToPositionGridMinutes(xSfGridCyclesDeg,ySfGridCyclesDeg)
%SfGridCyclesDegreeToPositionGridMinutes  Convert mesh sf coords to mesh position coords
%    [xGridMinutes,yGridMinutes] = SfGridCyclesDegToPositionGridMinutes(xSfGridCyclesDeg,ySfGridCyclesDeg)
%
% Convert passed x,y sf mesh grids in cycles/degree to corresponding
% position mesh grids in minutes.  Useful for psf/lsf/otf calculation.

%% Generate position 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(xSfGridCyclesDeg);
if (m ~= n)
    error('Passed grids should be square');
end
centerPosition = floor(n/2) + 1;
spatialFrequencyXExtentCyclesDeg = xSfGridCyclesDeg(centerPosition,end)-xSfGridCyclesDeg(centerPosition,1);
spatialFrequencyYExtentCyclesDeg = ySfGridCyclesDeg(end,centerPosition)-ySfGridCyclesDeg(1,centerPosition);
if (spatialFrequencyXExtentCyclesDeg ~= spatialFrequencyYExtentCyclesDeg)
    error('Spatial frequency extent not matched in x and y');
end

spatialFrequencyExtentCyclesMinute = spatialFrequencyXExtentCyclesDeg/60;
if (rem(n,2) == 0)
    positionMinutes = (-n/2:n/2-1)/spatialFrequencyExtentCyclesMinute;
else
    positionMinutes = (-floor(n/2):floor(n/2))/spatialFrequencyExtentCyclesMinute;
end
[xGridMinutes,yGridMinutes] = meshgrid(positionMinutes,positionMinutes);