In my experiment, I have two loops named: trials_Practice & trials_Main. trials_Main will be run around 70 to 77 times. In this loop, I want to introduce a break when half of the total times of the loop (around the completion of 35 trials) has been completed. I want to present a text component saying “2 minutes Break” after completing half of the main trials with ‘Press any key to continue’ as a response.
I am unable to figure out where I will write the code in the builder view of code component. I tried to do this to introduce a count variable and give start time condition into the text component. It didn’t work.
I know there is some way to pause a loop but I didn’t find out.
Could anyone have experienced the same problem in the past? Or anyone can add the link with the same problems’ answer.
Create a second routine containing your pause text and keyboard component. Insert a code component on that routine. In its “begin routine” tab, put something like this so that routine will run only when exactly 35 trials (counting from 0) have been completed:
if trials_Main.thisN != 34:
continueRoutine = False
This works perfect, but in my case I would like to make pause several times (e.g., after each of 25 trials, total of 250 stimuli will be presented). With this code only one pause have been made (after 25 trials and that is all. Should I use thisRepN instead of thisN?
Hi,
I’m having a similar issue. I have a basic study where I want to present 100 images in a random order. However, I want to have 2 blocks of 50 images each with a screen after the first 50 trials that says “You may now take a break” then have the participant press a key to resume the study. I would like to have my images presented in a random order for each participant and not repeat in the 2 blocks (so 100 images total with no repeats). I currently have all of my image names in 1 column in an excel file called Stimuli.xlsx and the column they are in is called Image. I tried your suggestion to create a routine that contains my pause text, keyboard component and code component that has the code you suggested. However, all it does it show the break routine after each trial and not after 50 trials. I am using PsychoPy version 3.2.4. I’d be very appreciative of your help.
I am not expert on this but I had a similar issue and it worked for me.
Please paste this code in begin routine block of code component. Place code component at the end of your condition loop.
if trials_Main.thisN != 50:
continueRoutine = False
That was a bug that re-surfaced around version 3.2.0. It was fixed late last year. If you are creating a new experiment, it would be worth updating to a later release.
That’s very strange. I’d be interested to see your .psyexp file if you are happy to share it. If this issue has arisen again, it really needs to be fixed for everybody (as having this code only run in the “each frame” tab can cause a single frame glitch where the very first frame of the unwanted routine will always display).
Hi Michael, I’m having the same issue. Break works find locally, shows up every 5 trials, but online it shows up after every trial. My PsychoPy version is 2020.2.4. I’ve tried on both Mac and Windows, same problem shows up both places. I’ve tried to put the code snippet in Begin Routine and Each Frame but makes no difference, it seems that online it just skips the conditional statement. Can you help me figure out why? The project gitlab is https://gitlab.pavlovia.org/tzhu9/cr-cat-learn
Sorry, the JavaScript side of things is not my forté. But I think there are a few other active topics on this at the moment, where hopefully a resolution will be found?
Hi Michael,
I recently came across this thread as I am also looking to insert a break every 40 trials in my experiment (80 unique trials that are repeated twice for a total of 160 trials) I inserted this code into my “begin routine” component:
It does successfully give a break every 40 trials, however it also pauses for the break after the first trial as well. I thought that the initial “trialsN > 0” would prevent this from happening, but it doesn’t seem like it did. Any ideas of why this is/what I can do to fix this?
Thanks so much and let me know!