Wiki

Clone wiki

StimServer / BuildingStimuli

Building stimuli lists

Use the function CreateStimulusStructure to help build an array of stimuli.

Each stimulus definition is contained in a matlab data structure, with the fields

     '.fhPresentationFunction' - function handle that will be used to present
         the stimulus.  It must be called like ...(hWindow, vtBlankTime, tFrameDuration, ...
                                                   <presentation params list>, ...
                                                   <stimulus arguments list>);
         It must return [tLastPresentation, bBlewBlankTime, bBlewFrameRate] = ...()
 
     '.cPresentationParameters' - A cell array of arbitrary presentation
         parameters to be passed to 'fhPresentationFunction'.
 
     '.cStimulusArguments' - A cell array of arbitrary stimulus parameters to be
         passed to 'fhPresentationFunction'.

The functions CreateStimulusStructure and PresentArbitraryStimulus will help here.

Basically, each structure contains a handle to a function that knows how to present a stimulus of a given type, as well as all the parameters needed to construct that stimulus.

The parameters at the each of each of the parameter lists <presentation params list> and <stimulus arguments list> can be left off, in which case they can be specified over the wire to customise the display of a stimulus. In that case they are set not by the toolbox directly, but by the triggering server through a UDP command.

Example

sStimuli(1) = CreateStimulusStructure(@PresentOscillatingGratingStimulus, {10}, {[], 1, fPPD, 0});

sStimuli(2) = CreateStimulusStructure(@PresentOscillatingGratingStimulus, {10}, {[], 4, fPPD});

This generates a stimulus list containing two stimuli. The first is an oscillating grating of 10 seconds duration (the "{10}" is the <presentation params list>), with 1 cycle per degree, specified calibration information ("fPPD" is the pixels per degree for the screen) and a fixed angle of zero degrees.

The second stimulus is another oscillating grating, but with 4 cycles per degree and no specified grating angle.

To present the first stimulus, you would just direct the server to show stimulus ID 1, specify a blanking time (5 seconds) and a frame duration (30 ms):

SS PRESENT 1 5 30e-3

To present the second stimulus, you would have to also specify a presentation angle for the grating:

SS PRESENT 2 5 30e-3 0 1 45

This will present stimulus two with no extra presentation arguments, one extra stimulus argument (the presentation angle), and set the presentation angle to 45 degrees.

See the communication protocol for more information.

Updated