diff --git a/static/css/default_style.css b/static/css/default_style.css index 5d0f187..523d9f3 100644 --- a/static/css/default_style.css +++ b/static/css/default_style.css @@ -82,6 +82,7 @@ body { .center-text { text-align:center; font-size: 60px; + line-height: 80px; position: relative; top: 50%; -ms-transform: translateY(-50%); diff --git a/static/js/utils/poldrack_fmri_utils.js b/static/js/utils/poldrack_fmri_utils.js new file mode 100644 index 0000000..cce9917 --- /dev/null +++ b/static/js/utils/poldrack_fmri_utils.js @@ -0,0 +1,124 @@ +/* ************************************ */ +/* Setup fMRI trigger listener and functions */ +/* ************************************ */ +var trigger_times = [] + +document.onkeypress = function(evt) { + evt = evt || window.event; + var charCode = evt.keyCode || evt.which; + var which_key = String.fromCharCode(charCode); + if (which_key == 't') { + time = jsPsych.totalTime().toString(); + trigger_times.push(time) + } else { + time = jsPsych.totalTime().toString(); + if (which_key == ' ') { + which_key = 'space' + } + console.log(which_key, time) + } +} + +var clear_triggers = function() { + trigger_times = [] +} + +function addID(exp_id) { + jsPsych.data.addDataToLastTrial({ + exp_id: exp_id, + trigger_times: trigger_times + }) + clear_triggers() +} + + +/* ************************************ */ +/* default jsPsych fMRI blocks */ +/* ************************************ */ + +var fmri_scanner_wait_block = { + type: 'poldrack-text', + text: "
Test run will start after scanner calibration

", + cont_key: [32], + data: { + trial_id: "fmri_scanner_wait" + }, + timing_response: -1, + timing_post_trial: 0 +}; + +// blank block to put after the last ignored trigger as a buffer before experiment +var fmri_buffer_block = { + type: 'poldrack-single-stim', + stimulus: '', + is_html: true, + choices: 'none', + timing_stim: 1000, + timing_response: 1000, + data: { + trial_id: "fmri_buffer" + }, + timing_post_trial: 0 +}; + +// block to wait for triggers +var create_trigger_block = function(trigger) { + var fMRI_wait_block = { + type: 'poldrack-text', + text: "
Scanner calibration
Please don't move!

", + cont_key: [trigger], + data: { + trial_id: "fmri_trigger_wait" + }, + timing_response: -1, + timing_post_trial: 0 + }; + return fMRI_wait_block +} + +var get_finger = function (choice) { + var keycode_lookup = {'B': 'thumb', 'Y': 'index', 'G': 'middle', + 'R': 'ring', 'M': 'pinky'} + var finger = keycode_lookup[String.fromCharCode(choice)] + return finger +} + +// test response keys +var create_key_test_block = function(choice) { + var button = get_finger(choice) + var instruct_text = "Please press your " + button + " finger" + if (button == null) { + instruct_text = "Wait for instructions from the experimenter." + } + var key_test_block = { + type: 'poldrack-text', + text: "
" + instruct_text + "

", + cont_key: [choice], + data: { + trial_id: "fmri_response_test" + }, + timing_response: -1, + timing_post_trial: 500 + }; + return key_test_block +} + +// setup function +var setup_fmri_intro = function(lst, choices = [], num_ignore = 16, trigger = 84) { + for (var i=0; i < choices.length; i++) { + lst.push(create_key_test_block(choices[i])) + } + lst.push(fmri_scanner_wait_block) + for (var j = 0; j < num_ignore; j++) { + lst.push(create_trigger_block(trigger)) + } + lst.push(fmri_buffer_block) +} + +// setup function +var setup_fmri_run = function(lst, num_ignore = 16, trigger = 84) { + for (var j = 0; j < num_ignore; j++) { + lst.push(create_trigger_block(trigger)) + } + lst.push(fmri_buffer_block) +} \ No newline at end of file