<!DOCTYPE html> <html> <!-- _ _ _ ___| |_ ___ _ __ (_) |_ / __| __/ _ \| '_ \ _____| | __| \__ \ || (_) | |_) |_____| | |_ |___/\__\___/| .__/ |_|\__| |_| AUTHORS: Luc Vermeylen & Frederick Verbruggen (2019) DESCRIPTION: This is the jsPsych version of the stop-signal task Modified by Kyoung Whan Choe to embed STOP-IT in Qualtrics (without consent form, etc) --> <head> <!-- import the jsPsych core library, specific plugins, jquery and some other scripts--> <title>Stop Signal Task</title> <!-- defines a title in the browser tab --> <link href="js/jspsych-6.0.5/css/jspsych.css" rel="stylesheet" type="text/css"> </link> <!-- standard jsPsych css stylesheet --> <script src="js/jquery-1.7.1.min.js"></script> <!-- the jquery library is used to communicate with the server (to store the data) through "AJAX" and PHP --> <script src="js/jspsych-6.0.5/jspsych.js"></script> <!-- jsPsych core library --> <script src="js/jspsych-6.0.5/plugins/jspsych-instructions.js"></script> <!-- plugins define specific tasks, e.g., presenting instructions --> <script src="js/jspsych-6.0.5/plugins/jspsych-fullscreen.js"></script> <script src="js/jspsych-6.0.5/plugins/jspsych-call-function.js"></script> <script src="js/jspsych-6.0.5/plugins/jspsych-html-keyboard-response.js"></script> <script src="js/jspsych-detect-held-down-keys.js"></script> <!-- custom plugin for detecting if a key is being held down --> <script src="js/custom-stop-signal-plugin.js"></script> <!-- custom plugin for the main stop-signal trial based on the image-keyboard-response plugin --> <script src="js/sprintf.js"></script> <!-- format variables in a string, used for customizable feedback strings in which the variables are not yet declared --> <script src="configuration/experiment_variables.js"></script> <!-- parameters to configure the experiment --> <script src="configuration/text_variables.js"></script> <!-- holds all the text variables for easy modification/translation --> <script src="stop-it_main.js"></script> </head> <body></body> <script> /* * Helper functions for saving data */ function filter_data() { var ignore_columns = ['raw_rt', 'trial_type', 'first_stimulus', 'second_stimulus', 'onset_of_first_stimulus', 'onset_of_second_stimulus', 'key_press', 'correct_response', 'trial_index', 'internal_node_id' ]; var rows = { trial_type: 'custom-stop-signal-plugin' }; // we are only interested in our main stimulus, not fixation, feedback etc. var selected_data = jsPsych.data.get().filter(rows).ignore(ignore_columns); // the next piece of codes orders the columns of the data file var d = selected_data.values() // get the data values // make an array that specifies the order of the object properties var arr = ['block_i', 'trial_i', 'stim', 'signal', 'SSD', 'response', 'rt', 'correct', 'focus', 'Fullscreen', 'time_elapsed', 'window_resolution' ]; new_arr = [] // we will fill this array with the ordered data function myFunction(item) { // this is function is called in the arr.forEach call below new_obj[item] = obj[item] return new_obj } // do it for the whole data array for (i = 0; i < d.length; i++) { obj = d[i]; // get one row of data new_obj = {}; arr.forEach(myFunction) // for each element in the array run my function selected_data.values()[i] = new_obj; // insert the ordered values back in the jsPsych.data object } return selected_data; } var timeline = []; // this array stores the events we want to run in the experiment // push all the procedures, which are defined in stop-it_main.js to the overall timeline timeline.push(start_procedure, block_procedure, end_procedure) // run the experiment! jsPsych.init({ timeline: timeline, preload_images: [fix_stim, go_stim1, go_stim2, stop_stim1, stop_stim2], on_data_update: function (data) { // each time the data is updated: // write the current window resolution to the data data.window_resolution = window.innerWidth + ' x ' + window.innerHeight; // is the experiment window the active window? (focus = yes, blur = no) data.focus = focus; data.Fullscreen = fullscr_ON; }, on_interaction_data_update: function ( data) { //interaction data logs if participants leaves the browser window or exits full screen mode interaction = data.event; if (interaction.includes("fullscreen")) { // some unhandy coding to circumvent a bug in jspsych that logs fullscreenexit when actually entering if (fullscr_ON == 'no') { fullscr_ON = 'yes'; return fullscr_ON } else if (fullscr_ON == 'yes') { fullscr_ON = 'no'; return fullscr_ON } } else if (interaction == 'blur' || interaction == 'focus') { focus = interaction; return focus; } }, exclusions: { // browser window needs to have these dimensions, if not, participants get the chance to maximize their window, if they don't support this resolution when maximized they can't particiate. min_width: minWidth, min_height: minHeight }, on_finish: function () { var selected_data = filter_data(); selected_data.localSave('csv', 'SST_data_test.csv'); }, }) </script> </html>