psychopy.org | Reference | Downloads | Github

Can I make the duration end time a variable?

Hi, I need to adjust the break time based on the type of stimulus I’m showing. For some, there’s no break time; for others, there’s a break time. I’m not sure if it’s working when I tried to make the duration end time conditional (i.e. $break_time). Is it supposed to work? If not, is there anything I can do to make the coding process more efficient? Thanks!

Hi @CatK, if you make the break time set to conditional, and pass it a time, the time will be evaluated as true or false, not an actual time. What you could do is create a variable that becomes true at the break time, in a code component. E.g.,

# Begin routine
componentStop = False

# Each Frame
if t >= breaktime:
    componentStop = True

Here, you would feed the componentStop variable as a duration to your component, and set the stop type to conditional.