I’m using PsychoPy v2021.2.3 on a Windows computer. I’m new to PsychoPy and only have a bit of experience with coding/programing.
In my experiment, I would like a baseline odd-even task to occur every 60-90 s for a duration of 6-8 s during my experimental task. How can I achieve this?
My experimental task consists of 84 trials, which should be mixed with trials of my baseline task.
If it is a case of presenting the other task on random trials, then in your excel spreadsheet you can have some rows for taskA and some for taskB and set the loop type to random. This demo would show you how to do that. conditions.xlsx (18.0 KB)
I used the interleavetasks_time.psyexp and it works! However, I would like TaskB to occur every 60-90 s for 6-8 s. How can I incorporate these time intervals?
Assuming that TaskB is in a loop within you main loop then you could set the nReps to showTaskB and then add the following in code components
Begin Experiment
myClock = core.Clock()
showTaskB = 0
End Routine just before the main task starts
myClock.reset()
interval = randint(60,90)
End Routine just before the TaskB loop
if myClock.getTime() > interval:
showTaskB = 1
myClock.reset()
End Routine within the Task B routine
if myClock.getTime() > 6:
showTaskB = 0
myClock.reset() # Remove this line if you want the 60-90 seconds to include the time on TaskB
interval = randint(60,90)
trials_TaskB.finished = True # Where trials_TaskB is the name of the TaskB loop
I have four conditions randomized across participants (A, B, C, D). For each condition, the loop for TaskB has to have its own name in the Builder. The TaskB routine, however, is always automatically the same. So trials_TaskB_condA.finished = True needs to change to trials_TaskB_condB.finished = True in the condition B loop and so on. I would like to avoid generating unique Routines per condition to be able to have unique code per Routine per condition.
I have this code component in the TaskB routine. The last line would need to extend to all conditions, so that trialsOddEvenA counts only in the condition A loop and trialsOddEvenB count only in the condition B loop and so on: