psychopy.org | Reference | Downloads | Github

PsychoPy Builder can output html/js

OK, this is the first part of the news you’ve all been waiting for. PsychoPy Builder can now output valid, working experiments for the web!! Right now this is only available in the repository but it will be part of the 1.85 release (if you aren’t comfortable with fetching psychopy from github then this new feature is too fragile for you for now, sorry!)

There are lots of caveats:

  • this is new and substantial and will surely have bugs. Test thoroughly
  • it’s limited to Text, Image, Mouse, Keyboard right now
  • no Code Components
  • no Excel files yet (only csv files for conditions please)

There’s more information at http://www.psychopy.org/online/online.html and detailed status will be maintained at
http://www.psychopy.org/online/status.html

7 Likes

Cool stuff Jon

what’s the server technology for storing the csv files? I presume you are returning the data from the browser in a json format and something is writing that to the local file store ? There will be quite some issues with web server setups I would imagine getting perms correct, and ensuring secure access to the directory to prevent spam data and AJAX Cross domain issues.

I’ve been supporting a jspsych user here storing largish exp data sets (few hundred trials) in databases.

Yes. There’s a php file that receives the data from the javascript running on the participant’s browser. I can’t actually tell you the communication protocol between those two (I didn’t write this code - my javascript/php skills are minimal). I think that’s fairly standard stuff (e.g. for wikis).

All you need to make this work in terms of the permissions is to create your data folder with write permissions for the web server. You can do this without having sudo rights if the user creates it directly using install. (Changing permissions of an existing folder requires sudo but creating it with install doesn’t) I think the command is:

install -g www -o $USER -d data

We haven’t done anything yet to prevent people spamming by running a study too much. Then again that could be done in your script. You could totally make your own Captcha using a PsychoPy Routine! :wink: Or provide participants a password that is needed to get past the info dialog at start of study?

We’re not currently providing any server space for users (like studies.psychopy.org) but we’re looking at how that could be funded.

Optionally the php file also pushes the data out to open science framework, which is done using RESTful requests over https I believe.

Sounds familiar, one issue is that the php may not work out of the box (at York for example. the php service has draconian pattern matching rule checking to try and stop exploits. It mostly stops anything non standard !) It will depend somewhat on the web server set up but its not insurmountable by any means, and does depend on your platform. For jspsych i gave up on the php data saving routines and rewrote them in a more supported set up here (coldfusion + mysql)

It’s really coming of age this web based exps malarky … glad to see PsychoPy up there …

I’ve recently started implementing web apps with PsychoPy (not PsychoJS!). I simply use Flask with PsychoPy in the backend. I created a REST API that would pass data between client and server serialized as JSON. User management/access control and server-side data storage is handled by Flask with a database backend (accessed via SQLAlchemy). No data is ever written to the server’s file system; everything ends up in the DB. If a user requests their data, the server would create CSV or XLSX data on-to-fly and send it to the client without writing anything to the FS. Data visualization is done client-side via D3.

That way, all new features, changes and fixes applied to PsychoPy’s Python code are immediately reflected in my app(s), and since I have created an API, users are free to even create their very own apps employing the PsychoPy server backend. They could, for instance, use PsychoPy functionality from within Matlab or from their smartphone or browser app very easily.

Obviously this approach does not allow for creation and temporally precise presentation of visual stimuli. But one could use the respective parts from PsychoJS for that purpose.

I’m currently quite a bit concerned about maintaining two separate implementations of everything (in Python and JS), as we’re already lacking manpower for the Python part alone, let alone the documentation.

Great news! I have psychpy experiment running on my desktop version and was looking for an internet based solution. The problem is that my experiment involves sound files (for stimuli as well as response).
My question is how fast this functionality can be added assuming i receive a research funding?
Also, i will need to have some kind of estimation/proposal to ask for funding.
Can you please provide more details ?
Thank you

1 Like

Yes, we would provide contract/invoice with the price and you would pay only when complete. Pricing is going to depend on the component. I think we (it requires both Ilixa Ltd. and me to do the work at the moment) can add sound for £1000.

In terms of a deadline you should let us know when you need it by, we’ll stipulate it in the contract and make sure we deliver by then.

The price wouldn’t include web server hosting etc so make sure you can cover those sides yourself.

1 Like

Wow, @richard your solution sound cool (if complicated). I’m not quite sure how you render the stimuli to the browser?
I only became keen on having a web engine when I discovered that they now support hardware-accelerated graphics and precise clocks. PsychoPy only makes sense to me with good precise graphics.

In terms of can we support it? I’m not writing any javascript code myself (not quite true - I already tweaked one piece). That’s why it needs financial input. On the plus side their code is less buggy than mine so might not need so much ‘supporting’ :wink: But I’m hoping we can find financial support that will allow this to be developed further and sustain itself.

1 Like

Hi Jon

well that is exactly the catch in my approach :wink: So currently I’m only using stuff from data.py to run different staircases, the user would typically interact with a website using the mouse, and d3 would render parameter probability distributions from staircase procedures (see below) etc. No real stimulus generation in that sense! But that’s what one could use PsychoJS for :slight_smile:

I will share the code once it’s out of the pre-alpha stage.

Yeah I can understand :slight_smile: I’m currently using PsychoPy for many non-time-critical tasks (e.g., taste threshold estimation, where we typically have ISIs of 20 to 30 sec). An entirely different application… But also shows how extremely versatile PsychoPy has become!

Sounds great! :slight_smile: I guess I’m sometimes a bit too skeptical at first. I generally like the idea of PsychoJS very much and I’m excited to see how researchers will make use of it!