Inserting a break into a series of randomly presented trials.

578 views
Skip to first unread message

Steve L

unread,
Feb 13, 2016, 12:18:28 PM2/13/16
to psychopy-users
I have used the builder tool to create a simple dot-probe experiment of 160 trials, presented in a random order.  Is it possible to add 3 breaks into this, after trial 39, 79 and 119, so I have 4 blocks of trials? I’d like to be able to do this within the same loop, i.e. without building a load of separate routines.

Thanks
Steve

Steve L

unread,
Feb 13, 2016, 12:28:38 PM2/13/16
to psychopy-users
Just to further clarify:  I have the list of 160 trials in one excel file. Which trials go in which blocks is unimportant, however it would be good to have 4 blocks so the participants get a break. The presentation of the trials is randomised and  each are viewed only once.

Steve L

unread,
Feb 13, 2016, 12:54:15 PM2/13/16
to psychopy-users
I figured it out. Added another routine within the loop, with a small code:

if TrialList.thisN in [39,79,119]:
    win.flip()
    event.waitKeys()
continueRoutine=False

Filled by the text for the break.

in case anyone is having the same problem :)

On Saturday, February 13, 2016 at 5:18:28 PM UTC, Steve L wrote:

Michael MacAskill

unread,
Feb 14, 2016, 7:25:20 PM2/14/16
to psychop...@googlegroups.com
Hi Steve,

This is a bad idea in theory (and possibly practice). Builder is designed around a frame-drawing & event loop, and by inserting a call to event.waitKeys(), you're breaking that cycle by putting in an indefinite pause, so Builder loses track of which frames have been drawn.

*** event.waitKeys() should only be used in Coder environments, where you control everything. It breaks the code structure and drawing/event loop that Builder relies upon. ***

In essence, your logic of checking the current trial number from a list is the way to go. But after that, a preferable route is to selectively set a variable which decides whether or not a subsequent "pause" routine runs.

e.g. Make your additional routine into a proper "pause" routine, which contains something like a text stimulus telling the participant to push a key when ready, and a keyboard component which ends the trial when any key is pushed. Surround the routine with its own loop, not linked to a conditions file, and with a variable name (say "pause_reps") in the nReps field.

Then your code would look something like this:

if TrialList.thisN in [39, 79, 119]:
pause_reps = 1
else:
pause_reps = 0

Put it in the "End routine" tab *of the trial routine*, i.e. the routine preceding the pause routine. That way, the pause routine will generally not run at all, except on the nominated trials, and the timing and drawing loops that Builder relies upon will be preserved, as you are letting the pause be controlled by a proper keyboard component, rather than brute forcing a waitKeys() period


Also, in the "begin experiment" tab, you might need to put this to give the variable an initial value:

pause_reps = 0

Cheers,

Mike



> On 14/02/2016, at 06:54, Steve L <lisk....@gmail.com> wrote:
>
> I figured it out. Added another routine within the loop, with a small code:
>
> if TrialList.thisN in [39,79,119]:
> win.flip()
> event.waitKeys()
> continueRoutine=False
>
> Filled by the text for the break.
>
> in case anyone is having the same problem :)

--
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

Steve L

unread,
Feb 15, 2016, 9:05:03 AM2/15/16
to psychopy-users
Appreciate your advice. I've tried this, however receive the error:

Error when generating experiment script:
'NoneType' object has no attribute 'params'

Michael MacAskill

unread,
Feb 15, 2016, 3:21:30 PM2/15/16
to psychop...@googlegroups.com
That message unfortunately doesn't tell us where the error is. You'll need to describe exactly what you did and what code went where.

Regards,

Michael


> On 16/02/2016, at 03:05, Steve L <lisk....@gmail.com> wrote:
>
> Appreciate your advice. I've tried this, however receive the error:
>
> Error when generating experiment script:
> 'NoneType' object has no attribute 'params'

Reply all
Reply to author
Forward
0 new messages