/usr/share/psychtoolbox-3/PsychOneliners/MakeGrid.m is in psychtoolbox-3-common 3.0.11.20131230.dfsg1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 30 31 32 33 34 35 36 37 38 39 40 41 42 | function [raster] = MakeGrid(nrow,ncol,xres,yres,plxres,plyres)
% [raster] = MakeGrid(nrow,ncol,xres,yres,plxres,plyres)
%
% Makes raster of elements centered on screen / in image (leftover space is
% divided equally over the edges)
%
% input:
% ncol: number of columns
% nrow: number of rows
% xres: horizontal resolution of screen or image
% yres: vertical resolution of screen or element
% plxres: hor resolution of raster element (can be smaller than xres, not larger)
% plyres: vert resolution of raster element (can be smaller than yres, not
% larger)
%
% output
% raster: struct with boundaries of raster elements
% is a matrix of structs of size number of raster elements
% vertically X number of raster element horizontally
%
% IH 2008
% DN 2008 v1.1 - coordinates sometimes faulty
% DN 2008 v1.2 - coordinates sometimes faulty (actually solved this
% time) + input checking
psychassert(plxres<=xres,'Raster element (plxres) bigger than image/screen (xres)');
psychassert(plyres<=yres,'Raster element (plyres) bigger than image/screen (yres)');
xresr = plxres*ncol;
yresr = plyres*nrow;
psychassert(xresr<=xres,'Too many raster elements horizontally (%d)\n%d pixels required, but only space for %d (xres)',ncol,xresr,xres);
psychassert(yresr<=yres,'Too many raster elements vertically (%d)\n%d pixels required, but only space for %d (yres)',nrow,yresr,yres);
for p=1:nrow,
for q=1:ncol,
raster(p,q).xmin = round((xres - xresr)/2 + (q-1)*plxres);
raster(p,q).xmax = round((xres - xresr)/2 + (q) *plxres);
raster(p,q).ymin = round((yres - yresr)/2 + (p-1)*plyres);
raster(p,q).ymax = round((yres - yresr)/2 + (p) *plyres);
end
end
|