Here’s my tip on using the Pavlovia Shelf
At the start of the experiment you need to retrieve the list for the current group.
// Retrieve the value of a dictionary field in a Shelf entry
fieldValue = await psychoJS.shelf.getDictionaryFieldValue({key: ["shelfName"], fieldName:"fieldName", defaultValue:"fieldName not found"});
fieldValue in this case will be your list of 10 images
You will also need a list of image indices.
imageIndices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
shuffles(imageIndices)
useRows = []
for Idx in range(10):
if fieldValue[imageIndices[Idx]] < 5:
fieldValue[imageIndices[Idx]] += 1
useRows.append(imageIndices[Idx])
if len(useRows) == 5:
break
This should give you a list of rows to select which are a random choice from your ten images with a maximum of 5 presentations of each within each group.
Then update the shelf at the end of the experiment
// Update the value of a dictionary field in a Shelf entry
await psychoJS.shelf.setDictionaryFieldValue({key: ["shelfName"], fieldName: "fieldName", fieldValue :fieldValue});