# Noise stimulus

**URL:** <https://mworks.discourse.group/t/noise-stimulus/1094>\
**Category:** Support\
**Created:** [May 15, 2025, 8:02pm UTC](https://mworks.discourse.group/t/noise-stimulus/1094 "2025-05-15T20:02:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![llglick](https://avatars.discourse-cdn.com/v4/letter/l/58956e/32.png) [@llglick](https://mworks.discourse.group/u/llglick)\
**Post date:** [May 15, 2025, 8:02pm UTC](https://mworks.discourse.group/t/noise-stimulus/1094/1 "2025-05-15T20:02:32Z")

</div>

Hi Chris,  
I have some questions about the white noise stimulus.  
First, in the [documentation](https://mworks.github.io/documentation/latest/components/white_noise_background.html), I don’t see any variables that control the size of the stimulus. I would like to make the stimulus smaller than the full screen. I realize that this is a “background” stimulus and so may not have this functionality. Would applying a mask be a reasonable solution? Would you add this at the “Present noise” or “Generate noise” stage?  
Second, I would like to add a brief stimulus that appears at the start of each frame to keep track of timing with our electrophysiology recordings. I am currently presenting frames at 10Hz. I would like a 50 ms stimulus to appear at the onset of each frame, so that the luminance is modulated and frames can be tagged. Is this something that I can add to the “Present noise” phase? It’s not obvious how since you just call the frame list once each trial.  
Thanks,  
Lindsey

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [May 16, 2025, 12:33pm UTC](https://mworks.discourse.group/t/noise-stimulus/1094/2 "2025-05-16T12:33:48Z")

</div>



---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [May 16, 2025, 12:37pm UTC](https://mworks.discourse.group/t/noise-stimulus/1094/3 "2025-05-16T12:37:35Z")

</div>



---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [May 16, 2025, 1:22pm UTC](https://mworks.discourse.group/t/noise-stimulus/1094/4 "2025-05-16T13:22:51Z")

</div>

Hi Lindsey,

> I don’t see any variables that control the size of the stimulus. I would like to make the stimulus smaller than the full screen. I realize that this is a “background” stimulus and so may not have this functionality. Would applying a mask be a reasonable solution? Would you add this at the “Present noise” or “Generate noise” stage?

You’re correct that the stimulus is designed to always fill the background, so it doesn’t have size parameters.

A mask would be one way to control the size of the stimulus. You could use it either when generating the noise or presenting the noise. However, if you use it during generation, the position of the noise will be fixed in the captured images. The more flexible approach would be to use it during presentation. To do this, you would add a [layer](https://mworks.github.io/documentation/latest/components/layer_stimulus.html) on top of the fullscreen noise. The layer would contain two stimuli: a [blank screen](https://mworks.github.io/documentation/latest/components/blank_fullscreen_stimulus.html) for the desired background color, and an inverted [mask](https://mworks.github.io/documentation/latest/components/mask_stimulus.html) that determines the shape and position of the visible noise.

Alternatively, you could control the size of the noise by adding size parameters to (and removing the “fullscreen” parameter from) the [image file](https://mworks.github.io/documentation/latest/components/image_stimulus.html) stimuli you use to present the noise frames. The only potential issue there is that you might need to present the images at their original aspect ratio (i.e. the aspect ratio of the display). Otherwise, the noise could look distorted. That said, I just tried it, and it looks OK to my eyes, so maybe this isn’t a valid concern.

> I would like to add a brief stimulus that appears at the start of each frame to keep track of timing with our electrophysiology recordings. I am currently presenting frames at 10Hz. I would like a 50 ms stimulus to appear at the onset of each frame, so that the luminance is modulated and frames can be tagged. Is this something that I can add to the “Present noise” phase? It’s not obvious how since you just call the frame list once each trial.

Do you want the 50ms stimulus to be drawn on top of the noise frame (meaning it would be visible for half the presentation time of each noise frame)? Or do you want it to appear before the noise frame?

If you want it on top of the noise, you should be able to do it by adding another movie stimulus. The movie would run at 20 frames per second and be configured to [loop](https://mworks.github.io/documentation/latest/components/movie_stimulus.html#loop). It would contain two stimuli: the 50ms stimulus, and a blank stimulus (e.g. a rectangle with alpha set to zero) to fill the other 50ms of the noise frame. As long as you queue it at the same time as the noise movie and set its [autoplay](https://mworks.github.io/documentation/latest/components/movie_stimulus.html#autoplay) parameter to true, it will stay in sync with the noise movie.

If you want the 50ms stimulus to display before the noise, you could probably also do that with an additional movie, but you’ll need more blank stimuli to fill out the interval where the noise is displayed.

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![llglick](https://avatars.discourse-cdn.com/v4/letter/l/58956e/32.png) [@llglick](https://mworks.discourse.group/u/llglick)\
**Post date:** [May 16, 2025, 1:42pm UTC](https://mworks.discourse.group/t/noise-stimulus/1094/5 "2025-05-16T13:42:18Z")

</div>

Hi Chris,  
Thanks- this is super helpful! I’ll try these out and let you know how it goes.  
Lindsey.

---

<div class="post-metadata">

**Author:** ![llglick](https://avatars.discourse-cdn.com/v4/letter/l/58956e/32.png) [@llglick](https://mworks.discourse.group/u/llglick)\
**Post date:** [May 16, 2025, 7:05pm UTC](https://mworks.discourse.group/t/noise-stimulus/1094/6 "2025-05-16T19:05:03Z")

</div>

Hi Chris,  
The mask works beautifully and I modified the “generate noise” protocol to create my two frames for the 20 Hz movie.  
It’s in the same directory as the noise movie frames, but a different folder. Given the pointer system (where thepath for the range replicator is just “images/”) what is the best way to make this second movie? Is the simplest thing to just copy the two frames into each noise stimulus movie folder and rename them as 3001.png and 3002.png (to follow the 3000 noise images) and then set the range replicator to grab those two frames? Or is there a different approach you’d recommend?  
Lindsey.

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [May 19, 2025, 2:59pm UTC](https://mworks.discourse.group/t/noise-stimulus/1094/7 "2025-05-19T14:59:12Z")

</div>

Hi Lindsey,

Is there a need to pre-generate the frames for the 20Hz movie? The frames of a [movie stimulus](https://mworks.github.io/documentation/latest/components/movie_stimulus.html) can be of any stimulus type (not just `image_file`). I was imagining you would just let MWorks render the frames at run time, in the usual way.

If you do need to pre-generate them, you could copy the frames to the “images” folder as you suggest. You could also put them in a subdirectory of the “images” folder. Then, when defining the stimuli for the 20Hz movie, the `path` attribute would use that subdirectory, e.g.

```auto
image_file onset_stim_frame_${rr_index} (
    path = 'images/onset_stim/frame_${rr_index}.png'
    ...

```

Chris

---

<div class="post-metadata">

**Author:** ![llglick](https://avatars.discourse-cdn.com/v4/letter/l/58956e/32.png) [@llglick](https://mworks.discourse.group/u/llglick)\
**Post date:** [May 19, 2025, 5:37pm UTC](https://mworks.discourse.group/t/noise-stimulus/1094/8 "2025-05-19T17:37:39Z")

</div>

Oh- I didn’t know you could make a movie from a stimulus. I thought it had to be loaded from an image. Thanks!  
Lindsey.

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [August 5, 2025, 2:33pm UTC](https://mworks.discourse.group/t/noise-stimulus/1094/9 "2025-08-05T14:33:56Z")

</div>


