Creating a round patch of gaussian noise

I would like to create a circular patch of gaussian noise similar to the attached images. Is there a way to do it using the NoiseStim object or other functions in order to avoid loading an external image.

@filippogambarota , in the Coder demos, you have the example, which needs a bit of modification to get what you want - e.g., see mask=“circle” param in GratingStim:

from psychopy import visual, event, core
import numpy

win = visual.Window([600, 600], allowGUI=False)

noiseTexture = numpy.random.rand(32, 32) * 2.0 - 1
patch = visual.GratingStim(win, tex=noiseTexture,
    size=(128, 128), units='pix',
    interpolate=False, autoLog=False, mask="circle")

while not event.getKeys():


Thank you very much!
Could you briefly explain the logic of the array generation? The documentation said that the tex= argument can be a number array ranging from -1 and 1. Are you rescaling values in order to present the full 255 grayscale range?

Yes its the PsychoPy default color scaling with -1 (black) to 1 (white) as a deviation from 0 (grey) - see docs:

The reason that these colors are expressed ranging between 1 and -1 (rather than 0:1 or 0:255) is that many experiments, particularly in visual science where PsychoPy has its roots, express colors as deviations from a grey screen. Under that scheme a value of -1 is the maximum decrement from grey and +1 is the maximum increment above grey.