Adding tint to images

OS: Windows11
PsychoPy version: 2026.1.3
Standard Standalone Installation? Y
Do you want it to also run online? N
What are you trying to achieve?:

I have 72 images of faces that I’m using for stimuli. Does PsychoPy have the capability to randomly place a color wash over the image (i.e., blue, red, or green)?

I’ve exclusively been using excel sheets and PsychoPy Builder, so I haven’t learned Python code. Any suggestions on how I could apply these manipulations to the image, either in PsychoPy Builder or with Python code? Thank you!

What I would do in this circumstance is add a coloured polygon component with low opacity (try 0.1) in front of the image. Try it with a fixed colour to check you’re happy with the result and then a small amount of code in a code component could be used to randomise the colour. If unbalanced is fine then you could have the following.

Begin Experiment

colourWash = ['blue', 'red', 'green']

Begin Routine

shuffle(colourWash)
thisExp.addData('colourWash',colourWash[0])

Then use $colourWash[0] set each repeat as the polygon fill colour.

Thank you immensely for this response and your other response ( Trial Randomization + Inter-block Break - - #2 by wakecarter ). Your instructions worked perfectly, and it’s wonderful to see the task running as envisioned.

I have one additional question - I would like the color of the first stimulus (the randomized color wash) to match the color of the second stimulus. There isn’t a break between the two.

There are two sequences this would apply to:

A: Face_image w randomized colorwash for 0.033s + mask_image w same color wash for 0.167

B: Face_image w randomized color wash for 0.2s → placeholder/blank grey screen (pulls a grey screen from the same mask_image column in my excel file) for 0.001s (fine if the color wash remains)

In other words, the randomized color should be selected once per trial and then used consistently for both the face and the mask in that trial.

That should just work so long as you only shuffle once per trial.

they are in two different routines within the trial loop, so the color wash applies to the face_image trial routine, but not the mask_routine

You appear to have stated that the colour mask should apply to the mask but also that it shouldn’t.

Add a tint polygon to the routines where you need the tint, or set the start as a condition if you sometimes want it and sometimes not.

Apologies, I meant that the tint should apply to both the face_image routine and mask_image routine, but that currently, the tint is only set to apply to the face_image routine.

I want the tint to be the same between the two routines, but it seems like that would require using a randomized polygon component during the face_image routine, and then for the mask_image routine to somehow pull whatever color was just presented to then present again.

I’m thinking a loop might be a way to solve this issue, could that be the case?

The polygon isn’t presenting a random colour, it’s presenting the first colour in a shuffled list. You choose when and how often to shuffle the list.