JsPsych Saving Options on Pavlovia

Okeydokey. I’m discussing it with my senior dev, update soon!

I built it, now waiting for a code review, so that I’m sure it’s solid. Meanwhile a suggestion. I noticed that jsPsych already offers all kinds of data filtering options. You could try them out in the browser console while the task is running. If my modifications pass the review, you’ll have access to these options.

Thank you!

Done! Here you can find a modified version of the Pavlovia plugin that allows you filter out data and/or upload arbitrary data to the Pavlovia server. It comes with a demo task and a bit of documentation. I hope this suits your needs!

That’s great - thanks Thomas :slight_smile:

1 Like

Hi Thomas,

Thank you a lot for this function ! I tried many hours to do that because I wanted to save JSON data but I’m not good enough ! You give an answer to my question on this post, now it’s simple :

    dataFilter: function(data) {
      let myjsondata = jsPsych.data.get().json();
      return myjsondata ;
  }

That way the file keep the csv extension but the text inside is json in fact. How could I put my post to resolve and make a link to this post ?

Happy to read this post solved it! About your question on using JSON as an extension instead of CSV, consider changing this line in the plugin.

Hi Thomas,

thanks for your answer concerning the json extension, I used it and it worked well. But i have one question, it seems that this part of the code is used only when the experiment finished without any problem. When there is incomplete data the data are not json nor csv, just some text with coma separator. Is it possible to fix that ?

Hey @F_Elisabeth, I guess so, but I’ll need to do a deep dive for it. I put in on my 2do list, but it might take a couple of days before I’ve got a result for you.

1 Like

@F_Elisabeth, I took a peek at the code. I see that our pavlovia plugin does attempt to store the data when a participant closes their web-browser half-way through a task, but that isn’t very reliable; it uses features that web-browsers have been disabling because they can be abused by malicious web-sites. Is this the scenario you’re thinking of when you speak of incomplete data or is it perhaps something else I’m not considering?

Hi, it’s okay ! It was just in case of a crash during the experiment or something like that. I have some pretest such as an “audiogram like” trial so in the case of a crash it would be interesting to not doing again but I’m conscious we have to do with what the browsers let us do. Anyway, thank you to had a look at it !

1 Like

Ahaaa, maybe make them separate jsPsych Tasks and chain those together?

1 Like

Also, inspired on issues reported in the thread below, I updated our Palovia plugin. It now offers a completedCallback which is called once the data is in. jsPsych experiment, token randomly consumed, no data stored - #9 by thomas_pronk

1 Like

Edit: I had forgotten to include completedCallback as an argument to the definition of my pavlovia finish trial, which is what was causing an error. The argument seems mandatory, although not sure if it should be.


Thanks for your work on this @thomas_pronk ! Another interesting pondering I have is why only the main data object from jsPsych is saved. For instance, I would like to save the interaction data but I am struggling to get it to work properly. My central attempt consists of adding a _save() call within the plugin trial method (in the case: ‘finish’ block, before await _finish) and data do get end up saved but I am getting an error on the screen to the participant.

I am attaching the file I am using (this is essentially a modified version of your script). Any help would be greatly appreciated! NB: The file is saved as .py but is actually a .js file – the forum does not let me upload .js files.
jspsych-pavlovia-2020.4-custom.py (16.7 KB)

I love it when people build on my code! :slight_smile: Here are some thoughts:

  • My hunch is that my dataFilter filter implementation would already solve it. It receives some data but you could interact with all kinds of jsPsych objects in there? However, I’m actually now that knowledgeable of jsPsych, so I might be wrong. Which takes me to…
  • Shall we chat about it on the jsPsych forum? (got a thread there). We might get some nice input from their devs.
  • And maybe move this the Pavlovia-plugin to a GitHub repo, then it’s easier for me to track your edits, file PRs etc.

How does this sound?

Thanks for your reply @thomas_pronk. I think I will do a PR for the plugin soon. I really want to try and figure out how to most effectively and efficiently also implement a case for the ‘command’ parameter of ‘save’ that sends a request to the pavlovia in the middle of the experiment.

In my current lab, we have to pause in the middle of experiments to save data to pavlovia which is just annoying. Why do we need to pause? Because pavlovia has been troublesome in the past with data not saving randomly and 1 experiment losing about 10% of PPs’ data, resulting in overall costs in the hundreds (which is substantial for a psychology lab).

Essentially, I want to be able to send a data save request to pavlovia in the middle of the experiment asynchronously without closing/reopening the connection sessions. That should be a sufficient solution for multiple data saves.

Will let you know when I have something to push to GitHub.

Thanks for your work!

About the issue you report: I guess we could tackle this on multiple levels. An earlier version of the plugin had the issue that redirecting a participant to another website at the end of a jsPsych task could result in the data not being saved properly. This particular issue should be fixed since version 2020.3 of the jsPsych Pavlovia plugin, in which you can specify a callback that’s triggered once Pavlovia confirms it received the data. By putting your redirect in this callback you can ensure that the participant is only sent on if the data is in.

Regardless, I’m all up for updates and improvements! Are you thinking of a PR via gitlab.pavlovia.org?

Hi there,
I’m at the moment integrating task with Pavlovia. As we also have a lot of data, I’m making use of your completedCallback function.
It works with showing the ‘alert’, as in your original code. Do you know whether it’s possible to instead show a div, like so:

$("#endExperiment").show();

When I use this code anywhere else in my script, it shows the div as expected. But when I put it within the callback, it doesn’t work. (I can manage to hide: $(’.jspsych-content-wrapper’).hide(), but not to then show my own div)

I’d be very grateful for any pointers.

Hey @JacquieS,

I’ve got two pointers for you:

  1. Perhaps the callback isn’t called? You could test this by adding a console.log statement in the callback. See Thomas Pronk / tutorial_js_console_log · GitLab
  2. Perhaps the #endExperiment div is inside of another div that’s hidden? You could test this by running your experiment to the end, check if the debug info at point 1 shows up in the console, and then manually execute the $("#endExperiment").show(); statement in the console.

Hope this helps!

Hi, I’m a user of jsPsych with Pavlovia (which has been fantastic so far!!)

However, we’ve had some recent issues with data saving and credits not being used in studies we’re running on Pavlovia with jsPsych 6.3.0. Is that version still supported on Pavlovia?

Are there other users having any issues with data saving and jsPsych / anyone with tips on resolving the data saving issues (no data is saved)? I’ve posted about the issue here as well: Credits not being used, and data not saving, for "Running" mode in jsPsych? - #10 by katiecollins

Thanks!