You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am currently setting up a picture naming experiment via jsPsych. Participants see 160 pictures in a random order and their task is to name them. Half of the pictures come from the related condition and the other half from the unrelated condition. Now I want to implement a question that appears randomly after 20% of the related pictures and randomly after 20% of the unrelated picture. The way I have done this so far is the following:
This way, after each trial I assign the data of the timelineVariable that was shown in this trial a "context-label" that eiter says "context" (in 20% of all cases) or "nocontext" (in 80% of all cases). I do this separately for the related and the unrelated cases.
Later, I define the question and create the following timeline:
var context = {
timeline:[context_question],
conditional_function: function(){
// get the data from the previous trial,
// and check which option was selected
var data = jsPsych.data.get().last(1).values()[0];
if (data.context == "context"){
return true;
} else {
return false;
}
}
}
timeline.push([...], voice_trial, context, [...]);
By this, the question only appears if the data of the last trial before the current trial had been (randomly) tagged with "context", which should be the case for 20% of all trials.
However, by this I cannot make sure that each participant sees the question after exactly 20% of all trials. This is because for the first trial, the conditional function cannot draw on the context-label of a last trial (because there is no last trial before the first) and the last trial in the timeline does not have a next trial that will draw upon its context-label. Thus, it may happen, that some participants see the question after 31 trials, some after 32 (20%) and some after 33, which is not ideal.
So, my question is, whether there is a way to randomly assign each timeline Variable randomly with either 'context' (20% of related and 20% of unrelated) or 'nocontext' (20% of related and 20% of unrelated), e.g. at the very beginning of the experiment and later base the conditional function on the context-label of the current (instead of the last) trial. This would make sure, that the question is shown after exactly 20% of all trials. Or do you have any other ideas how I could achieve my goal?
Thanks in advance and for all the other super helpful discussions here!
Best,
Nora
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I am currently setting up a picture naming experiment via jsPsych. Participants see 160 pictures in a random order and their task is to name them. Half of the pictures come from the related condition and the other half from the unrelated condition. Now I want to implement a question that appears randomly after 20% of the related pictures and randomly after 20% of the unrelated picture. The way I have done this so far is the following:
var voice_trial = {
type: "picnaming-voice-record-wav",
stimulus: jsPsych.timelineVariable('item'),
stimulus_duration: 2000,
trial_duration: rec_duration,
object: jsPsych.timelineVariable('object'),
stim_num: jsPsych.timelineVariable('stim_num'),
data: jsPsych.timelineVariable("data"),
on_finish: function(data) {
var context_related = jsPsych.randomization.sampleWithReplacement(["context", "nocontext"], 1, [2,8])[0]
var context_unrelated = jsPsych.randomization.sampleWithReplacement(["context", "nocontext"], 1, [2,8])[0]
if(jsPsych.timelineVariable('relatedness', true) == 'relatiert'){
data.context = context_related;
} else {
data.context = context_unrelated;
}
jsPsych.data.addDataToLastTrial(data);
This way, after each trial I assign the data of the timelineVariable that was shown in this trial a "context-label" that eiter says "context" (in 20% of all cases) or "nocontext" (in 80% of all cases). I do this separately for the related and the unrelated cases.
Later, I define the question and create the following timeline:
var context = {
timeline:[context_question],
conditional_function: function(){
// get the data from the previous trial,
// and check which option was selected
var data = jsPsych.data.get().last(1).values()[0];
if (data.context == "context"){
return true;
} else {
return false;
}
}
}
timeline.push([...], voice_trial, context, [...]);
By this, the question only appears if the data of the last trial before the current trial had been (randomly) tagged with "context", which should be the case for 20% of all trials.
However, by this I cannot make sure that each participant sees the question after exactly 20% of all trials. This is because for the first trial, the conditional function cannot draw on the context-label of a last trial (because there is no last trial before the first) and the last trial in the timeline does not have a next trial that will draw upon its context-label. Thus, it may happen, that some participants see the question after 31 trials, some after 32 (20%) and some after 33, which is not ideal.
So, my question is, whether there is a way to randomly assign each timeline Variable randomly with either 'context' (20% of related and 20% of unrelated) or 'nocontext' (20% of related and 20% of unrelated), e.g. at the very beginning of the experiment and later base the conditional function on the context-label of the current (instead of the last) trial. This would make sure, that the question is shown after exactly 20% of all trials. Or do you have any other ideas how I could achieve my goal?
Thanks in advance and for all the other super helpful discussions here!
Best,
Nora
Beta Was this translation helpful? Give feedback.
All reactions