Randomizing two different response types in the same routine

I am trying to build an experiment similar to the Posner cuing task but with some important complications beyond my novice skill level:

Within the same block of trials, after stimuli presentation (target) in each trail I am trying to have participants respond to one out of two different questions (instead of just reaction time) before continuing to the next trail, that is, I want to alternate between two different response types: resp 1 (press key A or key B) and resp 2 (press key 1, key 2 or key 3) at random intervals in the same block.

In a block of 100 trails, resp 1 should be presented in 90 of the trials (90 resp 1 trials) and resp 2 should be presented in 10 of the trials (10 resp 2 trials).

The stimuli alternates randomly between 4 different images in both resp 1 and resp 2 trials in 97 of the trials. But in the 3 remaining trials the stimuli is a 5th image and the response is always type 2. These 3 resp 2 trials are the critical trials and should be pseudo-randomized in the block so that they do not occur at fixed intervals but also have at least 20 trials between them.

Is it possible to do this within the same routine and have a conditions file randomly determine which stimuli and response type is presented internally? For example:

Block 1 (100 trials)
Routine: stimuli 1,2,3 or 4 (97%) → resp 1 (90%) or 2 (10%) → stimuli
type 5 (3%) → resp 2.

Or do I need separate routines for each trial type and then have an outer loop randomize the order of the routines and also determine how many times a routine type is run in the block? For example:

Block 1 (100 trials)
Routine 1 (90%): stimuli type 1,2,3 or 4 → resp type 1.
Routine 2 (10%): stimuli type 1,2,3 or 4 → resp type 2 (3%).
Routine 3: stimuli type 5 → resp type 2

I have attempted both solutions but without luck. I hope my questions are clear enough, I am a bit confused. Please let me know if this is understandable at all or if I should clarify.


As your stimuli differ between the two conditions, I would do it as a whole other routine. You could do it in the same routine and just alter a few variables, but multiple routines would be much more readable and easier to understand. If you set a value in your Excel document to be either 1 or 0 each routine (let’s call this value respType) then you can set nReps for one loop to be $respType and the other to be $1-respType. This means that, if respType is 1, the first will be shown (nReps=1) and the second skipped (nReps=1-1), and vice versa if respType is 0.

Thank you for your answer! I managed to solve it by making separate routines following your advice.