Re: [psychopy-users] How Skip a routine within a loop

562 views
Skip to first unread message

Michael MacAskill

unread,
Dec 19, 2015, 7:32:44 PM12/19/15
to psychop...@googlegroups.com
Hello,

I don't *think*

trials.finished = True

will have any effect until the end of the current loop iteration, whereas

continueRoutine = False

is checked on every screen refresh and so will terminate the current routine almost immediately.

So if in Routine 1, you do both of the above, the net effect is that Routine 1 will end immediately, but Routine 2 will run once, and only then will the loop terminate, before Routine 1 runs again.

In your case, you will want to set "trials.finished = True" so that the loop won't run again, but you will also need to set "continueRoutine = False" in *every other* routine within that loop.

e.g. in another code component in Routine 2, you could put something like this in its "begin routine" tab so that Routine 2 never even starts if you have set the loop to end in the previous routine:

if trials.finished:
continueRoutine = False

Regards,

Michael


> On 20/12/2015, at 02:36, PULKIT SINGHAL <singhal...@gmail.com> wrote:
>
> I have two routines in a loop and Routine 1 is a code component. Based on the condition in the code component, I terminate the loop.
>
> But when it is terminated, I want that Routine 2 should not be run. It should be skipped. But as of now when I have set "trials.finished = True" in Routine 1 code component , the loop does end but it ends up executing Routine 2 which I want to skip.
>
> Is that possible from the builder? I think it should be but somehow I am missing something here. I have tried both "trials.finished = True" and "continueRoutine = False " but in both cases Routine2 is not skipped. Thank you.

--
Michael R. MacAskill, PhD 66 Stewart St
Research Director, Christchurch 8011
New Zealand Brain Research Institute NEW ZEALAND

Senior Research Fellow, michael....@nzbri.org
Te Whare Wānanga o Otāgo, Otautahi Ph: +64 3 3786 072
University of Otago, Christchurch http://www.nzbri.org/macaskill

Message has been deleted

PULKIT SINGHAL

unread,
Dec 20, 2015, 1:35:07 AM12/20/15
to psychopy-users
Thank you for the response.Yes this should work. Although I applied a different solution which I got from previous psychopy question on this group itself.

I have kept the Routine2 in a loop with nRep as a variable: say $Rep. This variable I give the value in the Routine 1 based on my condition. If I have to exit the loop, I give Rep = 0; else Rep = 1.

Your solution is definitely a cleaner way to do this. I will try this as well. Thank you.

Regards,
Pulkit

Michael MacAskill

unread,
Dec 20, 2015, 5:30:25 AM12/20/15
to <psychopy-users@googlegroups.com>

> On 20/12/2015, at 19:35, PULKIT SINGHAL <singhal...@gmail.com> wrote:
>
> Thank you for the response.Yes this should work. Although I applied a different solution which I got from previous psychopy question on this group itself.

Yes, sorry, I must have been going through messages out of order and missed that Jeremy had already sorted this. There are many ways to skin a cat…

Cheers,

Michael

PULKIT SINGHAL

unread,
Dec 20, 2015, 6:22:29 AM12/20/15
to psychopy-users
Apparently your solution makes more sense now. In what I implemented, when I checked the data file, the particular trial in which the routine 2 is being run, values are being stored twice. Whereas in your solution, it is not run at all. Hence no duplicates.
Reply all
Reply to author
Forward
0 new messages