Duration of a fixation

Hi,

I would like to set the duration of a fixation cross based on following calculation (pls see image). Can I do it using builder please? I am completely newbie in programming. Do you know how to do it?

Duration of fixation = (i)3500 Millisecond - (ii) 400 Millisecond duration of another fixation - (iii)response time of the previous stimulus

Many thanks!
Faye

Hi @faye3309,

you should be able to accomplish this by setting the duration of the fixation component to $duration, setting the component to “set every repeat”, and including a code component with the following content:

Begin routine

duration = 3.5 - .4 - YourKeyboard.rt

YourKeyboard has to be replaced by the name of the keyboard component that is used to give the response of which you want to use the RT.

1 Like

Hi @ajus

Thanks for your reply! I tried to create a code component and followed the steps as suggested, but I received the the error message TypeError: unsupported operand type(s) for -: ‘float’ and ‘list’. Do you know where the problem is please?

And also sorry that I misunderstood the experimental design earlier. Participants should be first presented a fixation A (the duration of the fixation A is randomly presented between 0.4min-1.6min), then ->cue->target> fixation B (the duration of the fixation B is 3.5min - duration of fix A - respond time for the Target

Please see attached image for the experiment route. I have also attached my experiment file here.
Testing2.psyexp (17.0 KB)

Can I add the content fixDur = 0.4 + (1.6 - 0.4) * random() under the begin routine at code component for Fixation A, then add the content duration = 3.5 - fixDur - key_resp.rt at the begin route at code component for Fixation B please?

Many thanks
Faye

Is your keyboard component saving all responses rather than just first or last? If so, the rts are a list. You could access the first item using [0] or change the keyboard component.

The latter is easier if your routine ends on the first keyboard response.

I set to save first key only, but the error message is still there :smiling_face_with_tear:

Try print(‘varname’,value) above the code giving the error to check each component of the equation.

Your fixDur suggestion should work.

When I add the code as suggested, an error message says the ‘value’ is not defined. I finally used different way to solve the problem. Thank you so much!