Ensuring unique item selection in a longitudinal image recognition task

I have a couple of online demos which address this issue: Multi-session Randomisation and Presentation Cap, though I think they could be improved on. My recommendation would be to have a shelf entry of the trials seen for each participant and then randomly select rows excluding those trials to create a useRows list for the loop.

You would also need to load resources on the fly.

Further information on the shelf.

For example, if exclude is a list of indices from the shelf then you could pick 150 rows using something like:

useRows = []
while len(useRows) < 150:
     randIdx = randint(150000)
     if randIdx not in useRows and randIdx not in exclude:
          useRows.append(randIdx) # edited

This method might be faster than starting with a list of numbers 0 - 149999, shuffling them and then cycling though a similar loop. I don’t know how long it would take to shuffle a list that long.