I’m trying to build an experiment to be completed online in Pavlovia, but it requires calling complex functions from a Python script that cannot be ported to JavaScript easily. Porting these would mean having to rewrite an entire internal library from scratch, and that’s just not feasible.
Is there any way of calling these functions from PsychoJS, or a standard way of doing it? I was thinking of maybe hosting the Python scripts on an external webserver and getting PsychoJS to send requests to that server through AJAX, would something like that work?
I have a working PsychoPy implementation of the experiment which runs fine locally, if that’s helpful.
I see. My functions are matplotlib- and numpy-based functions to simulate a Battleship board (as in, the board game) and be able to act upon it easily, as well as some even more complex functions that do conditional sampling of board states and can build heatmaps from these. Could I host a webserver with the Python functions on it and make requests to it from PsychoJS?
numpy functions are generally simple to replicate if they don’t already exist.
I have no idea about the feasibility of your last question.
By “conditional sampling of board states and can build heatmaps” do you mean that you want to record which squares are picked across multiple participants (or multiple games) and build up a heat map of popular locations?
Presumably the ships are placed by the computer and the participant is picking squares to look for them.
Unfortunately I’m sure the functions cannot be replicated in JS easily (even though the grid overlay may come in handy for a section of the experiment!), so I’ll accept the first comment of yours as the solution and try to see if the webserver idea is feasible, and I’ll update back if it turns out to be. Thanks for your answers!
EDIT: For any future readers, hosting Python functions on a separate webserver and POSTing into them from PsychoJS works!