Running jsPsych on Pavlovia

250 views
Skip to first unread message

wiktor...@gmail.com

unread,
Dec 3, 2018, 5:24:23 AM12/3/18
to jsPsych
Hi,
could you point me to any reference/example how to save data generated by jsPsych on Pavlovia. Google does not give any answer. I saw that there is a Github issue on this topic on Pavlovia/psychojs page, and they provide a sketch of a simple solution that would require modifying jsPsych code. Is it possible that this will be implemented in some future version of jsPsych?

So far I have been running jsPsych on heroku+mlab, but I would like to switch to a more automated solution.

Best

wiktor...@gmail.com

unread,
Dec 3, 2018, 5:25:41 AM12/3/18
to jsPsych
BTW. Here is a link to the Github issue: https://github.com/psychopy/psychojs/issues/17

Josh de Leeuw

unread,
Dec 3, 2018, 8:11:53 AM12/3/18
to wiktor...@gmail.com, jsPsych
Hi,

The modification they suggest is not really a modification of jspsych code, but rather it utilizes the jspsych event handler to invoke the pavlovia save data API. I don't think the integration can get much better than that, but I'm open to ideas if you have a different approach in mind!

Cheers
Josh

--
You received this message because you are subscribed to the Google Groups "jsPsych" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jspsych+u...@googlegroups.com.
To post to this group, send email to jsp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jspsych/8e61518e-52ee-400b-99cb-49a6219a7344%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Josh de Leeuw

unread,
Dec 3, 2018, 8:23:48 AM12/3/18
to wiktor...@gmail.com, jsPsych
Ah, I see on second read that they are proposing to add new functions to jsPsych itself. I missed that because I've been talking with the pavlovia team and they changed the approach a bit to use pavlovia code instead of jsPsych code. Sorry for my overly hasty reply!

Here're the instructions that I've got from the pavlovia team. Let me know if it works for you!

  1. create a project with an html folder containing experiment files on gitlab.pavlovia.org (typically including an index.html and a name-of-study.js). The `html` folder will be copied (actually git-pulled) to the www.pavlovia.org/run when the study is activated. Another folder, called `data` will be created in the project by pavlovia as needed.
  2. you can activate the study from the www.pavlovia.org/explore graphical interface, or using a REST API command to pavlovia (but I'm not sure that's what you guys would do*)
  3. tweak your index.html to import a couple of supporting libs (pavlovia-connect.js provides the functions to initialise a pavlovia session and push the data):
[...]
<head>
  [...]
  <script type="text/javascript" src="https://pavlovia.org/run/lib/vendors/jquery-2.2.0.min.js"></script>
  <script type="text/javascript" src="https://pavlovia.org/run/lib/pavlovia-connect-3.0.0b11.js"></script>
[...]
</head>

[...]

    4. add calls to pavlovia.init and pavlovia.finish at the start and end of the jsPsych experiment:
[...]
/* start the experiment */
pavlovia.init();
jsPsych.init({
  timeline: timeline,
  on_finish: function(data) {
    jsPsych.data.displayData();
    pavlovia.finish(data);
  }
});
NB pavlovia.init() takes care of opening a session. pavlovia.finish uploads the experiment results to the server and closes the session. Log messages are written to the console. Errors are captured and displayed in an alert box.
5. When a participant runs, their data will be saved in a csv in ./data/ and pushed straight back to the gitlab.pavlovia.org project, so the scientist can then git pull to get it on their desktop 6. If the scientist changes the files and does git push then these are automatically pulled in to the running study (we're talking about providing more control to that process)

wiktor...@gmail.com

unread,
Dec 3, 2018, 10:45:36 AM12/3/18
to jsPsych
W dniu poniedziałek, 3 grudnia 2018 14:23:48 UTC+1 użytkownik Josh de Leeuw napisał:
> Ah, I see on second read that they are proposing to add new functions to jsPsych itself. I missed that because I've been talking with the pavlovia team and they changed the approach a bit to use pavlovia code instead of jsPsych code. Sorry for my overly hasty reply!
>
>
> Here're the instructions that I've got from the pavlovia team. Let me know if it works for you!
>
>
> create a project with an html folder containing experiment files on gitlab.pavlovia.org (typically including an index.html and a name-of-study.js). The `html` folder will be copied (actually git-pulled) to the www.pavlovia.org/run when the study is activated. Another folder, called `data` will be created in the project by pavlovia as needed.you can activate the study from the www.pavlovia.org/explore graphical interface, or using a REST API command to pavlovia (but I'm not sure that's what you guys would do*)tweak your index.html to import a couple of supporting libs (pavlovia-connect.js provides the functions to initialise a pavlovia session and push the data):
Thank you for your reply. This solution would be fantastically easy. However, I have encountered some issues that with the links to the libraries that you pasted, that ultimately prevent the app from starting. Log from console says:
Loading failed for the <script> with source “https://pavlovia.org/run/lib/vendors/jquery-2.2.0.min.js”. html:11:1
Loading failed for the <script> with source “https://pavlovia.org/run/lib/pavlovia-connect-3.0.0b11.js”. html:12:1
ReferenceError: pavlovia is not defined[Learn More]

Do you have any clue how to fix it? Or should I contact pavlovia developers?

Best,
Wiktor

wiktor...@gmail.com

unread,
Dec 3, 2018, 11:27:49 AM12/3/18
to jsPsych
Ohh, it seems that I found a solution. I have changed the links to:

<script type="text/javascript" src="lib/vendors/jquery-2.2.0.min.js"></script>
<script type="text/javascript" src="lib/pavlovia-connect-3.0.0b11.js"></script>

and now it seems to work perfectly. I will test it for some time, and in case of any troubles, I will come back here.
Thank you for your help!

Best,
Wiktor
Reply all
Reply to author
Forward
0 new messages