私は JSPsych で 10 の条件を持つ実験をコーディングしています。条件に応じて周波数が異なる 5 つの画像の配列を提示する必要があります。
for ループと randomize.sampleWithReplacement を使用して何らかの作業を行うことができましたが、必要な頻度で画像が表示されません。
たとえば、ある条件では、画像 5 を 8 回表示し、画像 4 を 6 回表示するなどとします。
プラグインと JSPsych 関数を使用してこれを実装する方法を知っている人はいますか?
これまでの私のコードは次のとおりです。
if (cond2 == 'uniform') {
var ratings_r = jsPsych.randomization.repeat(ratings, 4);
for (var i = 0; i < ratings_r.length; i++) {
timeline.push({
type: "html-button-response",
choices: ['Click here to continue'],
button_html: '<button class="jspsych-btn" style="display:none">%choice%</button>',
on_start: function() { setTimeout(function(){setDisplay("jspsych-btn","")}, 3000)},
is_html: true,
timeline: [{
stimulus: "<img src=" + ratings_r[i] + "><br><br><br>"
}
]
});
}
} if (cond2 == 'left-skew') {
var ratings_ls = jsPsych.randomization.sampleWithReplacement(ratings, 20, [2, 1, 1, 1, 1]);
console.log(ratings_ls)
for (var i = 0; i < ratings_ls.length; i++) {
timeline.push({
type: "html-button-response",
choices: ['Click here to continue'],
button_html: '<button class="jspsych-btn" style="display:none">%choice%</button>',
on_start: function() { setTimeout(function(){setDisplay("jspsych-btn","")}, 3000)},
is_html: true,
timeline: [{
stimulus: "<img src=" + ratings_ls[i] + "><br><br><br>"
}
]
});
}
} else {
var ratings_rs = jsPsych.randomization.sampleWithReplacement(ratings, 20, [1, 1, 1, 1, 4]);
console.log(ratings_rs)
for (var i = 0; i < ratings_rs.length; i++) {
timeline.push({
type: "html-button-response",
choices: ['Click here to continue'],
button_html: '<button class="jspsych-btn" style="display:none">%choice%</button>',
on_start: function() { setTimeout(function(){setDisplay("jspsych-btn","")}, 3000)},
is_html: true,
timeline: [{
stimulus: "<img src=" + ratings_rs[i] + "><br><br><br>"
}
]
});
}
};
これは最初の条件で機能します (非常に簡単なので)。
これは、私が JSPsych でコーディングした 2 番目の実験に過ぎないので、私は非常に初心者であり、提供できる助けをいただければ幸いです。
- - - - - - - - - アップデート - - - - - - -
私は今これを持っています:
if (cond2 == 'uniform') {
var uni = jsPsych.randomization.sampleWithoutReplacement([5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1]);
console.log(uni);
for (var i = 0; i < uni.length; i++) {
timeline.push({
type: "html-button-response",
choices: ['Click here to continue'],
button_html: '<button class="jspsych-btn" style="display:none">%choice%</button>',
on_start: function() { setTimeout(function(){setDisplay("jspsych-btn","")}, 3000)},
is_html: true,
timeline: [{
stimulus: "<img src=" + ratings[i] + "><br><br><br>"
}
]
});
}
} else if (cond2 == 'left-skew') {
var lesk = jsPsych.randomization.sampleWithoutReplacement([5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]);
console.log(lesk);
for (var i = 0; i < lesk.length; i++) {
timeline.push({
type: "html-button-response",
choices: ['Click here to continue'],
button_html: '<button class="jspsych-btn" style="display:none">%choice%</button>',
on_start: function() { setTimeout(function(){setDisplay("jspsych-btn","")}, 3000)},
is_html: true,
timeline: [{
stimulus: "<img src=" + ratings[i] + "><br><br><br>"
}
]
});
}
} else {
var risk = jsPsych.randomization.sampleWithoutReplacement([1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5]);
console.log(risk);
for (var i = 0; i < risk.length; i++) {
timeline.push({
type: "html-button-response",
choices: ['Click here to continue'],
button_html: '<button class="jspsych-btn" style="display:none">%choice%</button>',
on_start: function() { setTimeout(function(){setDisplay("jspsych-btn","")}, 3000)},
is_html: true,
timeline: [{
stimulus: "<img src=" + ratings[i] + "><br><br><br>"
}
]
});
}
};
表示頻度を規定するシャッフル配列を作成しましたが、画像がその回数表示されるようにループに組み込む方法がわかりません。画像には 1、2、3、4、5 のラベルが付けられています。