Dear Bonsai team
I am writing this to share with you the second lesson I had today
In a video-based behavioural experiment where we set a condition for the animals to enter a certain area. Something we can start from is to select an area with Crop and track the animals with Threshold > FindContours > BinaryRegionAnalysis and then set a threshold to see if this animal enter the selected area. One thing can happen is that the value in that area might value depends on the animals' subtle movement. Therefore, instead of setting one threshold to meet, one can do is to set multiple threshold for different conditions (or different states), which means that there is a one threshold for the animal in the threat zone and another threshold for the animal not being in the threat zone. Scan is a module that uses its input and output to determine the current state of the workflow. Therefore the workflow seems to be as follow.
1. Use Boolean to set a default state and send this to Scan
2. In the Scan, create two conditions. One condition is for one state. The other condition is for the other state
3. The first condition would accumulate the value whereas the other condition is the opposite of the first condition so there is a need to put a BitwiseNot.
4. Output the conditions as value and use GreaterThan as thresholds for each of them
5. Merge the two workflow for only one workflow output
The logic behind this is when the workflow is in the default state, it would process via the default condition. When the value of this condition pass the threshold, it would switch to the other condition and stay in that state until the condition does not anymore.
In my case, there are two states, the active state has a higher threshold to enter so only when the animals enter the threshold do the condition is satisfied. Otherwise, it would stay in the default state. When the active state returns back to the default state, it needs to cross a threshold that is higher than the baseline but lower than the high-threshold.
This is an elegant way to set two thresholds for a condition. I think it would be very useful to use Scan but I honestly think I have not understood everything in this workflow. Therefore, feel free to let me know if you have any concerns or comments.
Best Regards
Chi-Yu