Randomizing blocks in a nested timeline #1737
-
Hi! My goal is to build an experiment with two kinds of blocks of 15 trials with different rates of trial difficulty (e.g a hard block with 75% hard and 25% medium trials and an easy block with 75% easy and 25% medium trials, trial sequences randomized within blocks). My approach was the following:
experimental_trial = {
timeline: [prosp_confidence, fixation, rdk, retro_confidence, affect_slider, experimental_feedback, iti,]
}
var hard_params = [{direction:"0", coherence:"0.4"}, {direction:"180",coherence:"0.4"}, {direction:"0",coherence:"0.2"}, {direction:"180",coherence:"0.2"}]
var hard_block = {
timeline: [experimental_trial],
timeline_variables: hard_params,
sample: {
type: 'with-replacement',
size: 15,
weights: [0.25,0.25,0.75,0.75],
},
on_start: function() {
block_type = 'hard_block'
phase = 'experimental'}
}
var easy_params = [
{direction:"0", coherence:"0.4"},
{direction:"180", coherence:"0.4"},
{direction:"0", coherence:"0.8"},
{direction:"180", coherence:"0.8"}]
// build an easy block
var easy_block = {
timeline: [experimental_trial],
timeline_variables: easy_params,
sample: {
type: 'with-replacement',
size: 3, // 10 trials, with replacement
weights: [0.25,0.25,0.75,0.75], // The Alex trial is three times as likely to be sampled as the others.
},
on_start: function() {
block_type = 'easy_block'
phase = 'experimental'}
}
var blocks = ["hard_block", "easy_block"];
var experimental_timeline = jsPsych.randomization.sampleWithReplacement(blocks, 6);
experimental_procedure = {
timeline: experimental_timeline} However, the last part (4) does not seem to work and I have not found a way to randomize my hard and easy blocks in the experimental procedure level. So I'm wondering is my approach even possible or should I try to tackle it some other way? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @j22tis, I like this approach and I think it should work. I think the reason your last step isn't working is because you're sampling from an array of strings, rather than sampling the actual objects that are named with those strings. So try doing it without the quotes around var blocks = [hard_block, easy_block];
var experimental_timeline = jsPsych.randomization.sampleWithReplacement(blocks, 6);
experimental_procedure = {
timeline: experimental_timeline
} Does that work? |
Beta Was this translation helpful? Give feedback.
Hi @j22tis, I like this approach and I think it should work. I think the reason your last step isn't working is because you're sampling from an array of strings, rather than sampling the actual objects that are named with those strings. So try doing it without the quotes around
hard_block
andeasy_block
:Does that work?