I am trying to build an experiment in which I have something like the following:
# Open experiment handler experiment = data.ExperimentHandler(name=expInfo["Experiment"], version='', extraInfo=expInfo, runtimeInfo=None, originPath=None, savePickle=True, saveWideText=True, dataFileName=expInfo["DataFile"]) # Open trial handler trials = data.TrialHandler(nReps=expInfo["NumRepetitions"], method='random', extraInfo=expInfo, originPath=-1, trialList=data.importConditions(expInfo["FileConditions"]), seed=None, name='trials') experiment.addLoop(trials) # Loop trials for trial in trials: # Do stuff ... # If something happened (e.g., participant gave wrong response), redo trial a while later trials.trialList.append(trial)
Especially the part trials.trialList.append(trial), is this possible, and is it save? I guess it is possible, though it is not save, as fields like trials.nTotal and such do not get updated.
So, would this at all work, is there already a working solution around this ‘problem’, or is it an idea to be able to do something like trials.insertTrial(trial, index=2), which means that the trial gets inserted 2 trials later from now in the trialList, and all other fields in trials get updated too, so everything keeps working as is.