| Reference | Downloads | Github

Wisconsin Card Sorting Task - Feedback on Pavlovia

Hi everybody,

I just had another question relating to using feedback on a Wisconsin Card Sorting Task. I’m trying to get the WCST to work over Pavlovia for some experiments I’m planning on running this year. For the most part, it runs, but there’s one very serious issue. It seems like the way the experiment is coded in JS, it’s unable to determine what response would constitute a correct response, and what would constitute an incorrect response. The experiment is viewable right here:

The experiment works great when you just run it in builder view, in that the feedback function works correctly, and the experiment is logging error data properly. You’ll notice that for trials, I have responses coded using this code:

Begin Routine

corr = 0

Each Frame

for stimulus in [one_red_dot, two_yellow_triangles, three_green_crosses, four_blue_stars]:
if response.isPressedIn(stimulus):
print(stimulus.image, corrAns, stimulus.image==corrAns, type(stimulus.image), type(corrAns))
if stimulus.image == corrAns:
corr = 1
thisExp.addData(‘correct’, corr)
continueRoutine = False

And under feedback, I have code that looks like this:

Begin Experiment

msg = ‘’

Begin Routine

if (corr == 1):
msg="Correct! "

End Routine

if (trials.thisTrialN) == 21:
trials.finished = True

As I said, in the Builder version, this works great. In Pavlovia, however, it treats every response as incorrect. I’m assuming this has to do with the JavaScript version of the experiment. Maybe some things are lost in translation between converting from Python code to JS, but the solution is not apparent to me. If anybody has ever ran into this problem and knows how to solve it, it would be a huge help!


Hey @mcphedrm, apologies for the late reply. After switching the Coder from ‘Auto->JS’ to ‘Both’, I had to make the following changes to get the script to behave:

(a) Call addData() on psychoJS.experiment instead of thisExp
(b) Compare corrAns against a based string instead of stimulus.image.

Not that you should have guessed, but because stimulus.image is an HTML element, whereas corrAns is a string, we had a situation where the script was trying to compare apples and oranges so to speak. You can find the details below:

And in action:

Hope that helps some, here for more if not, s.