LED strobbing. Race condition ? #2086
Replies: 3 comments 6 replies
-
This seems like a fun project! Do you mind sharing your workflow as outlined in https://github.com/orgs/bonsai-rx/discussions/864? With regards to the video FPS, maybe there are a few things we can check first. If you copy over just the video recording pipeline to a new workflow and run it without the rest, are you able to achieve 150fps without any dropped frames (Timestamp + a CsvWriter/MatrixWriter if the CsvWriter can't keep up). How about with the Sleap inference pipeline enabled? |
Beta Was this translation helpful? Give feedback.
-
One optimization for the workflow - I think you can combine the DeltaAngle and Velocity branches together (to make sure they aren't interfering with each other for the LED control) using an ExpressionTransform. Something like this: The ExpressionTransform node isn't that well documented, we are still revising the documentation but here is a draft. Within the ExpressionTransform you might write something like this (not sure if this is the right logic you want so check it):
The outputs from the Zip node won't be called DeltaAngle or Velocity, I think they will just be called Item1 or Item2 but for some reason I wasn't able to check the outputs from the |
Beta Was this translation helpful? Give feedback.
-
I am also not sure what you are trying to do with the |
Beta Was this translation helpful? Give feedback.
-
Hello, I have been using Bonsai for the first time this week and it has been amazing how fast you can prototype ideas. Right now I am trying to deliver optogenetic stimulation to a fly when it stops moving or moves in a certain direction. I want to turn the LED so long as the fly is doing the selected action, with a LED pulse minimum duration of 0.5ms, however when the fly does the action for an extended period of time the LED starts strobing (undesirable) after being continuously on for a while (desirable). I bet this has something to do with a race condition, but I cant figure it out.
Furthermore, to terminate the process I had to add a bunch of
TakeUntil
all over the place, in seemingly arbitrary places: right after sources (like the camera) but also before and after some sinks (Arduino) but not other (VideoWriter). There is likely a better way of dealing with termination and a logic behind it, but right now it eludes me.Finally, and this is a long shot, I am streaming video at 150 FPS and supposedly recording it at the same frequency, however there is a lot of dropped frames, and a 30 minutes recording becomes 11 minutes since it seems ffmpeg does not account for the frame drop and saves a "150 FPS" video. I suspect I might be doing something silly/inefficient with all the publish/subscriptions that I have places to deal with the spaghetti, and this might be hindering frame rate.
I am attaching the full project, and also a toy example of the LED control which right now is the most critical issue.
Any help is greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions