| Reference | Downloads | Github

Builder new "Noise" Component

Mac OSX10.14; PsychoPy 3.02; stand alone, builder question

With a code component, I was trying to create a random gray checkerboard (uniform from -.7 to .7) with squares ~16pix by ~16pix with an np.array and blur it with something like Masks=ndimage.gaussian_filter(myImage, 15). I was trying to present with a grating component because I want to put it in a gaussian mask, but I couldn’t get it to work. Then wonder of wonders (bless you all) I discovered the new NOISE component in builder.:sunglasses:
But I am having trouble with a few things with the new noise component. The measurement unit is in deg (but I could change that). I want a 4 x 4 deg noise (can do), with squares of a certain approximate size (got it: noise element size), put it in a gaussian mask (got it). Here are my problems. (1) When I ask from a random uniform distribution, I get the same random uniform distribution repeated across the screen 16 times (4x4; tessellated). (2) The only way I can see to blur it is in the Noise tab, select filtered. But then I do not know what the underlying random selection of gray levels (gaussian, uniform, etc.). (3) I am not sure what I am doing in the filtered tab. I want low frequencies, so I set low frequency cut off 0, but should it be 1? If I set low cut off to 1 and high cut off to 2, does that mean I get freq. between 1 and 2 cycles per degree.
My first problem is the Tessellation problem (1 above). I couldn’t find any documentation. I realize Builder documentation might not exist yet. I could probably figure some of it out with the coder documentation, but I couldn’t find that either.
I think that its absolutely great that you came up with the new coder type, just when I needed it.

Hi, You might have worked this out for yourself by now (I don’t visit this forum very often). But maybe you havent or others will look at this for help. There is documentation for the coder version with some notes on things to watch out for here.

  1. Tessellation: the noise component generates a texture a bit like the image compoment. The overall frequency of this component is indepdendent of the other parameters and is determined by the Final spatial frequency setting in the advanced tab. Unfortuately (following ImageStim) the default is one reapeat of the texture per unit (so if units is degrees and size is 4 you get a 4x4 tessallation). Setting the final frequency to 1/size (in your case 1/4) fixes this. I have in mind to change the default in a future update as I would be the first to agree that this setting is unhelpful.

  2. Filtering noise: The Noise component is design to generate different types of noise but not to mix them. So filtered noise does not use the uderlying setting of ‘binary’, ‘uniform’ etc. The 4 left most tabs work indepedently of one another with the one that takes effect determined by the tyoe of noise selected. So when you filter your are not filtering a smaple of noise made by (say) the binary noise generator. Rather you are filtering a white noise sample. This is a close approximation to a gaussian luminance distribution of pixel values with one sample per texture pixel.

  3. The filters tab (mostly*) applies a band-pass Butterworth filter to a white noise sample. Order = 0 applie snot filter at all. Order 1 is a 1st order Butterworth (etc). The upper and lower cutoffs determine the pass band. If you set the lower cutoff to zero no lower cut off is applied. The filter becomes a low pass filter with only an upper cut off frequency. These refrequencies are in the stimulus units.

The mostly above refers to the Skew term. This lets you skew the shape of the noise spectrum to something other than white. It can be used with or without the Butterworth filter having any effect.

It would be possible, in theory, to apply the filter of the filtered noise option to the noise samples generated by the other options (perhaps via a tick box) and its something that might be added at a later date. The code for the filtering is available as a sparate module in coder is anyone wants to do it themselves.

Thank you. We had figured out some of it, but I still have only a few questions left. Like with (frequency filtering), what are the units? Pixels/cycle or what. Does that depend on the units selected in the Basic tab, or is it always the same. If I chose deg as my units in Basic, are the cutoffs in cycles/degree? (given the filter order).

To help me navigate the builder noise component, I copied out the instructions verbatim one gets when you hover your cursor over a field. Some places I added questions or comments. These I annotated with my initials (BP: blah, blah). I am going to attach that, it help me that I could see all the field hints (annotations) at once.

I think my last question is units of cutoff, as I asked above.

I don’t know if my attachment will come through just responding in (Apples) mail program or if I have to attach it in the Forum web page, but I will check later.

Thank you very much for your comments.

(Attachment AllTabs.pdf is missing)

Here I hope is my missing attachment

This is playing as a very fast movie. Can you send the frames separately?

Hi, The units for the filter follow those for the stimulus. So if the stimulus is in Deg the filter cuts off are cycles per degree. The filter order does not change this.

I did my annotation in acrobat, but this forum does not accept pdf files. I spend a few hours trying to get it into a format that would work. I give up. I am so sorry but here are 5 files (.png), one per tab (I skipped the image tab. So sorry, if it was in .pdf you could edit it, but I do not know how to send it. Quality was lost. I hope this is helpful. Andrew your comments were extremely helpful

Dear Bill
Thanks for posting this. To confirm all units are the same as the units for the stimulus as a whole and frequencies are in cycles / unit. e.g if units are deg then cutoff frequencies etc will be clycles / deg; if units cm, clycles /cm. The exception to this is the Final spatial frequency term which is the number of times the texture as a whole repeats per unit size.

The element size for binary, uniform and Gaussian distributed noise samples is in the stimulus units. These should result in an even number of noise samples in each direction - a crash error occurs otherise. If the resulting side length is not a power of 2 PsychoPy posts a red error message but will still produce an image. This error message does not come from the noiseStim component.

You comment on the skew, slope or exponent term for fitered noise. White noise ((exponent = 0) is comonly used. 1/f noise (pink noise, exponenemt -1) is also quite common. The comment “this looks nice” refers to the fact that this type of noise is visualy appealing. Having a spectrum close to natural images whis type of noise looks like clouds.

I will clarify the units etc in a future release; thanks for pointing out the uncertainties.

Best wishes