attachment:visangle2stimsize.m of TransformingVisualAngleAndPixelSize - MRC CBU Imaging Wiki
location: attachment:visangle2stimsize.m of TransformingVisualAngleAndPixelSize

Attachment 'visangle2stimsize.m'

Download

   1 % Provides x,y size in pixels to produce a given size in visual angle. 
   2 % If the screen and distance parameters are undefined, we use the CBU
   3 % scanner settings (see 
   4 % http://imaging.mrc-cbu.cam.ac.uk/mri/CbuStimulusDelivery). If using default
   5 % CBU scanner parameters, the sizey input is also optional.
   6 % use: [sizex,sizey] = visangle2stimsize(visanglex,[visangley],[totdistmm],[screenwidthmm],[screenres])
   7 % 25/9/2009 J Carlin
   8 
   9 function [sizex,sizey] = visangle2stimsize(visanglex,visangley,totdist,screenwidth,screenres)
  10 
  11 if nargin < 3
  12 	% mm
  13 	distscreenmirror=823;
  14 	distmirroreyes=90;
  15 	totdist=distscreenmirror+distmirroreyes;
  16 	screenwidth=268;
  17 
  18 	% pixels
  19 	screenres=1024;
  20 end
  21 
  22 visang_rad = 2 * atan(screenwidth/2/totdist);
  23 visang_deg = visang_rad * (180/pi);
  24 
  25 pix_pervisang = screenres / visang_deg;
  26 
  27 sizex = round(visanglex * pix_pervisang);
  28 
  29 if nargin > 1
  30 	sizey = round(visangley * pix_pervisang);
  31 end

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-12-07 12:00:14, 0.9 KB) [[attachment:stimsize2visangle.m]]
  • [get | view] (2009-12-07 11:59:52, 0.9 KB) [[attachment:visangle2stimsize.m]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.