Project runs on Psychopy but not on Pavlovia. Help with TypeError

URL of experiment: SC-IAT [PsychoPy]

Description of the problem:
I’ve created a cognitive task that works perfectly fine when ran locally in Psychopy. However, when I run it on Pavlovia I get the error below:
TypeError: Cannot read property ‘0’ of undefined.

It appears that this is happening during my first trial and loop when I import the stimulus and key from block1.xlsx. I’ve checked the file and there’s no missing cells of the sort. Can someone please point me in the direction of how to fix this??

Thank you!

What have you got in the selected rows field of your loop?

So that might be the problem? The excel file pulling in has 52 conditions (52 rows), for the study we’re either using 24trials (practice round) or 72 (test round). So in the selected field I therefore have:
np.random.choice(52, size = 24, replace = False) or np.random.choice(52, size =72 , replace = True).

I didn’t know how to get the appropriate number otherwise.

How about using all rows and 2 reps (Full Random). Then break the loop in code after a bespoke counter reaches 24 or 72. This would mean each condition will appear a maximum of twice in each section.

Alternatively you could use Random so everything appears once before the repeats start.

If that works and would work on both PsychoPy and Pavlovia I’m all for trying that.

To be clear you’re saying to change looptype = FullRandom, nReps = 2. Then are you saying to add code in builder?

This bit is in the loop definition. Breaking the loop would require something like

loopIdx += 1
if loopIdx == 24 and block == 0:
     trials.finished = True
elif loopIdx == 72 and block == 1:
     trials.finished = True

You would need loopIdx = 0 and block += 1 in an outer loop with 2 reps which separates the practice and main trials.

1 Like

My friend, thank you very much. This worked. I have individual loops for each pract and test trial because there’s different instructions before each. But the code within each definition works and was just tested on Pavlovia. I appreciate the response and help.

My best!

1 Like