How to stop trial with press of a button and then restart trial after pressing button again

Hello everyone,

I have a six trial experiment. In each trial, a video is played and two stimuli (a beep and a picture) pop-up during it at randomised ISI.

The experiment is meant for infants so I would like to be able to stop the experiment by pressing space bar when they stop paying attention or something happens etc and subsequently, restart the trial when I press the space bar again. Preferably a new pause screen should come up when I press the stop button. Much appreciate any help and/or example code to do this!

Hi @Achilles,

Please find attached a modification of something I coded previously.

If you press space during the trial, the trial will end and a pause trials starts. You can end the pause trial by pressing space again and the previous trial will be repeated.

Hope this helps.

Jan

repeat_trials.psyexp (12.0 KB)
input.xlsx (8.5 KB)

1 Like

Hello Jan,

I’m not so sure how to make your code work with my experiment. I’ve tried a couple of things but for starters I get ‘repeatTrialLoop’ not defined

Here are the experiment files I’m working on

Hi @Achilles,

The problem is that you added the code to the “Begin Experiment” instead of the “Begin Routine” tab.

You also need to increase the “nReps” for the repeatTrialLoop to something rather high (e.g., 100).

Finally, you need to make sure that “Force end of Routine” is ticked for the pause trial.

Jan

1 Like

woohoo, it works now! Silly mistakes! Thank you very much for your help Jan!

1 Like