Skip to content

Tokenized Image Stimulus

A tokenized-image stimulus is similar to the tokenized text stimulus, except that the token is an image instead of a text segment. A tokenized-image stimulus is primarily intended for creating GIF-like stimuli with precise timing control of each token (i.e., "frame"), or for supporting a self-paced viewing paradigm.

Required Properties

type

  • Definition: The type of stimulus (text, tokenized_text, image, etc.)
  • Possible values: For a tokenized-image stimulus, type must be specified as tokenized_image.
1
2
3
4
{
  "type": "tokenized_image",
  "content": ["a.jpg", "b.jpg", "c.jpg"]
}

content

  • Definition: A list consisting of the file names of the list of images to be displayed
  • Possible values: Must be the file names of the image files (e.g. ["a.jpg", "b.jpg", "c.jpg"])
1
2
3
4
{
  "type": "tokenized_image",
  "content": ["a.jpg", "b.jpg", "c.jpg"]
}

Optional Properties

barrier

  • Definition: If set to true, then all subsequent stimuli and responses will not be displayed until this tokenized image stimulus displays all its images.
  • Possible values: true or false
  • Default: true
  • See also: delay

1
2
3
4
5
{
  "type": "tokenized_image",
  "content": ["a.jpg", "b.jpg", "c.jpg"],
  "barrier": false
}
In trials using the above stimulus code, other stimuli and responses will be displayed at the same time as the tokenized image.
1
2
3
4
5
{
  "type": "tokenized_image",
  "content": ["a.jpg", "b.jpg", "c.jpg"],
  "barrier": true
}
In trials using the above stimulus code, the tokenized image will play before other stimuli and responses are displayed. This code is equivalent to code where the barrier property is not specified.

delay

height

  • Definition: The height to display all image tokens in, if a uniform height is desirable.
  • Possible values: A number; percentages (e.g., "50%"), pixels (e.g., "200px"), and other CSS width control units are supported.
  • Default (by omission): The actual height of the image
  • See also: width
1
2
3
4
5
{
  "type": "tokenized_image",
  "content": ["a.jpg", "b.jpg", "c.jpg"],
  "height": "200px"
}

key_advance

  • Definition: The key that a participant should press to display each image token when self_paced is true.
  • Possible values: Any alphanumeric character, and one of the following keys: "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "ShiftLeft", "ShiftRight", "ControlLeft", "ControlRight", "AltLeft", "AltRight"
  • Default: " " (i.e., the space bar)
1
2
3
4
5
6
{
  "type": "tokenized_image",
  "content": ["a.jpg", "b.jpg", "c.jpg"],
  "self_paced": true,
  "key_advance": "j"
}

keep_last

  • Definition: Whether to keep the last token on display after the stimulus completes presenting (only relevant when "mode" is "singleton").
  • Possible values: true or false
  • Default: false
  • See also: mode
1
2
3
4
5
6
{
  "type": "tokenized_image",
  "content": ["a.jpg", "b.jpg", "c.jpg"],
  "mode": "singleton",
  "keep_last": true
}

mode

  • Definition: The mode in which the tokenized image stimulus is displayed
  • Possible values: "plain" (a sequence of images unfolding from left to right) or "singleton" (i.e., GIF-like stimulus)
  • Default: singleton
  • See also: keep_last
1
2
3
4
5
{
  "type": "tokenized_image",
  "content": ["a.jpg", "b.jpg", "c.jpg"],
  "mode": "singleton"
}

parent

  • Definition: If specified, then the properties of the specified stimulus will be inherited by this stimulus, unless a property of the same name is defined in this stimulus.
  • Possible values: The name of another defined stimulus

1
2
3
4
5
6
7
"t_i_1": {
  "type": "tokenized_image",
  "content": ["a.jpg", "b.jpg", "c.jpg"],
  "height": "200px",
  "key_advance": "j",
  "barrier": false
}
1
2
3
4
5
6
"t_i_2": {
  "type": "tokenized_image",
  "content": ["d.jpg", "e.jpg", "f.jpg"],
  "parent": "t_i_1",
  "height": "300px"
}
Here, the t_i_2 stimulus inherits the barrier and key_advance properties of t_i_1. t_i_2 does not inherit the height property of t_i_1 because the stimulus definition of t_i_2 has its own specified height property.

Sample 2 out of 5 image frames:

1
2
3
4
5
{
  "type": "tokenized_image",
  "content": ["frame1.jpg", "frame2.jpg", "frame3.jpg", "frame4.jpg", "frame5.jpg"],
  "sampling": {"k": 2}
}
Setting "k": 2 randomly selects 2 of the 5 frames to present. Increasing k shows more frames; setting it to 0 disables sampling and presents all frames.

Sample 4 frames from a list of 3 frames with replacement:

1
2
3
4
5
{
  "type": "tokenized_image",
  "content": ["frame1.jpg", "frame2.jpg", "frame3.jpg"],
  "sampling": {"k": 4, "replacement": true}
}
With only 3 unique frames, setting "k": 4 would normally lead to an error. But here we set "replacement": true to allow the same frame to appear more than once, which is necessary when k exceeds the number of available frames.

Sample 3 frames with replacement and allow the same frame to appear consecutively:

1
2
3
4
5
{
  "type": "tokenized_image",
  "content": ["frame1.jpg", "frame2.jpg", "frame3.jpg", "frame4.jpg", "frame5.jpg"],
  "sampling": {"k": 3, "replacement": true, "adjacent_duplicates": true}
}
With replacement enabled, the same frame can appear more than once overall. Setting "adjacent_duplicates": true additionally allows the same frame to appear back-to-back. When false, consecutive duplicates are prevented.

self_paced

  • Definition: Whether participant interaction (in the form of a key-press specified by key_advance) is required to trigger the display of each image token. If true, then the display of image tokens is triggered by participant interaction, and reaction time for each image token is recorded. The recorded reaction time reflects how long participants spend viewing an image.
  • Possible values: true, false
  • Default: true

Note

At this time, only true is supported. Setting this to false will be ignored.

1
2
3
4
5
{
  "type": "tokenized_image",
  "content": ["a.jpg", "b.jpg", "c.jpg"],
  "self_paced": true
}

token_duration

  • Definition: The speed, in seconds per token, at which each token image in a tokenized image stimulus is presented.
  • Possible values: A number of seconds per token (i.e. 2) to be displayed, or a list of values specifying the duration of each token (i.e., [1, 2, 3]).
  • See also: self_paced

Note

This property has no effect when self_paced is true, as the display of each image token is triggered by participant interaction rather than automatic timing.

1
2
3
4
5
{
  "type": "tokenized_image",
  "content": ["a.jpg", "b.jpg", "c.jpg"],
  "token_duration": 2
}
In this sample code, a new token will be displayed every 2 seconds.

1
2
3
4
5
{
  "type": "tokenized_image",
  "content": ["a.jpg", "b.jpg", "c.jpg"],
  "token_duration": [1, 2, 3]
}
In this sample code, the first token is displayed for 1 second, the second for 2 seconds, and the third for 3 seconds.

width

  • Definition: The width at which the image is displayed
  • Possible values: A number; percentages (e.g., "50%"), pixels (e.g., "200px"), and other CSS width control units are supported.
  • Default (by omission): Each image is displayed at its native size
  • See also: height
1
2
3
4
5
{
  "type": "tokenized_image",
  "content": ["a.jpg", "b.jpg", "c.jpg"],
  "width": "200px"
}

See Also

Image Stimulus, Tokenized Text Stimulus, Tokenized Audio Stimulus