How to leave a fixation cross for a specific period of time after keyboard is pressed

Hello everyone!

For an fMRI experiment I am building, I need to set the time of a routine to 5.585s.
I have a fixation cross for 500ms, a prime for 35ms, a mask for 50ms, the stimulus presentation for 1s, and then a rating for 5s using a keyboard.

However, I would like that when people click on a button from the keyboard, the text disappears and a fixation cross reappears until the end of the 5.585s.

I have tried different things but I don’t have all the code vocabulary to make everything work!

For example, an idea could be to ‘force end of routine’ with the keypress, but then find a way to add a fixation cross in another routine during that time: (5.585s - the time of the previous routine). Is it a good idea? How could I implement this?

Or just find a way to hide the text when pressing on a keyboard button and then wait for the 5.585s to run out with a fixation cross?

Hey,
Adding another routine with a fixation cross sounds like the easiest solution.
Did you try implementing this? Because all you need to do is to end the routine on the keypress, as you said. And then adding a fixation cross for a defined time. This way, no code is required.
I got a little confused about when you want to show the fixation point, the text, etc.
Sharing the experiment with us/showing us the flow of your experiment can help.

Hello Alexane

you could change the opacity of the text-stimulus. Set the opacity of the text-component to 1 and Every repeat. Set the opacity of the fixation-cross to 0 and Every Repeat. Add a code-component before the text-components and the response-component. Insert the following code to the Every Frame tab.

if key_resp.keys:
    text.setOpacity(0)
    textFixa.setOpacity(1) 

The text-component text becomes “invisible” as soon as one key has been pressed and the text-component textFixa becomes visible.

Note: I used the generic names to the text-component and the keyboard-component. You need to use the component-names that your experiment uses.

Best wishes Jens

Thank you so much Jens, it is exactly what I needed! I worked perfectly!