Help adding up leftover time from stimuli routine and adding it to a fixation routine

First time poster, long time lurker,

I am in the process of converting the Why/How Localizer Task from Psychtoolbox to Psychopy (whyhowloc by spunt). I think I almost have it, but have hit a snag implementing one particular feature. The presentation time of the fixation crosses between blocks are meant to include all of the leftover time from each trial in the previous block. For example, if in a block of 8 stimuli presentations (each stimuli presentation lasts 1.75 secs) someone responds in 0.75 secs every time, then the fixation presentation should become 8 secs longer. Unfortunately, I do not now how to code and implement this feature over 16 blocks. Any assistance would be greatly appreciated. (23.2 KB) whyhow_stimuli.xlsx (15.3 KB)

Insert a code component. In its “begin routine” tab, put something like this:

# at the beginning of the block, set the time to zero:
if inner_loop_name.thisN == 0:
    extra_time = 0.0

Then in the “end routine”, increment it by the difference between the current elapsed time (t) and the intended time:

extra_time = extra_time + 1.75 - t

Then when you present the fixation cross later, add extra_time to its minimum duration.