Making things dynamic§

1

What is dynamic?§

In PsychoPy everything is organised in reference to time

  • We don’t have “slides” that simply follow each other like in some packages
  • Things overlap in time
  • Things can change their attributes in time
2

Why is that useful?§

You could use this, for instance, to:

  • gradually reveal an object
  • make an object move to make the task harder
  • make an object more interesting for participants (e.g. developmental)
    • rainbow text
    • throbbing heart
3

Code as arguments§

Most dialog entries have the option to take raw Python code if you start your entry with $ (or have that by default).

You can use this as more than a variable from your conditions file e.g.:

  • set stimulus position to travel in a circle with $[ sin(t*2*pi), cos(t*2*pi) ] and set this to update every frame
NB. If you actually need a dollar symbol to be in your text, do one of:
  • $”You won $5” [include quotes]
  • You won \$5
4

Interacting with the mouse§

When moving online, the features of the mouse can make for some really cool dynamic experiments that translate to touchscreens Mouse inputs .. _heartThrob:

5

Create a pulsating heart§

Download an image of a “love” heart, preferably one with a transparent background.

Let’s put that into a PsychoPy experiment and set its size to vary on every frame.

../_images/heart_red.png
6

Equation for a pulse§

Getting the maths to look right here is going to be the key.

It’s something based on a sinusoid. Recall that sin(t) varies smoothly between -1 and 1:

  • sin(t) : too small
  • 50*sin(t) : big enough (50 pixels) but it goes negative
  • 100+50*sin(t) : varying nicely between 50 and 150 pixels

That’s a good start. If we want to make it more pulse-like we need to raise the value to a power before scaling it up:

  • 100+50*sin(t)**4
7

More ideas and working code§

Inside the examples zip file, look under:

builder/dynamic

You’ll find working examples of a range of these stimulus setups

8

Coming next§

Block designs and counterbalancing

9