# Defining stimuli inside range replicators

**URL:** <https://mworks.discourse.group/t/defining-stimuli-inside-range-replicators/868>\
**Category:** Support\
**Created:** [January 23, 2023, 4:07pm UTC](https://mworks.discourse.group/t/defining-stimuli-inside-range-replicators/868 "2023-01-23T16:07:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yoon\_Bai](https://avatars.discourse-cdn.com/v4/letter/y/9fc348/32.png) [@Yoon\_Bai](https://mworks.discourse.group/u/Yoon_Bai)\
**Post date:** [January 23, 2023, 4:07pm UTC](https://mworks.discourse.group/t/defining-stimuli-inside-range-replicators/868/1 "2023-01-23T16:07:03Z")

</div>

Hi Chris,

I am trying to assign locations to a stimulus inside nested range replicators. For example, in the RSVP example, let’s say I am flashing 5 images in a single trial. I would like to place the 5 images at separate locations. Here is a block of pseudo code to explain my question better. I understand range replicators can’t assign local variables (location\_x, location\_y) to a rectangle property. Ultimately, I need to calculate the rotation variable based on the x,y location as well. I can’t figure out a workaround and hope you could help me.

Thanks,  
Yoon

```auto
stimulus_group my_stimuli {
    range_replicator (
        variable = location_x
        from = -area_sampled
        to = area_sampled
        step = 2
        ) {
        range_replicator (
        variable = location_y
        from = -area_sampled
        to = area_sampled
        step = 2
        ) {
            rectangle bar_stimulus (
                color = 1,1,1
                x_size = 3
                y_size = 0.2
                x_position = location_x
                y_position = location_y
                rotation = theta //needs to be calculated based on location
                )
        }
    }
}

```

---

<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:** [January 23, 2023, 10:14pm UTC](https://mworks.discourse.group/t/defining-stimuli-inside-range-replicators/868/2 "2023-01-23T22:14:57Z")

</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:** [January 23, 2023, 10:43pm UTC](https://mworks.discourse.group/t/defining-stimuli-inside-range-replicators/868/3 "2023-01-23T22:43:32Z")

</div>

Hi Yoon,

Please see the attached example. It uses a single, non-nested range replicator to define the stimuli. The location and rotation of each stimulus is taken from a list-valued variable. This lets you compute and assign the rotation of each stimulus inside your protocol. You could also re-assign the locations, if you wanted.

Cheers,  
Chris  
[nested\_range\_reps.mwel.zip](https://mworks.discourse.group/uploads/short-url/qdxAYY91485JREyNT2O0CEvLaRu.zip) (952 Bytes)

---

<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:** [January 23, 2023, 10:44pm UTC](https://mworks.discourse.group/t/defining-stimuli-inside-range-replicators/868/4 "2023-01-23T22:44:02Z")

</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:** [January 23, 2023, 10:58pm UTC](https://mworks.discourse.group/t/defining-stimuli-inside-range-replicators/868/5 "2023-01-23T22:58:30Z")

</div>

Sorry, I should have changed the name of that example, since it doesn’t use nested replicators.

---

<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:** [January 30, 2023, 2:00pm UTC](https://mworks.discourse.group/t/defining-stimuli-inside-range-replicators/868/6 "2023-01-30T14:00:33Z")

</div>


