Hello Psychopy community,
I am looking for some help for an experiment in psychology. I am not new to psychopy, but I am new to Python coding, especially on how to integrate code lines within the builder.
The experiment consist in a simple categoric decision task, where people see a series of word on the screen presented individually, and decide if that word belongs to the category animals or professions by pressing specific keys (1,2). So far, I made this task quite easily on psychopy, running multiple blocks withint the same experiment.
However, and hereās the tricky part, people should remember to press ENTER each 2:00 minutes; for doing so, then can check the elapsing time (in mm:ss - e.g.: 04:09) by pressing the SPACEBAR.
Thus, my questions are:
How can I program a clock that starts from the very beginning of the task and ends at the end? And how can I record this in the data?
For the SPACEBAR call, one strategy could to put a square with the same color of the background, big enough to cover the clock. How can I record this, together with the ENTER key, associated to the exact moment in 00:00 format?
Thanks a lot in advance for the help, and I attach here the psychopy experiment with the example data.
To present a running clock you can add a text component and in the ātextā field use
$t
and āset every frameā
You can then round t accordingly
ātā is the time of the ongoing clock that exists in the background of your experiment. For your keypress, is it that you want to watch the space bar across several routines?
Alternatively, (if I interpreted your solution correctly) you can make your text component (which is the clock itself) āclickableā so that participants click the clock every 2 minutes throughout the task using the mouse or touching it on a touch screen.
Hi Becca,
thanks a lot for your quick reply and very helpful comment.
I have tried your suggestion, but it runs a clock trial by trial (i.e.: it resets each time the next trial is displayed). I would like to have a clock that persists across several routines, from the end of the first trial, to the end of the last one.
To reply to the response question, I would like that the script would record the exact moment (even in ms) in which participant pressed the both the enter and the spacebar keys. Therefore, the clock displayed on the screen and the spacebar must be fully synchronised.
Sounds like time-based prospective memory. Hereās one I wrote in 2018 which does the space bar = show clock (a maximum of once per word)pm_time.psyexp (47.3 KB) WordLists .xlsx (13.2 KB)
Hi wakecarter,
yes, it is a time-based prospective memory task indeed. Thanks a lot for sharing the psychopy file: that is really useful. I will adapt it to my needs.
Cheers
Hi wakecarter,
thanks a lot for sharing the file. It has been very helpful. However, i have to ask you one thing that was not clear to me at all.
in the code, at each frame fpr the trial routine, i have found this code:
if showclock == 1:
now_clock = now_clock +1
if now_clock > 100:
showclock = 0
now_clock = 0
Specifically, I do not understand what this line means: now_clock = now_clock +1
I saw tha now_clock is defined as zero at the beginning of the experiment. Therefore, is +1 a frame that is added on now_clock? If this is the case, I would like to show the clock on the screen for 3 seconds. Given that the refresh rate of my screen is 60Hz, I thought that I can put 180 to make the clock appearance lasting 3 seconds. However, this is not only the case: in the experiment, although most part of the times the clock is actually shown for 3 seconds, sometimes it appears for 5 or even 6 secs. Do you know how can I make the clock appearanceās timing more precise? And was the code above the solution to reach such regularity?
Thanks a lot for your help.
The code was written for an offline experiment where the refresh rate is more consistent. It should show the close for 100 frames, but Iām not sure that timing by frame works as well online.
How about setting now_clock to t+3 when the space bar is pressed. Then you could have:
if showclock == 1 and t > now_clock:
showclock = 0
hi Beccaļ¼I added $t to the ātextā, but I found that the time displayed on the page has ten decimal places. How can I make it display only two decimal places? Assuming a positive timing of 10 seconds, thank you very much!ļ¼ļ¼