| Reference | Downloads | Github

Problems running backwards digit span task on pavlovia

URL of experiment:

Description of the problem: I created a backwards digit span task in psychopy that has been running into some issues on Pavlovia. Essentially the task is set up so that for each trial, a set number of random digits (e.g., three digits for Trial 1, four digits for Trial 2…) are pulled from an excel spreadsheet and displayed on the screen. I found some randomizing code on another discourse topic posted by someone who was trying to build a very similar digit span task, and someone suggested adding a code element before the trials like this:

from numpy.random import choice

And then for each trial, a loop is created that links the excel spreadsheet and has the following line of code under Selected Rows:

$choice(9, size=3, replace=False)

where size indicates the number of digits to pull from the spreadsheet. Here’s a picture for clarity:

It works fine on PsychoPy, but it seems like Pavlovia really doesn’t like the numpy function. I did some digging and found that it might be because the numpy function doesn’t exist in javascript, but I haven’t been able to find a javascript equivalent that will allow me to keep the experiment flow as is and use the choice function to set how many digits should be pulled from the spreadsheet. Is there a way to convert this code to a more pavlovia-friendly version? I’m very new to all this so any advice is much appreciated!

Many thanks!

How about something like:


Make sure that shuffle is defined in code_JS as per my crib sheet (pinned post).