My experiment uses the following code in PsychoPy to essentially randomize rows and columns, but it will not work correctly on Pavlovia. My original post about the details is here: Randomizing Columns and Rows
Essentially the code helps to randomly choose a row from my conditions file, randomize the list of three items in the row, and play the audio for each of those randomized items. This code works great on PsyhoPy Builder, but when I moved it to Pavlovia, the items are not all being played. For example, sometimes the sequence plays as “Tone1, Tone1, Tone1”, when it should always be some variation of “Tone1, Tone2, Tone3” in whatever order. Sometimes all tones play, but usually one of the tones plays more than once and not all tones are played. I have checked to make sure that the variables are labelled correctly in the audio properties and that it is set every repeat. I’ve also made sure my loop is set to random. My actual experiment code can be found here: https://gitlab.pavlovia.org/jfeiler/m-tone
I have added the following, per the Crib sheet, to my “Begin Experiment” tab on the code sequence:
# only on the first iteration per trial:
if trials.thisTrialN == 0:
tones = [Tone1,Tone2,Tone3]
# record the order in the data file:
# pull one out of the hat for this trial:
current_tone = tones.pop()
I’d really like to begin piloting my study, so any help would be GREATLY appreciated.
Do you mean if the randomization code didn’t run? If so, no I wouldn’t get the effect. It’s one of the most important parts that this code run because participants need to identify the tone of the word they hear, and if they’re always played in the same order, it loses its effect.
Thanks @wakecarter! This works for the first sequence of tones (1, 2, and 3), but then a loud single tone plays continuously, and no other tone sounds play even though there are six more trials of three tones. Is there something I need to adjust with the audio? Here is my current code:
@wakecarter No, it’s actually different Mandarin words that play each time. For example, trial 1 might be an audio recording of a Mandarin speaker saying ba1, ba2, ba4 (with the numbers representing the Mandarin lexical tone of the word), and trial 2 might be piao1, piao2, piao4. There are seven words each with three tones that need to play, and I need each word (ba, piao, etc.) to play fully through for each tone (1, 2, and 4), but I need the order in which 1, 2, and 4 play to be random and I need the order of each word (ba, piao, etc.) to be random as well.
That’s why I was originally using the shuffle(tones)to randomize the three tones of each word and then the current_tone = tones.pop() to pick one out randomly and play it by putting the current_tone variable in the sound component. Because of an inner loop set to n = 3, the sequence repeats three times and never picks the same tone twice for a word on PsychoPy builder. On Pavlovia, the same word# plays more than once sometimes. Here are some screenshots (spreadhseet, sequences, and loops) if that helps at all.