Trial duration conditioning on the type of image #785
Answered
by
vijaymarupudi
wangzhuoranivy
asked this question in
Q&A
-
Hi everyone, I am new with JsPsych and I have a problem with adjusting image duration based on what kind of image it is. I have two types of images: cats and person faces and I would like the cat images to last 200ms and person face images to last 700ms. However, I tried to use this.stimulus and it did not work. Could anyone help me out with this? Thanks a lot, Ivy
|
Beta Was this translation helpful? Give feedback.
Answered by
vijaymarupudi
Jun 25, 2020
Replies: 1 comment 1 reply
-
Try something like this. The second parameter of timelineVariable() should be true when used in a function. // display image
var pic_scr = {
type: "image-keyboard-response",
stimulus: jsPsych.timelineVariable("face"),
data: { screen: "picture" },
trial_duration: function() {
const imagePath = jsPsych.timelineVariable('face', true)
if (imagePath.includes('Cat')) {
return 200
} else {
return 700;
}
},
response_ends_trial: false
};
// determine the trial sequence
var VMRT_task = {
timeline: [focus_pt, pic_scr, blank1_scr],
timeline_variables: [
{ face: "img/Cat_1.jpg" },
{ face: "img/Cat_2.jpg" },
{ face: "img/Cat_3.jpg" },
{ face: "img/Face_1.bmp" },
{ face: "img/Face_2.bmp" },
{ face: "img/Face_3.bmp" }
],
// specify the randomization conditions
sample: {
type: "with-replacement",
size: 5
}
}; |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
wangzhuoranivy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try something like this. The second parameter of timelineVariable() should be true when used in a function.