Using BonVision to randomly display images and videos

375 views
Skip to first unread message

rmojica

unread,
Jul 26, 2021, 1:21:23 PM7/26/21
to Bonsai Users

Hi all,

I'm trying to make a single script to iterate through different videos, and randomly display a gray screen. I've setup a PythonSource to randomly choose a number within a range, and feed that number to either DrawVideo or DrawImage. However, once PythonSource runs once, my Repeat node seems to only repeat the DrawVideo or DrawImage instead of the entire sequence, so that only one same video plays over and over again.

I experimented with using CreateObservable for displaying my stimuli, but they wouldn't display at all. I also tried using Merge to join both branches after drawing the stimulus, and then connecting that node to Repeat, but that wouldn't work either. Lastly, I created a BehaviorSubject for my random number sampling, but adding a Repeat node to it made it so that every single time a number was sampled, the sequence would repeat indefinitely, multiple times per second.

Am I missing some built-in simpler way of presenting images and videos in the same workflow?
Screenshot 2021-07-26 131534.png
video_image_presentation.bonsai

Gonçalo Lopes

unread,
Aug 22, 2021, 8:15:50 PM8/22/21
to rmojica, Bonsai Users
Hi rmojica and welcome to the forums,

From looking at your workflow it seems you are trying to repeat the drawing of the video and texture, but the problem is that this will never happen because the RenderFrame source never ends. You need a sequence that ends for Repeat to work.

Of course, what decides that a presentation has ended is very subjective. I've attached a modification of your workflow that should stop all stimuli within 2 seconds and then repeat everything again. I haven't had the chance to test this as some fails were missing from your original project (mainly texture and video files), but hopefully it should give you some functional insights.

Hope this helps.

--
You received this message because you are subscribed to the Google Groups "Bonsai Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/efaa768f-1b74-4cf1-9bb6-68ff37910b39n%40googlegroups.com.
video_image_presentation_v2.bonsai
Reply all
Reply to author
Forward
0 new messages