| Reference | Downloads | Github

Variable is not passed onto grating texture

HI, this is a simple masked grating orientation discrimination task…
to create a mask I define a noiseTexture using Scipy, ie.
noiseTexture = scipy.random.rand(128,128)*2.0-1

and then I pass this onto the Texture parameter of the grating object I use to create the mask
however I get a NameError: name ‘noiseTexture’ is not defined

This seems weird - I have a similar version of this in version 1.92 and works fine but now I’ve nowgabor.psyexp (22.8 KB) programmed it from scratch in Psychopy3 installed with conda.

The code is attached and I would appreciate any help with this-


Hi, PsychoPy is first initializing all components before using them in the experiment. In line 124, it initializes “maskgrating” with tex = noiseTexture. But noiseTexture is only set later, when the routine “present_gabor” is started. You can avoid this by defining noiseTexture not only in the “beginRoutine” sheed of the code component but also in the “beginExperiment” sheed. That way, PsychoPy will have the texture ready to initialize the components at the beginning and update the texture as it goes though the trials. I hope you understand what I mean!

hi, great explanation, thanks a lot!