DrawStimulus
[writing is in progress]
DrawStimulus.m draws a stimulus to the screen (or plays the appropriate sound) using information in the pre-filled MTI (measured-timing-info) structure, and, if necessary, calls a stimulus's custom drawing routine.
1. Set up: In PTB-2 only, any clipping region (that is, masked region) is established. (What is a clipping region/mask region?)
The clipping region will be defined by the MTI.ds.makeClip field:
If makeClip==0, then no clipping region is used
If makeClip==1, [only available in PTB-2] then the points in the field MTI.ds.clipRect define a rectangle (in the global coordinates of the StimWindow) such that drawing only takes places within the rectangle
If makeClip==2, [only available in PTB-2] then the points in the field MTI.ds.clipRect define an oval (in the global coordinates of the StimWindow) such that drawing only takes places within the oval (the points are 1x4 and define a rectangle, but it is "filled" as an oval)
If makeClip==3, [only available in PTB-2] then the points in the field MTI.ds.clipRect define a polygon (in the global coordinates of the StimWindow) such that drawing only takes places within the polygon (see Screen('FillPoly?') for documentation on how to provide these points).
2. Pretime: Background is shown for the amount of time specified as the stimulus 'BGpretime'. To accomplish this:
The background color table (specified in MTI.ds.clut_bg) is set as the current color table, so that the background color is drawn to the screen.
We generate the stim trigger Stim_BGpre_trigger so that any trigger devices that are connected can generate triggers.
We wait for MTI.preBGframes video frames (if there are a non-zero number of wait frames)
3. The stimulus is displayed.
The stim trigger Stim_ONSET_trigger is generated
The stimulus is displayed according to the setting of MTI.ds.displayType:
'CLUTanim': Color Look Up Table Animation. In this mode.
'Movie': This assumes that the display structure MTI.ds has a list of offscreen fields that correspond to offscreen textures (PTB-3) or screens (PTB-2). On each frame, . At the conclusion of each frame we generate the trigger
'custom': calls custom proc
'Quicktime': shows quicktime movie
'Sound': plays a sound
4. Posttime: Background is shown for the amount of time specified as the stimulus 'BGposttime'
The background color table (specified in MTI.ds.clut_bg) is set as the current color table, so that the background color is drawn to the screen.
We wait for MTI.postBGframes (if there are a non-zero number of wait frames)
We generate the stim trigger Stim_BGpost_trigger so that any trigger devices that are connected can generate triggers.
5. Clean up: Any clipping region (that is, masked region) that might have been installed at the beginning is removed.