psychopy.org | Reference | Downloads | Github

Random inter-stimulus intervals

Hi Team,

Thanks in advance for any help.

OS: Windows 10:
PsychoPy version: 2020.1.3

What are you trying to achieve?:

I am looking to create a 3-minute Psychomotor Vigilance Task (PVT), whereby the stimulus is a fast ‘stopwatch’ kind of clock that presents itself on screen and participants must tap SPACE as soon as they see it.

  • Participants press SPACE to start following instructions (completed this part)
  • Have to wait a RANDOM amount of time for first stimulus (stopwatch)
  • On each trial, stopwatch runs rapidly from 0 seconds e.g., 0.001, 0.002, 0.003
  • Participant presses SPACE
  • Time-between each stimulus = RANDOM; from 2 - 10 seconds.
  • Each stimulus to last 500 milliseconds (i.e., clock to disappear on 0.5 seconds - a participants ‘missed’ message would be useful if I could please have help on this, I understand it might be incorporating ‘msg’ somewhere)

What did you try to make it work?:

For stopwatch:

$str(round(t, 1))

For randomised time-between-stimuli:, in the Begin Routine and Each Frame sections, I have tried:

jitter = random() * (integer - integer) + integer
jitter = round(jitter, 1)

and

ITIs = [2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] 
shuffle(ITIs)

**also putting:

ITIs.pop()

as the START time of the TEXT (milliseconds2) stimulus in

What specifically went wrong when you tried that?:
No error message but the stopwatch clock stimulus comes up every 2 seconds, and also starts from 2.0 each time.

i.e.:
Display = 2.0, 2.1, 2.2, 2.3, 2.4
Time-between-stimuli = 2 seconds every time

I have attached screenshots and recognise I am not particularly an expert in this so will try to provide as much detail as possible.

Many thanks,
Liam!


code ITIs

1 Like

Thanks for pointing this out, Michael. Apologies for not realising. Amended as appropriate and I will familiarise myself with forum conventions.

No worries, it just makes posts much easier to read and more likely to get answers.

This is a bit of a puzzle. An issue here is that you have ITIs.pop() in the “Start” field. That gets called once at the start of each routine, but then afterwards we don’t have any way of knowing what value was selected. So that should actually be done in a code component, and assigned to a variable name, and then you use that variable name in the “start” field. That way, you can also record the chosen value in the data for each trial, or print it out for debugging purposes.

There is a second issue, in that you create and shuffle the list in the “begin routine” tab. That way, the values are selected again from scratch at the start of every trial, so values will often be repeated, and will be presented in an unbalanced way. You should either do that step in the “begin experiment tab”, or if you have multiple, nested loops, put it in the “begin routine” tab, but add a check so that it only occurs on the first trial, e.g:

if your_loop_name.thisN == 0: # only on the first trial
    ITIs = blah blah
    shuffle(ITIs)

ITI = ITIs.pop()

# record the chosen value in the data:
thisExp.addData('ITI', ITI)

# and put $ITI in the "start" field

# TEMPORARY debugging code to check:
print('ITI: ' + str(ITI))

Also note that your stopwatch value needs to take into account that it will not be starting from time 0, but from when ITI seconds have elapsed, so the expression should probably be something like this (again, showing why we need to store the value in a variable so that it can be used in several places):

$str(round(t - ITI, 1))
1 Like

Thank-you, Michael. This worked a treat! I appreciate your swift responses.

No problem. Welcome along.