As previously mentioned, the istrials flag doesn’t do anything online.
You can reduce the number of rows online by using different techniques, such as:
if nReptsImlist == 0:
continueRoutine = False
in Begin Routine of imret2_loop instead of having a loop around it with nReps of nReptsImlist