update RT docs

This commit is contained in:
Josh de Leeuw 2021-02-13 08:56:57 -05:00
parent ad8b3097f9
commit 7f5870d55e
3 changed files with 993 additions and 748 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,69 +1,84 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head>
<head>
<title>My experiment</title> <title>My experiment</title>
<script src="../jspsych.js"></script> <script src="../jspsych.js"></script>
<script src="../plugins/jspsych-html-keyboard-response.js"></script> <script src="../plugins/jspsych-html-keyboard-response.js"></script>
<script src="../plugins/jspsych-image-keyboard-response.js"></script> <script src="../plugins/jspsych-image-keyboard-response.js"></script>
<script src="../plugins/jspsych-preload.js"></script>
<link rel="stylesheet" href="../css/jspsych.css"> <link rel="stylesheet" href="../css/jspsych.css">
</head> </head>
<body></body>
<script>
<body></body>
<script>
/* create timeline */ /* create timeline */
var timeline = []; var timeline = [];
/* preload images */
var preload = {
type: 'preload',
images: ['img/blue.png', 'img/orange.png']
}
timeline.push(preload);
/* define welcome message trial */ /* define welcome message trial */
var welcome_block = { var welcome = {
type: "html-keyboard-response", type: "html-keyboard-response",
stimulus: "Welcome to the experiment. Press any key to begin." stimulus: "Welcome to the experiment. Press any key to begin."
}; };
timeline.push(welcome_block); timeline.push(welcome);
/* define instructions trial */ /* define instructions trial */
var instructions = { var instructions = {
type: "html-keyboard-response", type: "html-keyboard-response",
stimulus: "<p>In this experiment, a circle will appear in the center " + stimulus: `
"of the screen.</p><p>If the circle is <strong>blue</strong>, " + <p>In this experiment, a circle will appear in the center
"press the letter f on the keyboard as fast as you can.</p>" + of the screen.</p><p>If the circle is <strong>blue</strong>,
"<p>If the circle is <strong>orange</strong>, press the letter j " + press the letter F on the keyboard as fast as you can.</p>
"as fast as you can.</p>" + <p>If the circle is <strong>orange</strong>, press the letter J
"<div style='width: 700px;'>"+ as fast as you can.</p>
"<div style='float: left;'><img src='img/blue.png'></img>" + <div style='width: 700px;'>
"<p class='small'><strong>Press the f key</strong></p></div>" + <div style='float: left;'><img src='img/blue.png'></img>
"<div class='float: right;'><img src='img/orange.png'></img>" + <p class='small'><strong>Press the F key</strong></p></div>
"<p class='small'><strong>Press the j key</strong></p></div>" + <div class='float: right;'><img src='img/orange.png'></img>
"</div>"+ <p class='small'><strong>Press the J key</strong></p></div>
"<p>Press any key to begin.</p>", </div>
<p>Press any key to begin.</p>
`,
post_trial_gap: 2000 post_trial_gap: 2000
}; };
timeline.push(instructions); timeline.push(instructions);
/* test trials */ /* test trials */
var test_stimuli = [ var test_stimuli = [
{ stimulus: "img/blue.png", data: { test_part: 'test', correct_response: 'f' } }, { stimulus: "img/blue.png", correct_response: 'f' },
{ stimulus: "img/orange.png", data: { test_part: 'test', correct_response: 'j' } } { stimulus: "img/orange.png", correct_response: 'j' }
]; ];
var fixation = { var fixation = {
type: 'html-keyboard-response', type: 'html-keyboard-response',
stimulus: '<div style="font-size:60px;">+</div>', stimulus: '<div style="font-size:60px;">+</div>',
choices: jsPsych.NO_KEYS, choices: jsPsych.NO_KEYS,
trial_duration: function(){ trial_duration: function () {
return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0]; return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0];
}, },
data: {test_part: 'fixation'} data: {
task: 'fixation'
}
} }
var test = { var test = {
type: "image-keyboard-response", type: "image-keyboard-response",
stimulus: jsPsych.timelineVariable('stimulus'), stimulus: jsPsych.timelineVariable('stimulus'),
choices: ['f', 'j'], choices: ['f', 'j'],
data: jsPsych.timelineVariable('data'), data: {
on_finish: function(data){ task: 'response',
data.correct = data.key_press == data.correct_response; correct_response: jsPsych.timelineVariable('correct_response')
}, },
on_finish: function (data) {
data.correct = data.response == data.correct_response;
}
} }
var test_procedure = { var test_procedure = {
@ -78,16 +93,16 @@
var debrief_block = { var debrief_block = {
type: "html-keyboard-response", type: "html-keyboard-response",
stimulus: function() { stimulus: function () {
var trials = jsPsych.data.get().filter({test_part: 'test'}); var trials = jsPsych.data.get().filter({ task: 'response' });
var correct_trials = trials.filter({correct: true}); var correct_trials = trials.filter({ correct: true });
var accuracy = Math.round(correct_trials.count() / trials.count() * 100); var accuracy = Math.round(correct_trials.count() / trials.count() * 100);
var rt = Math.round(correct_trials.select('rt').mean()); var rt = Math.round(correct_trials.select('rt').mean());
return "<p>You responded correctly on "+accuracy+"% of the trials.</p>"+ return `<p>You responded correctly on ${accuracy}% of the trials.</p>
"<p>Your average response time was "+rt+"ms.</p>"+ <p>Your average response time was ${rt}ms.</p>
"<p>Press any key to complete the experiment. Thank you!</p>"; <p>Press any key to complete the experiment. Thank you!</p>`;
} }
}; };
@ -96,9 +111,10 @@
/* start the experiment */ /* start the experiment */
jsPsych.init({ jsPsych.init({
timeline: timeline, timeline: timeline,
on_finish: function() { on_finish: function () {
jsPsych.data.displayData(); jsPsych.data.displayData();
} }
}); });
</script> </script>
</html> </html>

View File

@ -23,6 +23,8 @@ markdown_extensions:
guess_lang: false guess_lang: false
- toc: - toc:
permalink: true permalink: true
- pymdownx.superfences
- pymdownx.details
repo_url: 'https://github.com/jspsych/jsPsych' repo_url: 'https://github.com/jspsych/jsPsych'
repo_name: 'jspsych/jspsych' repo_name: 'jspsych/jspsych'
docs_dir: docs docs_dir: docs