# Randomly mixing experimental and baseline task trials

Hi all,

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.

Hi There,

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)

If it is that you need it presenting every X seconds you would need something like this (this example presents a second task every 3 seconds):

Hope this helps,
Becca

Hi Becca,

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?

Thank you!

Hi all,

Can someone help me with this second question?

Thank you

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()
``````

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:
myClock.reset()
``````

End Routine within the Task B routine

``````if myClock.getTime() > 6:
myClock.reset() # Remove this line if you want the 60-90 seconds to include the time on TaskB
interval = randint(60,90)
``````interval = randint(60,80)/10