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?)

  1. The clipping region will be defined by the MTI.ds.makeClip field:

    1. If makeClip==0, then no clipping region is used

    2. 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

    3. 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)

    4. 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:

  1. 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.

  2. We generate the stim trigger Stim_BGpre_trigger so that any trigger devices that are connected can generate triggers.

  3. We wait for MTI.preBGframes video frames (if there are a non-zero number of wait frames)

3. The stimulus is displayed.

  1. The stim trigger Stim_ONSET_trigger is generated

  2. The stimulus is displayed according to the setting of MTI.ds.displayType:

    1. 'CLUTanim': Color Look Up Table Animation. In this mode.

    2. '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

    3. 'custom': calls custom proc

    4. 'Quicktime': shows quicktime movie

    5. 'Sound': plays a sound

4. Posttime: Background is shown for the amount of time specified as the stimulus 'BGposttime'

  1. 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.

    1. We wait for MTI.postBGframes (if there are a non-zero number of wait frames)

    2. 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.