# Saccade-like trials in mworks

**URL:** <https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034>\
**Category:** Support\
**Created:** [September 9, 2024, 11:22pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034 "2024-09-09T23:22:54Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![ggaziv](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@ggaziv](https://mworks.discourse.group/u/ggaziv)\
**Post date:** [September 9, 2024, 11:22pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/1 "2024-09-09T23:22:54Z")

</div>

Hi Chris,

We’re considering running a modified version of our RSVP experiment, where each trial simulates a saccade-like scan of a “big” image.  
Each trial will consist of a sequence of crops (K = 6-8) from an image, presented without masks within a trial (200ms “on” per image, ~2-5sec per trial).  
The idea is that the user just hands over these N crops as the RSVP stimuli: 1…N where N = K \* n, n being the total number of “big” images, and every subset of images, [1 + (j - 1) \* K, 1 + j \* K]; j=1…n, defines a valid trial/sequence.

A) How should we revise our standard RSVP .mwel file to implement this experiment? (our current .mwel is attached)  
B) There is also another version of the above experiment, where the “saccades” appear in different orders. Specifically, we would allow for pemurations within a defined sequence across repeated presentations (but sequences should not mix).

Lastly, for this experiment, an entire trial should be invalidated if not fully completed (even if a part of the trial was successfully fixated on).

Many thanks in advance!  
Guy

