I’m running into psychopy/pavlovia freezing mid block and think it may be a result of processing constraints, but am not explicitly sure where or why.
We have an attentional capture task that has two conditions:
- an experimental condition where a distractor-present trial appears every 3 trials (this works fine)
- and then a control condition where distractor-present trials appear randomly but at the same 33% proportion as the experimental condition.
We are randomizing conditions within a single exp trials loop in builder, so the control condition took a little more code to make sure it would randomly select each trial from the 27-row spreadsheet once before starting it over (the spreadsheet instills the 1/3 distractor-present/absent ratio). However, we noticed that this would often present 3-4 distractor-present trials in a row, which I would like to mitigate as best as possible.
My RA and I just put together the below code to designate what each trial selection needs to respect (i.e., no more than two distractors in a row and every row of the spreadsheet before restarting). We had gotten the every row of spreadsheet aspect working, but then psychopy/pavlovia is now freezing/becoming unresponsive at seemingly random points when running through the control condition trials after we tried to implement control over the next trial if the last two trials were already distractor-present. We think that the program could be getting stuck in an infinite loop somewhere in here, but are unsure where.
URL of experiment: https://pavlovia.org/quirkm/attentional_historyv3
# this is all defined in the begin routine of a trials loop trial_id += 1 runTrials =  #this is defined in the beginning of experiment duplicateCheck = False; repeatedDistractor = False; rand_trial = str(randint(0,27)) numTrials = len(runTrials) #decide distractor trial type if expInfo['condition'] == "experimental": if trial_id % 3 == 0 : #distractor present select_trial = str(randint(0,9)) else: #distractor absent select_trial = str(randint(9,27)) else: if rand_trial in runTrials: duplicateCheck = True print("Already Ran") else: #if two trials have ran if (numTrials > 1): if (int(rand_trial) >= 0 and int(rand_trial) <= 8): if (0 <= int(runTrials[numTrials - 1]) <= 8): if (0 <= int(runTrials[numTrials - 2]) <= 8): repeatedDistractor = True if (repeatedDistractor == False): #using current randTrial #and adding it to run_trials select_trial = rand_trial runTrials.append(rand_trial) while(duplicateCheck or repeatedDistractor): if (repeatedDistractor): rand_trial = str(randint(9,27)) repeatedDistractor = False else: rand_trial = str(randint(0,27)) if (rand_trial not in runTrials): #if two trials have ran if (int(rand_trial) >= 0 and int(rand_trial) <= 8): if (0 <= int(runTrials[numTrials - 1]) <= 8): if (0 <= int(runTrials[numTrials - 2]) <= 8): repeatedDistractor = True else: repeatedDistractor = False else: repeatedDistractor = False else: repeatedDistractor = False if (duplicateCheck == False): #using current randTrial #and adding it to run_trials select_trial = rand_trial runTrials.append(rand_trial) else: duplicateCheck = True #generate non distractor if repeatedDistractor if (repeatedDistractor): rand_trial = str(randint(9,27)) else: rand_trial = str(randint(0,27)) #if 27th run if len(runTrials) == 27: #resetting list runTrials =  else: print("Current # of Ran Trials: " + str(len(runTrials))) print("Haven't reached 27 trials")
I’ve seen other threads suggest taking out the print statements to limit the output, but I don’t see that being the reason for the whole program to freeze up. If anyone has a suggestion about what in the code might not be closed correctly or a better way to implement control over the next trial following two distractors, I’d be really appreciative!!