sorry it took me so long to respond. I was on a deadline to finish the experiment. I ended up using a somewhat crude method, but it worked. I will share it here in case someone has the same problem I had.
As I mentioned above, my desired outcome was to have a loop structure, that allows for skipping back in the index.The context is that participants are reading a story word for word. That means only one word appears on the screen at a time and they can see the next word by pressing the space bar. Sometimes it is necessary to repeat the sentence that they are reading at the moment (error detected by the participant). Given that the sentences are unique and are of different lengths nesting a word loop in a sentence loop didn’t make any sense. Or let’s say it would’ve been a lot of work to implement (The way I see it I would have needed a seperate spreadsheet for every sentence).
People kept telling me that if I wanted a loop that allowed for jumping back in the index, I needed to drop the builder and directly write the psychopy script. I ended up doing a bit of that. Basically, I created a loop through the code junk that I could directly control. This way I could still work with the builder and have a custom loop.
I based my code of this video: Using Code to Randomize Two Lists of Stimuli within a Single Loop -- PsychoPy Mini Tutorials - YouTube
Here’s the loop setup:
import random, xlrd
in_file = 'gibberish_conditions.xlsx'
trial_index = 0
inbook = xlrd.open_workbook(in_file)
insheet = inbook.sheet_by_index(0)
#arrays to hold stimuli
sentence_list = 
word_num_list = 
normal_word_list = 
gibberish_word_list = 
new_sentence_list = 
last_word_list = 
for rowx in range(1, insheet.nrows):
# read in an entire row
row = insheet.row_values(rowx)
# save the words and colors
# Set experiment constants and vars
time_of_last_gibb = globalClock.getTime()
time_of_last_tp = globalClock.getTime()
experiment_start_time = globalClock.getTime()
tp_interval = random.randint(120, 180)
gib_interval = random.randint(70, 110)
In the trial, the information can be accessed by indexing the lists:
And then iterating the trial_index at the end of every trial:
Also, the information needs to be saved manually:
The trial is in a builder loop that runs for thousands of trials unless it is manually broken:
That is the gist of it.
Here are all the files, in case someone needs them (tested in 3.1.5):
gibberish_conditions.xlsx (142.9 KB) word_gibberish_12.psyexp (180.9 KB) loop_conditions.xlsx (7.8 KB) practice_conditions.xlsx (11.1 KB)