Getting started / Making an experiment

Element objects

Most objects in PsychBench fall under the umbrella of element objects. Elements are all the stimuli as well as functionality (e.g. recording response from subject) that can run in trials. There are many different element object types, e.g. picture, cross, linearDotMask, keyPress, etc. etc. We also add new element types regularly—if you have requests, please email contact@psychbench.org. You can also make your own element types or receive them from other people.

Most properties are specific to element type. However, there are some important properties that are common across some or all element types:

Element timing – start, end

Two properties that all elements have are start and end. Each element runs in a trial, and these properties set times or conditions for the element to start/end in the trial (or its pretrial interval). For stimuli this means stimulus onset/offset. For functionality it means when the functionality is active—for example, when the subject is able to respond. Each of start/end is a further struct with possible fields for different timing options. See property documentation for all the options, but below are a few examples just to get the idea.

Note some elements can end on their own—for example, by default a keyPress element ends on its own when it records a response. If so, you don’t need to set end (unless you want the element to maybe end earlier). Also note special timing beyond start/end is available in some element types, e.g. sequence elements.

Examples

element.start.t = 0;
element.end.duration = 2;

→ start at trial start (time from trial start = 0 sec) and run for 2 sec.

element.start.response = true;

→ start at any response from subject recorded by any response handler element.

element.start.responseBy = <cdsm>"recorder"<cdsm>;
element.start.and = <cdsm>"responseScore = true"<cdsm>;
element.end.duration = 2;

→ start at any response recorded by element in variable recorder and scored <cdm>true<cdm>, and run for 2 sec.

element.start(1).response = true;
element.start(1).timeFrom = 2;
element.start(2).t = 10;
element.end.endOf = <cdsm>"pictures(2)"<cdsm>;

→ start 2 sec from any response or 10 sec from trial start (whichever occurs first), and end at end of element in pictures(2).

Trial timing

By default each trial ends whenever no elements in it are left running or scheduled to start (e.g. by a start.t condition), and the next trial starts after a 0.75 sec interval. So the element timing you set also effectively sets trial timing. And trial repetition and order is typically set in your trial list. This is all you need for most experiments.

A few trial object properties allow other options: preTrialInterval, start (start trials at times relative to experiment sync in a past trial, e.g. in a scanner experiment), end (add further end conditions for a whole trial). See Trial timing if you need more information.

Visual elements

Many elements are visual elements, i.e. elements that can show a visual display. All visual elements have a number of properties for standard visual options and transformations:

position
depth
nn_eyes    (stereo display position)
rotation
flipHorz
flipVert
colorMask
alpha    (transparency)
intensity    (brightness)
contrastMult
convolution    (filters like Gaussian blur)
shader    (custom GLSL shaders)
various GLSL shader options
channelResolution    (bit depth)
backColor
addDisplay    (additive blending)

Response handler elements

Another important kind of element is response handler elements. These elements receive and record responses from the subject. Different response handler element types allow response by different methods, e.g. key press, mouse click, button box press, etc. Response handlers only record responses when they are running, so you can control when a subject can respond by that.

A response handler records each response as a value in record property response. What response values can be depends on the element type. For example, keyPress elements record response values that are numbers corresponding to keys pressed.

In addition to type-specific functionality, all response handlers let you do the following:

  • Set property translateResponse to translate response values into values that are more meaningful in the experiment
  • Set properties scoreResponse and correctResponse to score response. Response score can = <cd>true<cd>/<cd>false<cd> (correct/incorrect) or something more complex.
  • Record response and related information in record properties response, responseScore, responseTime, responseLatency, d_responseTime, numResponses
  • Set a maximum number of responses to record in property maxNumResponses. The element ends on its own after this. (Default = 1)
  • Start/End elements from response. This also lets you make feedback, possibly dependent on information like response score.
  • Step a staircase based on whether response is correct
  • Set property registerTrigger to register input as triggers. Set property syncExperiment to sync the experiment at trigger. This lets you set elements in the trial or whole later trials to start/end at times from sync, e.g. in a scanner experiment.