psychopy.org | Reference | Downloads | Github

Trying to create a Binder/Jupyter Notebook to run PsychoPy scripts

Background: I’ve not been able to run my experiment on Pavlovia because the component visual.RadialStim is not yet supported in PsychoJS. Yet I want to show people my experiment, especially my stimuli, even when they don’t have the local environment to run my script.

Current solution: So I’m trying to see if I can run my script on an interactive Jupyter notebook. This way I can share the notebook with others. I’ve been able to do that locally in a notebook run in my own local virtual environment. But I haven’t yet been able to do this through Binder. To do this, I need to ensure a Binder environment that includes psychopy. I’m using the environment.yml file provided by PsychoPy, but Binder keeps running into an error when it tries to load the environment. Specifically, it installed all the dependencies, but then stops after the following error message:

Question: My questions are thus multi-fold.
(1) Has anyone been able to run PsychoPy scripts through an online (not just local) Jupyter notebook?
(2) What do you do when you can’t run and share experiments because your PsychoPy components are not yet available in PsychoJS?
(3) Back to my initial problem, are there ways to export looping visual stimuli written in psychopy to gif or movie files?

Yes:

https://www.psychopy.org/api/visual/window.html#psychopy.visual.Window.getMovieFrame

1 Like

Michael: thank you so much for this. It solved my problem for gif files and it worked!!!

I will still need to eventually figure out how to run psychopy scripts with RadialStim components in either an html or jupyter/ipython notebook, though, as I’ll want to have my users interact with sliders to manipulate the demo stimuli. So if there is a way to solve that problem, I’d love to continue to use PsychoPy to work on the demos. Concurrently looking into matplotlib & plotly interactive & animation solutions, too.

I have no idea if that is possible. PsychoPy likes to control its own window and have access to its events and so on. I’m not sure if it can meaningfully run that way in a notebook-like environment. Perhaps @jon can advise?

It would be very nice as a teaching tool if it can be done. Otherwise, you might want to run it online via Pavlovia, and do the interaction entirely with PsychoPy objects.

Thank you, Michael, indeed it will be lovely if possible! I tried to run the program on Pavlovia, but unfortunately PsychoJS doesn’t support RadialStim components yet :confused: