restarting branch of workflow

117 views
Skip to first unread message

l.mue...@gmail.com

unread,
Dec 17, 2021, 10:50:17 AM12/17/21
to Bonsai Users
Hi all,

I am running an experiment where rats have to retrieve a couple of rewards from several goal locations in an open field and then return to a start box where they will stay for a coupel of seconds and then can retrieve more rewards from the goa locations etc...

I am tracking the position of the animal and I would like to plot a dot on the video feed where the goals are. Importantly, I want the dot to change colour (e.g. from red to green) when the animal retrieved a reward and then reset the colour when the animal is back in the start box. The idea is that the experimenter can see on the video feed when the animal collected all rewards.

So far I have managed to plot the dots on the video feed and make them change colour once the animal collects the reward, but I am struggling to implement the resetting part.
My approach is to generate a Boolean/frame ('StartBox') to indicate whether the animal is outside of start box or not. When the animal spends a certain time at a reward location (>3 seconds) I trigger the colour change for the respective dot (importantly only the first time as the animal might revisist a reward location several times). When the animal goes back into the start box I would like to restart all the branches that detect the reward location visits.

I hope this makes sense. Any help/pointers is much appreciated. Thanks a lot.

Cheers

Laurenz
test.bonsai

Gonçalo Lopes

unread,
Dec 29, 2021, 9:25:02 PM12/29/21
to l.mue...@gmail.com, Bonsai Users
Hi Laurenz,

Why not do this inside the Python script? It looks like you have the state of the start box also going in there if I understand the workflow correctly.

If you need to keep state between calls to the script, you can declare global variables as you would in a python file, just remember to declare them as global inside the function so you can write to them.

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/3aa18448-9d3a-467d-884b-352db7d8fe00n%40googlegroups.com.

l.mue...@gmail.com

unread,
Jan 2, 2022, 7:03:12 PM1/2/22
to Bonsai Users
Hi Goncalo,

Thanks for your response. That's a good point, I hadn't thought about that. I guess that would have been the easier solution. In the meantime I had read through Bruno's response in this thread. I found that very helpful and only after reading his reply and looking at the workflow he added, I finally understood how the SelectMany node works. So I managed to implement the whole thing in Bonsai, by moving all the plotting logic into a SelectMany node and using TakeUntil to trigger the restart of that branch (basically as Bruno suggests in his response in the other post).

Cheers

Laurenz 
Reply all
Reply to author
Forward
0 new messages