psychopy.org | Reference | Downloads | Github

Newbie Q: control dot stimulus color in time dependent manner

OS: MacOS Mojave
PsychoPy version: v3.0.7 standalone

Hi all,
I am very new to Psychopy, so excuse me for asking very straight forward questions.

I want to manipulate color of 50% of the dots in a dot stimulus in a time dependent manner. So, for example, the total duration of the dots is 10 sec. From time point 1 to 2 seconds I want 50% of the dots to change color. My dot stimulus is 3cm wide, has a 100% coherent movement direction in 45degree direction, the lifetime of the dots is infinite and the movement speed is 0.9 degree/second (so it is slow enough to follow a dot during it’s duration).

In order to target only 50% of the dots, I figured that I could create two identical dot stimuli and manipulate the color of only one of the dot stimuli from time point 1 to 2 seconds. Or is there another work around?

Now for the color change limited to time point 1 to 2 seconds: What doesn’t work is using a dot stimulus identical to the dot stimulus with a constant color during 10 sec from time point 0 to 1 second, a dot stimulus with the color change from time point 1 to 2 seconds and again a dot stimulus identical to the continuous color dot stimulus. This doesn’t work because I want existing dots to change color, other wise there is a position 'jump" of the dots at the 1 sec and 2 sec time points.

Is there a way to target change the color of a dot stimulus during a part of it’s duration? Should I use the Custom Code element from the Builder? And how would such a code look like?

Many thanks!

OK, no replies yet, but it was pretty simple to achieve in the end. This is what I did. I entered this in the Custom Code element under the “Every Frame” tab:

if frameN > randColor:
        dots_blue_2.setColor([240,0.5,1])
if frameN > randColor + 2:
        dots_blue_2.setColor([240,1,1])

where randColor is a random frame number and dots_blue_2 is the name of the dot stimulus. In the dot stimulus element the color is set at [240,1,1] in HSV space as constant.