psychopy.org | Reference | Downloads | Github

Design with Timer (clock) hidden from view unless called by user

Hi All,

I’m very new to psychopy and Python in general, but I’m very interested in getting up to speed so that I can use this program to build some research tasks. In short, I’m invested in learning this program but I think I’ll need some pointers along the way.

My basic task design is that participants engage in an ongoing activity of some kind (e.g., a stroop task), but they are also asked to press the space bar at a specific point in the future (e.g., press the space bar after 30 seconds have passed). That all seems simple enough, but what I’d like to do is have a clock present that is a timer that counts down from the time prompted (e.g., ‘30 secs’) down to zero AND have the clock only visible when it is called by participant’s button press. That is, the clock is running in the background and is only shown to the participant when they press a button. The goal here is to allow the participant to track the time elapsed and allow me to check their time checking behavior.

I found code for a countdown timer in a previous thread and could modify that as need for a digital clock, but, and here’s where it gets a bit tricky, ideally I’d like to present an analogue clock face showing the amount of time remaining. I’ve considered building one from the ground up (or piggy-backing on someone else’s python code) and using that to implement the clock function. Another possibility, although perhaps a bit more crude, is to make videos of analogue times set to different durations (e.g., 30 sec, 45 sec, 60 sec) and pull those into the screen somehow.

So, I have two question:

  1. What is the easiest/most efficient way to “hide and reveal” the clock? I thought I could just have it present the whole time and add an object (a box) in front of it that can removed for 1 second after a button press and automatically returns (clock is always there, but is obscured).
  2. Any suggestions for how to make the analogue timer? Could the video option work or would it be better to have psychopy/python build such a clock?

Thank you in advance for your help with this. As I said, I’m eager to learn to build this, but my efforts would greatly benefit from input from current psychopy users who are more familiar with it’s funcitons.

-Scott

Yes, that works.

You can draw one directly. Much easier than trying to go the movie route.

Fortunately there’s even an example built in to PsychoPy for you :wink:

Switch to the Coder view: Demos menu -> Stimuli -> clockface.py

That code could be integrated into a Builder code component. Put the stimulus creation stuff in the Begin Experiment tab, and the stimulus updating stuff (minus the while loop) in the Each frame tab.

This is tremendously helpful. Thank you! I’ve managed to modify the code so that the clock counts down (second hand moves backwards, with other hands removed).

Is there an easy way to draw a circle for the clock and add hash marks at the 1/4 intervals?
Also, how do I move it’s position and rescale it?

Anything that points me in the right direction would be most appreciated.

http://www.psychopy.org/api/visual/circle.html

A ShapeStim as a line (like the second hand but static), positioned and oriented using some high school geometry.

Check out the shapes.py demo and consult the API for the ShapeStim as required:
http://www.psychopy.org/api/visual/shapestim.html

Thank you very much! It’s coming along nicely now.

Hi Scott,

I have come across the same problem. If you have been able to get it done, would be able to share the psyexp file?

Thanks