psychopy.org | Reference | Downloads | Github

Skipping a routine after a number of loops

I’m using the standalone version of PsychoPy 1.82.01 on Mac OS X

I am trying to make a dot probe task with four trial blocks with a 30 second break in-between (screen shot below). The task is working perfectly, but as I am randomising the blocks in a block loop, the final block contains a break before the experiment ends which is not necessary. I am trying to remove this final break so that the final block of trials ends and the end of experiment message appears.

I have read through some of the old forum and StackOverflow posts, and I have tried a few things to get it to stop the break routine but nothing I have tried has worked up to yet. I placed the break routine in a loop and entered the code below in the routine (I also have myCount = 0 in the begin experiment section). As I have four blocks, I thought if it counted three iterations of the loop, on the fourth it would stop the break routine and go straight to the end of message.

I am relatively new to PsychoPy so I apologise if this is a simple issue, and I hope I have included enough information. I would be extremely grateful for any suggestions as I have been scratching my head over it for a few days now.

1 Like

Looks like you’re pretty close, but I see more than one potential issue:

  1. I think you don’t need the break_loop at all. You don’t need to repeat your break more than once between blocks? I think you can simply get rid of that (and so also the line about break_loop.finished=True
  2. Depending on the version of PsychoPy you’re using, parts of the code may need to go into the “Each frame” block. For very recent versions it’s fine in Begin Routine as you’ve done here but, for older versions, setting the continueRoutine=False could only be done after routine had started. So in those versions you would need to increment myCount in Begin Routine but then do the if statement in Each Frame
  3. Last issue is that block_loop.thisN will already do the counting for you BUT be aware that it starts with 0 (as do most python indices) so block_loop.thisN > 3 only on the 5th trial! (On the 4th trial block_loop.thisN == 3)

Hope one of those helpers fixes the issue for you
Jon

1 Like

Thank you very much!

Placing the if statement in each frame works perfectly.

James

Thank you very much Jon (and James)!

I had the same issue in my experiment and solved it by your post.

For PyschoPy 1.84.2 (Builder), the code can be inserted in the “Begin Routine”, as:

if Block.thisN == 5:
    continueRoutine = False

(Block or block_loop, depending on how it is called).

Best!

Fer

1 Like