Hi everyone,
I am a new user for Bonsai and am using it to track a mouse in the open field test, but I have a trouble.
I need to automatically start video recording if a mouse is put into the open field and then stop the recording at a designed recording duration (for example, 30 min).
I´m using the following workflow.
Camera Capture > Crop > Grayscale > Threshold > FindContours > BinaryRegionAnalysis > LargerstBinaryRegion > SourceArea > GreaterThan > VideoWriter
I'm trying to define the start recording point when "LargestBinaryRegin" is greater than a designed value (nearly equal to an averaged mouse size I use in experiments).
I tried to use Videowriter connecting to the GreaterThan but it did not work.
I don’t know how to define the recording duration. Should I use “Timer”?
Apologies if this has been asked previously, but I couldn't find a solution.
Thank you for your help.
Best,
Hideki

--
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.
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/d9f08ad4-5f14-4ae5-9fd0-8a7996e3c8c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Hideki and welcome to the forums,This is an interesting question and a good exercise. You can use the SkipWhile operator to specify when to start recording, however because you want to record both the video and potentially tracking, it is best to separate the workflow into 2 parts. The first part extracts what should be recorded, the second one specifies when it should be recorded, like so (also attached a workflow for Bonsai 2.4-preview):As you can see, I've defined two PublishSubject variables (Video and Tracking) in the top part. Then on the bottom half I decide when to start and stop the recording by using TakeUntil, SubscribeWhen and SkipWhile.SkipWhile ignores values until some condition, SubscribeWhen starts the workflow only when something happens and TakeUntil terminates the workflow when something happens.This way you can keep both your processing logic and start/stop recording logic clean and modular.Hope this helps.
On Tue, 25 Jun 2019 at 18:53, Hideki Miwa <hidek...@gmail.com> wrote:
--Hi everyone,
I am a new user for Bonsai and am using it to track a mouse in the open field test, but I have a trouble.
I need to automatically start video recording if a mouse is put into the open field and then stop the recording at a designed recording duration (for example, 30 min).
I´m using the following workflow.
Camera Capture > Crop > Grayscale > Threshold > FindContours > BinaryRegionAnalysis > LargerstBinaryRegion > SourceArea > GreaterThan > VideoWriter
I'm trying to define the start recording point when "LargestBinaryRegin" is greater than a designed value (nearly equal to an averaged mouse size I use in experiments).
I tried to use Videowriter connecting to the GreaterThan but it did not work.
I don’t know how to define the recording duration. Should I use “Timer”?
Apologies if this has been asked previously, but I couldn't find a solution.
Thank you for your help.
Best,
Hideki
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...@googlegroups.com.
Thanks Gonçalo !