Hello,
I’m very new in Psychopy and I have a question.
I’m running Psychopy v2021.1.2. on Windows. I have created an AX discrimination test but I don’t know how to make the trial number appear on the screen.
Please give me detailed information on how to do it
Many thanks,
George
Becca
October 27, 2021, 11:08am
2
Hi George,
add a text component to the routine where you want the trial number to appear. Then in the Text field add:
$main_trial.thisN
and set the field to “set every repeat”
Note that main_trial
refers to the name of the loop you are currently in, so if you were in your practice loop you would use $practice_trial.thisN
Hope this helps,
Becca
Hi Becca,
Thank you for your response!
This seems to work, however, I would like to add current trial out of total trials (e.g., 2/30)
I used $main_trial.thisN+1+ "/ " + $main_trial.nTotal
and $str(main_trial.thisN+1) + " / " + $str(main_trial.nTotal)
but these seem not work.
Any ideas would be much appreciated!
George
Becca
October 27, 2021, 11:55am
4
very close! you only ever need one dollar sign (at the start of the field to indicate this will be python code
try
$str(main_trial.thisN+1) + " / " + str(main_trial.nTotal)
Many many thanks! That works perfect locally. I hope it works online too!
What if I wanted to add text around this, to say “You are now X/X trials through the experiment”? How could I do that?
$"You are now " + str(main_trial.thisN+1) + " / " + str(main_trial.nTotal) + " trials through the experiment"
1 Like