MatVis Demonstration Code (user donations)

MatVis Home Commands Demonstration Code User Sites Acquiring MatVis Neurometrics Home

clear all;
% MatVis demo program that presents crossed and uncrossed dynamic stereograms
% first declare a few variables
width = 120; height = 100; gap=60; size = 50;
% initialize MatVis default to 640 x 480 pixels
matvis('init');

% set the background intensity
bkg = 190; matvis('background', bkg);

% declare two trials with 10 spatial images each
matvis('trial',1,10,[100 100],[height width+width+gap]);
matvis('
trial',2,10,[100 100],[height width+width+gap]);

% change the spatial noise pattern every "num" video frames
% num, spatial pattern #, num, spatial pattern #...
num = 5; temporal=[num, 1, num, 3, num, 5, num, 4, num, 2, num, 6, num, 7, num, 8, num, 9, num, 10];
% repeat the temporal sequence thirty times for each trial
matvis('temporal',1,30,temporal); matvis('temporal',2,30,temporal);

% build the noise patterns for each trial
frame=ones(height,width+width+gap)*bkg;
off = 2; % disparity in pixels
for trial = 1:2,
for spatial=1:10,

surround = rand(height,width)*200; box = rand(size, size)*200;
frame(:,1:width)= surround; frame(:,width+gap+1:width+width+gap) = surround;
if trial == 1 ,

frame((height-size)/2:(height-size)/2+size-1,(width-size)/2+off:(width-size)/2+size-1+off)= box;
frame((height-size)/2:(height-size)/2+size-1,width+gap+(width-size)/2-off:width+gap+(width-size)/2+size-1-off)= box;

else

frame((height-size)/2:(height-size)/2+size-1,(width-size)/2-off:(width-size)/2+size-1-off)= box;
frame((height-size)/2:(height-size)/2+size-1,width+gap+(width-size)/2+off:width+gap+(width-size)/2+size-1+off)= box;

end
% save the current frame for this trial
matvis('spatial',trial,spatial,frame);

end;
end;

% display each trial (dynamic stereogram) then exit
matvis('run',1,0);
matvis('
run',2,0);
matvis('
exit');