Participants are presented with pictures and then fixation cross. I need to set duration for the fixation cross from 3 to 3.5 seconds. It should be random each time. I am a complete newby in Python and already tried several codes proposed on the forum. Unfortunatelly, they do not work for me.
you need to insert a code-component preceding the text-component that you use to set the fixation cross. In the code-component initialise a variable in the Begin Experiment tab for the fixation-duration
fixDur = 0
In the Begin Routine tab enter the following code
fixDur = 3 + (3.5 - 3) * random()
You might want to add the following line in the End Routine tab.
thisExp.addData("FixDur", fixDur)
This adds a column containing fixDur to your result file. In the fixation text-component set the property duration to $fixDur.
Notice this solutions gives rather fine-grained fixation durations. The function random generates a random number between 0 and 1. And we simply setting a lower and upper boundary with min+(max-min).
You can test this in Excel. the function to generate random numbers in Excel is called rand().
looks good. It is not a count-down. The number in middle stays on screen for a period lasting between 3 - 3.5 sec. How “large” is your experiment? If it is not too large, you could use this example to build your experiment.
Thank you. When I copy-paste your code in my experiment, weirdly it refuses to work. Again because of $ dollar sign in the duration line. I guess the only chance is to rebuild my experiment in your file. Sounds like nonsense, but we have what we have
When I follow you steps, it can visualize the stimulus, but once the time is over, the whole experiment stops and does not go to the next step.
I have the following error: