Stop Image Component from autodrawing

PsychoPy version

Standard Standalone?

What are you trying to achieve?:
I have three image components in a trial routine inside of a loop, which get images from different files. For some trials, I only want two of the image components to be drawn, while the third one should not be drawn.

What did you try to make it work?:
I added a code snippet and in the ‘Begin Routine’ tab, I added:

if my_condition:

What specifically went wrong when you tried that?:
The component is still being drawn. I can see in the generated code that the Builder adds this bit, after the section where the ‘Begin Routine’ code is run:

if myImageComponent.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
    # [...]

So the Builder’s automatically generated code overrides what I want to do.

Possible not-great solutions
I could skip adding the image Component using the Builder entirely, and instead create it “manually” in the ‘Begin Experiment’ tab. But the experiment is already fairly complicated so if possible I want to avoid this additional code, to increase readability for colleagues who are less knowledgeable in Python.

I could also have a completely blank (same color as background) image file that I would use for trials where the image should be invisible, but that seems pretty convoluted.

So, does anyone know a clean method for temporarily “hiding”/disabling image components? :slight_smile: I feel like I’m missing something basic.

Maybe you have already tried this, but would it help to set the opacity of the image temporarily to 0 (in the each frame tab or wherever), thus making it “invisible” even if it is still being drawn by PsychoPy?

Brilliant idea, I was needlessly complicating things. Works great, thanks :slight_smile:

1 Like