# Noise stimulus

**URL:** <https://mworks.discourse.group/t/noise-stimulus/1019>\
**Category:** Support\
**Created:** [August 12, 2024, 9:24pm UTC](https://mworks.discourse.group/t/noise-stimulus/1019 "2024-08-12T21:24:39Z")\
**Posts on this page:** 10\
**Page:** 2

<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:** [October 17, 2024, 9:34pm UTC](https://mworks.discourse.group/t/noise-stimulus/1019/23 "2024-10-17T21:34:14Z")

</div>

Hi Lindsey,

The error message shows that MWorks is looking in the right place for the image file. Did you run the “Generate noise” protocol to create the noise images?

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:** [October 17, 2024, 9:46pm UTC](https://mworks.discourse.group/t/noise-stimulus/1019/24 "2024-10-17T21:46:37Z")

</div>

Yes- I used the same protocol to generate the noise images- the path for those images is set in the noise\_stimulus.py file. I had included a screenshot of that in the previous email.  
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:** [October 17, 2024, 10:03pm UTC](https://mworks.discourse.group/t/noise-stimulus/1019/25 "2024-10-17T22:03:42Z")

</div>

Can you send me the MWEL and Python files you’re using?

---

<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:** [October 18, 2024, 4:36pm UTC](https://mworks.discourse.group/t/noise-stimulus/1019/26 "2024-10-18T16:36:31Z")

</div>

Hi Chris,  
Here are the two files.  
I edited the .py file to add the fileName variable and targeted my folder structure. And I edited a bunch of stuff in the mwel, but the most relevant is that the presentation mode only starts once it has received inputs from our microscope (line 106)- so you will need to comment this to make it run.  
Lindsey.

> **(attachments)**
>
> [noise\_stimulus.mwel](https://mworks.discourse.group/uploads/short-url/qJ756S1L7osO4HNAMEtBMfJPnmk.mwel) (4.21 KB)  
> [noise\_stimulus.py](https://mworks.discourse.group/uploads/short-url/l1vRr1Ga6LnxV8FwdbX0fxW4MiV.py) (1.66 KB)

---

<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:** [October 18, 2024, 6:45pm UTC](https://mworks.discourse.group/t/noise-stimulus/1019/27 "2024-10-18T18:45:10Z")

</div>

Hi Lindsey,

The files you sent work correctly for me.

One thing that you may not have noticed is that every time the experiment is loaded, the Python code creates a new subdirectory using the current date and time (whose name is stored in the variable `sessiondir`) and writes/reads images to/from this subdirectory. So if you generate noise images, then close and re-load the experiment, it’s not going to find any of the images you just created.

If you want to pre-generate the images and use them during multiple sessions, you should remove this data/time subdirectory. The easiest way to do this is to define `sessiondir` to be `.`:

```auto
sessiondir = '.'

```

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:** [October 18, 2024, 7:01pm UTC](https://mworks.discourse.group/t/noise-stimulus/1019/28 "2024-10-18T19:01:50Z")

</div>

Ah- that is definitely my problem.  
I will try that.  
Thanks,  
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:** [October 21, 2024, 1:48pm UTC](https://mworks.discourse.group/t/noise-stimulus/1019/29 "2024-10-21T13:48:36Z")

</div>

Hi Chris,  
That was the issue- I can now replay the movies in a new MWorks session.  
However, when presenting this way, it will only present as many frames as are hard-coded by the stimulus duration in the mwel. Is there any way around this, or do I need to edit the mwel according to the duration of the movie that I want?  
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:** [October 21, 2024, 2:41pm UTC](https://mworks.discourse.group/t/noise-stimulus/1019/30 "2024-10-21T14:41:56Z")

</div>

Hi Lindsey,

Because the variable `noise_frames_per_trial` is used in a range replicator, its value has to be known at load time. If you want to change the movie duration at run time, you could hard code the _maximum_ number of frames per trial in the replicator, and then set the actual number of frames per trial to a smaller value. For example:

```
range_replicator (
    variable = rr_index
    from = 1
    to = 72000 // Max 20 minutes @ 60Hz
    step = 1
    ...

var noise_frames_per_trial = 36000 // 10 minutes @ 60Hz

```

Does that make sense?

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:** [October 21, 2024, 2:57pm UTC](https://mworks.discourse.group/t/noise-stimulus/1019/31 "2024-10-21T14:57:43Z")

</div>

Yes. 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 1, 2025, 1:46pm UTC](https://mworks.discourse.group/t/noise-stimulus/1019/32 "2025-05-01T13:46:22Z")

</div>



[Previous page](https://mworks.discourse.group/t/noise-stimulus/1019.md?page=1)
