Randomized time interval for fixation cross presentation

Hi guys,

I am very new to PsychoPy, do not have any idea about python (yet) and therefore use the builder view completely to build the experiment. I am currently working on a Windows 10, using the PsychoPy version3 (v2020.2.5).

I am currently trying to build a Dichotic Listening Paradigm where an audio stimulus is presented after a randomized period of time. Participants then have to respond using a keyboard press. My current problem is that I am unable to randomize the Inter-Trial-Interval, meaning the time after the response to the previous stimuli and the presentation of the next fixation cross for the next trial. This ITI is supposed to be randomly between 0.5 and 1 seconds. Is there any way to do this using the builder view? If so, where do I need to go and what do I need to add / click? If I have to use the python script to include this information, where would I need to put it?

I hope this is sufficient information and anyone of you will be able to help me with this!

Thank you so much for your help in advance,
Greetings from Germany

Katrin

Hello Katrin,

you need to add a code-element to your iti-routine. Make the code-element the top row of your iti-routine. In the begin routine tab add the following code.

This gives you numbers between 0.5 and 1 in steps of 0.1

``````iti = randint(5,10)/10
``````

If you want to have a finer resolution, you could change the code-element to

``````iti = randint(10,20)*0.05
``````

That results in steps of 0.05. Use the variable iti (or whatever you want to call it) as a duration for your iti-routine.

Best wishes Jens

1 Like

Dear Jens,

first of all thank you so much for your quick help and feedback! I have tried to include the code you suggested to my code.

------Prepare to start Routine “ITI”-------

iti = random(10,20)*0.05
continueRoutine = True

keep track of which components have finished

ITIComponents = [Fixkreuz]

Is this the correct position?

Unfortunately, I have received the following feedback:

File “…”, line 356, in
iti = random(10,20)*0.05
File “mtrand.pyx”, line 423, in numpy.random.mtrand.RandomState.random
TypeError: random() takes at most 1 positional argument (2 given)

Experiment ended.

I understand this as though I should only write 1 nuber into the function random. However your suggestions says that I should include 2 numbers. Hence, I am a little lost here. Did I not put it at the right position? Is there anything else I need to add? I would be very grateful if you could help me out once more.

Thank you so much,
Have a great evening
Best wishes

Katrin

Dear Katrin,

sorry, my error. It should read (see attachment)

``````iti = randint(10,20)*0.05
``````

iti.psyexp (6.6 KB) Stimuli.xlsx (8.4 KB)

Best wishes Jens

1 Like

Dear Jens,

thank you so much, it worked!

Best,
Katrin

Dear Katrin,

Do you mind marking it as solution? Then it is found more easily.

Best wishes Jens