jsPsych+JATOS saving data trial by trial #811
-
Hi, I'm new to jsPsych. Apologies if this question has already been answered. Is it possible to permanently save the data (to JATOS) trial by trial rather than at the end of the experiment only? More generally, if the experiment crashes halfway through for some reason, is it possible to recover the data obtained up until that point? Many thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
JATOS itself allows to save data trial by trial. With jatos.appendResultData one can append data multiple time as long as the study is still running (http://www.jatos.org/jatos.js-Reference.html#jatosappendresultdata). Although I'm not so much of an expert in jsPsych, as far as I know jsPsych delivers all result data at once in the end of the whole study (but I'm happy to be corrected). |
Beta Was this translation helpful? Give feedback.
-
Thanks @kristian-lange! Just to add to his response: in jsPsych, it is possible to send the data back after every trial using the trial's on_finish function. It would look something like this: var trial = {
...
on_finish: function(data) {
// convert the data object to a JSON string
var trial_json_results = JSON.stringify(data);
// append this data to the end of the current results in JATOS
jatos.appendResultData(trial_json_results);
}
}; However I haven't actually tested this code so not 100% sure it works. If you want to send the data back after every trial in the experiment, you could instead put the above code to save the data into jsPsych's Finally, you asked about saving the data if the experiment crashes part-way through. Unfortunately it's not possible to do this if the experiment crashes due to an error on the page, but you can save the data before the participant leaves the page by putting the above code into jsPsych's jsPsych.init({
...
on_close: function() {
// get all of the data and convert it to a JSON string
var all_results = jsPsych.data.get().json();
// send back to JATOS
jatos.submitResultData(all_results);
}
}); |
Beta Was this translation helpful? Give feedback.
Thanks @kristian-lange! Just to add to his response: in jsPsych, it is possible to send the data back after every trial using the trial's on_finish function. It would look something like this:
However I haven't actually tested this code so not 100% sure it works.
If you want to send the data back after every trial in the experiment, you could instead put the above code to save the data into jsPsych's
on_trial_finish
parame…