| Reference | Downloads | Github

Jittered interstimulus interval (ISI) - how to print single value used from array in output file

Hi everyone,

I am using Psychopy version 1.90.1, running on Windows 10.

I am using the following code to generate an array for the jittered inter-stimulus interval (ISI) in my EEG experiment.

jitter_1 = np.arange(2, 2.51, 0.017)

To my understanding this will create an array in steps on 0.017 between the values of 2 and 2.51, giving 31 possible values for the jittered ISI. It will then shuffle this array on each repetition of the routine, thus giving a randomly selected value for the ISI on each trial.

I have come across the following code to add experiment data to my output excel file:

thisExp.addData (‘jitter_1’, jitter_1)

However, my problem is that because I am creating a shuffled array, the print out includes a list of values from the array rather than the single value used for the ISI on the specific trial (see extract below).

Can anyone tell me how to work out which single value was used on each of my trials for the ISI?

Is there a different piece of code I can use to print the single value taken from my array to the output file?


Is the information already in the print out of my array? For example, perhaps the first value on the list is the one used in that trial.

Thank you for your time and help in advance,
Please do let me know if any further information is required, I am new to the forum and this is my first post.


Extract from output excel file:

Hi Mica,

Firstly, if you are wanting to specify such precise times, you should probably be using integer numbers of frames (screen refreshes) rather than time values.

# list of screen refresh counts:
jitter_1 = range(60, 91) # 2.0 – 2.5 s @ 60 Hz

Secondly, presumably you need to extract a value form your ISI list to use on each trial (to specify the duration of some stimulus, for example). This can be by indexing using the current trial number, e.g:


In that case, use the same expression to save the value for this trial:

thisExp.addData('jitter_1', jitter_1[your_loop_name.thisN])
1 Like

Hi Michael,

Thank you very much for your detailed and prompt reply.

This is very helpful, I believe this is now working correctly as I have a column in my output file titled “jitter_1” with values ranging from 60 - 91.

I just wanted to confirm a couple of things with you:

  1. Is it correct to select “duration (frames)” from the dropdown in builder for stop duration?

  2. Is this the correct code to define stop duration?

  3. By my calculation 60 - 91 frames = 1 - 1.5 seconds (i.e. frames/60), rather than 2 - 2.5 seconds. I intend to convert all my timings to frames to be consistent throughout the experiment so just wanted to double check this first.

Many thanks in advance

Hopefully they should just range from 60–90 (a quirk of Python is that the end value is not included).

No, this would always give you the same, constant jitter value (the first value in the list). You need to index the list so that on each trial you get a new value. As above, replace the constant index 0 with the trial number of your loop, e.g. your_loop_name.thisN

Ensure you also use thisExp.addData('jitter_1', jitter_1[your_loop_name.thisN]) to save the same value for this trial within the data file.

Correct, typo on my part, sorry. Add 60 to the start and end as required.