jsPsych/docs/markdown_docs/plugins/overview.md
2014-11-10 09:10:57 -05:00

6.7 KiB
Raw Blame History

Plugins

In jsPsych, plugins define the kinds of tasks that subjects perform in experiments. Some plugins define very general tasks, like displaying instructions or displaying a visual stimulus and getting a keyboard response. Other plugins are more specific, displaying particular kinds of interactive stimuli, or running a specific kind of perceptual discrimination task. Creating an experiment with jsPsych involves figuring out which plugins are needed for the kinds of tasks you want to have your subjects perform.

Plugins provide a structure for a particular task. For example, the jspsych-single-stim plugin defines a simple structure for showing a visual stimulus and collecting a keyboard response. To use the plugin, you need to specify the content, such as what the stimulus is, what keys the subject is allowed to press, and how long the stimulus should be on the screen. Many of these content options have reasonable default values; even though the jspsych-single-stim plugin has many different options, you only need to specify the stimulus in order to use it. Each plugin has its own documentation page, which describes what the plugin does and what options are available.

Using a plugin

To use a plugin, you'll need to load the plugin's JavaScript file on your experiment page:

<script src="jspsych/plugins/jspsych-single-stim.js" type="text/javascript"></script>

Once a plugin is loaded, you can define a block that uses that plugin. The following JavaScript code defines a trial using the jspsych-single-stim plugin to display an image file ('images/happy_face.jpg'). This trial uses the default values for valid keys, length of display, and so on. You could override these values by adding them to the object.

var single_stim_block = {
	type: 'single-stim',
	stimuli: 'images/happy_face.jpg'
}

Here's an exampe of overriding the default value for timing_post_trial:

var single_stim_block = {
	type: 'single-stim',
	stimuli: 'images/happy_face.jpg',
	timing_post_trial: 2000
}

List of available plugins

This table is a description of all plugins that are currently bundled with jsPsych. Click on the name of a plugin to view its documentation page.

Plugin Description
jspsychanimation Shows a sequence of images at a specified frame rate. Records key presses (including timing information) made by the subject while they are viewing the animation.
jspsychcallfunction Executes an arbitrary function call. Doesn't display anything to the subject, and the subject is usually unaware that this plugin has even executed. It's useful for performing tasks at specified times in the experiment, such as saving data.
jspsychcategorize The subject responds to a stimulus using the keyboard and can be given feedback about the correctness of their response.
jspsychcategorizeanimation A mash-up of the animation and categorize plugin. The subject responds to an animation and can be given feedback about their response.
jspsychfreesort Displays a set of images on the screen in random locations. Subjects can click and drag the images to move them around the screen. Records all the moves made by the subject, so the sequence of moves can be recovered from the data.
jspsychhtml Displays an external HTML page (such as a consent form) and lets the subject respond by clicking a button or pressing a key. Plugin can validate their response, which is useful for making sure that a subject has granted consent before starting the experiment.
jspsychmultistimmultiresponse A more generalized version of the single-stim plugin. Can display multiple stimuli in a single trial, and collect multiple responses in a single trial.
jspsychpalmer Shows grid-like stimuli inspired by Stephen Palmer's work. The stimuli are editable: subjects can add and subtract parts interactively. Also contains a method for generating the HTML code to render the stimuli, allowing them to be used in other plugins.
jspsychsamedifferent A same-different judgment task. A stimulus is shown, followed by a brief gap, and then another stimulus is shown. The subject indicates whether the stimuli are the same or different.
jspsychsimilarity Two stimuli are shown sequentially, and the subject indicates how similar they are by dragging a slider object.
jspsychsinglestim A basic plugin for displaying a stimulus and getting a keyboard response.
jspsychsurveylikert Displays likert-style questions. The subject responds by dragging a slider.
jspsychsurveytext Shows a prompt with a text box. The subject writes a response and then submits by clicking a button.
jspsychtext Shows HTML-formatted text on the screen.
jspsychvisualsearchcircle A customizable visual-search task modelled after Wang, Cavanagh, & Green (1994). The subject indicates whether or not a target is present among a set of distractors. The stimuli are displayed in a circle, evenly-spaced, equidistant from a fixation point.
jspsychvslanimateocclusion A visual statistical learning paradigm based on Fiser & Aslin (2002). A sequence of stimuli are shown in an oscillatory motion. An occluding rectangle is in the center of the display, and the stimuli change when they are behind the rectangle.
jspsychvslgridscene A visual statistical learning paradigm based on Fiser & Aslin (2001). A scene made up of individual stimuli arranged in a grid is shown. This plugin can also generate the HTML code to render the stimuli for use in other plugins.
jspsychxab A two-alternative forced choice task. A target (X) is shown, followed by a brief gap, and then two choices (A & B) are displayed. The subject must pick whichever one matches X (matches is defined however the experimenter wishes; it could be a literal match, or it could be a match on some particular property).