Visual component plugins for online (Javascript / Pavlovia) require PIXI access

I posted this in the PsychoJS repository issues (here: Github Issue), but that doesn’t seem to be active right now?

To summarise, I’ve built a Python visual component using the new-ish plugin system. That works great, but now I need to build the Javascript equivalent for online. For that I need access to the underlying PIXI classes (as the built-in PsychoJS components do), but there doesn’t seem to be any way to import PIXI directly from the server?

I know that in an older version of PsychoPy/PsychoJS you could import from pixi.js-legacy on the Pavlovia server (as well as the separate PsychoJS libraries individually), but that no longer seems to work?

What would be the best approach to deal with this?

Thanks for any assistance you can offer!

I can’t answer your question myself, but please could you describe what your plugin does – i.e. what do your visual components look like?

Maybe you need to create a visual stimulus in PsychoJS that can then be used in the Component?

1 Like

It’s a pretty basic static ‘dots grid’ plugin for judgement experiments. It has similarities to both the dots and the noise components, but it’s static in the sense that the dots don’t move. Instead they have a dominant colour probability (fixed per-trial), and the dots update which colour they are at a customisable rate (currently 10x10 dots at 20fps, but either of those may need to be increased).

0667-0853-ezgif.com-crop

Here’s (hopefully) an gif showing the Python version. Because we need it running online, probably on very low-end machines, I want to avoid the overhead of, e.g., an array of ShapeStim or some other ‘heavy’ object (which would also be a pain to code), and just use PIXI.Graphics for each dot. Ideally it would use a GL mesh or a shader, but hopefully that’s not required.

Thanks for the reply, Jon! That is how I got an older version of this working, but I was hoping the plugin system might allow for a more elegant solution which doesn’t break Builder compatibility (useful to let experimenters do their own tweaking during piloting).

I’m not sure of the best way to add a stimulus to PsychoJS without using an entire custom version of PsychoJS in the experiment? I can always just edit the generated Javascript code to replace the PsychoJS import with my own, though.

Eventually I’d like to have the time to do a proper PR (if you think it’s worthwhile) to include in PsychoJS, but right now I just need to get something working.

Hi Jon, I’ve been trying to use a custom-build of PsychoJS which incorporates my component, but I’m running into an issue. I removed /lib from the default .gitignore so it pushes my /lib instead of the one Pavlovia supplies, but this is apparently verboten? I’m getting this message when trying to pilot:

**[500] "unable to link the PsychoJS library, possibly because a lib directory already exists: [Errno 17] File exists: '/var/www/run.pavlovia.org/lib' -> '/var/www/run.pavlovia.org//run//MGTest/plugintest/lib'" ( #None )**

Is there a way around this, or an alternative procedure you would recommend?

Thanks for your help!

To use your own custom PsychoJS library, revert .gitignore and delete your online lib folder.

Upload a copy of your library and change your experiment so it exports HTML files manually instead of on sync.

Export HTML from the file menu

Edit the line 5 of the JS file from:

import { core, data, sound, util, visual, hardware } from './lib/psychojs-2024.2.4.js';

to

import { core, data, sound, util, visual, hardware } from 'psychojs-custom.js'; 

where psychojs-custom.js is the name of your modified library.

Then save the JS file and sync without exporting HTML again.

Here’s an example experiment running a custom library to allow YouTube videos
https://run.pavlovia.org/test-suite/youtube/

Thanks so much! That does work and I have things running online now.

I’m still thinking about Builder compatibility for non-technically-minded experimenters. It would be nice to have a way to either specify the location of a custom psychojs library, or to support plugins more seamlessly on the JS side. Do you know if there’s any plans for that?

Thanks again!

It would certainly be nice to have a PsychoJS plugin system, but it isn’t a priority since most plugins revolve around hardware.

Since we don’t want non-technically-minded users using custom PsychoJS libraries, I don’t think that having a Builder option to specify one is likely to happen any time soon, beyond the selection already available in the use version field.