I am trying to build a time-based prospective memory task. The task includes an ongoing task which is a spatial working memory task and a PM task which is pressing the “enter” button whenever 2 minutes pass. For this, I built a spatial working memory task and I am trying to create a timer (which shows only minutes and seconds) that will pop up for 5 seconds whenever participants pass the tab button and show how much time has already passed.
I am new to Psychopy and I don’t know the coding component well. Therefore, I’ve examined the past posts about the time-based PM tasks in the Psychopy forum and found conversations and shared time-based PM tasks (from Digital Clock during experiment 1) that have the timer the same as what I would like to build. I’ve tried to integrate these codes into my experiment. Now, the timer shows up at the right top corner of the screen but, it starts to count from 0 whenever it shows up. Also, it doesn’t work synchronized with my working memory task. It interrupts the experiment. I am sharing the images about this problem.
I would like to create a timer that will work starting from the experiment to the end and the timer should not interrupt the experiment.
As I said, I am new to Psychopy, so I couldn’t solve the problem with the timer function.
I would be glad if you help me to build a time-based PM task using Psychopy.
Thanks in advance.
Hi Wake Carter,
Thank you for your reply. I found your time-based PM task before from one of the old topics. I tried to apply your codes to my experiment. When I applied the same codes to my experiment, the timer appeared, but it interrupted the ongoing task (working memory task). Besides, the timer doesn’t work well. It appears in the right corner in every interstimulus interval, it stays until pressing the space bar again and, it starts 0 whenever it appears.
I would like to create a timer that works with ongoing tasks simultaneously and appears when I press the space tab as in your time-based Pm task.
I am sharing my codes for the timer:
Begin Routine:
pm_clock=core.Clock()
clock_flag = 0
Each Frame:
mins = math.floor(pm_clock.getTime()/60)
secs = round(pm_clock.getTime()-mins*60,0)
clock_time.text=str(int(mins)).zfill(2) + ':' + str(int(secs)).zfill(2)
if showclock == 1:
now_clock = now_clock +1
if now_clock > 250:
showclock = 0
now_clock = 0
if "space" in response.keys:
continueRoutine = True
if showclock < 1:
if clock_flag < 1:
thisExp.addData('Time_View', round(pm_clock.getTime(),0))
showclock = 1
clock_flag = 1
now_clock=0
elif "enter" in response.keys:
continueRoutine = True
if time_flag < 1:
thisExp.addData('Time_Response', round(pm_clock.getTime(),0))
if secs < 6:
timescore = 1
elif secs > 114:
timescore = 1
else:
timescore = 0
thisExp.addData('Time_Score', timescore)
time_flag = 1
elif len(response.keys) > 0:
continueRoutine = False
I could’nt get what is wrong. I’d be pleasure if you could help.