| Reference | Downloads | Github

Repeating a subset of trials multiple times in a loop


I am using a loop for my trial sequence and I have created a .csv file that contains data for each trial (stimulus path and stimulus category).
What I am doing now is selecting a subset S of all row indices which correspond to the stims that will be presented during the experiment.
In my loop for this block, I set selected rows to S to select all stimuli that should be presented.
All of this works out fine.

What I want to do now is select a couple of stimuli that shall be repeated n times. Just adding a couple of indices to S multiple times doesn’t cut it for me, since row-selection in a loop does not care about the amount of times a row index is present in a given list, but just whether it is present at all.
A hacky way to get this would be to “reserve” n indices for each stimulus and then just use one of those for each stimulus that shall not be repeated more than once, but this would involve a couple more changes.

Is there a built-in way to repeat a subset of stimuli multiple times, using loops in the builder interface, while preserving randomized presentation order (“random” setting in the loop)?

Best wishes

It’s not “built-in” (i.e. it would require a couple of lines of custom code), but yes, it can be done.

To give you a solution, we need to know how you want to select the stimuli that get repeated. e.g. would it be controlled by a column in the conditions file, or be randomised in some way? If so, how exactly?

Hey Michael, thanks for the response!

my current set up is the following: I have a conditions file with a unique row for each possible stimulus.

In the beginning of the experiment I generate a trial list containing indices of rows of my conditions file, where some indices appear multiple times in that list, corresponding to the trials I want to repeat more often.

I am open to change the set up in favor of something which lets me repeat trials multiple times, though! Right now I just don’t know what a canonical/elegant approach looks like, I just have rather hacky ideas in mind.

Best wishes

Just to clarify, I assumed by “repeat”, you meant repeat selected trials consecutively, e.g. trials 1, 4, 8, 8, 8, 12. Or do you mean repeated, but at any point, e.g. trials 8, 4, 8, 12, 1, 8?

Sorry for not making that clear. I want to repeat trials in a randomized order, e.g. 8, 4, 8, 12, 1, 8.

OK, this is trickier. It does make think that this might be easier to do with some custom code rather than using a conditions file. Can you show us an excerpt of your current conditions file, and describe the design (i.e. the total number of trials, what balancing there is, and exactly how you want to decide which trials to repeat from subject to subject, including how many trials to be repeated, and how many times)? i.e. we need to figure out how to effectively take your list of unique conditions, repeat the required ones, and then probably output that to disk to be used as a custom conditions file for each run of the experiment.

Thanks for the support!
I found a way of repeating those trials but forgot to post here to update, so in case anyone who has a similar problem stumbles upon this, this is what I did:

Since the number of repeats for trials is bounded (3 in my case), what I did was paste all rows of my conditions.csv three times to the conditions file (so now my conditions file had blocks of rows A, A, A instead of just having a single block A of rows).
Now when creating my list of selected rows, for each repeat trial with index i I added the three entries i, i + N, i + 2N to the list of selected rows, where N corresponds to the total amount of unique conditions (i.e. the length of my conditions.csv before I tripled it).

This way my repeat trials are repeated the right amount of times.

I am happy to rephrase this if anything was left unclear but I’m too tired right now :smiley: