# Follow-up Mworks Code Question

**URL:** <https://mworks.discourse.group/t/follow-up-mworks-code-question/905>\
**Category:** Support\
**Created:** [August 9, 2023, 12:30am UTC](https://mworks.discourse.group/t/follow-up-mworks-code-question/905 "2023-08-09T00:30:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgouldin](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sgouldin](https://mworks.discourse.group/u/sgouldin)\
**Post date:** [August 9, 2023, 12:30am UTC](https://mworks.discourse.group/t/follow-up-mworks-code-question/905/1 "2023-08-09T00:30:40Z")

</div>

Hi Chris,

I really appreciate all of your help on my last experiment question (images presented at different durations). Everything seemed to be working well when I tested it without a monkey (showed each image at three different durations randomly). However, when I ran it with the animal today it seemed to exit before all of the stimuli had been presented (ended at 1930 stimuli shown when there should be 2400). I ran it again with the animal and it ended at a different number, ~2100 stimuli shown. Adding up the number of successful, failure and ignore trials gave me 2499.

I assume I have something wrong in my state code where the animal is failing a trial in a way where it doesn’t count as ‘stimuli shown’, but does accept the stimuli in the block. But working with some other co-workers we were unable to figure out exactly what is wrong.

Would I be able to send you code, or a snippet of code and see if you notice anything immediately?

Thank you,  
Sarah

---

<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 9, 2023, 11:40am UTC](https://mworks.discourse.group/t/follow-up-mworks-code-question/905/2 "2023-08-09T11:40:44Z")

</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:** [August 9, 2023, 11:47am UTC](https://mworks.discourse.group/t/follow-up-mworks-code-question/905/3 "2023-08-09T11:47:18Z")

</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:** [August 9, 2023, 11:47am UTC](https://mworks.discourse.group/t/follow-up-mworks-code-question/905/4 "2023-08-09T11:47:49Z")

</div>

Hi Sarah,

Sure. Send me the code, and I’ll take a look.

Thanks,  
Chris

---

<div class="post-metadata">

**Author:** ![sgouldin](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sgouldin](https://mworks.discourse.group/u/sgouldin)\
**Post date:** [August 9, 2023, 6:11pm UTC](https://mworks.discourse.group/t/follow-up-mworks-code-question/905/5 "2023-08-09T18:11:10Z")

</div>

Hi Chris,

Sorry I think the attachments were too large in my initial email so I will attach just the code and not the images. Thank you so much! Again, I assume the monkey is getting into a failure state where stimulus presented isn’t incrementing, but it is accepted in stimulus block.

Sarah

[mayo\_day\_1.mwel](https://mworks.discourse.group/uploads/short-url/vQtyt4kw4HH9uORe3nMiGG3pOF.mwel) (26.2 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:** [August 10, 2023, 2:37pm UTC](https://mworks.discourse.group/t/follow-up-mworks-code-question/905/6 "2023-08-10T14:37:51Z")

</div>

Hi Sarah,

I think the issue is that if “RSVP wait” transitions to “RSVP failure”, reject\_selections is never called.

Because the “selectable object” in question is the block, a selection is made any time the block begins executing. If you don’t explicitly reject the selection in a failed trial, it remains in a “pending” state until accept\_selections or reject\_selections is called in a subsequent trial, at which point it will be accepted or rejected along with the current selection. If it’s accepted, then it’s “lost”, and you end up presenting fewer stimuli than you intended.

Since all routes through the experiment pass through one of “RSVP success”, “RSVP failure”, or “RSVP ignore”, I suggest doing all accepting/rejecting of selections in those states and nowhere else. Hopefully that will resolve the issue, but if not, please let me know!

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![sgouldin](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sgouldin](https://mworks.discourse.group/u/sgouldin)\
**Post date:** [August 10, 2023, 4:10pm UTC](https://mworks.discourse.group/t/follow-up-mworks-code-question/905/7 "2023-08-10T16:10:51Z")

</div>

Hi Chris,

Thank you so much! I will try to test run the animal this afternoon and see if I run into any problems. But that makes a lot of sense thank you!!

Sarah

---

<div class="post-metadata">

**Author:** ![sgouldin](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sgouldin](https://mworks.discourse.group/u/sgouldin)\
**Post date:** [August 15, 2023, 10:50pm UTC](https://mworks.discourse.group/t/follow-up-mworks-code-question/905/8 "2023-08-15T22:50:27Z")

</div>

It works!! Thank 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:** [August 28, 2023, 5:52pm UTC](https://mworks.discourse.group/t/follow-up-mworks-code-question/905/9 "2023-08-28T17:52:40Z")

</div>


