It would be nice to have helper functions for generating stimuli. For example, a set of stimuli in jsPsych for a Stroop experiment can be defined in an object as follows:
/*defining stimuli*/
var test_stimuli = [
{
stimulus: "<p style='color:red;font-size:60pt;'>RED</p>",
data: { stim_type: 'congruent', response: 'r'}
},
{
stimulus: "<p style='color:blue;font-size:60pt;'>RED</p>",
data: { stim_type: 'incongruent', response: 'b'}
},
{
stimulus: "<p style='color:green;font-size:60pt;'>RED</p>",
data: { stim_type: 'incongruent', response: 'g'}
},
{
stimulus: "<p style='color:yellow;font-size:60pt;'>RED</p>",
data: { stim_type: 'incongruent', response: 'y'}
}
The above defines 4 individual items, and it takes a bit of copying and pasting to define the remaining combinations.
GOAL
It would be nice to have the stimuli described in table, say tidy format like a dataframe:
| html |
word |
color |
congruency |
| red |
red |
red |
con |
| green |
red |
green |
inc |
| blue |
blue |
yellow |
inc |
Then, write a function that converts the data.frame to the JS object format.
It would be nice to have helper functions for generating stimuli. For example, a set of stimuli in jsPsych for a Stroop experiment can be defined in an object as follows:
The above defines 4 individual items, and it takes a bit of copying and pasting to define the remaining combinations.
GOAL
It would be nice to have the stimuli described in table, say tidy format like a dataframe:
Then, write a function that converts the data.frame to the JS object format.