Automatic loading of files into filecapture

333 views
Skip to first unread message

jarto...@gmail.com

unread,
Nov 17, 2017, 5:57:15 AM11/17/17
to Bonsai Users
Hello,

I'm trying to make bonsai load a video file into filecapture automatically after the previous video file ends. Is this possible somehow? I tried by externalizing the filename as a string node and connected it to a python source that returns string, but it only changes the file if I restart the workflow.

Felix

Gonçalo Lopes

unread,
Nov 19, 2017, 6:49:13 AM11/19/17
to jarto...@gmail.com, Bonsai Users
Hi Felix,

This is exactly the problem I use to explain how higher-order operators work in Bonsai, so I would be very happy to get your feedback on how that part of the documentation is written, and whether it helps you solve your situation:


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+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/bonsai-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/f9ea9498-7312-4f48-9302-d3bf952cf893%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jarto...@gmail.com

unread,
Nov 24, 2017, 9:45:23 AM11/24/17
to Bonsai Users
Thank you very much for the answer Goncalo, I followed the guide and it's working now. Sorry to bother you with these questions but I encountered two other problems.

1. I'm trying to implement a different color filter for every video that comes from EnumerateFiles. I'm doing this by externalizing the lower and upper threshold of the HsvThreshold node and connecting them to PythonTransform nodes which give them different values based on the filenames that come from EnumerateFiles, but it doesn't seem to adjust them correctly. Should I put the filters into a WindowWorkflow too?

2. In a different workflow I'm tracking the head of a mouse based on it's orientation, major axis length and the centroid. The problem is that the Source.Orientation node resets when it would turn past a specific point. Long story short the workflow is now tracking the two endpoints of the major axis of the LargestBinaryRegion and a separate node tracks when the "reset" happens and it gives back a single True boolean value when it resets. Is there a way to switch which endpoint is being tracked based on when a single True boolean value is produced?

Thanks for your answers in advance, and again, sorry for bothering you.
-Felix


2017. november 19., vasárnap 12:49:13 UTC+1 időpontban goncaloclopes a következőt írta:
Hi Felix,

This is exactly the problem I use to explain how higher-order operators work in Bonsai, so I would be very happy to get your feedback on how that part of the documentation is written, and whether it helps you solve your situation:


Hope this helps!
On 17 November 2017 at 10:57, <jarto...@gmail.com> wrote:
Hello,

I'm trying to make bonsai load a video file into filecapture automatically after the previous video file ends. Is this possible somehow? I tried by externalizing the filename as a string node and connected it to a python source that returns string, but it only changes the file if I restart the workflow.

Felix

--
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.

Gonçalo Lopes

unread,
Nov 26, 2017, 7:18:19 AM11/26/17
to jarto...@gmail.com, Bonsai Users
Hi Felix,

No bother, these are great questions! Some thoughts:

1) Where exactly are you placing the HsvThreshold operator? Can you share your current workflow? It sounds to me that indeed you might want to place the HsvThreshold operator inside WindowWorkflow, but would be good to confirm how you are trying to do it.

2) Indeed the object orientation reflects only a half-circle, since the algorithm does not know apriori where is the head of the animal. You can adjust for this by making some simple assumptions between frames (e.g. the animal is not going to turn more than 180º between two frames). You can find some examples of how to do this in this thread asking a similar question.

Hope this helps!

To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users+unsubscribe@googlegroups.com.

jarto...@gmail.com

unread,
Nov 28, 2017, 7:39:19 AM11/28/17
to Bonsai Users
Hi Goncalo,

thanks again for the great answers.

1) I'll post my current workflow under this response. It's a bit messy, I tried putting the pythontransform inside the Batching windowworkflow, but it seems it doesn't recognize the value, but when I click on the source, it says the correct filename and changes too when the video changes. If I try to zip the pythontransform and the windowworkflow together, the program starts, runs for like 2 seconds and then stops. I believe it's because it quickly goes through all the filenames and doesn't wait for the videos to finish.

2) I combined your code with my tracker and it works like a charm, so thanks again, it was a really big help.
Batching_stuff.bonsai

Gonçalo Lopes

unread,
Nov 29, 2017, 2:52:09 PM11/29/17
to jarto...@gmail.com, Bonsai Users
Hi Felix,

I am still not completely sure about what you are trying to do, but I am now assuming that you want to apply the HsvThreshold on the concatenated video, but using potentially different thresholds for frames coming from specific files.

If this is the case, and you still want to record the original frames to the a file before the threshold, you need to carry the threshold value together with the frames and use InputMapping to set the value just before processing.

I am attaching a modified workflow of the workflow that does this.
Hope it helps!

To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users+unsubscribe@googlegroups.com.
Batching_stuff_v2.bonsai

jarto...@gmail.com

unread,
Dec 1, 2017, 8:30:58 AM12/1/17
to Bonsai Users
Thanks for the answer. I made some slight modifications to your workflow. What it does is based on the filename it changes the lower and upper thersholds of the HSVThreshold node. For some reason, if I try to compare the string value from the filename, it doesn't recognize the correct filename. What I did is I renamed my videos to "001", "002", etc. and I use that part of the string in the pythontransforms. This way it works and the threshold values change when the filename changes. I'll upload the current workflow if anyone needs something like it. Thank you again so much for your help!
Batching_stuff_v3.bonsai
Reply all
Reply to author
Forward
0 new messages