> **(attachments)**
>
> [d1\_v80.mwel](https://mworks.discourse.group/uploads/short-url/xjP0WE5f6OxdFHrTi3BEpqOEhSh.mwel) (25 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:** [September 11, 2024, 12:03pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/2 "2024-09-11T12:03:54Z")

</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:** [September 11, 2024, 12:03pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/3 "2024-09-11T12:03:54Z")

</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:** [September 11, 2024, 12:04pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/4 "2024-09-11T12:04:21Z")

</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:** [September 11, 2024, 12:24pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/5 "2024-09-11T12:24:36Z")

</div>

Hi Guy & Ani,

If I understood correctly,

1. each set of crops of a particular image constitutes a trial,
2. the order of the crops within a trial should be variable, and
3. the trial is a failure if the monkey breaks fixation at any time.

Is that right? If so, then I have a few questions/comments:

- How will the order of the crops in a trial be determined? Is it random, or will you draw from a set of predetermined sequences?

- Rather than creating separate image files for each crop, you could use just the “big” image and “crop” at runtime using [masks](https://mworks.github.io/documentation/latest/components/mask_stimulus.html) (or even just four [rectangles](https://mworks.github.io/documentation/latest/components/rectangle_stimulus.html)). That would give you the option of varying the content of each crop, if you wanted. Just something to consider.

Thanks,  
Chris

---

<div class="post-metadata">

**Author:** ![ggaziv](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@ggaziv](https://mworks.discourse.group/u/ggaziv)\
**Post date:** [September 11, 2024, 4:36pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/6 "2024-09-11T16:36:18Z")

</div>

Yes!

- We would ideally like to have both configurations available: Random order and fixed (predetermined). But definitely the more important one is the predetermined sequence.
- Interesting option but we would ideally have the crops controlled and determined on the user’s end.

---

<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:** [September 12, 2024, 2:55pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/7 "2024-09-12T14:55:09Z")

</div>

Ok, thanks. I will put together an example of how this could work and send it to you.

Chris

---

<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:** [September 16, 2024, 3:15pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/8 "2024-09-16T15:15:22Z")

</div>

Hi Guy & Ani,

I’ve attached an example that demonstrates a possible way to implement this experiment. Here are the key points:

- Each image file is named with two indices (e.g. `img_3_5.png`). The first index identifies the “big” image, and the second index gives the crop number. (An alternate approach would be to have a separate directory for each “big” image.)

- The selection variable (`image_selection`) selects a “big” image.

- The set of crops for each “big” image is loaded at the beginning of the trial and unloaded at the end.

- If fixation is broken at any point during the trial, the whole “big” image is rejected and will be selected again in a later trial.

- At present, the crop order is sequential. If you wanted to switch to random order, you could add another selection variable (e.g. `crop_selection`) to determine the crop order.

If you have any questions, please let me know.

Cheers,  
Chris  
[simulated\_saccade.zip](https://mworks.discourse.group/uploads/short-url/cC1KvkunuSReyy25g03SbqKenyc.zip) (94.0 KB)

---

<div class="post-metadata">

**Author:** ![ggaziv](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@ggaziv](https://mworks.discourse.group/u/ggaziv)\
**Post date:** [September 16, 2024, 6:17pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/9 "2024-09-16T18:17:43Z")

</div>

Perfect! Thank you so much, Chris.  
To clarify, is this tested and ready to go as is as a substitute for the RSVP example previously sent (up to hyperparameters ofc)? What about `stimulus_presented` and those other guys relied on during preprocessing?  
We are going to be tight in monkey time for this experiment so just trying to minimize the room for errors in execution.

Thanks again.  
Guy

---

<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:** [September 16, 2024, 6:35pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/10 "2024-09-16T18:35:48Z")

</div>

> To clarify, is this tested and ready to go as is as a substitute for the RSVP example previously sent (up to hyperparameters ofc)?

No, it’s just a demonstration of how things might work. You will need to adapt the methods it uses to your actual experiment.

Writing full-fledged experiment code is not a service I provide (either for the DiCarlo Lab or anyone else).

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![ggaziv](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@ggaziv](https://mworks.discourse.group/u/ggaziv)\
**Post date:** [September 16, 2024, 6:53pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/11 "2024-09-16T18:53:25Z")

</div>

Got it, thanks!  
Will be in touch if running into difficulty.

---

<div class="post-metadata">

**Author:** ![ggaziv](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@ggaziv](https://mworks.discourse.group/u/ggaziv)\
**Post date:** [September 18, 2024, 2:44am UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/12 "2024-09-18T02:44:12Z")

</div>

If I were to unroll my image crops to a single index 1…n, would the following modification do the trick?

```auto
stimulus_group crops {
    range_replicator (
        variable = rr_index
        from = 1
        to = crops_per_image
        step = 1
        ) {
        image_file im_${rr_index} (
            // path = 'images/img_${current_image}/crop_${rr_index}.PNG'
            path = 'images/img$((current_image * crops_per_image + rr_index)).PNG'
            x_size = stimulus_size
            x_position = stimulus_pos_x
            y_position = stimulus_pos_y
            deferred = explicit
            announce_load = false
            )
    }
}

selection image_selection (
    // values = 1 : image_set_size
    values = 0 : image_set_size - 1
    selection = random_without_replacement
    advance_on_accept = true
    )

```

---

<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:** [September 18, 2024, 12:17pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/13 "2024-09-18T12:17:00Z")

</div>

Almost. You need to put a `$` in front of `rr_index` (one of the quirks of [replicators](https://mworks.github.io/documentation/latest/guide/designing.html#replicators)):

```
path = 'images/img$(current_image * crops_per_image + $rr_index).PNG'

```

And you need to change `crops_per_image` from a [macro](https://mworks.github.io/documentation/latest/mwel/index.html#expression) to a variable:

```
var crops_per_image = 6

```

Then it should work.

Chris

---

<div class="post-metadata">

**Author:** ![ggaziv](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@ggaziv](https://mworks.discourse.group/u/ggaziv)\
**Post date:** [September 18, 2024, 3:41pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/14 "2024-09-18T15:41:05Z")

</div>

Thanks! Hmmm do we understand this error then?

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/mworks/original/1X/35618a46449f6802f19f26ace180fe7da0d544c8.jpeg)

---

<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:** [September 18, 2024, 4:15pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/15 "2024-09-18T16:15:14Z")

</div>

You need to declare the “images” directory as a [resource](https://mworks.github.io/documentation/latest/components/resources.html), like my example does. You’ll need to do the same for the sounds directory (and any other resource files that your experiment needs).

Somewhere in your MWEL file, add the following lines:

```auto
resource ('images')
resource ('/Library/Application Support/MWorks/Examples/RSVPDemo/sounds')

```

Chris

---

<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:** [September 18, 2024, 5:39pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/16 "2024-09-18T17:39:09Z")

</div>

Regarding the “There are no more items left to draw” error:

My example set the selection variable’s [advance\_on\_accept](https://mworks.github.io/documentation/latest/components/selection_variable.html#advance-on-accept) parameter to true, so that it didn’t have to invoke [next\_selection](https://mworks.github.io/documentation/latest/components/next_selection.html#next-selection). Since your experiment already uses `next_selection`, just remove that parameter from the definition of `image_selection`:

```auto
selection image_selection (
    values = 0 : image_set_size - 1
    selection = random_without_replacement
    )

```

That should fix the problem.

Chris

---

<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 28, 2024, 4:25pm UTC](https://mworks.discourse.group/t/saccade-like-trials-in-mworks/1034/17 "2024-10-28T16:25:47Z")

</div>


