Hi,
I have been playing with the new Shelf feature and specifically with the counterbalance part. Below some tips that may save you time during troubleshooting.
-
It does not work with old-ish versions of PsychoPy e.g. 2022.1.4. If you get the error below then update to the newest version of psychopy e.g. 2022.2.2
-
On the documentation it states that the snippet
[thisGroup, finished] = await psychoJS.shelf.counterBalanceSelect({key: ['groups'], groups: ['A', 'B', 'C'], groupSizes: [10, 10, 10]})
will return thethisGroup
and thefinished
.
I have not managed to make this work; it will either return
finished is not defined
or
TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))
depending on whether you added the code component before or after the trials.
What worked for me is the snippet below
thisGroup = await psychoJS.shelf.counterBalanceSelect({key: ['groups'], groups: ['A', 'B', 'C'], groupSizes: [10, 10, 10]})
(this can be found in the link “demo file” by @becca) -
To save the values of the group and the finished vars in your data use either dot notation or bracket and name e.g.
psychoJS.experiment.addData("thisGroup.finished", thisGroup.finished);
psychoJS.experiment.addData("thisGroup.group", thisGroup.group);
or (untested)
psychoJS.experiment.addData("thisGroup.finished", thisGroup['finished']);
psychoJS.experiment.addData("thisGroup.group", thisGroup['group']);
-
Do not place the component with the code snippet in 2 above inside a loop - it will give an error (object is not iterable)
I hope the above help.
BW
Yiannis