checkerboard stimulus

Hi!
I'm fairly new to psychtoolbox and would like some help creating a
checkerboard stimulus. As of now, my code places a rectangle in the
center of the screen and blends from black to gray and I don't
understand why. What I tried to do is see if I can get half of the
center rectangle to be black and white and from there, do this to the
whole screen; eventually, creating a checkerboard. Nevertheless,
this isn't working for me.

I've also tried to use the checkerboard() function as my image matrix
parameter in Screen('MakeTexture'...), but this didn't work for me as
well.

Below is my code. Please help!

Thanks,
Charles


function vbl = checkerBoard(movieDurationInMsec, patchWidth)
%
%
%
% This function shows random noise movie for the given duration
% (movieDurationInMsec).
%
% Example: whiteNoiseMovie(3000) - this will show a white noise movie
for
% 3000 msec or 3 sec.
% determine which screen to use
whichScreen = max(Screen('Screens'));
%-----------------------------------------------------------------
---------
% Hides the mouse cursor
HideCursor;
%-----------------------------------------------------------------
---------
% Opens a graphics window on the main monitor (screen 0). If you
have
% multiple monitors connected to your computer, then you can
specify
% a different monitor by supplying a different number in the
second
% argument to OpenWindow, e.g. Screen('OpenWindow', 2).
%-----------------------------------------------------------------
---------
win = Screen('OpenWindow', whichScreen);
rect = Screen('Rect',win);
refreshRate = Screen(whichScreen,'FrameRate',[]); % refreshRate
given in Hz
oneFrameDuration = 1000 * 1/refreshRate; % frame duration in msec
numberOfFrames = movieDurationInMsec/oneFrameDuration;
%-----------------------------------------------------------------
---------
%patchWidth = 200; % in pixels
patchHeight = 100; % in pixels
sourceRect = [0 0 patchWidth patchHeight]; % this is essentially
the size of the stimulus(width and height in pixels)
%sourceRect2 =[500 400 800 700];
%targRect2 = ArrangeRects(4, sourceRect2, rect, 0);
targRect = centerRect(sourceRect,rect); % rectangle where the
stimulus will be drawn
vbl = zeros(1,1);

%--------------------------------------------------------------
------------
for i = 1:numberOfFrames
seed = [0 255];
%textureInd = Screen('MakeTexture',win,uint8(255*rand
(100,200)));% A random intensity matrix
textureInd = Screen('MakeTexture',win,seed );% A random
intensity matrix
Screen('DrawTexture',win,textureInd, [0 0 size(seed, 2) size
(seed,1)], targRect);
%Screen('DrawTexture',win,textureInd, sourceRect2,[100 100
200 200]);
%Screen('DrawTextures',win,textureInd, sourceRect,targRect2);
%Screen('DrawTextures',win,textureInd, sourceRect2,targRect2);
vbl(i) = Screen('Flip',win);
end
%-----------------------------------------------------------------
---------
% close PTB window
Screen('Close',win)
ShowCursor
%-----------------------------------------------------------------
---------
Oops, I mean Part. 5 (Animation II).
http://rcbi.rochester.edu/ks/part5.pdf

keith

On Apr 2, 2008, at 4:30 PM, Keith Schneider wrote:

> Hi Charles,
>
> There is a checkerboard tutorial in Lecture 6 of my Psychophysics
> Toolbox seminar. Check it out at http://rcbi.rochester.edu/ks/ptb.htm
>
> keith
>
> On Apr 2, 2008, at 10:53 AM, ccarlos206 wrote:
>
>> Hi!
>> I'm fairly new to psychtoolbox and would like some help creating a
>> checkerboard stimulus. As of now, my code places a rectangle in the
>> center of the screen and blends from black to gray and I don't
>> understand why. What I tried to do is see if I can get half of the
>> center rectangle to be black and white and from there, do this to the
>> whole screen; eventually, creating a checkerboard. Nevertheless,
>> this isn't working for me.
>>
>> I've also tried to use the checkerboard() function as my image matrix
>> parameter in Screen('MakeTexture'...), but this didn't work for me as
>> well.
>>
>> Below is my code. Please help!
>>
>> Thanks,
>> Charles
>>
>>
>> function vbl = checkerBoard(movieDurationInMsec, patchWidth)
>> %
>> %
>> %
>> % This function shows random noise movie for the given duration
>> % (movieDurationInMsec).
>> %
>> % Example: whiteNoiseMovie(3000) - this will show a white noise movie
>> for
>> % 3000 msec or 3 sec.
>> % determine which screen to use
>> whichScreen = max(Screen('Screens'));
>> %-----------------------------------------------------------------
>> ---------
>> % Hides the mouse cursor
>> HideCursor;
>> %-----------------------------------------------------------------
>> ---------
>> % Opens a graphics window on the main monitor (screen 0). If you
>> have
>> % multiple monitors connected to your computer, then you can
>> specify
>> % a different monitor by supplying a different number in the
>> second
>> % argument to OpenWindow, e.g. Screen('OpenWindow', 2).
>> %-----------------------------------------------------------------
>> ---------
>> win = Screen('OpenWindow', whichScreen);
>> rect = Screen('Rect',win);
>> refreshRate = Screen(whichScreen,'FrameRate',[]); % refreshRate
>> given in Hz
>> oneFrameDuration = 1000 * 1/refreshRate; % frame duration in msec
>> numberOfFrames = movieDurationInMsec/oneFrameDuration;
>> %-----------------------------------------------------------------
>> ---------
>> %patchWidth = 200; % in pixels
>> patchHeight = 100; % in pixels
>> sourceRect = [0 0 patchWidth patchHeight]; % this is essentially
>> the size of the stimulus(width and height in pixels)
>> %sourceRect2 =[500 400 800 700];
>> %targRect2 = ArrangeRects(4, sourceRect2, rect, 0);
>> targRect = centerRect(sourceRect,rect); % rectangle where the
>> stimulus will be drawn
>> vbl = zeros(1,1);
>>
>> %--------------------------------------------------------------
>> ------------
>> for i = 1:numberOfFrames
>> seed = [0 255];
>> %textureInd = Screen('MakeTexture',win,uint8(255*rand
>> (100,200)));% A random intensity matrix
>> textureInd = Screen('MakeTexture',win,seed );% A random
>> intensity matrix
>> Screen('DrawTexture',win,textureInd, [0 0 size(seed, 2) size
>> (seed,1)], targRect);
>> %Screen('DrawTexture',win,textureInd, sourceRect2,[100 100
>> 200 200]);
>> %Screen('DrawTextures',win,textureInd, sourceRect,targRect2);
>> %Screen('DrawTextures',win,textureInd, sourceRect2,targRect2);
>> vbl(i) = Screen('Flip',win);
>> end
>> %-----------------------------------------------------------------
>> ---------
>> % close PTB window
>> Screen('Close',win)
>> ShowCursor
>> %-----------------------------------------------------------------
>> ---------
>>
>>
>>
>>
>> ------------------------------------
>>
>> Post your message to: psychtoolbox@yahoogroups.com
>> Please indicate OS9, OSX, or WIN version, and include your full name.
>> Denis Pelli, David Brainard, and Allen Ingling.
>> http://psychtoolbox.org
>> Yahoo! Groups Links
>>
>>
>>
>>
>
>
> ------------------------------------
>
> Post your message to: psychtoolbox@yahoogroups.com
> Please indicate OS9, OSX, or WIN version, and include your full name.
> Denis Pelli, David Brainard, and Allen Ingling.
> http://psychtoolbox.org
> Yahoo! Groups Links
>
>
>
>