From 91af86070bd8ed5c4fbd4dca39299d0096961013 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 23 Jun 2026 18:14:53 +0100 Subject: [PATCH 001/116] Update behavior plot to use Bonsai ImGui package style --- bonsai/Bonsai.config | 15 + .../TrialChoiceOutcomeVisualizer.cs | 370 +++ src/Extensions/TrialOutcomeVisualizer.cs | 26 +- src/test_ethogram.bonsai | 6 +- src/test_visualizer.bonsai | 2060 ++++++++++++++++- 5 files changed, 2452 insertions(+), 25 deletions(-) create mode 100644 src/Extensions/TrialChoiceOutcomeVisualizer.cs diff --git a/bonsai/Bonsai.config b/bonsai/Bonsai.config index e5893024..858cf57f 100644 --- a/bonsai/Bonsai.config +++ b/bonsai/Bonsai.config @@ -22,6 +22,11 @@ + + + + + @@ -97,6 +102,11 @@ + + + + + @@ -141,6 +151,11 @@ + + + + + diff --git a/src/Extensions/TrialChoiceOutcomeVisualizer.cs b/src/Extensions/TrialChoiceOutcomeVisualizer.cs new file mode 100644 index 00000000..2fd82436 --- /dev/null +++ b/src/Extensions/TrialChoiceOutcomeVisualizer.cs @@ -0,0 +1,370 @@ +using AindDynamicForagingDataSchema; +using Bonsai; +using Hexa.NET.ImPlot; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Numerics; +using System.Reactive; +using System.Linq; +using System.Reactive.Linq; + +[Combinator] +[Description("Draws a progress bar showing a value between 0 and 1.")] +public class TrialChoiceOutcomeVisualizer +{ + public bool Visible {get; set;} + public List TrialOutcomes {get; set;} + public float MarkerSize {get; set;} + public float MarkerWeight {get; set;} + public float TopPlotHeight {get; set;} + public float BottomPlotHeight {get; set;} + public float RollingLineThickness {get; set;} + public int RollingWindowSize {get; set;} + + public IObservable Process(IObservable source) + { + return Observable.Create(observer => + { + var sourceObserver = Observer.Create( + value => + { + var trialIndices = CreateTrialIndices(TrialOutcomes.Count); + var choiceValues = ExtractChoiceValues(TrialOutcomes); + var rewardValues = ExtractRewardValues(TrialOutcomes); + var finishedTrialValues = ExtractFinishedTrialValues(TrialOutcomes); + var rollingChoiceAvg = ComputeRollingAverage(choiceValues, RollingWindowSize); + var rollingRewardRate = ComputeRollingAverage(rewardValues, RollingWindowSize); + var rollingFinishedRate = ComputeRollingAverage(finishedTrialValues.Select(v => (float?)v).ToArray(), RollingWindowSize); + // Categorize trials + List rightChoiceX; + List leftChoiceX; + List rightRewardedX; + List rightUnrewardedX; + List leftRewardedX; + List leftUnrewardedX; + List noChoiceX; + List rightRewardedAutoX; + List rightUnrewardedAutoX; + List leftRewardedAutoX; + List leftUnrewardedAutoX; + + CategorizeTrials(TrialOutcomes, + out rightChoiceX, + out leftChoiceX, + out rightRewardedX, + out rightUnrewardedX, + out leftRewardedX, + out leftUnrewardedX, + out noChoiceX, + out rightRewardedAutoX, + out rightUnrewardedAutoX, + out leftRewardedAutoX, + out leftUnrewardedAutoX + ); + + // Extract probability traces + var pRewardLeft = ExtractPRewardLeft(TrialOutcomes); + var pRewardRight = ExtractPRewardRight(TrialOutcomes); + + if (Visible) + { + if (ImPlot.BeginPlot("Trial Outcomes", new Vector2(-1, TopPlotHeight), ImPlotFlags.NoTitle)) + { + double[] tickPositions = new double[] {0, 1}; + ImPlot.SetupAxisTicks(ImAxis.Y1, ref tickPositions[0], 2, new string[] {"R", "L"}); + ImPlot.SetupAxisLimits(ImAxis.Y1, -0.5f, 1.5f); + ImPlot.SetupLegend(ImPlotLocation.East, ImPlotLegendFlags.Outside); + + // plot left choices + ScatterHorizontalSeries("Left Choice", leftChoiceX.ToArray(), 1.2f, ImPlotMarker.Circle, MarkerSize, MarkerWeight, new Vector4(0, 1, 0, 0), new Vector4(0, 0.7f, 0, 1)); + + // plot left rewarded choices + ScatterHorizontalSeries("Left Rewarded", leftRewardedX.ToArray(), 1f, ImPlotMarker.Circle, MarkerSize, MarkerWeight, new Vector4(0, 1, 0, 1), new Vector4(0, 0.7f, 0, 1)); + + // plot right choices + ScatterHorizontalSeries("Right Choice", rightChoiceX.ToArray(), -0.2f, ImPlotMarker.Circle, MarkerSize, MarkerWeight, new Vector4(0, 1, 0, 0), new Vector4(0, 0.7f, 0, 1)); + + // plot right rewrded choices + ScatterHorizontalSeries("Right Rewarded", rightRewardedX.ToArray(), 0f, ImPlotMarker.Circle, MarkerSize, MarkerWeight, new Vector4(0, 1, 0, 1), new Vector4(0, 0.7f, 0, 1)); + + // plot no choice + ScatterHorizontalSeries("No Choice", noChoiceX.ToArray(), 0.5f, ImPlotMarker.Square, MarkerSize, MarkerWeight, new Vector4(0, 0, 0, 0.2f), new Vector4(0, 0, 0, 0.2f)); + + ImPlot.EndPlot(); + } + if (ImPlot.BeginPlot("Trial History", new Vector2(-1, BottomPlotHeight), ImPlotFlags.NoTitle)) + { + double[] tickPositions = new double[] {0, 1}; + ImPlot.SetupAxisTicks(ImAxis.Y1, ref tickPositions[0], 2); + ImPlot.SetupAxisLimits(ImAxis.Y1, -0.5f, 1.5f); + ImPlot.SetupLegend(ImPlotLocation.East, ImPlotLegendFlags.Outside); + + PlotRollingLine("pL", trialIndices, pRewardLeft, new Vector4(1, 0, 0, 1), RollingLineThickness); + PlotRollingLine("pR", trialIndices, pRewardRight, new Vector4(0, 0, 1, 1), RollingLineThickness); + + PlotRollingLine("Choice Fraction", trialIndices, rollingChoiceAvg, new Vector4(0, 0, 0, 1), RollingLineThickness); + PlotRollingLine("Reward Rate", trialIndices, rollingRewardRate, new Vector4(0, 1, 0, 1), RollingLineThickness); + PlotRollingLine("Finished Rate", trialIndices, rollingFinishedRate, new Vector4(0, 0.5f, 0.5f, 1), RollingLineThickness); + + ImPlot.EndPlot(); + } + observer.OnNext(value); + } + }, + observer.OnError, + observer.OnCompleted); + return source.SubscribeSafe(sourceObserver); + }); + } + + private void ScatterHorizontalSeries(string label, float[] values, float ySet, ImPlotMarker markerType, float size, float weight, Vector4 fillColor, Vector4 outlineColor) + { + float[] ys = new float[values.Length]; + for (int i = 0; i < values.Length; i++) + { + ys[i] = ySet; + } + + ImPlot.SetNextMarkerStyle(markerType, size, fillColor, weight, outlineColor); + ImPlot.PlotScatter(label, ref values[0], ref ys[0], values.Length); + } + + /// + /// Plots a line for rolling averages. + /// + private static void PlotRollingLine( + string label, + float[] xValues, + float[] yValues, + Vector4 color, + float lineThickness) + { + if (xValues.Length == 0) return; + + ImPlot.SetNextLineStyle(color, lineThickness); + ImPlot.PlotLine(label, ref xValues[0], ref yValues[0], xValues.Length); + } + + /// + /// Creates an array of trial indices for x-axis plotting. + /// + private static float[] CreateTrialIndices(int count) + { + var indices = new float[count]; + for (int i = 0; i < count; i++) + { + indices[i] = i; + } + return indices; + } + + /// + /// Categorizes trials and collects their x positions. + /// + private static void CategorizeTrials( + List trialList, + out List rightChoiceX, + out List leftChoiceX, + out List rightRewardedX, + out List rightUnrewardedX, + out List leftRewardedX, + out List leftUnrewardedX, + out List noChoiceX, + out List rightRewardedAutoX, + out List rightUnrewardedAutoX, + out List leftRewardedAutoX, + out List leftUnrewardedAutoX) + { + rightChoiceX = new List(); + leftChoiceX = new List(); + rightRewardedX = new List(); + rightUnrewardedX = new List(); + leftRewardedX = new List(); + leftUnrewardedX = new List(); + noChoiceX = new List(); + rightRewardedAutoX = new List(); + rightUnrewardedAutoX = new List(); + leftRewardedAutoX = new List(); + leftUnrewardedAutoX = new List(); + + for (int i = 0; i < trialList.Count; i++) + { + var trial = trialList[i]; + float x = i; + bool isAutoResponse = trial.Trial.IsAutoResponseRight.HasValue; + + if (!trial.IsRightChoice.HasValue) + { + noChoiceX.Add(x); + } + else if (trial.IsRightChoice.Value) + { + if (isAutoResponse) + { + if (trial.IsRewarded) + { + rightRewardedAutoX.Add(x); + } + else + { + rightUnrewardedAutoX.Add(x); + } + } + else + { + rightChoiceX.Add(x); + if (trial.IsRewarded) + { + rightRewardedX.Add(x); + } + else + { + rightUnrewardedX.Add(x); + } + } + } + else + { + if (isAutoResponse) + { + if (trial.IsRewarded) + { + leftRewardedAutoX.Add(x); + } + else + { + leftUnrewardedAutoX.Add(x); + } + } + else + { + leftChoiceX.Add(x); + if (trial.IsRewarded) + { + leftRewardedX.Add(x); + } + else + { + leftUnrewardedX.Add(x); + } + } + } + } + } + + /// + /// Extracts PRewardLeft values from trials. + /// + private static float[] ExtractPRewardLeft(List trialList) + { + var values = new float[trialList.Count]; + for (int i = 0; i < trialList.Count; i++) + { + values[i] = (float)trialList[i].Trial.PRewardLeft; + } + return values; + } + + /// + /// Extracts PRewardRight values from trials. + /// + private static float[] ExtractPRewardRight(List trialList) + { + var values = new float[trialList.Count]; + for (int i = 0; i < trialList.Count; i++) + { + values[i] = (float)trialList[i].Trial.PRewardRight; + } + return values; + } + + /// + /// Computes rolling average over a window of values, ignoring null entries. + /// + private static float[] ComputeRollingAverage(float?[] values, int windowSize) + { + if (values == null || values.Length == 0) + { + return new float[0]; + } + + var result = new float[values.Length]; + + for (int i = 0; i < values.Length; i++) + { + int windowStart = Math.Max(0, i - windowSize + 1); + float sum = 0; + int validCount = 0; + + for (int j = windowStart; j <= i; j++) + { + if (values[j].HasValue) + { + sum += values[j].Value; + validCount++; + } + } + + result[i] = validCount > 0 ? sum / validCount : 0.5f; + } + + return result; + } + + /// + /// Extracts choice values (1 for right, 0 for left, null for no choice) from trials. + /// + private static float?[] ExtractChoiceValues(List trialList) + { + var values = new float?[trialList.Count]; + for (int i = 0; i < trialList.Count; i++) + { + var choice = trialList[i].IsRightChoice; + if (choice.HasValue) + { + values[i] = choice.Value ? 1.0f : 0.0f; + } + else + { + values[i] = null; + } + } + return values; + } + + /// + /// Extracts reward values (1 for rewarded, 0 for not rewarded) from trials. + /// Only considers trials where a choice was made. + /// + private static float?[] ExtractRewardValues(List trialList) + { + var values = new float?[trialList.Count]; + for (int i = 0; i < trialList.Count; i++) + { + if (trialList[i].IsRightChoice.HasValue) + { + values[i] = trialList[i].IsRewarded ? 1.0f : 0.0f; + } + else + { + values[i] = null; + } + } + return values; + } + + /// + /// Extracts finished trial values (1 if choice was made, 0 if not) from all trials. + /// + private static float[] ExtractFinishedTrialValues(List trialList) + { + var values = new float[trialList.Count]; + for (int i = 0; i < trialList.Count; i++) + { + values[i] = trialList[i].IsRightChoice.HasValue ? 1.0f : 0.0f; + } + return values; + } +} + diff --git a/src/Extensions/TrialOutcomeVisualizer.cs b/src/Extensions/TrialOutcomeVisualizer.cs index 8247f312..ca2c4d5e 100644 --- a/src/Extensions/TrialOutcomeVisualizer.cs +++ b/src/Extensions/TrialOutcomeVisualizer.cs @@ -574,31 +574,31 @@ void DrawTrials() // Align 0.5 to 0, 1 to 1 and 0 to -1 ImPlot.SetupAxisLimits(ImAxis.Y2, -y2Max, y2Max, ImPlotCond.Always); ImPlot.SetAxes(ImAxis.X1, ImAxis.Y2); - PlotProbabilityBars(trialIndices, pRewardRight, 1, RightChoiceColor, "P(Reward Right)"); - PlotProbabilityBars(trialIndices, pRewardLeft, -1, LeftChoiceColor, "P(Reward Left)"); + // PlotProbabilityBars(trialIndices, pRewardRight, 1, RightChoiceColor, "P(Reward Right)"); + // PlotProbabilityBars(trialIndices, pRewardLeft, -1, LeftChoiceColor, "P(Reward Left)"); // Switch back to Y1 for everything else ImPlot.SetAxes(ImAxis.X1, ImAxis.Y1); PlotRollingLine(trialIndices, rollingChoiceAvg, "Right Choice Rate", ProbabilityTraceColor); - PlotRollingLine(trialIndices, rollingRewardRate, "Reward Rate", RewardRateLineColor); - PlotRollingLine(trialIndices, rollingFinishedRate, "Finished Trial Rate", FinishedTrialRateColor); + // PlotRollingLine(trialIndices, rollingRewardRate, "Reward Rate", RewardRateLineColor); + // PlotRollingLine(trialIndices, rollingFinishedRate, "Finished Trial Rate", FinishedTrialRateColor); // Right choices: bars extend upward from Y=1 (past 1) PlotRewardedBars(rightRewardedX, RightChoiceY, 1, RightChoiceColor, "Right + Rewarded"); PlotUnrewardedBars(rightUnrewardedX, RightChoiceY, 1, RightChoiceColor, "Right + Unrewarded"); - // Left choices: bars extend downward from Y=0 (past 0 into negative) - PlotRewardedBars(leftRewardedX, LeftChoiceY, -1, LeftChoiceColor, "Left + Rewarded"); - PlotUnrewardedBars(leftUnrewardedX, LeftChoiceY, -1, LeftChoiceColor, "Left + Unrewarded"); + // // Left choices: bars extend downward from Y=0 (past 0 into negative) + // PlotRewardedBars(leftRewardedX, LeftChoiceY, -1, LeftChoiceColor, "Left + Rewarded"); + // PlotUnrewardedBars(leftUnrewardedX, LeftChoiceY, -1, LeftChoiceColor, "Left + Unrewarded"); - // Auto-response trials with purple outline - PlotRewardedBarsWithOutline(rightRewardedAutoX, RightChoiceY, 1, RightChoiceColor, "Right + Rewarded (Auto)"); - PlotUnrewardedBarsWithOutline(rightUnrewardedAutoX, RightChoiceY, 1, RightChoiceColor, "Right + Unrewarded (Auto)"); - PlotRewardedBarsWithOutline(leftRewardedAutoX, LeftChoiceY, -1, LeftChoiceColor, "Left + Rewarded (Auto)"); - PlotUnrewardedBarsWithOutline(leftUnrewardedAutoX, LeftChoiceY, -1, LeftChoiceColor, "Left + Unrewarded (Auto)"); + // // Auto-response trials with purple outline + // PlotRewardedBarsWithOutline(rightRewardedAutoX, RightChoiceY, 1, RightChoiceColor, "Right + Rewarded (Auto)"); + // PlotUnrewardedBarsWithOutline(rightUnrewardedAutoX, RightChoiceY, 1, RightChoiceColor, "Right + Unrewarded (Auto)"); + // PlotRewardedBarsWithOutline(leftRewardedAutoX, LeftChoiceY, -1, LeftChoiceColor, "Left + Rewarded (Auto)"); + // PlotUnrewardedBarsWithOutline(leftUnrewardedAutoX, LeftChoiceY, -1, LeftChoiceColor, "Left + Unrewarded (Auto)"); - // No choice: cross marker at middle + // // No choice: cross marker at middle PlotNoChoiceMarkers(noChoiceX, NoChoiceColor, "No Choice"); ImPlot.EndPlot(); diff --git a/src/test_ethogram.bonsai b/src/test_ethogram.bonsai index 5c71d1eb..8a9fa995 100644 --- a/src/test_ethogram.bonsai +++ b/src/test_ethogram.bonsai @@ -41,7 +41,7 @@ - PT2.024S + PT1.219S @@ -93,7 +93,7 @@ - PT2.085S + PT1.095S @@ -164,7 +164,7 @@ - PT2.207S + PT2.974S diff --git a/src/test_visualizer.bonsai b/src/test_visualizer.bonsai index 886110b4..40a1c302 100644 --- a/src/test_visualizer.bonsai +++ b/src/test_visualizer.bonsai @@ -8,6 +8,7 @@ xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns:p2="clr-namespace:;assembly=Extensions" xmlns:p3="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" + xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -79,7 +80,7 @@ - true + false @@ -184,7 +185,7 @@ - true + false @@ -232,11 +233,10 @@ 5 0 5 - false 0.5 5 - true - 0 + + 0 @@ -246,18 +246,2054 @@ - true - false + false + true - - 32 + + + 500 + + + + + + + TrialOutcomes 0 + + + Frame + + + Frame + + + TrialOutcomes + + + + + + + + + true + + + true + false + + + true + false + + + true + false + + + false + true + + + false + false + + + false + true + + + true + true + + + true + true + + + false + true + + + true + true + + + true + true + + + true + true + + + true + false + + + false + false + + + true + true + + + false + false + + + true + true + + + false + false + + + false + true + + + false + false + + + false + true + + + true + true + + + false + true + + + true + true + + + true + false + + + + true + + + true + false + + + false + true + + + true + true + + + + true + + + false + false + + + true + false + + + + false + + + true + true + + + false + true + + + + false + + + false + true + + + false + false + + + false + false + + + true + true + + + false + true + + + false + false + + + true + false + + + false + false + + + true + false + + + false + true + + + true + false + + + true + false + + + true + false + + + false + true + + + false + true + + + true + true + + + true + false + + + true + false + + + false + true + + + false + false + + + false + false + + + false + false + + + false + true + + + false + false + + + true + true + + + false + true + + + true + false + + + false + false + + + + true + + + false + false + + + + true + + + true + true + + + true + false + + + false + false + + + false + false + + + false + true + + + true + false + + + + false + + + true + false + + + + false + + + true + true + + + true + false + + + true + true + + + false + false + + + false + true + + + true + true + + + true + true + + + false + true + + + false + true + + + false + true + + + false + false + + + false + true + + + true + false + + + + true + + + false + true + + + true + true + + + true + true + + + false + true + + + true + true + + + false + false + + + false + false + + + + true + + + true + true + + + true + true + + + + false + + + true + true + + + false + false + + + true + true + + + false + true + + + false + true + + + false + true + + + true + true + + + true + true + + + false + false + + + true + true + + + false + true + + + true + true + + + false + false + + + false + true + + + true + true + + + true + true + + + false + false + + + true + true + + + false + false + + + true + false + + + true + true + + + false + true + + + true + false + + + true + true + + + true + true + + + true + false + + + true + false + + + true + true + + + true + true + + + true + false + + + true + true + + + false + true + + + true + true + + + true + false + + + false + false + + + true + true + + + true + false + + + false + false + + + false + true + + + false + false + + + false + false + + + true + false + + + false + true + + + true + false + + + true + false + + + false + false + + + true + false + + + true + false + + + false + true + + + true + false + + + true + true + + + false + false + + + + true + + + true + false + + + true + false + + + true + true + + + false + true + + + true + true + + + true + false + + + true + true + + + true + false + + + true + false + + + + false + + + + true + + + true + true + + + true + false + + + false + true + + + false + false + + + true + false + + + true + false + + + true + true + + + false + true + + + false + true + + + false + true + + + true + false + + + true + true + + + false + true + + + + false + + + true + true + + + false + false + + + true + false + + + true + true + + + true + true + + + + false + + + false + false + + + true + false + + + false + true + + + true + true + + + true + true + + + false + false + + + false + true + + + false + false + + + true + false + + + true + false + + + false + true + + + true + true + + + true + true + + + true + false + + + true + false + + + true + true + + + + false + + + + true + + + false + true + + + false + true + + + false + true + + + true + false + + + true + true + + + true + true + + + + false + + + true + false + + + true + false + + + false + true + + + + false + + + false + true + + + true + false + + + true + false + + + false + true + + + true + true + + + false + true + + + true + true + + + true + false + + + false + false + + + + false + + + false + false + + + true + false + + + false + false + + + false + true + + + true + true + + + true + false + + + false + true + + + false + true + + + false + true + + + false + true + + + false + true + + + false + false + + + false + false + + + true + false + + + true + true + + + true + true + + + true + false + + + + true + + + true + true + + + false + false + + + true + true + + + true + true + + + false + false + + + false + true + + + true + false + + + false + true + + + + true + + + false + true + + + false + false + + + true + false + + + false + true + + + false + false + + + + false + + + + false + + + true + false + + + true + true + + + true + false + + + + false + + + false + true + + + true + true + + + false + true + + + true + false + + + false + true + + + true + true + + + true + true + + + + true + + + + true + + + false + false + + + false + false + + + true + true + + + false + true + + + true + false + + + false + true + + + + true + + + false + true + + + true + true + + + + true + + + false + true + + + false + false + + + true + true + + + false + false + + + + true + + + true + true + + + + false + + + false + false + + + true + false + + + true + true + + + true + true + + + + true + + + true + true + + + false + false + + + false + false + + + false + true + + + true + true + + + true + true + + + + false + + + false + false + + + true + false + + + true + false + + + false + true + + + true + true + + + false + true + + + false + true + + + false + true + + + false + true + + + false + false + + + + true + + + true + false + + + false + true + + + true + true + + + false + false + + + false + true + + + false + true + + + true + false + + + false + true + + + true + true + + + false + true + + + true + false + + + true + false + + + true + false + + + true + true + + + true + true + + + false + false + + + true + false + + + true + false + + + false + false + + + true + false + + + false + true + + + false + false + + + false + false + + + false + true + + + true + false + + + true + false + + + false + false + + + true + true + + + false + false + + + true + false + + + true + false + + + true + false + + + true + true + + + true + true + + + false + false + + + true + false + + + false + true + + + false + true + + + true + true + + + false + false + + + true + false + + + false + false + + + false + true + + + false + true + + + true + true + + + false + true + + + true + false + + + false + false + + + false + true + + + false + false + + + true + false + + + true + false + + + false + false + + + true + true + + + true + false + + + true + false + + + true + false + + + true + false + + + true + true + + + true + true + + + false + false + + + true + false + + + false + false + + + false + true + + + false + true + + + false + false + + + true + true + + + + false + + + true + false + + + true + true + + + true + true + + + false + true + + + true + true + + + false + false + + + true + true + + + false + false + + + true + false + + + false + true + + + + true + + + true + false + + + true + true + + + + false + + + true + false + + + true + false + + + true + false + + + + false + + + true + true + + + true + true + + + true + true + + + false + true + + + true + true + + + false + true + + + true + true + + + true + true + + + false + true + + + true + false + + + true + true + + + true + false + + + true + false + + + true + true + + + false + false + + + true + false + + + true + true + + + false + false + + + false + true + + + false + false + + + false + false + + + true + false + + + true + false + + + true + true + + + + false + + + true + true + + + false + false + + + + false + + + false + true + + + false + true + + + true + false + + + false + false + + + + false + + + false + false + + + false + false + + + true + true + + + + true + + + false + false + + + true + true + + + true + false + + + false + true + + + true + true + + + true + false + + + false + true + + + false + false + + + false + true + + + true + false + + + true + false + + + + true + + + false + true + + + false + true + + + false + true + + + true + false + + + false + true + + + true + true + + + true + true + + + true + true + + + false + false + + + true + true + + + + false + + + false + false + + + true + true + + + true + false + + + true + true + + + false + false + + + false + true + + + false + true + + + false + true + + + false + false + + + false + true + + + false + false + + + false + false + + + + true + + + true + true + + + false + true + + + false + false + + + false + true + + + true + false + + + true + false + + + true + false + + + false + false + + + true + true + + + true + true + + + true + false + + + false + false + + + false + false + + + true + true + + + true + true + + + true + true + + + true + false + + + false + true + + + false + true + + + true + true + + + true + true + + + true + true + + + true + false + + + true + true + + + false + false + + + true + false + + + true + true + + + true + false + + + false + true + + + false + true + + + 3 + 1 + 200 + 100 + 2 + 20 + + @@ -311,6 +2347,12 @@ + + + + + + \ No newline at end of file From f31ffcc8fdeee1e25ed7339039cb017389319396 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Fri, 26 Jun 2026 17:56:42 +0100 Subject: [PATCH 002/116] Construct behavior visualizer with time based rolling graph --- src/Extensions.csproj | 2 +- src/Extensions/LineStyling.cs | 38 ++ src/Extensions/PlotStyling.cs | 46 ++ src/Extensions/ScatterStyling.cs | 40 ++ src/test_behavior_visualizer.bonsai | 698 +++++++++++++++++++++++ src/test_visualizer.bonsai | 849 ++++++++++++++-------------- 6 files changed, 1245 insertions(+), 428 deletions(-) create mode 100644 src/Extensions/LineStyling.cs create mode 100644 src/Extensions/PlotStyling.cs create mode 100644 src/Extensions/ScatterStyling.cs create mode 100644 src/test_behavior_visualizer.bonsai diff --git a/src/Extensions.csproj b/src/Extensions.csproj index fa0f74c2..7961aa56 100644 --- a/src/Extensions.csproj +++ b/src/Extensions.csproj @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/src/Extensions/LineStyling.cs b/src/Extensions/LineStyling.cs new file mode 100644 index 00000000..d8fc7dde --- /dev/null +++ b/src/Extensions/LineStyling.cs @@ -0,0 +1,38 @@ +using Hexa.NET.ImPlot; +using System; +using System.ComponentModel; +using Bonsai.ImPlot; + +using ImPlot = Hexa.NET.ImPlot.ImPlot; +using Bonsai; +using System.Reactive.Linq; +using System.Reactive; +using System.Linq; +using System.Drawing; +using System.Numerics; + +[Combinator] +public class LineStyling +{ + public float ColorR {get; set;} + public float ColorG {get; set;} + public float ColorB {get; set;} + public float ColorA {get; set;} + public float LineThickness {get; set;} + + public unsafe IObservable Process(IObservable source) + { + return Observable.Create(observer => + { + var sourceObserver = Observer.Create( + value => + { + ImPlot.SetNextLineStyle(new Vector4(ColorR, ColorG, ColorB, ColorA), LineThickness); + observer.OnNext(value); + }, + observer.OnError, + observer.OnCompleted); + return source.SubscribeSafe(sourceObserver); + }); + } +} \ No newline at end of file diff --git a/src/Extensions/PlotStyling.cs b/src/Extensions/PlotStyling.cs new file mode 100644 index 00000000..860c1488 --- /dev/null +++ b/src/Extensions/PlotStyling.cs @@ -0,0 +1,46 @@ +using Hexa.NET.ImPlot; +using System; +using System.ComponentModel; +using Bonsai.ImPlot; + +using ImPlot = Hexa.NET.ImPlot.ImPlot; +using Bonsai; +using System.Reactive.Linq; +using System.Reactive; +using System.Linq; + +[Combinator] +public class PlotStyling +{ + public double[] TickPositions {get; set;} + public string[] TickLabels {get; set;} + public ImPlotLocation ImPlotLocationFlags {get; set;} + public ImPlotLegendFlags ImPlotLegendFlags {get; set;} + + public unsafe IObservable Process(IObservable source) + { + return Observable.Create(observer => + { + var sourceObserver = Observer.Create( + value => + { + if (TickPositions.Count() > 0) + { + if (TickLabels.Count() == TickPositions.Count()) + { + ImPlot.SetupAxisTicks(ImAxis.Y1, ref TickPositions[0], TickPositions.Count(), TickLabels); + } else + { + ImPlot.SetupAxisTicks(ImAxis.Y1, ref TickPositions[0], TickPositions.Count()); + } + } + ImPlot.SetupLegend(ImPlotLocationFlags, ImPlotLegendFlags); + observer.OnNext(value); + }, + observer.OnError, + observer.OnCompleted); + return source.SubscribeSafe(sourceObserver); + }); + } +} + diff --git a/src/Extensions/ScatterStyling.cs b/src/Extensions/ScatterStyling.cs new file mode 100644 index 00000000..0d6235a2 --- /dev/null +++ b/src/Extensions/ScatterStyling.cs @@ -0,0 +1,40 @@ +using Hexa.NET.ImPlot; +using System; +using ImPlot = Hexa.NET.ImPlot.ImPlot; +using Bonsai; +using System.Reactive.Linq; +using System.Reactive; +using System.Linq; +using System.Numerics; + +[Combinator] +public class ScatterStyling +{ + public ImPlotMarker ImPlotMarker {get; set;} + public float Size {get; set;} + public float FillColorR {get; set;} + public float FillColorG {get; set;} + public float FillColorB {get; set;} + public float FillColorA {get; set;} + public float OutlineColorR {get; set;} + public float OutlineColorG {get; set;} + public float OutlineColorB {get; set;} + public float OutlineColorA {get; set;} + public float OutlineWeight {get; set;} + + public unsafe IObservable Process(IObservable source) + { + return Observable.Create(observer => + { + var sourceObserver = Observer.Create( + value => + { + ImPlot.SetNextMarkerStyle(ImPlotMarker, Size, new Vector4(FillColorR, FillColorG, FillColorB, FillColorA), OutlineWeight, new Vector4(OutlineColorR, OutlineColorG, OutlineColorB, OutlineColorA)); + observer.OnNext(value); + }, + observer.OnError, + observer.OnCompleted); + return source.SubscribeSafe(sourceObserver); + }); + } +} diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai new file mode 100644 index 00000000..feca9f8c --- /dev/null +++ b/src/test_behavior_visualizer.bonsai @@ -0,0 +1,698 @@ + + + + + + + Frame + + + Frame + + + EventPlot + true + + -1 + 150 + + NoTitle + AutoFit + RangeFit + + + EventPlot + + + Frame + + + ContinuousPlot + true + + -1 + 150 + + NoTitle + AutoFit + None + + + ContinuousPlot + + + + EventPlot + + + + + 0 + 1 + + + R + L + + West + None + + + + + ContinuousPlot + + + + + 0 + 1 + + + West + None + + + + LickLeft + + + Value + + + + 0.9 + + + + new(it as LickLeft) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickLeft + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + LickRight + + + Value + + + + 0.1 + + + + new(it as LickRight) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickRight + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + TimedTrial + + + 1000 + Seconds + Value.Trial.PRewardLeft + + + ContinuousPlot + + + + 1 + 0 + 0 + 1 + 2 + + + + true + None + + + 1000 + Seconds + Value.Trial.PRewardRight + + + ContinuousPlot + + + + 0 + 0 + 1 + 1 + 2 + + + + true + None + + + Data + + + + + A + false + + + + + TimeBase + + + LickLeft + + + + S + false + + + + + TimeBase + + + LickRight + + + + + + + + + 0.1 + 1 + + + + Random + + + + PT0S + PT0.01S + + + + + 0.01 + + + + + TimeBase + + + + 0 + 1 + + + + + 500 + + + + + 0.5 + + + + + 0 + 500 + + + + + 0 + 1 + 0 + 0.05 + Linear + + + + + 3.14 + + + + + + + (it +1) * 0.5 + + + + 0 + 1 + + + + + 500 + + + + + 0.5 + + + + it + + + + + + + + + true + + + + + 0 + 1 + + + + + 500 + + + + + 0.9 + + + + + + + + + + + + Item3 ? Item2 : Item1 + + + + 0 + 500 + + + + + 0 + 1 + 0 + 0.05 + Linear + + + + + + + (it +1) * 0.5 + + + + 0 + 1 + + + + + 500 + + + + + 0.5 + + + + + + + + + + + + + + + + + + + + 0 + 1 + + + + + 500 + + + + + 0.5 + + + + + + + + + + true + + + + + + + + + + 0 + 1 + + + + + 500 + + + + + 0.05 + + + + + + + Item3 ? Item1 : Item2 + + + + + + Item2 + + + + + + + + + 0.59164587077011477 + 0.40913708100521279 + 5 + 0 + 5 + 0.5 + 5 + + 0 + + + + + + + + + + true + false + + + + SampleTrial + + + + Source1 + + + Random + + + + + + TimeSpan.FromSeconds(it) + + + + + + + + + PT0.606S + + + + + 1 + + + + + + + + + + + + + + + + + + + + TimeBase + + + + + + + + + TimedTrial + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test_visualizer.bonsai b/src/test_visualizer.bonsai index 40a1c302..50e0322e 100644 --- a/src/test_visualizer.bonsai +++ b/src/test_visualizer.bonsai @@ -80,7 +80,7 @@ - false + true @@ -246,8 +246,8 @@ - false - true + true + false @@ -261,11 +261,6 @@ TrialOutcomes - - - 0 - - Frame @@ -290,7 +285,11 @@ false - true + false + false + + + false false @@ -298,35 +297,43 @@ false - false + true + true + + + true true + + true + false + false false false - true + false true - true + false true - true + false false true - true - true + false + false - true + false true @@ -335,22 +342,22 @@ true - false + true false - false + true true - true + false false false - true + false true @@ -362,24 +369,28 @@ true - false + true + true + + + true false - false - true + true + false true - true + false - false - true + true + false true - true + false true @@ -387,7 +398,7 @@ - true + false true @@ -398,11 +409,11 @@ true - true + false true - + true true @@ -411,11 +422,15 @@ true - false + true + + + true + true - false + true true @@ -423,24 +438,32 @@ false - true + false - - false + false + true false true + + true + true + false false - false + false + + false + true + true true @@ -451,18 +474,18 @@ false - false + true - true - false + false + true false - false + true - true + false false @@ -470,25 +493,29 @@ true - true + false false - true + false false true - false + true false - true + false - false + true true + + + false + true true @@ -503,7 +530,7 @@ false - true + false false @@ -517,13 +544,17 @@ false false + + + false + false true - false - false + true + true true @@ -537,17 +568,21 @@ true false + + true + true + false - false + true - + false true false - false + true @@ -562,7 +597,7 @@ false - false + true false @@ -570,15 +605,15 @@ false - false - true + true + false true false - + true false @@ -586,11 +621,15 @@ false - + false + true + + + false false - true + true @@ -605,10 +644,26 @@ false false + + false + false + + + false + false + + + true + true + false true + + false + false + true true @@ -618,7 +673,7 @@ true - false + true true @@ -626,7 +681,7 @@ true - false + true true @@ -635,15 +690,15 @@ false - true + false - true - false + false + true - true + false false @@ -659,7 +714,7 @@ false - true + false true @@ -667,18 +722,18 @@ false - false + true - false - false + true + true true - true + false true @@ -687,7 +742,7 @@ - false + true true @@ -695,15 +750,11 @@ false - false - - - true true false - true + false false @@ -711,14 +762,14 @@ false - true + false - true - true + + false - true + false true @@ -727,11 +778,11 @@ true - true + false false - true + false true @@ -739,7 +790,7 @@ false - false + true false @@ -750,7 +801,7 @@ true - true + false true @@ -758,13 +809,9 @@ false - true + true - - false - false - true false @@ -773,17 +820,13 @@ true true - - false - true - true false - true - true + false + false true @@ -802,11 +845,15 @@ true - true + false true - true + false + false + + + false false @@ -814,11 +861,11 @@ true - false + true - true + false true @@ -838,17 +885,21 @@ false - false - false + + true false - true + false false false + + + true + false false @@ -859,7 +910,7 @@ false - true + false true @@ -867,18 +918,14 @@ true - false + true false false - true - false - - - true + false false @@ -890,19 +937,19 @@ false - true + false true - false - false + + true - + false true - true + false false @@ -917,12 +964,16 @@ false true + + false + false + true true - true + false false @@ -934,7 +985,7 @@ false - true + false false @@ -942,15 +993,19 @@ false - + false true - true + false true true + true + + + false false @@ -958,11 +1013,11 @@ true - false + true false - true + false @@ -975,6 +1030,18 @@ false + false + + + true + true + + + true + true + + + true true @@ -987,10 +1054,10 @@ true - false + true - true + false true @@ -998,11 +1065,11 @@ true - - false + false + true - true + false true @@ -1011,20 +1078,28 @@ true - false + true - true + false true - true + false true false + + false + true + + + false + true + false false @@ -1035,22 +1110,26 @@ false - true + false true true + + false + false + true true - false + true false - false + true true @@ -1058,12 +1137,12 @@ false - true - false + false + true - true - false + false + true false @@ -1075,70 +1154,74 @@ true + false + + + false true - true + false false - true + false false - true - true + false + false - + true false - + false true false - true + false - false - true + + false false - true + false - true + false true - true + false true true - + true false - true + false true - false + true - false + true - + true false @@ -1147,10 +1230,18 @@ true + true + + + false false true + true + + + false false @@ -1162,7 +1253,7 @@ true - false + true true @@ -1170,31 +1261,35 @@ true - true - false + false + true false false - + true false + + true + true + false false true - false + true - false + true false - false + true true @@ -1202,16 +1297,20 @@ true - true - false + + true false true + + + false + false - true + false false @@ -1231,14 +1330,14 @@ false - false + true - true + false false - true + false true @@ -1250,7 +1349,7 @@ false - + true true @@ -1259,19 +1358,15 @@ false - false - - - true true - true + false true false - false + true false @@ -1285,14 +1380,6 @@ false true - - - true - - - false - true - false false @@ -1302,7 +1389,7 @@ false - false + true true @@ -1310,7 +1397,7 @@ false - + true false @@ -1318,24 +1405,20 @@ false - true + false false - - true - true - true false - + true false false - true + false true @@ -1345,24 +1428,20 @@ false true - - true - false - false - true + false true - true + false - true - true + false + false - + false true @@ -1370,7 +1449,7 @@ true - false + true false @@ -1379,22 +1458,18 @@ true - true + false - false + true true true - false - - - false true - + false true @@ -1403,22 +1478,22 @@ true - true + false - + false true false - true + false false false - true + false true @@ -1427,14 +1502,18 @@ - true + false true true - + true + false + + + true false @@ -1446,7 +1525,7 @@ false - true + false true @@ -1457,17 +1536,9 @@ true - - true - true - - - false - false - false - false + true false @@ -1482,8 +1553,8 @@ true - - false + true + true false @@ -1495,7 +1566,7 @@ true - false + true false @@ -1507,11 +1578,11 @@ false - true + false false - true + false false @@ -1519,67 +1590,71 @@ false - true + false false false - + false true - true - false + false + true false true - true + false true - false + false - false + true true - false + true true + true + + + false false false - true + false true - true + false false - true + false true false - true + false true - false + true true @@ -1595,50 +1670,38 @@ true - false + true true false - - false - false - true - false - - - false true - false + true false - false + true false - - false - true - true false true - false + true false false - true + false true @@ -1647,18 +1710,14 @@ true - false - - - true - false + true - true - false + false + true - true + true @@ -1670,15 +1729,15 @@ false - true + false false false - true + false - false + true true @@ -1689,10 +1748,6 @@ false false - - true - false - false false @@ -1701,10 +1756,6 @@ false true - - false - true - true true @@ -1713,30 +1764,18 @@ false true - - true - false - false false - false + true true false false - - true - false - - - true - false - false false @@ -1746,7 +1785,7 @@ true - true + false false @@ -1755,11 +1794,11 @@ true - false + true - true - false + false + true true @@ -1770,16 +1809,16 @@ true - false - false + true + true true - false + true false - false + true false @@ -1791,34 +1830,18 @@ false - false - - - true true - - false - - - true + false false - - true - true - - - true - true - false true - true + false true @@ -1826,39 +1849,27 @@ false - true + false true false false - - true - false - - - false - true - true - true - false - - - true + false true - + false false - true + false false @@ -1866,11 +1877,11 @@ false - true + false false - + true false @@ -1878,7 +1889,7 @@ true - true + false true @@ -1886,7 +1897,7 @@ true - false + true true @@ -1895,10 +1906,10 @@ false - true + false - true + false true @@ -1907,15 +1918,11 @@ false - true - - - true false true - true + false true @@ -1933,10 +1940,18 @@ false false + + false + true + true false + + false + true + true true @@ -1951,14 +1966,14 @@ false - false + true false - false + true - true + false false @@ -1967,68 +1982,52 @@ true - true - - - false - true + false true false false - - - false - false true false - true + false true - false + true false false - - false - - - false - false + true + true - false + true false true - true + false - + false true false false - - true - true - true false @@ -2042,7 +2041,7 @@ true - true + false false @@ -2051,14 +2050,14 @@ false - false + true false - true + false - true + false false @@ -2066,12 +2065,8 @@ false - - true - - - false - true + true + false false @@ -2087,15 +2082,15 @@ false - true + false true true - true - true + false + false true @@ -2103,14 +2098,18 @@ false - false + true + + + + true true true - + false false @@ -2119,31 +2118,31 @@ true - true + false - true + false false true - true + false false false - false + true true - false - true + true + false false - true + false false @@ -2154,55 +2153,51 @@ true - false - false + true + true - false + true false - - - true - true - true + false false - true + false false - false + true false true - true + false false - true - false + false + true true - false + true false - false + true true true - true + false true @@ -2210,7 +2205,11 @@ false - false + + true + + + false @@ -2222,11 +2221,11 @@ true - true - true + + false - true + false true @@ -2238,7 +2237,7 @@ true - false + true true @@ -2246,7 +2245,7 @@ true - true + false true @@ -2254,7 +2253,7 @@ true - true + false false @@ -2263,18 +2262,14 @@ false - false - - - true - false + true true true - true + false false @@ -2282,14 +2277,14 @@ true - false - true + true + false 3 1 - 200 - 100 + 150 + 150 2 20 @@ -2349,10 +2344,10 @@ - - - - + + + + \ No newline at end of file From c98e3270ea5f1acd5bfe6dcda3226d84d977afc4 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Fri, 26 Jun 2026 19:09:02 +0100 Subject: [PATCH 003/116] Add trial choice / categorisation plotting --- src/Extensions.csproj | 1 + src/Extensions/CategorizeTrial.cs | 111 ++++++++++++++++ src/Extensions/ExtractChoiceValues.cs | 28 +++++ src/test_behavior_visualizer.bonsai | 175 ++++++++++++++++++++++++-- 4 files changed, 308 insertions(+), 7 deletions(-) create mode 100644 src/Extensions/CategorizeTrial.cs create mode 100644 src/Extensions/ExtractChoiceValues.cs diff --git a/src/Extensions.csproj b/src/Extensions.csproj index 7961aa56..fd8959e5 100644 --- a/src/Extensions.csproj +++ b/src/Extensions.csproj @@ -19,5 +19,6 @@ + \ No newline at end of file diff --git a/src/Extensions/CategorizeTrial.cs b/src/Extensions/CategorizeTrial.cs new file mode 100644 index 00000000..2b134474 --- /dev/null +++ b/src/Extensions/CategorizeTrial.cs @@ -0,0 +1,111 @@ +using Bonsai; +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Reactive.Linq; +using Bonsai.Harp; +using AindDynamicForagingDataSchema; +using System.Xml.Serialization; + +[Combinator] +[Description("")] +[WorkflowElementCategory(ElementCategory.Transform)] +[XmlInclude(typeof(CategorizedTrial.Choice))] +[XmlInclude(typeof(CategorizedTrial.Category))] +public class CategorizeTrial +{ + public IObservable> Process(IObservable> source) + { + return source.Select(value => + { + var trial = value.Value; + bool isAutoResponse = trial.Trial.IsAutoResponseRight.HasValue; + var categorizedTrial = new CategorizedTrial(); + if (!trial.IsRightChoice.HasValue) + { + categorizedTrial.ChoiceCategory = CategorizedTrial.Choice.NoChoice; + } + else if (trial.IsRightChoice.Value) + { + if (isAutoResponse) + { + if (trial.IsRewarded) + { + categorizedTrial.TrialCategory = CategorizedTrial.Category.RightRewardedAuto; + } + else + { + categorizedTrial.TrialCategory = CategorizedTrial.Category.RightUnrewardedAuto; + } + } + else + { + categorizedTrial.ChoiceCategory = CategorizedTrial.Choice.RightChoice; + if (trial.IsRewarded) + { + categorizedTrial.TrialCategory = CategorizedTrial.Category.RightRewarded; + } + else + { + categorizedTrial.TrialCategory = CategorizedTrial.Category.RightUnrewarded; + } + } + } + else + { + if (isAutoResponse) + { + if (trial.IsRewarded) + { + categorizedTrial.TrialCategory = CategorizedTrial.Category.LeftRewardedAuto; + } + else + { + categorizedTrial.TrialCategory = CategorizedTrial.Category.LeftUnrewardedAuto; + } + } + else + { + categorizedTrial.ChoiceCategory = CategorizedTrial.Choice.LeftChoice; + if (trial.IsRewarded) + { + categorizedTrial.TrialCategory = CategorizedTrial.Category.LeftRewarded; + } + else + { + categorizedTrial.TrialCategory = CategorizedTrial.Category.LeftUnrewarded; + } + } + } + + + return new Timestamped(categorizedTrial, value.Seconds); + }); + } +} + + +public class CategorizedTrial +{ + public enum Choice + { + NoChoice, + RightChoice, + LeftChoice + } + public enum Category + { + RightRewardedAuto, + LeftRewardedAuto, + RightUnrewardedAuto, + LeftUnrewardedAuto, + RightRewarded, + RightUnrewarded, + LeftRewarded, + LeftUnrewarded, + } + + public Choice ChoiceCategory {get; set;} + public Category TrialCategory {get; set;} +} diff --git a/src/Extensions/ExtractChoiceValues.cs b/src/Extensions/ExtractChoiceValues.cs new file mode 100644 index 00000000..eb673a7e --- /dev/null +++ b/src/Extensions/ExtractChoiceValues.cs @@ -0,0 +1,28 @@ +using Bonsai; +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Reactive.Linq; +using Bonsai.Harp; +using AindDynamicForagingDataSchema; + +[Combinator] +[Description("")] +[WorkflowElementCategory(ElementCategory.Transform)] +public class ExtractChoiceValues +{ + public IObservable Process(IObservable> source) + { + return source.Select(value => { + var choice = value.Value.IsRightChoice; + if (choice.HasValue) + { + return choice.Value ? 1.0f : 0.0f; + } else + { + return (float?)null; + } + }); + } +} diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index feca9f8c..0e6318e6 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -7,12 +7,12 @@ xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns:p1="clr-namespace:;assembly=Extensions" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" + xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" xmlns:wie="clr-namespace:Bonsai.Windows.Input;assembly=Bonsai.Windows.Input" xmlns:num="clr-namespace:Bonsai.Numerics;assembly=Bonsai.Numerics" xmlns:p2="clr-namespace:Bonsai.Numerics.Distributions;assembly=Bonsai.Numerics" xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp" xmlns:p3="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" - xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -184,6 +184,143 @@ TimedTrial + + + + + Value.ChoiceCategory + + + NoChoice + + + + Source1 + + + + NoChoice + + + + + + + + + + + + + 0.5 + + + + LeftChoice + + + + Source1 + + + + LeftChoice + + + + + + + + + + + + + 0.7 + + + + RightChoice + + + + Source1 + + + + RightChoice + + + + + + + + + + + + + 0.3 + + + + + + + new ( + it as Choice +) + + + Seconds + + + + + + + + + 1000 + Seconds + Value.Choice + + + EventPlot + + + + Circle + 3 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + + + + true + None + + + Value.TrialCategory + + + + + + + + + TimedTrial + 1000 Seconds @@ -353,7 +490,7 @@ - true + false @@ -519,8 +656,8 @@ - true - false + false + true @@ -546,7 +683,7 @@ - PT0.606S + PT0.127S @@ -686,13 +823,37 @@ - + + + + + - + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 9007b01e5dec16cc24d094203facebdae025e48d Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 30 Jun 2026 10:52:36 +0100 Subject: [PATCH 004/116] Add extension class for trial categorization --- src/Extensions/CategorizeTrial.cs | 30 +++-------------------------- src/Extensions/CategorizedTrial.cs | 24 +++++++++++++++++++++++ src/test_behavior_visualizer.bonsai | 8 ++++---- 3 files changed, 31 insertions(+), 31 deletions(-) create mode 100644 src/Extensions/CategorizedTrial.cs diff --git a/src/Extensions/CategorizeTrial.cs b/src/Extensions/CategorizeTrial.cs index 2b134474..d9dadacc 100644 --- a/src/Extensions/CategorizeTrial.cs +++ b/src/Extensions/CategorizeTrial.cs @@ -11,8 +11,6 @@ [Combinator] [Description("")] [WorkflowElementCategory(ElementCategory.Transform)] -[XmlInclude(typeof(CategorizedTrial.Choice))] -[XmlInclude(typeof(CategorizedTrial.Category))] public class CategorizeTrial { public IObservable> Process(IObservable> source) @@ -24,7 +22,7 @@ public IObservable> Process(IObservable> Process(IObservable> Process(IObservable> Process(IObservable - false + true @@ -656,8 +656,8 @@ - false - true + true + false @@ -683,7 +683,7 @@ - PT0.127S + PT0.285S From 16069d27b9b115561697ddcd956dba94be048c77 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 30 Jun 2026 10:53:29 +0100 Subject: [PATCH 005/116] Update references to trial categories --- src/Extensions/CategorizeTrial.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Extensions/CategorizeTrial.cs b/src/Extensions/CategorizeTrial.cs index d9dadacc..c514c752 100644 --- a/src/Extensions/CategorizeTrial.cs +++ b/src/Extensions/CategorizeTrial.cs @@ -30,11 +30,11 @@ public IObservable> Process(IObservable> Process(IObservable> Process(IObservable> Process(IObservable Date: Tue, 30 Jun 2026 11:44:01 +0100 Subject: [PATCH 006/116] Another round of styling on behavior plot --- src/test_behavior_visualizer.bonsai | 1076 +++++++++++++++------------ 1 file changed, 586 insertions(+), 490 deletions(-) diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 4892ff9f..99483962 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -1,441 +1,94 @@  - - - Frame - - - Frame - - - EventPlot - true - - -1 - 150 - - NoTitle - AutoFit - RangeFit - - - EventPlot - - - Frame - - - ContinuousPlot - true - - -1 - 150 - - NoTitle - AutoFit - None - - - ContinuousPlot - - - - EventPlot - - - - - 0 - 1 - - - R - L - - West - None - - - - - ContinuousPlot - - - - - 0 - 1 - - - West - None - - - - LickLeft - - - Value - - - - 0.9 - - - - new(it as LickLeft) - - - Seconds - - - - - - 1000 - Item2 - Item1.LickLeft - - - EventPlot - - - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - LickRight - - - Value - - - - 0.1 - - - - new(it as LickRight) - - - Seconds - - - - - - 1000 - Item2 - Item1.LickRight - - - EventPlot - - - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - TimedTrial - - - - - - Value.ChoiceCategory - - - NoChoice + + Data - - Source1 + + + A + false + - - - NoChoice - + + + TimeBase - - - - - - - - - - - 0.5 - - - - LeftChoice - - - - Source1 + + LickLeft - - - LeftChoice - + + + S + false + - - - - - - - - - - - 0.7 - - - - RightChoice - - - - Source1 + + + TimeBase - - - RightChoice - - - - - - - - - - - - - 0.3 - - - - - - - new ( - it as Choice -) - - - Seconds - - - - - - - - - 1000 - Seconds - Value.Choice - - - EventPlot - - - - Circle - 3 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - 1 - 1 - - - - true - None - - - Value.TrialCategory - - - - - - - - - TimedTrial - - - 1000 - Seconds - Value.Trial.PRewardLeft - - - ContinuousPlot - - - - 1 - 0 - 0 - 1 - 2 - - - - true - None - - - 1000 - Seconds - Value.Trial.PRewardRight - - - ContinuousPlot - - - - 0 - 0 - 1 - 1 - 2 - - - - true - None - - - Data - - - - - A - false - - - - - TimeBase - - - LickLeft - - - - S - false - - - - - TimeBase - - - LickRight - - - - - - - - - 0.1 - 1 - - - - Random - - - - PT0S - PT0.01S - - - - - 0.01 - - - - - TimeBase - - - - 0 - 1 - - - - - 500 - - - - - 0.5 + + LickRight + + + + + + + + + 0.1 + 1 + + + + Random + + + + PT0S + PT0.01S + + + + + 0.01 + + + + + TimeBase + + + + 0 + 1 + + + + + 500 + + + + + 0.5 @@ -465,14 +118,14 @@ (it +1) * 0.5 - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -489,19 +142,19 @@ - - true + + true - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -510,8 +163,8 @@ - - + + @@ -542,14 +195,14 @@ (it +1) * 0.5 - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -573,14 +226,14 @@ - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -594,24 +247,24 @@ - - true + + false - - + + - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -671,7 +324,7 @@ Random - + TimeSpan.FromSeconds(it) @@ -683,7 +336,7 @@ - PT0.285S + PT0.792S @@ -791,69 +444,512 @@ + + + Frame + + + Frame + + + EventPlot + true + + -1 + 150 + + NoTitle + AutoFit + RangeFit + + + EventPlot + + + Frame + + + ContinuousPlot + true + + -1 + 150 + + NoTitle + AutoFit + None + + + ContinuousPlot + + + + EventPlot + + + + + 0 + 1 + + + R + L + + West + None + + + + + ContinuousPlot + + + + + 0 + 1 + + + West + None + + + + LickLeft + + + Value + + + + 0.9 + + + + new(it as LickLeft) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickLeft + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + LickRight + + + Value + + + + 0.1 + + + + new(it as LickRight) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickRight + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + TimedTrial + + + + + + Value.ChoiceCategory + + + NoChoice + + + + Source1 + + + + NoChoice + + + + + + + + + + + + + 0.5 + + + + LeftChoice + + + + Source1 + + + + LeftChoice + + + + + + + + + + + + + 0.85 + + + + RightChoice + + + + Source1 + + + + RightChoice + + + + + + + + + + + + + 0.15 + + + + + + + new ( + it as Choice +) + + + Seconds + + + + + + + + + 1000 + Seconds + Value.Choice + + + EventPlot + + + + Circle + 3 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + + + + true + None + + + Value.TrialCategory + + + LeftRewarded + + + + Source1 + + + + LeftRewarded + + + + + + + + + + + + + 0.8 + + + + RightRewarded + + + + Source1 + + + + RightRewarded + + + + + + + + + + + + + 0.2 + + + + + + + new ( + it as Choice +) + + + + + + + + + 1000 + Seconds + Value.Choice + + + EventPlot + + + + Circle + 3 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 1 + 1 + + + + true + None + + + TimedTrial + + + 1000 + Seconds + Value.Trial.PRewardLeft + + + ContinuousPlot + + + + 1 + 0 + 0 + 1 + 2 + + + + true + None + + + 1000 + Seconds + Value.Trial.PRewardRight + + + ContinuousPlot + + + + 0 + 0 + 1 + 1 + 2 + + + + true + None + - - + - + - + - + - - + + - - - + + + - - + + - - - + + + - - + - + - - + - - - - - - - - - - + + + + + + + + + + + + - + - - + + + - + + + + + + + + + + + + \ No newline at end of file From 90bf9c4f7ced5645b6ca76c28ccf3ba72811bfdc Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 30 Jun 2026 14:05:55 +0100 Subject: [PATCH 007/116] Add initial bias plot --- src/Extensions.csproj | 1 + src/test_behavior_visualizer.bonsai | 223 +++++++++++++++++++++++----- 2 files changed, 190 insertions(+), 34 deletions(-) diff --git a/src/Extensions.csproj b/src/Extensions.csproj index fd8959e5..8628665e 100644 --- a/src/Extensions.csproj +++ b/src/Extensions.csproj @@ -20,5 +20,6 @@ + \ No newline at end of file diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 99483962..0d2b69dd 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -60,6 +60,20 @@ Random + + + + + + + + -0.1 + 0.1 + + + + BiasRandom + PT0S @@ -143,7 +157,7 @@ - true + false @@ -309,8 +323,8 @@ - true - false + false + true @@ -336,7 +350,7 @@ - PT0.792S + PT0.768S @@ -384,63 +398,65 @@ - + - - + - + - + - + - - - + + - - + + + - - + + - + - - - - + + - - + + + + - - + - + + - - + + - - + + - - + + - + + + + @@ -876,6 +892,122 @@ true None + + Frame + + + BiasPlot + true + + -1 + 150 + + NoTitle + AutoFit + None + + + BiasPlot + + + + BiasPlot + + + + + -1 + 1 + + + R + L + + West + None + + + + TimedTrial + + + BiasRandom + + + + + + Item2 + + + + + + + it > 1 ? 1 : it + + + it < -1 ? -1 : it + + + Seconds + + + + + + + + + 1000 + Seconds + Value + + + BiasPlot + + + + 0 + 0 + 0 + 1 + 2 + + + + true + None + + + 1 + Seconds + Value + + + BiasPlot + + + + Circle + 5 + 0 + 1 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + + true + None + + @@ -950,6 +1082,29 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 6145c446a580e7c78e3eae8ee45b43b2e3af62cf Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 30 Jun 2026 14:29:22 +0100 Subject: [PATCH 008/116] Create behaviour visualizer extension --- src/Extensions/BehaviorVisualizer.bonsai | 573 +++++++++ src/test_behavior_visualizer.bonsai | 1340 ++++++++++++---------- 2 files changed, 1301 insertions(+), 612 deletions(-) create mode 100644 src/Extensions/BehaviorVisualizer.bonsai diff --git a/src/Extensions/BehaviorVisualizer.bonsai b/src/Extensions/BehaviorVisualizer.bonsai new file mode 100644 index 00000000..6be7917a --- /dev/null +++ b/src/Extensions/BehaviorVisualizer.bonsai @@ -0,0 +1,573 @@ + + + + + + + + + + + + BehaviorPlot + + + + + + + Frame + + + + + + Behavior1 + true + 1 + None + + 0 + 0 + + 0 + + + true + + + EventPlot + true + + -1 + 150 + + NoTitle + AutoFit + RangeFit + + + EventPlot + + + true + + + ContinuousPlot + true + + -1 + 150 + + NoTitle + AutoFit + None + + + ContinuousPlot + + + + EventPlot + + + + + 0 + 1 + + + R + L + + West + None + + + + + ContinuousPlot + + + + + 0 + 1 + + + West + None + + + + + + + LickLeft + + + Value + + + + 0.9 + + + + new(it as LickLeft) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickLeft + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + + + + LickRight + + + Value + + + + 0.1 + + + + new(it as LickRight) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickRight + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + + + + TimedTrial + + + + + + Value.ChoiceCategory + + + NoChoice + + + + Source1 + + + + NoChoice + + + + + + + + + + + + + 0.5 + + + + LeftChoice + + + + Source1 + + + + LeftChoice + + + + + + + + + + + + + 0.85 + + + + RightChoice + + + + Source1 + + + + RightChoice + + + + + + + + + + + + + 0.15 + + + + + + + new ( + it as Choice +) + + + Seconds + + + + + + + + + 1000 + Seconds + Value.Choice + + + EventPlot + + + + Circle + 3 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + + + + true + None + + + Value.TrialCategory + + + LeftRewarded + + + + Source1 + + + + LeftRewarded + + + + + + + + + + + + + 0.8 + + + + RightRewarded + + + + Source1 + + + + RightRewarded + + + + + + + + + + + + + 0.2 + + + + + + + new ( + it as Choice +) + + + + + + + + + 1000 + Seconds + Value.Choice + + + EventPlot + + + + Circle + 3 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 1 + 1 + + + + true + None + + + TimedTrial + + + 1000 + Seconds + Value.Trial.PRewardLeft + + + ContinuousPlot + + + + 1 + 0 + 0 + 1 + 2 + + + + true + None + + + 1000 + Seconds + Value.Trial.PRewardRight + + + ContinuousPlot + + + + 0 + 0 + 1 + 1 + 2 + + + + true + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 0d2b69dd..91b1771c 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -11,6 +11,7 @@ xmlns:p3="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" + xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" xmlns:implot="clr-namespace:Bonsai.ImPlot;assembly=Bonsai.ImPlot" xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -262,7 +263,7 @@ - false + true @@ -324,7 +325,7 @@ false - true + false @@ -350,7 +351,7 @@ - PT0.768S + PT0.641S @@ -464,334 +465,561 @@ Frame - - Frame - - - EventPlot - true - - -1 - 150 - - NoTitle - AutoFit - RangeFit - - - EventPlot - - - Frame - - - ContinuousPlot - true - - -1 - 150 - - NoTitle - AutoFit - None - - - ContinuousPlot - - - - EventPlot - - - - - 0 - 1 - - - R - L - - West - None - - - - - ContinuousPlot - - - - - 0 - 1 - - - West - None - - - - LickLeft - - - Value - - - - 0.9 - - - - new(it as LickLeft) - - - Seconds - - - - - - 1000 - Item2 - Item1.LickLeft - - - EventPlot - - - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - LickRight - - - Value - - - - 0.1 - - - - new(it as LickRight) - - - Seconds - - - - - - 1000 - Item2 - Item1.LickRight - - - EventPlot - - - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - TimedTrial - - - - - - Value.ChoiceCategory - - - NoChoice - - - - Source1 - - - - NoChoice - - - - - - - - - - - - - 0.5 - - - - LeftChoice - - - - Source1 - - - - LeftChoice - - - - - - - - - - - - - 0.85 - - - - RightChoice + + BehaviorPlot - - Source1 - - - - RightChoice - - - - - - - - - - - - - 0.15 - - - - - - - new ( + + + + + + + + BehaviorPlot + + + + + + + Frame + + + + + + Behavior1 + true + 1 + None + + 0 + 0 + + 0 + + + true + + + EventPlot + true + + -1 + 150 + + NoTitle + AutoFit + RangeFit + + + EventPlot + + + true + + + ContinuousPlot + true + + -1 + 150 + + NoTitle + AutoFit + None + + + ContinuousPlot + + + + EventPlot + + + + + 0 + 1 + + + R + L + + West + None + + + + + ContinuousPlot + + + + + 0 + 1 + + + West + None + + + + + + + LickLeft + + + Value + + + + 0.9 + + + + new(it as LickLeft) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickLeft + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + + + + LickRight + + + Value + + + + 0.1 + + + + new(it as LickRight) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickRight + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + + + + TimedTrial + + + + + + Value.ChoiceCategory + + + NoChoice + + + + Source1 + + + + NoChoice + + + + + + + + + + + + + 0.5 + + + + LeftChoice + + + + Source1 + + + + LeftChoice + + + + + + + + + + + + + 0.85 + + + + RightChoice + + + + Source1 + + + + RightChoice + + + + + + + + + + + + + 0.15 + + + + + + + new ( it as Choice ) - - - Seconds - - - - - - - - - 1000 - Seconds - Value.Choice - - - EventPlot - - - - Circle - 3 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - 1 - 1 - - - - true - None - - - Value.TrialCategory - - - LeftRewarded - - - - Source1 - - - - LeftRewarded - - - - - - - - - - - - - 0.8 - - - - RightRewarded - - - - Source1 - - - - RightRewarded - + + + Seconds + + + + + + + + + 1000 + Seconds + Value.Choice + + + EventPlot + + + + Circle + 3 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + + + + true + None + + + Value.TrialCategory + + + LeftRewarded + + + + Source1 + + + + LeftRewarded + + + + + + + + + + + + + 0.8 + + + + RightRewarded + + + + Source1 + + + + RightRewarded + + + + + + + + + + + + + 0.2 + + + + + + + new ( + it as Choice +) + + + + + + + + + 1000 + Seconds + Value.Choice + + + EventPlot + + + + Circle + 3 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 1 + 1 + + + + true + None + + + TimedTrial + + + 1000 + Seconds + Value.Trial.PRewardLeft + + + ContinuousPlot + + + + 1 + 0 + 0 + 1 + 2 + + + + true + None + + + 1000 + Seconds + Value.Trial.PRewardRight + + + ContinuousPlot + + + + 0 + 0 + 1 + 1 + 2 + + + + true + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -801,310 +1029,198 @@ - - - 0.2 - - - - - - - new ( - it as Choice -) - - - - - - - - - 1000 - Seconds - Value.Choice - - - EventPlot - - - - Circle - 3 - 0 - 1 - 0 - 1 - 0 - 1 - 0 - 1 - 1 - - - - true - None - - - TimedTrial - - - 1000 - Seconds - Value.Trial.PRewardLeft - - - ContinuousPlot - - - - 1 - 0 - 0 - 1 - 2 - - - - true - None - - - 1000 - Seconds - Value.Trial.PRewardRight - - - ContinuousPlot - - - - 0 - 0 - 1 - 1 - 2 - - - - true - None - - - Frame - - - BiasPlot - true - - -1 - 150 - - NoTitle - AutoFit - None - - - BiasPlot - - - - BiasPlot - - - - - -1 - 1 - - - R - L - - West - None - - - - TimedTrial - - - BiasRandom - - - - - - Item2 - - - - - - - it > 1 ? 1 : it - - - it < -1 ? -1 : it - - - Seconds - - - - - - - - - 1000 - Seconds - Value - - - BiasPlot - - - - 0 - 0 - 0 - 1 - 2 - - - - true - None - - - 1 - Seconds - Value - - - BiasPlot - - - - Circle - 5 - 0 - 1 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - + + + Frame + - - + + + BiasPlot true - None - + + -1 + 150 + + NoTitle + AutoFit + None + + + + + BiasPlot + + + + + + + + BiasPlot + + + + + + + -1 + 1 + + + R + L + + West + None + + + + + + TimedTrial + + + + + BiasRandom + + + + + + + + + + Item2 + + + + + + + + + + + + + it > 1 ? 1 : it + + + + + it < -1 ? -1 : it + + + + + Seconds + + + + + + + + + + + + + + + 1000 + Seconds + Value + + + + + BiasPlot + + + + + + 0 + 0 + 0 + 1 + 2 + + + + + + true + None + + + + + 1 + Seconds + Value + + + + + BiasPlot + + + + + + Circle + 5 + 0 + 1 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + + + + true + None + + - - + - - + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From ba6b85a44afcf5efca747b3bc63b4c7aa01365db Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 30 Jun 2026 14:39:36 +0100 Subject: [PATCH 009/116] workflow reordering --- src/test_behavior_visualizer.bonsai | 579 +--------------------------- 1 file changed, 10 insertions(+), 569 deletions(-) diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 91b1771c..18a6418a 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -11,14 +11,13 @@ xmlns:p3="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" - xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" xmlns:implot="clr-namespace:Bonsai.ImPlot;assembly=Bonsai.ImPlot" xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns="https://bonsai-rx.org/2018/workflow"> - Data + TrialData @@ -158,7 +157,7 @@ - false + true @@ -263,7 +262,7 @@ - true + false @@ -324,7 +323,7 @@ - false + true false @@ -351,7 +350,7 @@ - PT0.641S + PT0.874S @@ -465,569 +464,11 @@ Frame - - BehaviorPlot - - - - - - - - - - BehaviorPlot - - - - - - - Frame - - - - - - Behavior1 - true - 1 - None - - 0 - 0 - - 0 - - - true - - - EventPlot - true - - -1 - 150 - - NoTitle - AutoFit - RangeFit - - - EventPlot - - - true - - - ContinuousPlot - true - - -1 - 150 - - NoTitle - AutoFit - None - - - ContinuousPlot - - - - EventPlot - - - - - 0 - 1 - - - R - L - - West - None - - - - - ContinuousPlot - - - - - 0 - 1 - - - West - None - - - - - - - LickLeft - - - Value - - - - 0.9 - - - - new(it as LickLeft) - - - Seconds - - - - - - 1000 - Item2 - Item1.LickLeft - - - EventPlot - - - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - - - - LickRight - - - Value - - - - 0.1 - - - - new(it as LickRight) - - - Seconds - - - - - - 1000 - Item2 - Item1.LickRight - - - EventPlot - - - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - - - - TimedTrial - - - - - - Value.ChoiceCategory - - - NoChoice - - - - Source1 - - - - NoChoice - - - - - - - - - - - - - 0.5 - - - - LeftChoice - - - - Source1 - - - - LeftChoice - - - - - - - - - - - - - 0.85 - - - - RightChoice - - - - Source1 - - - - RightChoice - - - - - - - - - - - - - 0.15 - - - - - - - new ( - it as Choice -) - - - Seconds - - - - - - - - - 1000 - Seconds - Value.Choice - - - EventPlot - - - - Circle - 3 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - 1 - 1 - - - - true - None - - - Value.TrialCategory - - - LeftRewarded - - - - Source1 - - - - LeftRewarded - - - - - - - - - - - - - 0.8 - - - - RightRewarded - - - - Source1 - - - - RightRewarded - - - - - - - - - - - - - 0.2 - - - - - - - new ( - it as Choice -) - - - - - - - - - 1000 - Seconds - Value.Choice - - - EventPlot - - - - Circle - 3 - 0 - 1 - 0 - 1 - 0 - 1 - 0 - 1 - 1 - - - - true - None - - - TimedTrial - - - 1000 - Seconds - Value.Trial.PRewardLeft - - - ContinuousPlot - - - - 1 - 0 - 0 - 1 - 2 - - - - true - None - - - 1000 - Seconds - Value.Trial.PRewardRight - - - ContinuousPlot - - - - 0 - 0 - 1 - 1 - 2 - - - - true - None - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Behavior1 + LickLeft + LickRight + TimedTrial From f2d1222b2f6ec006f6defe92287f5ad57b0d226e Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 30 Jun 2026 15:35:52 +0100 Subject: [PATCH 010/116] Save visualizers as extensions --- src/Extensions/BehaviorVisualizer.bonsai | 3 +- src/Extensions/CameraPreviewVisualizer.bonsai | 749 +++++++++ src/test_behavior_visualizer.bonsai | 1491 ++++++++++++++++- 3 files changed, 2221 insertions(+), 22 deletions(-) create mode 100644 src/Extensions/CameraPreviewVisualizer.bonsai diff --git a/src/Extensions/BehaviorVisualizer.bonsai b/src/Extensions/BehaviorVisualizer.bonsai index 6be7917a..4d231097 100644 --- a/src/Extensions/BehaviorVisualizer.bonsai +++ b/src/Extensions/BehaviorVisualizer.bonsai @@ -16,6 +16,7 @@ + BehaviorPlot @@ -25,7 +26,7 @@ - Frame + Behavior diff --git a/src/Extensions/CameraPreviewVisualizer.bonsai b/src/Extensions/CameraPreviewVisualizer.bonsai new file mode 100644 index 00000000..a5aab501 --- /dev/null +++ b/src/Extensions/CameraPreviewVisualizer.bonsai @@ -0,0 +1,749 @@ + + + + + + Source1 + + + Key + + + + + + ToArray + + + + Source1 + + + + 1 + + + + List + + + List + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CameraPreview + + + + Source1 + + + Item1 + + + CameraList + + + Item2 + + + + + + CameraFeeds + + + + + + + Camera + + + true + 1 + None + + 0 + 0 + + 0 + + + Table + + + Table + + + true + + + CameraList + + + + + + + + SelectCameraStream + true + + Camera1 + Camera2 + + + + SelectedControllerCamera + + + Table + + + true + + + CurrentStream + + + Value + + + FlipState + + + + + + Flipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + Item1 + + + Item2 + + + + + + + + + Vertical + + + + NotFlipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + + + Item1 + + + + + + new ( + it.Size.Width / 2 as X, + it.Size.Height / 2 as Y +) + + + + + + + + + + 320 + 240 + + + + + + + + + Rotation + + + + + + + + + + 320 + 240 + + + 0 + 0 + + 0 + + 1 + 1 + + + + + + + + + + + 1,0,0;0,1,0 + Linear + + 0 + 0 + 0 + 0 + + + + + Frame + + + + Rgba + Repeat + Repeat + Linear + Linear + + + + + + + + + PreviewImage + true + + 320 + 320 + + + 0 + 0 + + + 1 + 1 + + + + Table + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + FlipHorizontal + true + Flip Horizontal + false + + + true + + + FlipVertical + true + Flip Vertical + false + + + + + + Horizontal + + + + Source1 + + + Item1 + + + Item2 + + + + + + + + + + + + + + + + + + + + + + 1 + + + + Vertical + + + + Source1 + + + Item1 + + + + Item2 + + + + + + + + + + + + + + + + + + + + + 0 + + + + Both + + + + Source1 + + + + + + + + + + + + + -1 + + + + Neither + + + + Source1 + + + Item1 + + + + Item2 + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + FlipState + + + Table + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + RotateCCW + true + << + + + + 90 + + + + true + + + RotateCW + true + >> + + + + -90 + + + + + 0 + + + + + + + + + + + Rotation + + + SelectedControllerCamera + + + CameraList + + + + 0 + + + + + + + GetStream + + + + Source1 + + + + 1 + + + + Camera + + + CameraFeeds + + + Camera + + + + + + + + + + + Source1 + + + Key + + + + + + + Camera2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CurrentStream + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 18a6418a..35ae5ee2 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -10,9 +10,13 @@ xmlns:p2="clr-namespace:;assembly=Extensions" xmlns:p3="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" + xmlns:cv="clr-namespace:Bonsai.Vision;assembly=Bonsai.Vision" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" + xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" xmlns:implot="clr-namespace:Bonsai.ImPlot;assembly=Bonsai.ImPlot" xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" + xmlns:p4="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" + xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -157,7 +161,7 @@ - true + false @@ -262,7 +266,7 @@ - false + true @@ -323,7 +327,7 @@ - true + false false @@ -350,7 +354,7 @@ - PT0.874S + PT0.658S @@ -460,15 +464,1454 @@ + + CameraData + + + + + 0 + + + + + CameraFeed + + + + Camera1 + + + + CameraFeed + + + TimeBase + + + + + + + + + + + + + + + + + + + + + + + Camera1 + + + + + + + Camera2 + + + + CameraFeed + + + TimeBase + + + + + + + + + + + + + + + + + + + + + + + Camera2 + + + + + + + + + + Item2 + Item1 + + + TriggeredCamerasStream + + + + + + + + + + + + + + + + + + + Frame - - Behavior1 - LickLeft - LickRight - TimedTrial + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + Behavior + + + true + + + Camera + + + BehaviorVisualizer + + + + + + + + + + + BehaviorPlot + + + + + + + Behavior + + + + + + Behavior1 + true + 1 + None + + 0 + 0 + + 0 + + + true + + + EventPlot + true + + -1 + 150 + + NoTitle + AutoFit + RangeFit + + + EventPlot + + + true + + + ContinuousPlot + true + + -1 + 150 + + NoTitle + AutoFit + None + + + ContinuousPlot + + + + EventPlot + + + + + 0 + 1 + + + R + L + + West + None + + + + + ContinuousPlot + + + + + 0 + 1 + + + West + None + + + + + + + LickLeft + + + Value + + + + 0.9 + + + + new(it as LickLeft) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickLeft + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + + + + LickRight + + + Value + + + + 0.1 + + + + new(it as LickRight) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickRight + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + + + + TimedTrial + + + + + + Value.ChoiceCategory + + + NoChoice + + + + Source1 + + + + NoChoice + + + + + + + + + + + + + 0.5 + + + + LeftChoice + + + + Source1 + + + + LeftChoice + + + + + + + + + + + + + 0.85 + + + + RightChoice + + + + Source1 + + + + RightChoice + + + + + + + + + + + + + 0.15 + + + + + + + new ( + it as Choice +) + + + Seconds + + + + + + + + + 1000 + Seconds + Value.Choice + + + EventPlot + + + + Circle + 3 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + + + + true + None + + + Value.TrialCategory + + + LeftRewarded + + + + Source1 + + + + LeftRewarded + + + + + + + + + + + + + 0.8 + + + + RightRewarded + + + + Source1 + + + + RightRewarded + + + + + + + + + + + + + 0.2 + + + + + + + new ( + it as Choice +) + + + + + + + + + 1000 + Seconds + Value.Choice + + + EventPlot + + + + Circle + 3 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 1 + 1 + + + + true + None + + + TimedTrial + + + 1000 + Seconds + Value.Trial.PRewardLeft + + + ContinuousPlot + + + + 1 + 0 + 0 + 1 + 2 + + + + true + None + + + 1000 + Seconds + Value.Trial.PRewardRight + + + ContinuousPlot + + + + 0 + 0 + 1 + 1 + 2 + + + + true + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TriggeredCamerasStream + + + CameraPreviewVisualizer + + + + Source1 + + + Key + + + + + + ToArray + + + + Source1 + + + + 1 + + + + List + + + List + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CameraPreview + + + + Source1 + + + Item1 + + + CameraList + + + Item2 + + + + + + CameraFeeds + + + + + + + Camera + + + true + 1 + None + + 0 + 0 + + 0 + + + Table + + + Table + + + true + + + CameraList + + + + + + + + SelectCameraStream + true + + Camera1 + Camera2 + + + + SelectedControllerCamera + + + Table + + + true + + + CurrentStream + + + Value + + + FlipState + + + + + + Flipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + Item1 + + + Item2 + + + + + + + + + Vertical + + + + NotFlipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + + + Item1 + + + + + + new ( + it.Size.Width / 2 as X, + it.Size.Height / 2 as Y +) + + + + + + + + + + 320 + 240 + + + + + + + + + Rotation + + + + + + + + + + 320 + 240 + + + 0 + 0 + + 0 + + 1 + 1 + + + + + + + + + + + 1,0,0;0,1,0 + Linear + + 0 + 0 + 0 + 0 + + + + + Frame + + + + Rgba + Repeat + Repeat + Linear + Linear + + + + + + + + + PreviewImage + true + + 320 + 320 + + + 0 + 0 + + + 1 + 1 + + + + Table + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + FlipHorizontal + true + Flip Horizontal + false + + + true + + + FlipVertical + true + Flip Vertical + false + + + + + + Horizontal + + + + Source1 + + + Item1 + + + Item2 + + + + + + + + + + + + + + + + + + + + + + 1 + + + + Vertical + + + + Source1 + + + Item1 + + + + Item2 + + + + + + + + + + + + + + + + + + + + + 0 + + + + Both + + + + Source1 + + + + + + + + + + + + + -1 + + + + Neither + + + + Source1 + + + Item1 + + + + Item2 + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + FlipState + + + Table + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + RotateCCW + true + << + + + + 90 + + + + true + + + RotateCW + true + >> + + + + -90 + + + + + 0 + + + + + + + + + + + Rotation + + + SelectedControllerCamera + + + CameraList + + + + 0 + + + + + + + GetStream + + + + Source1 + + + + 1 + + + + Camera + + + CameraFeeds + + + Camera + + + + + + + + + + + Source1 + + + Key + + + + + + + Camera2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CurrentStream + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -638,30 +2081,36 @@ - + + + - - - - + - - - - + + + - - - + + + + + + + + + + + \ No newline at end of file From 217ad48ed83500bc93da1f81aff9add6cc5712fc Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 30 Jun 2026 16:39:26 +0100 Subject: [PATCH 011/116] Prototype metadata visualizer --- src/Extensions/CameraPreviewVisualizer.bonsai | 4 +- src/test_behavior_visualizer.bonsai | 1553 +++-------------- 2 files changed, 258 insertions(+), 1299 deletions(-) diff --git a/src/Extensions/CameraPreviewVisualizer.bonsai b/src/Extensions/CameraPreviewVisualizer.bonsai index a5aab501..13b3ccc1 100644 --- a/src/Extensions/CameraPreviewVisualizer.bonsai +++ b/src/Extensions/CameraPreviewVisualizer.bonsai @@ -288,7 +288,7 @@ - Frame + Table @@ -605,7 +605,7 @@ - Camera2 + Camera1 diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 35ae5ee2..d1c50be5 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -15,8 +15,6 @@ xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" xmlns:implot="clr-namespace:Bonsai.ImPlot;assembly=Bonsai.ImPlot" xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" - xmlns:p4="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" - xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -328,7 +326,7 @@ false - false + true @@ -354,7 +352,7 @@ - PT0.658S + PT0.817S @@ -581,9 +579,25 @@ + + true + 1 + None + + 0 + 0 + + 0 + Frame + + Frame + + + true + true 2 @@ -606,1313 +620,248 @@ Camera - - BehaviorVisualizer - - - - - - - - - - - BehaviorPlot - - - - - - - Behavior - - - - - - Behavior1 - true - 1 - None - - 0 - 0 - - 0 - - - true - - - EventPlot - true - - -1 - 150 - - NoTitle - AutoFit - RangeFit - - - EventPlot - - - true - - - ContinuousPlot - true - - -1 - 150 - - NoTitle - AutoFit - None - - - ContinuousPlot - - - - EventPlot - - - - - 0 - 1 - - - R - L - - West - None - - - - - ContinuousPlot - - - - - 0 - 1 - - - West - None - - - - - - - LickLeft - - - Value - - - - 0.9 - - - - new(it as LickLeft) - - - Seconds - - - - - - 1000 - Item2 - Item1.LickLeft - - - EventPlot - - - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - - - - LickRight - - - Value - - - - 0.1 - - - - new(it as LickRight) - - - Seconds - - - - - - 1000 - Item2 - Item1.LickRight - - - EventPlot - - - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - - - - TimedTrial - - - - - - Value.ChoiceCategory - - - NoChoice - - - - Source1 - - - - NoChoice - - - - - - - - - - - - - 0.5 - - - - LeftChoice - - - - Source1 - - - - LeftChoice - - - - - - - - - - - - - 0.85 - - - - RightChoice - - - - Source1 - - - - RightChoice - - - - - - - - - - - - - 0.15 - - - - - - - new ( - it as Choice -) - - - Seconds - - - - - - - - - 1000 - Seconds - Value.Choice - - - EventPlot - - - - Circle - 3 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - 1 - 1 - - - - true - None - - - Value.TrialCategory - - - LeftRewarded - - - - Source1 - - - - LeftRewarded - - - - - - - - - - - - - 0.8 - - - - RightRewarded - - - - Source1 - - - - RightRewarded - - - - - - - - - - - - - 0.2 - - - - - - - new ( - it as Choice -) - - - - - - - - - 1000 - Seconds - Value.Choice - - - EventPlot - - - - Circle - 3 - 0 - 1 - 0 - 1 - 0 - 1 - 0 - 1 - 1 - - - - true - None - - - TimedTrial - - - 1000 - Seconds - Value.Trial.PRewardLeft - - - ContinuousPlot - - - - 1 - 0 - 0 - 1 - 2 - - - - true - None - - - 1000 - Seconds - Value.Trial.PRewardRight - - - ContinuousPlot - - - - 0 - 0 - 1 - 1 - 2 - - - - true - None - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Frame + + + true + + + Metadata + + + Behavior1 + LickLeft + LickRight + TimedTrial + Behavior TriggeredCamerasStream - - CameraPreviewVisualizer + + Camera + + + + Expo + + + + + 1 + + + + + + + + + + + + + 0.13.5 + 0.13.5 + Task6 + 0001-01-01T00:00:00.0000000+00:00 + Stage1 + Plimbo + false + false + + + + MetadataVisualizer Source1 + + CurrentMetadata + + + + + + Metadata + + + true + 7 + None + + 0 + 0 + + 0 + + + true + + + CurrentMetadata + - Key + Experimenter - - + + + 0 + - - ToArray - - - - Source1 - - - - 1 - - - - List - - - List - - - - - - - - - - - - - - - - - + + + + - - + + true + Expo - - + + true - - + + CurrentMetadata - - CameraPreview - - - - Source1 - - - Item1 - - - CameraList - - - Item2 - - - - - - CameraFeeds - - - - - - - Camera - - - true - 1 - None - - 0 - 0 - - 0 - - - Table - - - Table - - - true - - - CameraList - - - - - - - - SelectCameraStream - true - - Camera1 - Camera2 - - - - SelectedControllerCamera - - - Table - - - true - - - CurrentStream - - - Value - - - FlipState - - - - - - Flipped - - - - Source1 - - - Item2 - - - - 2 - - - - - - - - - - - - - Item1 - - - Item2 - - - - - - - - - Vertical - - - - NotFlipped - - - - Source1 - - - Item2 - - - - 2 - - - - - - - - - - - - - - - Item1 - - - - - - new ( - it.Size.Width / 2 as X, - it.Size.Height / 2 as Y -) - - - - - - - - - - 320 - 240 - - - - - - - - - Rotation - - - - - - - - - - 320 - 240 - - - 0 - 0 - - 0 - - 1 - 1 - - - - - - - - - - - 1,0,0;0,1,0 - Linear - - 0 - 0 - 0 - 0 - - - - - Frame - - - - Rgba - Repeat - Repeat - Linear - Linear - - - - - - - - - PreviewImage - true - - 320 - 320 - - - 0 - 0 - - - 1 - 1 - - - - Table - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - FlipHorizontal - true - Flip Horizontal - false - - - true - - - FlipVertical - true - Flip Vertical - false - - - - - - Horizontal - - - - Source1 - - - Item1 - - - Item2 - - - - - - - - - - - - - - - - - - - - - - 1 - - - - Vertical - - - - Source1 - - - Item1 - - - - Item2 - - - - - - - - - - - - - - - - - - - - - 0 - - - - Both - - - - Source1 - - - - - - - - - - - - - -1 - - - - Neither - - - - Source1 - - - Item1 - - - - Item2 - - - - - - - - - - - - - - - - - - - - - - - 2 - - - - - - - FlipState - - - Table - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - RotateCCW - true - << - - - - 90 - - - - true - - - RotateCW - true - >> - - - - -90 - - - - - 0 - - - - - - - - - - - Rotation - - - SelectedControllerCamera - - - CameraList - - - - 0 - - - - - - - GetStream - - - - Source1 - - - - 1 - - - - Camera - - - CameraFeeds - - - Camera - - - - - - - - - - - Source1 - - - Key - - - - - - - Camera2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CurrentStream - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Subject - - + + + + + + + true + Plimbo + + + true + + + CurrentMetadata + + + SessionName + + + + + + + + true + Stage1 + + + true + + + CurrentMetadata + + + Experiment + + + + + + + + true + Task6 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Habituation + + + true + + + Habituation + true + None + 0 + 0 + 0 + + + true + + + true + START + + + true + + + true + STOP - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Frame @@ -2083,34 +1032,44 @@ - - + + + - - - - + + - - - - + + - - - + + + + + + + + + + + + + + + + \ No newline at end of file From 764c226c763d227ef5b64372874f6bf8d0ba2009 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 30 Jun 2026 16:57:03 +0100 Subject: [PATCH 012/116] Fix ordering and add table outline styling --- src/test_behavior_visualizer.bonsai | 106 +++++++++++++++++----------- 1 file changed, 64 insertions(+), 42 deletions(-) diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index d1c50be5..4b60aba8 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -264,7 +264,7 @@ - true + false @@ -326,7 +326,7 @@ false - true + false @@ -352,7 +352,7 @@ - PT0.817S + PT0.951S @@ -601,7 +601,7 @@ true 2 - None + Borders 0 0 @@ -620,12 +620,22 @@ Camera - - Frame + + true + + true + 1 + Borders + + 0 + 0 + + 0 + Metadata @@ -688,6 +698,9 @@ Metadata + + true + true 7 @@ -806,6 +819,9 @@ 0 0 + + + true @@ -826,36 +842,39 @@ - - - - - - - - + + + + + + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + + + + @@ -1033,43 +1052,46 @@ + + - + - - + + - + - + - - - - + + + + - - - + + + - + - + + \ No newline at end of file From e4c8a2906abd50640f7e73cd080a125793bc237c Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 1 Jul 2026 09:53:22 +0100 Subject: [PATCH 013/116] Integrate bias visualizer --- src/Extensions/BiasVisualizer.bonsai | 283 +++++++++ src/Extensions/PlotStyling.cs | 8 + src/test_behavior_visualizer.bonsai | 369 ++++------- src/test_bias_visualizer.bonsai | 903 +++++++++++++++++++++++++++ 4 files changed, 1326 insertions(+), 237 deletions(-) create mode 100644 src/Extensions/BiasVisualizer.bonsai create mode 100644 src/test_bias_visualizer.bonsai diff --git a/src/Extensions/BiasVisualizer.bonsai b/src/Extensions/BiasVisualizer.bonsai new file mode 100644 index 00000000..4753cce7 --- /dev/null +++ b/src/Extensions/BiasVisualizer.bonsai @@ -0,0 +1,283 @@ + + + + + + + + + + BiasVisualizer + + + + + + + Frame + + + BiasPlot + true + + -1 + 150 + + NoTitle + AutoFit + None + + + BiasPlot + + + + BiasPlot + + + + + -1 + 1 + + + R + L + + West + None + 1.1 + -1.1 + + + + + + + TimedBias + + + 1000 + Seconds + Value.Bias + + + BiasPlot + + + + 0 + 0 + 0 + 1 + 2 + + + + true + None + + + 1 + Seconds + Value.Bias + + + BiasPlot + + + + Circle + 5 + 0 + 1 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + + true + None + + + + Value.Bias + + + BiasPlot + + + {0:N2} + it + + + + + + + + Seconds + + + + + + + + + + + + + + true + 0.86 + 38.60000000000089 + 0.861054598987593 + + 0 + -10 + + None + + + + + 1 + + + + new (it as LeftBias) + + + + + + + + + 1000 + Seconds + Value.LeftBias + + + BiasPlot + + + + 1 + 0 + 0 + 0.7 + 1 + + + + true + None + + + + -1 + + + + new (it as RightBias) + + + + + + + + + 1000 + Seconds + Value.RightBias + + + BiasPlot + + + + 0 + 0 + 1 + 0.7 + 1 + + + + true + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Extensions/PlotStyling.cs b/src/Extensions/PlotStyling.cs index 860c1488..9761c1c2 100644 --- a/src/Extensions/PlotStyling.cs +++ b/src/Extensions/PlotStyling.cs @@ -16,6 +16,8 @@ public class PlotStyling public string[] TickLabels {get; set;} public ImPlotLocation ImPlotLocationFlags {get; set;} public ImPlotLegendFlags ImPlotLegendFlags {get; set;} + public double? YAxisMax {get; set;} + public double? YAxisMin {get; set;} public unsafe IObservable Process(IObservable source) { @@ -34,6 +36,12 @@ public unsafe IObservable Process(IObservable source) ImPlot.SetupAxisTicks(ImAxis.Y1, ref TickPositions[0], TickPositions.Count()); } } + + if (YAxisMax != null && YAxisMin != null) + { + ImPlot.SetupAxisLimits(ImAxis.Y1, (double)YAxisMax, (double)YAxisMin, ImPlotCond.Always); + } + ImPlot.SetupLegend(ImPlotLocationFlags, ImPlotLegendFlags); observer.OnNext(value); }, diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 4b60aba8..4e283254 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -3,18 +3,16 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wie="clr-namespace:Bonsai.Windows.Input;assembly=Bonsai.Windows.Input" xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" - xmlns:num="clr-namespace:Bonsai.Numerics;assembly=Bonsai.Numerics" xmlns:p1="clr-namespace:Bonsai.Numerics.Distributions;assembly=Bonsai.Numerics" - xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" + xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" + xmlns:num="clr-namespace:Bonsai.Numerics;assembly=Bonsai.Numerics" + xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp" xmlns:p2="clr-namespace:;assembly=Extensions" xmlns:p3="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" - xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" xmlns:cv="clr-namespace:Bonsai.Vision;assembly=Bonsai.Vision" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" - xmlns:implot="clr-namespace:Bonsai.ImPlot;assembly=Bonsai.ImPlot" - xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -35,6 +33,43 @@ LickLeft + + TimedTrial + + + BiasRandom + + + + + + Item2 + + + + + + + it > 1 ? 1 : it + + + it < -1 ? -1 : it + + + new (it as Bias) + + + Seconds + + + + + + + + + TimedBias + S @@ -352,7 +387,7 @@ - PT0.951S + PT0.957S @@ -393,72 +428,85 @@ - - + + + + + - + + - + - - - - + - - + - + - - + - - + + - + - + - - - - - + + + + - + - - - + + - - - - - - + + + + + + + + - + - - + + + - + + + + + + + + + + + + + + @@ -611,12 +659,34 @@ true + + true + 1 + None + + 0 + 0 + + 0 + + + true + Behavior true + + Bias + + + + + + true + Camera @@ -646,12 +716,19 @@ TimedTrial Behavior + + Bias + TimedBias + TriggeredCamerasStream Camera + + Camera + Expo @@ -881,217 +958,35 @@ - - - Frame - - - - - BiasPlot - true - - -1 - 150 - - NoTitle - AutoFit - None - - - - - BiasPlot - - - - - - - - BiasPlot - - - - - - - -1 - 1 - - - R - L - - West - None - - - - - - TimedTrial - - - - - BiasRandom - - - - - - - - - - Item2 - - - - - - - - - - - - - it > 1 ? 1 : it - - - - - it < -1 ? -1 : it - - - - - Seconds - - - - - - - - - - - - - - - 1000 - Seconds - Value - - - - - BiasPlot - - - - - - 0 - 0 - 0 - 1 - 2 - - - - - - true - None - - - - - 1 - Seconds - Value - - - - - BiasPlot - - - - - - Circle - 5 - 0 - 1 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - - - - true - None - - - - + - + + - - - - + + + + + + + - - - - + + - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/test_bias_visualizer.bonsai b/src/test_bias_visualizer.bonsai new file mode 100644 index 00000000..47115795 --- /dev/null +++ b/src/test_bias_visualizer.bonsai @@ -0,0 +1,903 @@ + + + + + + + Frame + + + CameraData + + + + + 0 + + + + + CameraFeed + + + + Camera1 + + + + CameraFeed + + + TimeBase + + + + + + + + + + + + + + + + + + + + + + + Camera1 + + + + + + + Camera2 + + + + CameraFeed + + + TimeBase + + + + + + + + + + + + + + + + + + + + + + + Camera2 + + + + + + + + + + Item2 + Item1 + + + TriggeredCamerasStream + + + + + + + + + + + + + + + + + + + + + TrialData + + + + + A + false + + + + + TimeBase + + + LickLeft + + + + S + false + + + + + TimeBase + + + LickRight + + + + + + + + + 0.1 + 1 + + + + Random + + + + + + + + + -0.1 + 0.1 + + + + BiasRandom + + + + PT0S + PT0.01S + + + + + 0.01 + + + + + TimeBase + + + + 0 + 1 + + + + + 500 + + + + + 0.5 + + + + + 0 + 500 + + + + + 0 + 1 + 0 + 0.05 + Linear + + + + + 3.14 + + + + + + + (it +1) * 0.5 + + + + 0 + 1 + + + + + 500 + + + + + 0.5 + + + + it + + + + + + + + + true + + + + + 0 + 1 + + + + + 500 + + + + + 0.9 + + + + + + + + + + + + Item3 ? Item2 : Item1 + + + + 0 + 500 + + + + + 0 + 1 + 0 + 0.05 + Linear + + + + + + + (it +1) * 0.5 + + + + 0 + 1 + + + + + 500 + + + + + 0.5 + + + + + + + + + + + + + + + + + + + + 0 + 1 + + + + + 500 + + + + + 0.5 + + + + + + + + + + true + + + + + + + + + + 0 + 1 + + + + + 500 + + + + + 0.05 + + + + + + + Item3 ? Item1 : Item2 + + + + + + Item2 + + + + + + + + + 0.59164587077011477 + 0.40913708100521279 + 5 + 0 + 5 + 0.5 + 5 + + 0 + + + + + + + + + + + true + + + + SampleTrial + + + + Source1 + + + Random + + + + + + TimeSpan.FromSeconds(it) + + + + + + + + + PT0.372S + + + + + 1 + + + + + + + + + + + + + + + + + + + + TimeBase + + + + + + + + + TimedTrial + + + TimedTrial + + + BiasRandom + + + + + + Item2 + + + + + + + it > 1 ? 1 : it + + + it < -1 ? -1 : it + + + new (it as Bias) + + + Seconds + + + + + + + + + TimedBias + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + BiasPlot + + + + + + + Frame + + + BiasPlot + true + + -1 + 150 + + NoTitle + AutoFit + None + + + BiasPlot + + + + BiasPlot + + + + + -1 + 1 + + + R + L + + West + None + 1.1 + -1.1 + + + + + + + TimedBias + + + 1000 + Seconds + Value.Bias + + + BiasPlot + + + + 0 + 0 + 0 + 1 + 2 + + + + true + None + + + 1 + Seconds + Value.Bias + + + BiasPlot + + + + Circle + 5 + 0 + 1 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + + true + None + + + + Value.Bias + + + BiasPlot + + + {0:N2} + it + + + + + + + + Seconds + + + + + + + + + + + + + + true + 0.26 + 9.6599999999998385 + 0.26182802890512547 + + 0 + -10 + + None + + + + + 1 + + + + new (it as LeftBias) + + + + + + + + + 1000 + Seconds + Value.LeftBias + + + BiasPlot + + + + 1 + 0 + 0 + 0.7 + 1 + + + + true + None + + + + -1 + + + + new (it as RightBias) + + + + + + + + + 1000 + Seconds + Value.RightBias + + + BiasPlot + + + + 0 + 0 + 1 + 0.7 + 1 + + + + true + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 59acda96ed895bd1179400d8abf598cc43dc9a93 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 1 Jul 2026 10:30:14 +0100 Subject: [PATCH 014/116] Remove redundant choice visualizer Switched to time-based visualization so trial-based no longer needed --- .../TrialChoiceOutcomeVisualizer.cs | 370 ------------------ src/test_behavior_visualizer.bonsai | 2 +- src/test_bias_visualizer.bonsai | 276 +------------ 3 files changed, 8 insertions(+), 640 deletions(-) delete mode 100644 src/Extensions/TrialChoiceOutcomeVisualizer.cs diff --git a/src/Extensions/TrialChoiceOutcomeVisualizer.cs b/src/Extensions/TrialChoiceOutcomeVisualizer.cs deleted file mode 100644 index 2fd82436..00000000 --- a/src/Extensions/TrialChoiceOutcomeVisualizer.cs +++ /dev/null @@ -1,370 +0,0 @@ -using AindDynamicForagingDataSchema; -using Bonsai; -using Hexa.NET.ImPlot; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Numerics; -using System.Reactive; -using System.Linq; -using System.Reactive.Linq; - -[Combinator] -[Description("Draws a progress bar showing a value between 0 and 1.")] -public class TrialChoiceOutcomeVisualizer -{ - public bool Visible {get; set;} - public List TrialOutcomes {get; set;} - public float MarkerSize {get; set;} - public float MarkerWeight {get; set;} - public float TopPlotHeight {get; set;} - public float BottomPlotHeight {get; set;} - public float RollingLineThickness {get; set;} - public int RollingWindowSize {get; set;} - - public IObservable Process(IObservable source) - { - return Observable.Create(observer => - { - var sourceObserver = Observer.Create( - value => - { - var trialIndices = CreateTrialIndices(TrialOutcomes.Count); - var choiceValues = ExtractChoiceValues(TrialOutcomes); - var rewardValues = ExtractRewardValues(TrialOutcomes); - var finishedTrialValues = ExtractFinishedTrialValues(TrialOutcomes); - var rollingChoiceAvg = ComputeRollingAverage(choiceValues, RollingWindowSize); - var rollingRewardRate = ComputeRollingAverage(rewardValues, RollingWindowSize); - var rollingFinishedRate = ComputeRollingAverage(finishedTrialValues.Select(v => (float?)v).ToArray(), RollingWindowSize); - // Categorize trials - List rightChoiceX; - List leftChoiceX; - List rightRewardedX; - List rightUnrewardedX; - List leftRewardedX; - List leftUnrewardedX; - List noChoiceX; - List rightRewardedAutoX; - List rightUnrewardedAutoX; - List leftRewardedAutoX; - List leftUnrewardedAutoX; - - CategorizeTrials(TrialOutcomes, - out rightChoiceX, - out leftChoiceX, - out rightRewardedX, - out rightUnrewardedX, - out leftRewardedX, - out leftUnrewardedX, - out noChoiceX, - out rightRewardedAutoX, - out rightUnrewardedAutoX, - out leftRewardedAutoX, - out leftUnrewardedAutoX - ); - - // Extract probability traces - var pRewardLeft = ExtractPRewardLeft(TrialOutcomes); - var pRewardRight = ExtractPRewardRight(TrialOutcomes); - - if (Visible) - { - if (ImPlot.BeginPlot("Trial Outcomes", new Vector2(-1, TopPlotHeight), ImPlotFlags.NoTitle)) - { - double[] tickPositions = new double[] {0, 1}; - ImPlot.SetupAxisTicks(ImAxis.Y1, ref tickPositions[0], 2, new string[] {"R", "L"}); - ImPlot.SetupAxisLimits(ImAxis.Y1, -0.5f, 1.5f); - ImPlot.SetupLegend(ImPlotLocation.East, ImPlotLegendFlags.Outside); - - // plot left choices - ScatterHorizontalSeries("Left Choice", leftChoiceX.ToArray(), 1.2f, ImPlotMarker.Circle, MarkerSize, MarkerWeight, new Vector4(0, 1, 0, 0), new Vector4(0, 0.7f, 0, 1)); - - // plot left rewarded choices - ScatterHorizontalSeries("Left Rewarded", leftRewardedX.ToArray(), 1f, ImPlotMarker.Circle, MarkerSize, MarkerWeight, new Vector4(0, 1, 0, 1), new Vector4(0, 0.7f, 0, 1)); - - // plot right choices - ScatterHorizontalSeries("Right Choice", rightChoiceX.ToArray(), -0.2f, ImPlotMarker.Circle, MarkerSize, MarkerWeight, new Vector4(0, 1, 0, 0), new Vector4(0, 0.7f, 0, 1)); - - // plot right rewrded choices - ScatterHorizontalSeries("Right Rewarded", rightRewardedX.ToArray(), 0f, ImPlotMarker.Circle, MarkerSize, MarkerWeight, new Vector4(0, 1, 0, 1), new Vector4(0, 0.7f, 0, 1)); - - // plot no choice - ScatterHorizontalSeries("No Choice", noChoiceX.ToArray(), 0.5f, ImPlotMarker.Square, MarkerSize, MarkerWeight, new Vector4(0, 0, 0, 0.2f), new Vector4(0, 0, 0, 0.2f)); - - ImPlot.EndPlot(); - } - if (ImPlot.BeginPlot("Trial History", new Vector2(-1, BottomPlotHeight), ImPlotFlags.NoTitle)) - { - double[] tickPositions = new double[] {0, 1}; - ImPlot.SetupAxisTicks(ImAxis.Y1, ref tickPositions[0], 2); - ImPlot.SetupAxisLimits(ImAxis.Y1, -0.5f, 1.5f); - ImPlot.SetupLegend(ImPlotLocation.East, ImPlotLegendFlags.Outside); - - PlotRollingLine("pL", trialIndices, pRewardLeft, new Vector4(1, 0, 0, 1), RollingLineThickness); - PlotRollingLine("pR", trialIndices, pRewardRight, new Vector4(0, 0, 1, 1), RollingLineThickness); - - PlotRollingLine("Choice Fraction", trialIndices, rollingChoiceAvg, new Vector4(0, 0, 0, 1), RollingLineThickness); - PlotRollingLine("Reward Rate", trialIndices, rollingRewardRate, new Vector4(0, 1, 0, 1), RollingLineThickness); - PlotRollingLine("Finished Rate", trialIndices, rollingFinishedRate, new Vector4(0, 0.5f, 0.5f, 1), RollingLineThickness); - - ImPlot.EndPlot(); - } - observer.OnNext(value); - } - }, - observer.OnError, - observer.OnCompleted); - return source.SubscribeSafe(sourceObserver); - }); - } - - private void ScatterHorizontalSeries(string label, float[] values, float ySet, ImPlotMarker markerType, float size, float weight, Vector4 fillColor, Vector4 outlineColor) - { - float[] ys = new float[values.Length]; - for (int i = 0; i < values.Length; i++) - { - ys[i] = ySet; - } - - ImPlot.SetNextMarkerStyle(markerType, size, fillColor, weight, outlineColor); - ImPlot.PlotScatter(label, ref values[0], ref ys[0], values.Length); - } - - /// - /// Plots a line for rolling averages. - /// - private static void PlotRollingLine( - string label, - float[] xValues, - float[] yValues, - Vector4 color, - float lineThickness) - { - if (xValues.Length == 0) return; - - ImPlot.SetNextLineStyle(color, lineThickness); - ImPlot.PlotLine(label, ref xValues[0], ref yValues[0], xValues.Length); - } - - /// - /// Creates an array of trial indices for x-axis plotting. - /// - private static float[] CreateTrialIndices(int count) - { - var indices = new float[count]; - for (int i = 0; i < count; i++) - { - indices[i] = i; - } - return indices; - } - - /// - /// Categorizes trials and collects their x positions. - /// - private static void CategorizeTrials( - List trialList, - out List rightChoiceX, - out List leftChoiceX, - out List rightRewardedX, - out List rightUnrewardedX, - out List leftRewardedX, - out List leftUnrewardedX, - out List noChoiceX, - out List rightRewardedAutoX, - out List rightUnrewardedAutoX, - out List leftRewardedAutoX, - out List leftUnrewardedAutoX) - { - rightChoiceX = new List(); - leftChoiceX = new List(); - rightRewardedX = new List(); - rightUnrewardedX = new List(); - leftRewardedX = new List(); - leftUnrewardedX = new List(); - noChoiceX = new List(); - rightRewardedAutoX = new List(); - rightUnrewardedAutoX = new List(); - leftRewardedAutoX = new List(); - leftUnrewardedAutoX = new List(); - - for (int i = 0; i < trialList.Count; i++) - { - var trial = trialList[i]; - float x = i; - bool isAutoResponse = trial.Trial.IsAutoResponseRight.HasValue; - - if (!trial.IsRightChoice.HasValue) - { - noChoiceX.Add(x); - } - else if (trial.IsRightChoice.Value) - { - if (isAutoResponse) - { - if (trial.IsRewarded) - { - rightRewardedAutoX.Add(x); - } - else - { - rightUnrewardedAutoX.Add(x); - } - } - else - { - rightChoiceX.Add(x); - if (trial.IsRewarded) - { - rightRewardedX.Add(x); - } - else - { - rightUnrewardedX.Add(x); - } - } - } - else - { - if (isAutoResponse) - { - if (trial.IsRewarded) - { - leftRewardedAutoX.Add(x); - } - else - { - leftUnrewardedAutoX.Add(x); - } - } - else - { - leftChoiceX.Add(x); - if (trial.IsRewarded) - { - leftRewardedX.Add(x); - } - else - { - leftUnrewardedX.Add(x); - } - } - } - } - } - - /// - /// Extracts PRewardLeft values from trials. - /// - private static float[] ExtractPRewardLeft(List trialList) - { - var values = new float[trialList.Count]; - for (int i = 0; i < trialList.Count; i++) - { - values[i] = (float)trialList[i].Trial.PRewardLeft; - } - return values; - } - - /// - /// Extracts PRewardRight values from trials. - /// - private static float[] ExtractPRewardRight(List trialList) - { - var values = new float[trialList.Count]; - for (int i = 0; i < trialList.Count; i++) - { - values[i] = (float)trialList[i].Trial.PRewardRight; - } - return values; - } - - /// - /// Computes rolling average over a window of values, ignoring null entries. - /// - private static float[] ComputeRollingAverage(float?[] values, int windowSize) - { - if (values == null || values.Length == 0) - { - return new float[0]; - } - - var result = new float[values.Length]; - - for (int i = 0; i < values.Length; i++) - { - int windowStart = Math.Max(0, i - windowSize + 1); - float sum = 0; - int validCount = 0; - - for (int j = windowStart; j <= i; j++) - { - if (values[j].HasValue) - { - sum += values[j].Value; - validCount++; - } - } - - result[i] = validCount > 0 ? sum / validCount : 0.5f; - } - - return result; - } - - /// - /// Extracts choice values (1 for right, 0 for left, null for no choice) from trials. - /// - private static float?[] ExtractChoiceValues(List trialList) - { - var values = new float?[trialList.Count]; - for (int i = 0; i < trialList.Count; i++) - { - var choice = trialList[i].IsRightChoice; - if (choice.HasValue) - { - values[i] = choice.Value ? 1.0f : 0.0f; - } - else - { - values[i] = null; - } - } - return values; - } - - /// - /// Extracts reward values (1 for rewarded, 0 for not rewarded) from trials. - /// Only considers trials where a choice was made. - /// - private static float?[] ExtractRewardValues(List trialList) - { - var values = new float?[trialList.Count]; - for (int i = 0; i < trialList.Count; i++) - { - if (trialList[i].IsRightChoice.HasValue) - { - values[i] = trialList[i].IsRewarded ? 1.0f : 0.0f; - } - else - { - values[i] = null; - } - } - return values; - } - - /// - /// Extracts finished trial values (1 if choice was made, 0 if not) from all trials. - /// - private static float[] ExtractFinishedTrialValues(List trialList) - { - var values = new float[trialList.Count]; - for (int i = 0; i < trialList.Count; i++) - { - values[i] = trialList[i].IsRightChoice.HasValue ? 1.0f : 0.0f; - } - return values; - } -} - diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 4e283254..0a440bfe 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -387,7 +387,7 @@ - PT0.957S + PT0.331S diff --git a/src/test_bias_visualizer.bonsai b/src/test_bias_visualizer.bonsai index 47115795..828022a0 100644 --- a/src/test_bias_visualizer.bonsai +++ b/src/test_bias_visualizer.bonsai @@ -12,8 +12,6 @@ xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns:p2="clr-namespace:;assembly=Extensions" xmlns:p3="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" - xmlns:implot="clr-namespace:Bonsai.ImPlot;assembly=Bonsai.ImPlot" - xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -278,7 +276,7 @@ - true + false @@ -444,8 +442,8 @@ - - true + false + false @@ -471,7 +469,7 @@ - PT0.372S + PT0.151S @@ -631,273 +629,13 @@ - - - - - - BiasPlot - - - - - - - Frame - - - BiasPlot - true - - -1 - 150 - - NoTitle - AutoFit - None - - - BiasPlot - - - - BiasPlot - - - - - -1 - 1 - - - R - L - - West - None - 1.1 - -1.1 - - - - - - - TimedBias - - - 1000 - Seconds - Value.Bias - - - BiasPlot - - - - 0 - 0 - 0 - 1 - 2 - - - - true - None - - - 1 - Seconds - Value.Bias - - - BiasPlot - - - - Circle - 5 - 0 - 1 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - - true - None - - - - Value.Bias - - - BiasPlot - - - {0:N2} - it - - - - - - - - Seconds - - - - - - - - - - - - - - true - 0.26 - 9.6599999999998385 - 0.26182802890512547 - - 0 - -10 - - None - - - - - 1 - - - - new (it as LeftBias) - - - - - - - - - 1000 - Seconds - Value.LeftBias - - - BiasPlot - - - - 1 - 0 - 0 - 0.7 - 1 - - - - true - None - - - - -1 - - - - new (it as RightBias) - - - - - - - - - 1000 - Seconds - Value.RightBias - - - BiasPlot - - - - 0 - 0 - 1 - 0.7 - 1 - - - - true - None - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Frame + TimedBias - \ No newline at end of file From 455efbf6a9835c26dff10c35db68eb9e5a656fa6 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 1 Jul 2026 10:54:40 +0100 Subject: [PATCH 015/116] Initial test of refactored event visualizer --- src/Extensions/SoftwareEventVisualizer.cs | 559 +++++++++--------- .../SoftwareEventVisualizerBuilder.cs | 177 ------ src/test_ethogram.bonsai | 107 ++-- 3 files changed, 334 insertions(+), 509 deletions(-) delete mode 100644 src/Extensions/SoftwareEventVisualizerBuilder.cs diff --git a/src/Extensions/SoftwareEventVisualizer.cs b/src/Extensions/SoftwareEventVisualizer.cs index 7076ae56..3d2037da 100644 --- a/src/Extensions/SoftwareEventVisualizer.cs +++ b/src/Extensions/SoftwareEventVisualizer.cs @@ -1,98 +1,95 @@ -using Bonsai.Design; -using Bonsai.Expressions; using AllenNeuralDynamics.AindBehaviorServices.DataTypes; -using AllenNeuralDynamics.Core.Design; +using Bonsai; using Hexa.NET.ImGui; using Hexa.NET.ImPlot; using System; using System.Collections.Generic; -using System.Drawing; +using System.ComponentModel; using System.Numerics; +using System.Reactive; +using Bonsai.Harp; +using System.Reactive.Linq; +using System.Collections.Immutable; using System.Runtime.InteropServices; -using System.Windows.Forms; +using System.Drawing; +using System.Xml.Serialization; -public class SoftwareEventVisualizer : BufferedVisualizer +[Combinator] +public class SoftwareEventVisualizer { + public bool Visible {get; set;} + public ImmutableList> SoftwareEvents {get; set;} + public string TrialBreakEventName {get; set;} + private const float MinPlotHeight = 100.0f; private const double YAxisMin = 0.0; private const double YAxisMax = 1.0; private const float InputWidth = 80.0f; - private float fontSize = 16.0f; - private float timeWindow = 30.0f; - - private List shadedAreaPlotters = new List(); - private List pointPlotters = new List(); - - private ImGuiControl imGuiCanvas; - private DateTimeOffset startTime; + private float timeWindow = 120.0f; + public List ShadedAreaPlotters {get; set;} + public List PointPlotters {get; set;} + private int maxTrials = 0; private readonly Dictionary> eventHistory = new Dictionary>(); - private double latestTimestamp = 0; - private string trialBreakEventName = ""; - private int maxTrials = 0; private readonly List trialBreaks = new List(); + private double lastTrialBreak = 0; + private double latestTimestamp = 0; - private bool HasTrialBreaks { get { return !string.IsNullOrEmpty(trialBreakEventName); } } + private bool HasTrialBreaks { get { return !string.IsNullOrEmpty(TrialBreakEventName); } } private int TrialCount { get { return HasTrialBreaks ? trialBreaks.Count + 1 : 1; } } - private struct EventRecord + public IObservable Process(IObservable source) { - public double Timestamp; - } - - private struct ShadedSegment - { - public double Timestamp; - public ShadedAreaPlotter Config; - } - - /// - public override void Show(object value) - { - } - - /// - protected override void ShowBuffer(IList> values) - { - foreach (var v in values) + return Observable.Create(observer => { - if (!(v.Value is SoftwareEvent)) continue; - var softwareEvent = (SoftwareEvent)v.Value; - - double timestamp = (v.Timestamp - startTime).TotalSeconds; - - string name = softwareEvent.Name; - if (string.IsNullOrEmpty(name)) continue; - - if (HasTrialBreaks && name == trialBreakEventName) - { - trialBreaks.Add(timestamp); - } - - List records; - if (!eventHistory.TryGetValue(name, out records)) - { - records = new List(); - eventHistory[name] = records; - } - records.Add(new EventRecord { Timestamp = timestamp }); - } - - CleanupOldEvents(); - - base.ShowBuffer(values); - if (imGuiCanvas != null) imGuiCanvas.Invalidate(); + eventHistory.Clear(); + trialBreaks.Clear(); + lastTrialBreak = 0; + var sourceObserver = Observer.Create( + value => + { + if (Visible) + { + foreach (var v in SoftwareEvents) + { + double timestamp = v.Seconds; + latestTimestamp = timestamp; + + string name = v.Value.Name; + if (HasTrialBreaks && name == TrialBreakEventName) + { + if ((timestamp - lastTrialBreak) > 0.1) + { + trialBreaks.Add(timestamp); + lastTrialBreak = timestamp; + } + } + + List records; + if (!eventHistory.TryGetValue(name, out records)) + { + records = new List(); + eventHistory[name] = records; + } + records.Add(new EventRecord { Timestamp = timestamp }); + } + + CleanupOldEvents(); + + DrawEvents(); + + observer.OnNext(value); + } + }, + observer.OnError, + observer.OnCompleted); + return source.SubscribeSafe(sourceObserver); + }); } - /// - /// Removes old event records outside the visible window. - /// Keeps the last event before the window for shaded area continuity. - /// private void CleanupOldEvents() - { - latestTimestamp = (DateTimeOffset.Now - startTime).TotalSeconds; - + { double cutoffTime = latestTimestamp - timeWindow; if (HasTrialBreaks && maxTrials > 0 && trialBreaks.Count > 0) @@ -144,42 +141,49 @@ private void CleanupOldEvents() } } - private static Vector4 ToVec4(Color color) + private void DrawEvents() { - return new Vector4(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f); - } + ImGui.Text("Time Window (s):"); + ImGui.SameLine(); + ImGui.SetNextItemWidth(InputWidth); + ImGui.InputFloat("##timewindow", ref timeWindow); + if (timeWindow < 1.0f) timeWindow = 1.0f; - void StyleColors() - { - ImGui.StyleColorsLight(); - ImPlot.StyleColorsLight(ImPlot.GetStyle()); - } + var availableSize = ImGui.GetContentRegionAvail(); + float plotHeight = Math.Max(availableSize.Y, MinPlotHeight); - /// - /// Converts absolute timestamp to plot-relative time where 0 = now. - /// - private double ToPlotTime(double timestamp) - { - return timestamp - latestTimestamp; - } + double plotTMin = -(double)timeWindow; + double plotTMax = 0.0; - /// - /// Returns which trial a timestamp belongs to. - /// - private int GetTrialIndex(double timestamp) - { - if (!HasTrialBreaks || trialBreaks.Count == 0) return 0; - for (int i = trialBreaks.Count - 1; i >= 0; i--) + int firstVisible, numVisible; + GetVisibleTrialRange(out firstVisible, out numVisible); + + double yMin = HasTrialBreaks ? (double)firstVisible : YAxisMin; + double yMax = HasTrialBreaks ? (double)(firstVisible + numVisible) : YAxisMax; + + ImPlot.SetNextAxesLimits(plotTMin, plotTMax, yMin, yMax, ImPlotCond.Always); + if (ImPlot.BeginPlot("Software Events", new Vector2(-1, plotHeight), ImPlotFlags.NoTitle)) { - if (timestamp >= trialBreaks[i]) - return i + 1; + ImPlot.SetupAxes("Time (s)", HasTrialBreaks ? "Trial" : "Value"); + ImPlot.SetupAxisLimits(ImAxis.Y1, yMin, yMax, ImPlotCond.Always); + ImPlot.SetupLegend(ImPlotLocation.North, ImPlotLegendFlags.Outside | ImPlotLegendFlags.Horizontal); + + if (HasTrialBreaks && numVisible > 0) + { + SetupTrialAxisTicks(firstVisible, numVisible); + } + + DrawAllShadedAreas(plotTMin, plotTMax); + + foreach (var config in PointPlotters) + { + DrawPointMarkers(config, plotTMin, plotTMax); + } + + ImPlot.EndPlot(); } - return 0; } - /// - /// Computes visible trial range based on MaxTrials rolling window. - /// private void GetVisibleTrialRange(out int firstVisible, out int numVisible) { int total = TrialCount; @@ -200,65 +204,49 @@ private void GetVisibleTrialRange(out int firstVisible, out int numVisible) } } - /// - /// Builds merged timeline of shaded area events, sorted by timestamp. - /// - private List BuildMergedTimeline() + unsafe private void SetupTrialAxisTicks(int firstVisibleTrial, int numVisibleTrials) { - var merged = new List(); - - foreach (var config in shadedAreaPlotters) - { - List records; - if (!eventHistory.TryGetValue(config.EventName, out records)) - continue; + if (numVisibleTrials <= 0) return; - for (int i = 0; i < records.Count; i++) - { - merged.Add(new ShadedSegment - { - Timestamp = records[i].Timestamp, - Config = config - }); - } - } + var positions = new double[numVisibleTrials]; + var labelData = new byte[numVisibleTrials][]; - merged.Sort(delegate(ShadedSegment a, ShadedSegment b) + for (int t = 0; t < numVisibleTrials; t++) { - return a.Timestamp.CompareTo(b.Timestamp); - }); - - return merged; - } + int trialNum = firstVisibleTrial + t; + positions[t] = trialNum + 0.5; + labelData[t] = System.Text.Encoding.UTF8.GetBytes(trialNum.ToString() + '\0'); + } - /// - /// Draws a single shaded rectangle in a given trial row. - /// - unsafe private void DrawShadedRect(ShadedAreaPlotter config, double tStart, double tEnd, int trialIndex) - { - double x0 = ToPlotTime(tStart); - double x1 = ToPlotTime(tEnd); - double yLow = HasTrialBreaks ? (double)trialIndex : 0.0; - double yHigh = HasTrialBreaks ? (double)(trialIndex + 1) : 1.0; + var handles = new GCHandle[numVisibleTrials]; + var ptrs = new IntPtr[numVisibleTrials]; - var color = ToVec4(config.Color); - ImPlot.SetNextLineStyle(color, 0f); - ImPlot.SetNextFillStyle(color, config.Alpha); + try + { + for (int t = 0; t < numVisibleTrials; t++) + { + handles[t] = GCHandle.Alloc(labelData[t], GCHandleType.Pinned); + ptrs[t] = handles[t].AddrOfPinnedObject(); + } - fixed (double* xs = new double[] { x0, x1 }) - fixed (double* ysL = new double[] { yLow, yLow }) - fixed (double* ysH = new double[] { yHigh, yHigh }) + fixed (double* posPtr = positions) + fixed (IntPtr* labelPtrs = ptrs) + { + ImPlot.SetupAxisTicks(ImAxis.Y1, posPtr, numVisibleTrials, (byte**)labelPtrs, false); + } + } + finally { - ImPlot.PlotShaded(config.EventName, xs, ysL, ysH, 2); + for (int t = 0; t < numVisibleTrials; t++) + { + if (handles[t].IsAllocated) handles[t].Free(); + } } } - /// - /// Draws shaded areas as mutually exclusive regions, split at trial boundaries when active. - /// unsafe private void DrawAllShadedAreas(double plotTMin, double plotTMax) { - if (shadedAreaPlotters.Count == 0) return; + if (ShadedAreaPlotters.Count == 0) return; var timeline = BuildMergedTimeline(); if (timeline.Count == 0) return; @@ -323,9 +311,46 @@ unsafe private void DrawAllShadedAreas(double plotTMin, double plotTMax) } } - /// - /// Draws scatter markers for a PointPlotter, offset by trial row when active. - /// + private double ToPlotTime(double timestamp) + { + return timestamp - latestTimestamp; + } + + private static Vector4 ToVec4(Color color) + { + return new Vector4(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f); + } + + unsafe private void DrawShadedRect(ShadedAreaPlotter config, double tStart, double tEnd, int trialIndex) + { + double x0 = ToPlotTime(tStart); + double x1 = ToPlotTime(tEnd); + double yLow = HasTrialBreaks ? (double)trialIndex : 0.0; + double yHigh = HasTrialBreaks ? (double)(trialIndex + 1) : 1.0; + + var color = ToVec4(config.Color); + ImPlot.SetNextLineStyle(color, 0f); + ImPlot.SetNextFillStyle(color, config.Alpha); + + fixed (double* xs = new double[] { x0, x1 }) + fixed (double* ysL = new double[] { yLow, yLow }) + fixed (double* ysH = new double[] { yHigh, yHigh }) + { + ImPlot.PlotShaded(config.EventName, xs, ysL, ysH, 2); + } + } + + private int GetTrialIndex(double timestamp) + { + if (!HasTrialBreaks || trialBreaks.Count == 0) return 0; + for (int i = trialBreaks.Count - 1; i >= 0; i--) + { + if (timestamp >= trialBreaks[i]) + return i + 1; + } + return 0; + } + unsafe private void DrawPointMarkers(PointPlotter config, double plotTMin, double plotTMax) { List records; @@ -377,159 +402,153 @@ unsafe private void DrawPointMarkers(PointPlotter config, double plotTMin, doubl } } - /// - /// Sets up Y axis ticks with trial labels at row centers. - /// - unsafe private void SetupTrialAxisTicks(int firstVisibleTrial, int numVisibleTrials) + private List BuildMergedTimeline() { - if (numVisibleTrials <= 0) return; - - var positions = new double[numVisibleTrials]; - var labelData = new byte[numVisibleTrials][]; - - for (int t = 0; t < numVisibleTrials; t++) - { - int trialNum = firstVisibleTrial + t; - positions[t] = trialNum + 0.5; - labelData[t] = System.Text.Encoding.UTF8.GetBytes(trialNum.ToString() + '\0'); - } - - var handles = new GCHandle[numVisibleTrials]; - var ptrs = new IntPtr[numVisibleTrials]; + var merged = new List(); - try + foreach (var config in ShadedAreaPlotters) { - for (int t = 0; t < numVisibleTrials; t++) - { - handles[t] = GCHandle.Alloc(labelData[t], GCHandleType.Pinned); - ptrs[t] = handles[t].AddrOfPinnedObject(); - } + List records; + if (!eventHistory.TryGetValue(config.EventName, out records)) + continue; - fixed (double* posPtr = positions) - fixed (IntPtr* labelPtrs = ptrs) + for (int i = 0; i < records.Count; i++) { - ImPlot.SetupAxisTicks(ImAxis.Y1, posPtr, numVisibleTrials, (byte**)labelPtrs, false); + merged.Add(new ShadedSegment + { + Timestamp = records[i].Timestamp, + Config = config + }); } } - finally + + merged.Sort(delegate(ShadedSegment a, ShadedSegment b) { - for (int t = 0; t < numVisibleTrials; t++) - { - if (handles[t].IsAllocated) handles[t].Free(); - } - } + return a.Timestamp.CompareTo(b.Timestamp); + }); + + return merged; } - private void DrawEvents() + private struct EventRecord { - latestTimestamp = (DateTimeOffset.Now - startTime).TotalSeconds; + public double Timestamp; + } - ImGui.Text("Time Window (s):"); - ImGui.SameLine(); - ImGui.SetNextItemWidth(InputWidth); - ImGui.InputFloat("##timewindow", ref timeWindow); - if (timeWindow < 1.0f) timeWindow = 1.0f; + private struct ShadedSegment + { + public double Timestamp; + public ShadedAreaPlotter Config; + } - var availableSize = ImGui.GetContentRegionAvail(); - float plotHeight = Math.Max(availableSize.Y, MinPlotHeight); + public interface IPlotter +{ + string EventName { get; set; } +} - double plotTMin = -(double)timeWindow; - double plotTMax = 0.0; +public class ShadedAreaPlotter : IPlotter +{ + private string _eventName; + private Color _color; + private float _alpha; - int firstVisible, numVisible; - GetVisibleTrialRange(out firstVisible, out numVisible); + public ShadedAreaPlotter() + { + _eventName = ""; + _color = Color.CornflowerBlue; + _alpha = 0.3f; + } - double yMin = HasTrialBreaks ? (double)firstVisible : YAxisMin; - double yMax = HasTrialBreaks ? (double)(firstVisible + numVisible) : YAxisMax; + [Description("The software event name to filter on.")] + public string EventName + { + get { return _eventName; } + set { _eventName = value; } + } - ImPlot.SetNextAxesLimits(plotTMin, plotTMax, yMin, yMax, ImPlotCond.Always); - if (ImPlot.BeginPlot("Software Events", new Vector2(-1, plotHeight), ImPlotFlags.NoTitle)) - { - ImPlot.SetupAxes("Time (s)", HasTrialBreaks ? "Trial" : "Value"); - ImPlot.SetupAxisLimits(ImAxis.Y1, yMin, yMax, ImPlotCond.Always); - ImPlot.SetupLegend(ImPlotLocation.North, ImPlotLegendFlags.Outside | ImPlotLegendFlags.Horizontal); + [XmlIgnore] + [Description("The color of the shaded area.")] + public Color Color + { + get { return _color; } + set { _color = value; } + } - if (HasTrialBreaks && numVisible > 0) - { - SetupTrialAxisTicks(firstVisible, numVisible); - } + [Browsable(false)] + [XmlElement("Color")] + public string ColorHtml + { + get { return ColorTranslator.ToHtml(Color); } + set { try { Color = ColorTranslator.FromHtml(value); } catch { } } + } - DrawAllShadedAreas(plotTMin, plotTMax); + [Description("The transparency of the shaded area (0.0 to 1.0).")] + public float Alpha + { + get { return _alpha; } + set { _alpha = value; } + } +} - foreach (var config in pointPlotters) - { - DrawPointMarkers(config, plotTMin, plotTMax); - } +public class PointPlotter : IPlotter +{ + private string _eventName; + private Color _color; + private float _yPosition; + private float _markerSize; + private ImPlotMarker _marker; - ImPlot.EndPlot(); - } + public PointPlotter() + { + _eventName = ""; + _color = Color.Red; + _yPosition = 0.5f; + _markerSize = 6.0f; + _marker = ImPlotMarker.Circle; } - /// - public override void Load(IServiceProvider provider) + [Description("The software event name to filter on.")] + public string EventName { - var context = (ITypeVisualizerContext)provider.GetService(typeof(ITypeVisualizerContext)); - var builder = ExpressionBuilder.GetVisualizerElement(context.Source).Builder as SoftwareEventVisualizerBuilder; - if (builder != null) - { - fontSize = builder.FontSize; - timeWindow = builder.TimeWindow; - shadedAreaPlotters = builder.ShadedAreaPlotters ?? new List(); - pointPlotters = builder.PointPlotters ?? new List(); - trialBreakEventName = builder.TrialBreakEventName ?? ""; - maxTrials = builder.MaxTrials; - } - - if (startTime == default(DateTimeOffset)) - { - startTime = DateTimeOffset.Now; - } - - imGuiCanvas = new ImGuiControl(); - imGuiCanvas.Dock = DockStyle.Fill; - imGuiCanvas.Render += (sender, e) => - { - var dockspaceId = ImGui.DockSpaceOverViewport( - 0, - ImGui.GetMainViewport(), - ImGuiDockNodeFlags.AutoHideTabBar | ImGuiDockNodeFlags.NoUndocking); + get { return _eventName; } + set { _eventName = value; } + } - StyleColors(); - ImGui.PushFont(ImGui.GetFont(), fontSize); + [XmlIgnore] + [Description("The color of the marker.")] + public Color Color + { + get { return _color; } + set { _color = value; } + } - if (ImGui.Begin("SoftwareEventVisualizer")) - { - DrawEvents(); - } + [Browsable(false)] + [XmlElement("Color")] + public string ColorHtml + { + get { return ColorTranslator.ToHtml(Color); } + set { try { Color = ColorTranslator.FromHtml(value); } catch { } } + } - ImGui.End(); - ImGui.PopFont(); - var centralNode = ImGuiP.DockBuilderGetCentralNode(dockspaceId); - if (!ImGui.IsWindowDocked() && !centralNode.IsNull) - { - unsafe - { - var handle = centralNode.Handle; - uint dockId = handle->ID; - ImGuiP.DockBuilderDockWindow("SoftwareEventVisualizer", dockId); - } - } - }; + [Description("The fixed Y position of the marker (0.0 to 1.0).")] + public float YPosition + { + get { return _yPosition; } + set { _yPosition = value; } + } - var visualizerService = (IDialogTypeVisualizerService)provider.GetService(typeof(IDialogTypeVisualizerService)); - if (visualizerService != null) - { - visualizerService.AddControl(imGuiCanvas); - } + [Description("The size of the marker in pixels.")] + public float MarkerSize + { + get { return _markerSize; } + set { _markerSize = value; } } - /// - public override void Unload() + [Description("The marker style.")] + public ImPlotMarker Marker { - if (imGuiCanvas != null) - { - imGuiCanvas.Dispose(); - imGuiCanvas = null; - } + get { return _marker; } + set { _marker = value; } } } +} \ No newline at end of file diff --git a/src/Extensions/SoftwareEventVisualizerBuilder.cs b/src/Extensions/SoftwareEventVisualizerBuilder.cs deleted file mode 100644 index f4bc55f8..00000000 --- a/src/Extensions/SoftwareEventVisualizerBuilder.cs +++ /dev/null @@ -1,177 +0,0 @@ -using Bonsai; -using Bonsai.Expressions; -using AllenNeuralDynamics.AindBehaviorServices.DataTypes; -using Hexa.NET.ImPlot; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Linq; -using System.Linq.Expressions; -using System.Xml.Serialization; - -public interface IPlotter -{ - string EventName { get; set; } -} - -public class ShadedAreaPlotter : IPlotter -{ - private string _eventName; - private Color _color; - private float _alpha; - - public ShadedAreaPlotter() - { - _eventName = ""; - _color = Color.CornflowerBlue; - _alpha = 0.3f; - } - - [Description("The software event name to filter on.")] - public string EventName - { - get { return _eventName; } - set { _eventName = value; } - } - - [XmlIgnore] - [Description("The color of the shaded area.")] - public Color Color - { - get { return _color; } - set { _color = value; } - } - - [Browsable(false)] - [XmlElement("Color")] - public string ColorHtml - { - get { return ColorTranslator.ToHtml(Color); } - set { try { Color = ColorTranslator.FromHtml(value); } catch { } } - } - - [Description("The transparency of the shaded area (0.0 to 1.0).")] - public float Alpha - { - get { return _alpha; } - set { _alpha = value; } - } -} - -public class PointPlotter : IPlotter -{ - private string _eventName; - private Color _color; - private float _yPosition; - private float _markerSize; - private ImPlotMarker _marker; - - public PointPlotter() - { - _eventName = ""; - _color = Color.Red; - _yPosition = 0.5f; - _markerSize = 6.0f; - _marker = ImPlotMarker.Circle; - } - - [Description("The software event name to filter on.")] - public string EventName - { - get { return _eventName; } - set { _eventName = value; } - } - - [XmlIgnore] - [Description("The color of the marker.")] - public Color Color - { - get { return _color; } - set { _color = value; } - } - - [Browsable(false)] - [XmlElement("Color")] - public string ColorHtml - { - get { return ColorTranslator.ToHtml(Color); } - set { try { Color = ColorTranslator.FromHtml(value); } catch { } } - } - - [Description("The fixed Y position of the marker (0.0 to 1.0).")] - public float YPosition - { - get { return _yPosition; } - set { _yPosition = value; } - } - - [Description("The size of the marker in pixels.")] - public float MarkerSize - { - get { return _markerSize; } - set { _markerSize = value; } - } - - [Description("The marker style.")] - public ImPlotMarker Marker - { - get { return _marker; } - set { _marker = value; } - } -} - -[TypeVisualizer(typeof(SoftwareEventVisualizer))] -[WorkflowElementCategory(ElementCategory.Combinator)] -[Description("Visualizes software events as shaded areas and/or point markers over time.")] -public class SoftwareEventVisualizerBuilder : SingleArgumentExpressionBuilder -{ - private float _fontSize; - private float _timeWindow; - - public SoftwareEventVisualizerBuilder() - { - _fontSize = 16.0f; - _timeWindow = 30.0f; - ShadedAreaPlotters = new List(); - PointPlotters = new List(); - } - - [Description("Font size for text rendering.")] - public float FontSize - { - get { return _fontSize; } - set { _fontSize = value; } - } - - [Description("Number of seconds to display on the X axis.")] - public float TimeWindow - { - get { return _timeWindow; } - set { _timeWindow = value; } - } - - [Description("Shaded area plotter configurations.")] - public List ShadedAreaPlotters { get; set; } - - [Description("Point plotter configurations.")] - public List PointPlotters { get; set; } - - [Description("Software event name that triggers a new trial row. Leave empty to disable trial breaks.")] - public string TrialBreakEventName { get; set; } - - [Description("Maximum number of trial rows to display. When exceeded, only the last N trials are shown. 0 = show all.")] - public int MaxTrials { get; set; } - - /// - public override Expression Build(IEnumerable arguments) - { - var source = arguments.First(); - return Expression.Call(typeof(SoftwareEventVisualizerBuilder), "Process", null, source); - } - - static IObservable Process(IObservable source) - { - return source; - } -} diff --git a/src/test_ethogram.bonsai b/src/test_ethogram.bonsai index 8a9fa995..4a35e11c 100644 --- a/src/test_ethogram.bonsai +++ b/src/test_ethogram.bonsai @@ -1,6 +1,7 @@  + + + Frame + PT1S @@ -248,53 +254,26 @@ - - - - 16 - 10 - - - TrialOutcome - CornflowerBlue - 0.3 - - - RewardPeriod - Crimson - 0.3 - - - ITI - Cyan - 0.3 - - - - - TrialOutcome - SaddleBrown - 0.5 - 6 - Circle - - - LickLeft - Red - 0.8 - 6 - Down - - - LickRight - DodgerBlue - 0.2 - 6 - Up - - - Break - 5 + + + + SoftwareEventHistory + + + Frame + + + SoftwareEventHistory + + + + + + + + + false + @@ -364,7 +343,6 @@ - @@ -372,21 +350,26 @@ - - - - - - - - + + + + + + + + - + - - - - + + + + + + + + + \ No newline at end of file From 6f0125307a61271c1616ebd9d33320b6e41a7ccd Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 1 Jul 2026 11:17:49 +0100 Subject: [PATCH 016/116] Testing point plotters --- src/test_ethogram.bonsai | 263 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 259 insertions(+), 4 deletions(-) diff --git a/src/test_ethogram.bonsai b/src/test_ethogram.bonsai index 4a35e11c..70d9851f 100644 --- a/src/test_ethogram.bonsai +++ b/src/test_ethogram.bonsai @@ -47,7 +47,7 @@ - PT1.219S + PT2.178S @@ -99,7 +99,7 @@ - PT1.095S + PT2.874S @@ -170,7 +170,7 @@ - PT2.974S + PT0.133S @@ -272,7 +272,262 @@ - false + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Break + + + TrialOutcome + CornflowerBlue + 0.3 + + + RewardPeriod + Crimson + 0.3 + + + ITI + Cyan + 0.3 + + + + + TrialOutcome + SaddleBrown + 0.5 + 6 + Circle + + + LickLeft + Red + 0.8 + 6 + Down + + + LickRight + DodgerBlue + 0.2 + 6 + Up + + From 32acf3e7debcf902ebea6236398e5302cc215af0 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 2 Jul 2026 12:05:52 +0100 Subject: [PATCH 017/116] Blockout pre-session visualizer --- src/Extensions/PreSessionVisualizer.bonsai | 405 +++++++++++++++++++++ src/test_behavior_visualizer.bonsai | 64 +++- 2 files changed, 458 insertions(+), 11 deletions(-) create mode 100644 src/Extensions/PreSessionVisualizer.bonsai diff --git a/src/Extensions/PreSessionVisualizer.bonsai b/src/Extensions/PreSessionVisualizer.bonsai new file mode 100644 index 00000000..ba8e4a09 --- /dev/null +++ b/src/Extensions/PreSessionVisualizer.bonsai @@ -0,0 +1,405 @@ + + + + + + + + + PreSessionVisualizer + + + + + + + PreSession + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + KeepLeftOpen + true + Keep Left Open + + + KeepRightOpen + true + Keep Right Open + + + KeepBothOpen + true + Keep Both Open + + + + + + true + + + DrainLeft + true + Drain 5ml Left + + + Drain Right + true + Drain 5ml Right + + + Drain Both + true + Drain 5ml Both + + + + + + + + + true + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + MoveLeft + true + Move Left + + + ForwardLeft + true + Forward Left + + + ForwardRight + true + Forward Right + + + Up + true + Up + + + + + + true + + + MoveRight + true + Move Right + + + BackLeft + true + Back Left + + + BackRight + true + Back Right + + + Down + true + Down + + + + + + + + + true + + + STOP + true + STOP + + + Home + true + Home + + + Initialize + true + Initialize + + + + + + + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + x1: + + + true + + + true + 0.00mm + + + + + + true + + + true + y1: + + + true + + + true + 0.00mm + + + + + + true + + + true + y2: + + + true + + + true + 0.00mm + + + + + + true + + + true + z: + + + true + + + true + 0.00mm + + + + + + true + + + true + step: + + + true + + + true + 0.25mm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 0a440bfe..e7dbbe8a 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -194,7 +194,7 @@ - false + true @@ -360,7 +360,7 @@ - false + true false @@ -387,7 +387,7 @@ - PT0.331S + PT0.322S @@ -709,6 +709,34 @@ Metadata + + true + + + true + None + + + PreSession + true + pre-session + None + + + PreSession + + + InterSession + true + inter-session + None + + + InterSession + + + + Behavior1 LickLeft @@ -726,8 +754,10 @@ Camera - - Camera + + + Camera + @@ -958,12 +988,16 @@ + + PreSession + + @@ -979,14 +1013,22 @@ + + + + - - - - - + + + - + + + + + + + \ No newline at end of file From fe5fe6ea5b70be6009817d88faaf38459f9c8e9a Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 2 Jul 2026 13:52:00 +0100 Subject: [PATCH 018/116] Prototype for inter-session tab --- src/Extensions/MultiLineInputTextBuilder.cs | 41 +++++++ src/test_behavior_visualizer.bonsai | 120 +++++++++++++++++++- 2 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 src/Extensions/MultiLineInputTextBuilder.cs diff --git a/src/Extensions/MultiLineInputTextBuilder.cs b/src/Extensions/MultiLineInputTextBuilder.cs new file mode 100644 index 00000000..1bf56860 --- /dev/null +++ b/src/Extensions/MultiLineInputTextBuilder.cs @@ -0,0 +1,41 @@ +using System; +using System.ComponentModel; +using System.Reactive; +using System.Reactive.Linq; +using Bonsai.ImGui; +using ImGui = Hexa.NET.ImGui.ImGui; + +/// +/// Represents an operator that draws an input text box and generates +/// a sequence of notifications whenever the text changes. +/// +[Description("Draws a multi-line input text box and generates a sequence of notifications whenever the text changes.")] +public class MultiLineInputTextBuilder : TextControlBuilder +{ + /// + /// Gets or sets the maximum number of characters allowed in the text box. + /// + [Description("The maximum number of characters allowed in the text box.")] + public ulong Capacity { get; set; } + + /// + protected override IObservable Generate(IObservable source) + { + return Observable.Create(observer => + { + var buf = Text ?? string.Empty; + observer.OnNext(buf); + var bufSize = (System.UIntPtr)Capacity; + var label = "##" + Name; + var sourceObserver = Observer.Create( + _ => + { + if (Visible && ImGui.InputTextMultiline(label, ref buf, bufSize)) + observer.OnNext(buf); + }, + observer.OnError, + observer.OnCompleted); + return source.SubscribeSafe(sourceObserver); + }); + } +} \ No newline at end of file diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index e7dbbe8a..de299b36 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -361,7 +361,7 @@ true - false + true @@ -387,7 +387,7 @@ - PT0.322S + PT0.775S @@ -991,6 +991,100 @@ PreSession + + InterSession + + + true + 3 + Borders + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + GiveLeft + true + Give Left + + + true + + + GiveRight + true + Give Right + + + + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + MoveLeft + true + Move Left + + + true + + + MoveRight + true + Move Right + + + + + + + + + true + + + SessionInfo + true + Session Info + + + true + + + Notes + true + Notes + 16384 + @@ -1029,6 +1123,28 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From ffcd4323b325d4f1d875035d4aa6de020cfff8be Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 2 Jul 2026 14:19:19 +0100 Subject: [PATCH 019/116] Completed inter-session visualizer --- src/Extensions/InterSessionVisualizer.bonsai | 149 +++++ src/test_behavior_visualizer.bonsai | 585 +++++++++---------- 2 files changed, 437 insertions(+), 297 deletions(-) create mode 100644 src/Extensions/InterSessionVisualizer.bonsai diff --git a/src/Extensions/InterSessionVisualizer.bonsai b/src/Extensions/InterSessionVisualizer.bonsai new file mode 100644 index 00000000..cef93000 --- /dev/null +++ b/src/Extensions/InterSessionVisualizer.bonsai @@ -0,0 +1,149 @@ + + + + + + + + + InterSessionVisualizer + + + + + + + InterSession + + + true + 3 + Borders + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + GiveLeft + true + Give Left + + + true + + + GiveRight + true + Give Right + + + + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + MoveLeft + true + Move Left + + + true + + + MoveRight + true + Move Right + + + + + + + + + true + + + SessionInfo + true + Session Info + + + true + + + Notes + true + Notes + 16384 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index de299b36..9ac9c33d 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -194,7 +194,7 @@ - true + false @@ -299,7 +299,7 @@ - false + true @@ -360,8 +360,8 @@ - true - true + + false @@ -387,7 +387,7 @@ - PT0.775S + PT0.177S @@ -759,6 +759,12 @@ Camera + + + N + false + + Expo @@ -772,9 +778,9 @@ - + - + @@ -789,301 +795,299 @@ false - + + + + + + M + false + + + + + Expo + + + + + 1 + + + + + + + + + + + + + 0.13.5 + 0.13.5 + Task7 + 0001-01-01T00:00:00.0000000+00:00 + Stage2 + Plimbo + false + false + + + + + + + + + MetadataVisualizer Source1 - - CurrentMetadata - - - - - Metadata - - - true - - - true - 7 - None - - 0 - 0 - - 0 - - - true - - - CurrentMetadata - - - Experimenter - - - - 0 - - - - - - - - - true - Expo - - - true - - - CurrentMetadata + - - Subject - - - - - - - - true - Plimbo - - - true - - - CurrentMetadata - - - SessionName - - - - - - - - true - Stage1 - - - true - - - CurrentMetadata - - - Experiment - - - - - - - - true - Task6 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - Habituation - - - true - - - Habituation - true - None - 0 - 0 - 0 + + MetadataVisualizer + + + + Source1 + + + CurrentMetadata + + + + + + Metadata + + + true + + + true + 7 + None + + 0 + 0 + + 0 + + + true + + + CurrentMetadata + + + Experimenter + + + + + + Source1 + + + Count + + + + 0 + + + + + + + + + + + + + + 0 + + + + + + + + + true + Expo + + + true + + + CurrentMetadata + + + Subject + + + + + + + + true + Plimbo + + + true + + + CurrentMetadata + + + SessionName + + + + + + + + true + Stage1 + + + true + + + CurrentMetadata + + + Experiment + + + + + + + + true + Task6 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Habituation + + + true + + + Habituation + true + None + 0 + 0 + 0 + + + + + + true + + + true + START + + + true + + + true + STOP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - true - - - true - START - - - true - - - true - STOP + + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PreSession - - InterSession - - - true - 3 - Borders - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - GiveLeft - true - Give Left - - - true - - - GiveRight - true - Give Right - - - - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - MoveLeft - true - Move Left - - - true - - - MoveRight - true - Move Right - - - - - - - - - true - - - SessionInfo - true - Session Info - - - true - - - Notes - true - Notes - 16384 + + InterSession @@ -1123,28 +1127,15 @@ + + - - - - - + - - - - - - - - - - - \ No newline at end of file From b51a22bd7679caa53eb7f6195b4d927b9b3fdafe Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 2 Jul 2026 14:24:34 +0100 Subject: [PATCH 020/116] Create IncludeWorkflow for metadata --- src/Extensions/MetadataVisualizer.bonsai | 247 +++++++++ src/test_behavior_visualizer.bonsai | 648 ++++++++--------------- 2 files changed, 454 insertions(+), 441 deletions(-) create mode 100644 src/Extensions/MetadataVisualizer.bonsai diff --git a/src/Extensions/MetadataVisualizer.bonsai b/src/Extensions/MetadataVisualizer.bonsai new file mode 100644 index 00000000..589fb728 --- /dev/null +++ b/src/Extensions/MetadataVisualizer.bonsai @@ -0,0 +1,247 @@ + + + + + + Source1 + + + + + + MetadataVisualizer + + + + Source1 + + + CurrentMetadata + + + + + + Metadata + + + true + + + true + 7 + None + + 0 + 0 + + 0 + + + true + + + CurrentMetadata + + + Experimenter + + + + + + Source1 + + + Count + + + + 0 + + + + + + + + + + + + + + 0 + + + + + + + + + true + Expo + + + true + + + CurrentMetadata + + + Subject + + + + + + + + true + Plimbo + + + true + + + CurrentMetadata + + + SessionName + + + + + + + + true + Stage1 + + + true + + + CurrentMetadata + + + Experiment + + + + + + + + true + Task6 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Habituation + + + true + + + Habituation + true + None + 0 + 0 + 0 + + + + + + true + + + true + START + + + true + + + true + STOP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 9ac9c33d..b8ee4d5e 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -3,13 +3,13 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wie="clr-namespace:Bonsai.Windows.Input;assembly=Bonsai.Windows.Input" xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" - xmlns:p1="clr-namespace:Bonsai.Numerics.Distributions;assembly=Bonsai.Numerics" + xmlns:p1="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" + xmlns:p2="clr-namespace:Bonsai.Numerics.Distributions;assembly=Bonsai.Numerics" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" xmlns:num="clr-namespace:Bonsai.Numerics;assembly=Bonsai.Numerics" xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp" - xmlns:p2="clr-namespace:;assembly=Extensions" - xmlns:p3="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" + xmlns:p3="clr-namespace:;assembly=Extensions" xmlns:cv="clr-namespace:Bonsai.Vision;assembly=Bonsai.Vision" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" @@ -33,6 +33,89 @@ LickLeft + + + PT5S + + + + + Expo + + + + + 1 + + + + + + + + + + + + + 0.13.5 + 0.13.5 + Task6 + 0001-01-01T00:00:00.0000000+00:00 + Stage1 + Plimbo + false + false + + + + + + + + M + false + + + + + Expo + + + + + 1 + + + + + + + + + + + + + 0.13.5 + 0.13.5 + Task7 + 0001-01-01T00:00:00.0000000+00:00 + Stage2 + Plimbo + false + false + + + + + + + + + + SessionInfo + TimedTrial @@ -46,7 +129,7 @@ Item2 - + @@ -89,9 +172,9 @@ - - 0.1 - 1 + + 0.1 + 1 @@ -103,9 +186,9 @@ - - -0.1 - 0.1 + + -0.1 + 0.1 @@ -127,14 +210,14 @@ TimeBase - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -169,14 +252,14 @@ (it +1) * 0.5 - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -193,19 +276,19 @@ - - false + + true - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -214,8 +297,8 @@ - - + + @@ -246,14 +329,14 @@ (it +1) * 0.5 - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -277,14 +360,14 @@ - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -298,24 +381,24 @@ - - true + + false - - + + - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -341,16 +424,16 @@ - - 0.59164587077011477 - 0.40913708100521279 - 5 - 0 - 5 - 0.5 - 5 - - 0 + + 0.59164587077011477 + 0.40913708100521279 + 5 + 0 + 5 + 0.5 + 5 + + 0 @@ -359,9 +442,9 @@ - - - false + + true + false @@ -375,7 +458,7 @@ Random - + TimeSpan.FromSeconds(it) @@ -387,7 +470,7 @@ - PT0.177S + PT0.424S @@ -428,85 +511,100 @@ - - - + + - + - - + + - + + - - + + + + + - - + + + - - + - - - + - - + - - - - - + + + - + - + - - - - + + - + + - - + - - - + + + - - - - + + + + + + - - + + - + + + + + + + + + + + + + + + + + + @@ -759,329 +857,11 @@ Camera - - - N - false - - - - - Expo - - - - - 1 - - - - - - - - - - - - - 0.13.5 - 0.13.5 - Task6 - 0001-01-01T00:00:00.0000000+00:00 - Stage1 - Plimbo - false - false - - - - - - - - M - false - - - - - Expo - - - - - 1 - - - - - - - - - - - - - 0.13.5 - 0.13.5 - Task7 - 0001-01-01T00:00:00.0000000+00:00 - Stage2 - Plimbo - false - false - - - - - - - + + SessionInfo - - MetadataVisualizer - - - - Source1 - - - - - - MetadataVisualizer - - - - Source1 - - - CurrentMetadata - - - - - - Metadata - - - true - - - true - 7 - None - - 0 - 0 - - 0 - - - true - - - CurrentMetadata - - - Experimenter - - - - - - Source1 - - - Count - - - - 0 - - - - - - - - - - - - - - 0 - - - - - - - - - true - Expo - - - true - - - CurrentMetadata - - - Subject - - - - - - - - true - Plimbo - - - true - - - CurrentMetadata - - - SessionName - - - - - - - - true - Stage1 - - - true - - - CurrentMetadata - - - Experiment - - - - - - - - true - Task6 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - Habituation - - - true - - - Habituation - true - None - 0 - 0 - 0 - - - - - - true - - - true - START - - - true - - - true - STOP - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Metadata PreSession @@ -1122,20 +902,6 @@ - - - - - - - - - - - - - - \ No newline at end of file From 692c59056118f5b348bb65d83612cd634459bd63 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 2 Jul 2026 15:12:23 +0100 Subject: [PATCH 021/116] Use reactive timestamps to revert to active software event display --- src/Extensions/SoftwareEventVisualizer.cs | 16 +- src/test_ethogram.bonsai | 221 +++------------------- 2 files changed, 34 insertions(+), 203 deletions(-) diff --git a/src/Extensions/SoftwareEventVisualizer.cs b/src/Extensions/SoftwareEventVisualizer.cs index 3d2037da..87eb785b 100644 --- a/src/Extensions/SoftwareEventVisualizer.cs +++ b/src/Extensions/SoftwareEventVisualizer.cs @@ -1,4 +1,4 @@ -using AllenNeuralDynamics.AindBehaviorServices.DataTypes; +using AllenNeuralDynamics.AindBehaviorServices.DataTypes; using Bonsai; using Hexa.NET.ImGui; using Hexa.NET.ImPlot; @@ -18,7 +18,7 @@ public class SoftwareEventVisualizer { public bool Visible {get; set;} - public ImmutableList> SoftwareEvents {get; set;} + public ImmutableList> SoftwareEvents {get; set;} public string TrialBreakEventName {get; set;} private const float MinPlotHeight = 100.0f; @@ -34,6 +34,7 @@ public class SoftwareEventVisualizer private readonly Dictionary> eventHistory = new Dictionary>(); private readonly List trialBreaks = new List(); private double lastTrialBreak = 0; + private DateTimeOffset startTime; private double latestTimestamp = 0; private bool HasTrialBreaks { get { return !string.IsNullOrEmpty(TrialBreakEventName); } } @@ -43,6 +44,8 @@ public IObservable Process(IObservable source) { return Observable.Create(observer => { + startTime = DateTimeOffset.Now; + SoftwareEvents.Clear(); eventHistory.Clear(); trialBreaks.Clear(); lastTrialBreak = 0; @@ -53,8 +56,7 @@ public IObservable Process(IObservable source) { foreach (var v in SoftwareEvents) { - double timestamp = v.Seconds; - latestTimestamp = timestamp; + double timestamp = (v.Timestamp - startTime).TotalSeconds; string name = v.Value.Name; if (HasTrialBreaks && name == TrialBreakEventName) @@ -89,7 +91,9 @@ public IObservable Process(IObservable source) } private void CleanupOldEvents() - { + { + latestTimestamp = (DateTimeOffset.Now - startTime).TotalSeconds; + double cutoffTime = latestTimestamp - timeWindow; if (HasTrialBreaks && maxTrials > 0 && trialBreaks.Count > 0) @@ -143,6 +147,8 @@ private void CleanupOldEvents() private void DrawEvents() { + latestTimestamp = (DateTimeOffset.Now - startTime).TotalSeconds; + ImGui.Text("Time Window (s):"); ImGui.SameLine(); ImGui.SetNextItemWidth(InputWidth); diff --git a/src/test_ethogram.bonsai b/src/test_ethogram.bonsai index 70d9851f..dfdccaad 100644 --- a/src/test_ethogram.bonsai +++ b/src/test_ethogram.bonsai @@ -47,7 +47,7 @@ - PT2.178S + PT2.266S @@ -99,7 +99,7 @@ - PT2.874S + PT1.529S @@ -170,7 +170,7 @@ - PT0.133S + PT1.415S @@ -205,29 +205,19 @@ PT0S - - - - - SoftwareEvent - - - SoftwareEvent - - - - 0 - 5 - - - Break + + SoftwareEvent + - + + + + SoftwareEvent @@ -253,6 +243,12 @@ + + + + + + @@ -315,177 +311,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Break @@ -607,14 +432,14 @@ - - - - - - + + + + + + - + From cbd011cd31c13b7182eabfb140030545a075679a Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 2 Jul 2026 15:30:33 +0100 Subject: [PATCH 022/116] Integrate ethogram into test workflow and finalize blockout --- src/Extensions/SoftwareEventVisualizer.cs | 5 +- src/test_behavior_visualizer.bonsai | 626 +++++++++++++++++----- 2 files changed, 481 insertions(+), 150 deletions(-) diff --git a/src/Extensions/SoftwareEventVisualizer.cs b/src/Extensions/SoftwareEventVisualizer.cs index 87eb785b..6d141f2e 100644 --- a/src/Extensions/SoftwareEventVisualizer.cs +++ b/src/Extensions/SoftwareEventVisualizer.cs @@ -20,8 +20,8 @@ public class SoftwareEventVisualizer public bool Visible {get; set;} public ImmutableList> SoftwareEvents {get; set;} public string TrialBreakEventName {get; set;} + public float PlotHeight {get; set;} - private const float MinPlotHeight = 100.0f; private const double YAxisMin = 0.0; private const double YAxisMax = 1.0; private const float InputWidth = 80.0f; @@ -156,7 +156,6 @@ private void DrawEvents() if (timeWindow < 1.0f) timeWindow = 1.0f; var availableSize = ImGui.GetContentRegionAvail(); - float plotHeight = Math.Max(availableSize.Y, MinPlotHeight); double plotTMin = -(double)timeWindow; double plotTMax = 0.0; @@ -168,7 +167,7 @@ private void DrawEvents() double yMax = HasTrialBreaks ? (double)(firstVisible + numVisible) : YAxisMax; ImPlot.SetNextAxesLimits(plotTMin, plotTMax, yMin, yMax, ImPlotCond.Always); - if (ImPlot.BeginPlot("Software Events", new Vector2(-1, plotHeight), ImPlotFlags.NoTitle)) + if (ImPlot.BeginPlot("Software Events", new Vector2(-1, PlotHeight), ImPlotFlags.NoTitle)) { ImPlot.SetupAxes("Time (s)", HasTrialBreaks ? "Trial" : "Value"); ImPlot.SetupAxisLimits(ImAxis.Y1, yMin, yMax, ImPlotCond.Always); diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index b8ee4d5e..8c36e1f4 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -3,13 +3,16 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wie="clr-namespace:Bonsai.Windows.Input;assembly=Bonsai.Windows.Input" xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" - xmlns:p1="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" - xmlns:p2="clr-namespace:Bonsai.Numerics.Distributions;assembly=Bonsai.Numerics" - xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" + xmlns:p1="clr-namespace:Bonsai.Numerics.Distributions;assembly=Bonsai.Numerics" + xmlns:p2="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" + xmlns:p3="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" + xmlns:p4="clr-namespace:AllenNeuralDynamics.AindBehaviorServices.DataTypes;assembly=AllenNeuralDynamics.AindBehaviorServices" xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" + xmlns:p5="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" + xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns:num="clr-namespace:Bonsai.Numerics;assembly=Bonsai.Numerics" xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp" - xmlns:p3="clr-namespace:;assembly=Extensions" + xmlns:p6="clr-namespace:;assembly=Extensions" xmlns:cv="clr-namespace:Bonsai.Vision;assembly=Bonsai.Vision" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" @@ -33,6 +36,226 @@ LickLeft + + + PT1S + + + + + + + + 0 + 3 + + + + + + + + + + + + + + + + PT1.724S + + + + + 0 + + + + + ResponsePeriod + + + + SoftwareEvent + + + + + + + + + + + + + + + + + + + + + 0 + 3 + + + + + + + + + + + + + + + + PT2.727S + + + + + 0 + + + + + RewardPeriod + + + + SoftwareEvent + + + + + + + + + + + + + + + + + + PT2S + + + + + + false + + + + + TrialOutcome + + + + SoftwareEvent + + + + + + + 0 + 3 + + + + + + + + + + + + + + + + PT0.896S + + + + + 0 + + + + + ITI + + + + SoftwareEvent + + + + + + + + + + + + + + + + + + PT0S + + + + + Break + + + + SoftwareEvent + + + + + + SoftwareEvent + + + TimeBase + + + + + + + + + + + + + + + + + + SoftwareEventHistory + PT5S @@ -57,15 +280,15 @@ - - 0.13.5 - 0.13.5 - Task6 - 0001-01-01T00:00:00.0000000+00:00 - Stage1 - Plimbo - false - false + + 0.13.5 + 0.13.5 + Task6 + 0001-01-01T00:00:00.0000000+00:00 + Stage1 + Plimbo + false + false @@ -96,15 +319,15 @@ - - 0.13.5 - 0.13.5 - Task7 - 0001-01-01T00:00:00.0000000+00:00 - Stage2 - Plimbo - false - false + + 0.13.5 + 0.13.5 + Task7 + 0001-01-01T00:00:00.0000000+00:00 + Stage2 + Plimbo + false + false @@ -129,7 +352,7 @@ Item2 - + @@ -172,9 +395,9 @@ - - 0.1 - 1 + + 0.1 + 1 @@ -186,9 +409,9 @@ - - -0.1 - 0.1 + + -0.1 + 0.1 @@ -210,14 +433,14 @@ TimeBase - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -252,14 +475,14 @@ (it +1) * 0.5 - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -276,19 +499,19 @@ - - true + + true - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -297,8 +520,8 @@ - - + + @@ -329,14 +552,14 @@ (it +1) * 0.5 - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -360,14 +583,14 @@ - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -381,24 +604,24 @@ - - false + + true - - + + - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -424,16 +647,16 @@ - - 0.59164587077011477 - 0.40913708100521279 - 5 - 0 - 5 - 0.5 - 5 - - 0 + + 0.59164587077011477 + 0.40913708100521279 + 5 + 0 + 5 + 0.5 + 5 + + 0 @@ -442,9 +665,9 @@ - - true - false + + true + true @@ -458,7 +681,7 @@ Random - + TimeSpan.FromSeconds(it) @@ -470,7 +693,7 @@ - PT0.424S + PT0.802S @@ -517,94 +740,112 @@ - + - - + - - - + + + - - - - + + + + - + + - - + + + + + - - + + - - + - - - + - - - + - - - + + - - - - - - + + + + - + - - + - - - - + + + + + - + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -779,6 +1020,12 @@ Bias + + true + + + Ethogram + @@ -846,16 +1093,95 @@ Bias TimedBias + + Ethogram + + + SoftwareEventHistory + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + Break + 200 + + + TrialOutcome + CornflowerBlue + 0.3 + + + RewardPeriod + Crimson + 0.3 + + + ITI + Cyan + 0.3 + + + + + TrialOutcome + SaddleBrown + 0.5 + 2 + Circle + + + LickLeft + Red + 0.8 + 2 + Down + + + LickRight + DodgerBlue + 0.2 + 2 + Up + + + + TriggeredCamerasStream Camera - - - Camera - + + Camera SessionInfo @@ -874,34 +1200,40 @@ - - + + - + + - + - - - - - - - + + + + + + + - - + - + + - - - + + + + + + + + \ No newline at end of file From cc086be000d4fdd7af2e55f21a7030df28fddfdf Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 2 Jul 2026 15:33:36 +0100 Subject: [PATCH 023/116] Group visualizer structure logic --- src/test_behavior_visualizer.bonsai | 305 ++++++++++++++-------------- 1 file changed, 156 insertions(+), 149 deletions(-) diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 8c36e1f4..e2b1935c 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -63,7 +63,7 @@ - PT1.724S + PT0.56S @@ -115,7 +115,7 @@ - PT2.727S + PT2.592S @@ -186,7 +186,7 @@ - PT0.896S + PT0.034S @@ -500,7 +500,7 @@ - true + false @@ -605,7 +605,7 @@ - true + false @@ -666,8 +666,8 @@ - true - true + false + false @@ -693,7 +693,7 @@ - PT0.802S + PT0.689S @@ -979,108 +979,150 @@ Frame - - Frame - - - true - - - true - 2 - Borders - - 0 - 0 - - 0 - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - Behavior - - - true - - - Bias - - - true - - - Ethogram - - - - - - true - - - Camera - - - - - - true - - - true - 1 - Borders - - 0 - 0 - - 0 - - - Metadata - - - true - - - true - None - - - PreSession - true - pre-session - None - - - PreSession - - - InterSession - true - inter-session - None - - - InterSession - - - + + VisualizerStructure + + + + + + + Frame + + + true + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + Behavior + + + true + + + Bias + + + true + + + Ethogram + + + + + + true + + + Camera + + + + + + true + + + true + 1 + Borders + + 0 + 0 + + 0 + + + Metadata + + + true + + + true + None + + + PreSession + true + pre-session + None + + + PreSession + + + InterSession + true + inter-session + None + + + InterSession + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Behavior1 @@ -1123,12 +1165,6 @@ - - - - - - Break 200 @@ -1199,41 +1235,12 @@ - - - - - - - + - - - - + - - - - - - - - - - - - - - - - - - - - - - + + \ No newline at end of file From 9b22cdaa41f2cee5e2801601b349751ededca3ae Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 2 Jul 2026 15:53:20 +0100 Subject: [PATCH 024/116] Add plot layout, context and behavior visualizer --- src/main.bonsai | 1281 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 1280 insertions(+), 1 deletion(-) diff --git a/src/main.bonsai b/src/main.bonsai index a5e1dbe9..af64d787 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -8,6 +8,13 @@ xmlns:p3="clr-namespace:System.Reactive;assembly=System.Reactive.Core" xmlns:p4="clr-namespace:AllenNeuralDynamics.AindBehaviorServices.DataTypes;assembly=AllenNeuralDynamics.AindBehaviorServices" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" + xmlns:p5="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" + xmlns:gui="clr-namespace:Bonsai.Gui;assembly=Bonsai.Gui" + xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:p6="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" + xmlns:ui="clr-namespace:Bonsai.Design;assembly=Bonsai.Design" + xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" + xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -392,7 +399,1279 @@ - + + Visualizers + + + + + + 0 + + + + + + + + + TrialPlots + + + + GlobalTrialOutcome + + + 16 + + + + SoftwareEvent + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + LickRight + + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + + + LickLeft + + + + GiveRewardRight + + + + + + Source1 + + + + + + + + + + + WaterRight + + + + GiveRewardRight + + + + + + + Source1 + + + + + + + + + + + WaterLeft + + + + + + + 16 + 20 + + + QuiscentPeriod + Gold + 0.3 + + + ResponsePeriod + SandyBrown + 0.3 + + + RewardConsumptionPeriod + RosyBrown + 0.3 + + + ItiPeriod + Green + 0.3 + + + + + LickLeft + Red + 0.9 + 6 + Down + + + LickRight + Blue + 0.1 + 6 + Up + + + IsRightTriggerQuickRetract + DarkCyan + 0.5 + 6 + Plus + + + DeliverSecondaryReinforcer + Sienna + 0.5 + 6 + Plus + + + WaterRight + Blue + 0.2 + 6 + Circle + + + WaterLeft + Red + 0.8 + 6 + Circle + + + + 5 + + + + true + true + 1 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ManualOverrides + + + + OffsetControl + + + + + 0.05 + + + + + 1 + + + + BumpSize + + + ManipulatorBiasTracker + + + {0:F2} + + + + + + + + true + true + Microsoft Sans Serif, 20.25pt + 0.00 + + + + Left + true + true + Microsoft Sans Serif, 15.75pt + ◀️ + + + BumpLeft + + + + Source1 + + + BumpSize + + + + + + Item2 + + + + -1 + + + + ManualSpoutDelta + + + + + + + + + + + + + + + + Right + true + true + Microsoft Sans Serif, 15.75pt + + + + BumpRight + + + + Source1 + + + BumpSize + + + + + + Item2 + + + ManualSpoutDelta + + + + + + + + + + + + + + + true + true + 2 + 1 + + + + + + + ExperimentState + + + + + + + + false + true + Microsoft Sans Serif, 22.125pt + 1 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Spout offset + true + true + Microsoft Sans Serif, 15.75pt + Spout offset + + + + GiveWaterUI + + + + Left + true + true + 💧◀ + + + TriggerLeft + + + + Source1 + + + + false + + + + GiveManualWaterRight + + + + + + + + + + + + + Right + true + true + 💧▶ + + + TriggerRight + + + + Source1 + + + + true + + + + GiveManualWaterRight + + + + + + + + + + + + + ManualWater + true + true + 2 + 1 + + + Percent + 0.5 + + + Percent + 0.5 + + + + + + + + GiveManualWaterRight + + + GiveManualWaterRight + + + GiveRewardRight + + + + + + + + + + + + + + + + + + 💧 + true + true + Microsoft Sans Serif, 8.25pt + + + + + ForceAutoWater + + + + GlobalAutoWaterState + + + !it.IsLeft + + + + + + + + SetLeft + true + true + 🎣◀ + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetLeft() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + + GlobalAutoWaterState + + + !it.IsRight + + + + + + + + SetRight + true + true + 🎣▶ + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetRight() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + + GlobalAutoWaterState + + + it.HasValue + + + + + + + + Reset + false + true + + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.Reset() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + + ForceAutoWater + true + true + 3 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 🎣 + true + true + Microsoft Sans Serif, 8.25pt + + + + + true + true + Microsoft Sans Serif, 15.75pt + + + + Manual Control + true + true + Microsoft Sans Serif, 36pt + 1 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + LauncherControl + + + + + + + + ExperimentState + + + + + + + + + Start + true + true + Start Experiment + + + StartExperimentToggleButton + + + + End + true + true + End Experiment + + + EndExperimentButton + + + + LauncherControl + true + true + Microsoft Sans Serif, 26pt + 2 + 4 + + + + + + + + + + + StartExperimentToggleButton + + + + 1 + + + + + StartExperimentShortcut + + + EndExperimentButton + + + + 1 + + + + + EndExperiment + + + StartExperiment + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + + + + + true + true + 1 + 2 + + + + + + + + true + true + 3 + 1 + + + + + + + + + TriggeredCamerasStream + + + + + + + + + + + true + true + 2 + 1 + + + + + + + true + true + 1 + 2 + + + Percent + 0.75 + + + Percent + 0.25 + + + + + + + + GlobalTrial + + + 2 + 16 + + + + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DynamicForaging + true + + + Maximized + + + + GlobalTrialOutcome + + + HarpTimestampSource + + + TimedTrial + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + HarpTimestampSource + + + LickRight + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + + HarpTimestampSource + + + LickLeft + + + + true + 1 + None + + 0 + 0 + + 0 + + + Frame + + + VisualizerStructure + + + + + + + Frame + + + true + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + Behavior + + + true + + + Bias + + + true + + + Ethogram + + + + + + true + + + Camera + + + + + + true + + + true + 1 + Borders + + 0 + 0 + + 0 + + + Metadata + + + true + + + true + None + + + PreSession + true + pre-session + None + + + PreSession + + + InterSession + true + inter-session + None + + + InterSession + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Behavior1 + LickLeft + LickRight + TimedTrial + Behavior + + + + + + + + + + + + + + + + + + From e2a98de34de6ce88b0387daf963928bc150a3cb8 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 2 Jul 2026 15:58:37 +0100 Subject: [PATCH 025/116] Add bias visualizer --- src/main.bonsai | 55 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index af64d787..0985a12e 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -1426,6 +1426,20 @@ Maximized + + + true + 1 + None + + 0 + 0 + + 0 + + + Frame + GlobalTrialOutcome @@ -1461,6 +1475,21 @@ LickRight + + GlobalTrialMetrics + + + Bias + + + new (it as Bias) + + + HarpTimestampSource + + + TimedBias + IsRightLickEvent @@ -1489,20 +1518,6 @@ LickLeft - - - true - 1 - None - - 0 - 0 - - 0 - - - Frame - VisualizerStructure @@ -1655,6 +1670,10 @@ TimedTrial Behavior + + Bias + TimedBias + @@ -1663,12 +1682,16 @@ - + - + + + + + From ffb2b17a260c7800952c6c652ff84bedf59d6faf Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 2 Jul 2026 16:02:27 +0100 Subject: [PATCH 026/116] Integrate software event visualizer --- src/main.bonsai | 267 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 186 insertions(+), 81 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index 0985a12e..d6cd141e 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -1426,98 +1426,155 @@ Maximized - - - true - 1 - None - - 0 - 0 - - 0 - - - Frame - - - GlobalTrialOutcome - - - HarpTimestampSource - - - TimedTrial - - - IsRightLickEvent - - + + ImGuiContext - - Source1 + + + true + 1 + None + + 0 + 0 + + 0 - - Value + + Frame + - - HarpTimestampSource - - - LickRight - - - GlobalTrialMetrics - - - Bias - - - new (it as Bias) - - - HarpTimestampSource - - - TimedBias - - - IsRightLickEvent - - + + DataTransformations - - Source1 + + GlobalTrialOutcome + + + HarpTimestampSource + + + TimedTrial + + + GlobalTrialMetrics - Value + Bias + + + new (it as Bias) + + + HarpTimestampSource + + + TimedBias + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + HarpTimestampSource + + + LickRight + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + + HarpTimestampSource + + + LickLeft + + + SoftwareEvent + + + HarpTimestampSource + + + + + + + + + + + + EthogramEvents - - - + + + + + + + + + + + + + + + - - HarpTimestampSource - - - LickLeft - VisualizerStructure @@ -1674,24 +1731,72 @@ Bias TimedBias + + Ethogram + + + EthogramEvents + + + + + + + + + true + + Break + 200 + + + TrialOutcome + CornflowerBlue + 0.3 + + + RewardPeriod + Crimson + 0.3 + + + ITI + Cyan + 0.3 + + + + + TrialOutcome + SaddleBrown + 0.5 + 2 + Circle + + + LickLeft + Red + 0.8 + 2 + Down + + + LickRight + DodgerBlue + 0.2 + 2 + Up + + + + - - - - + - - - - - - - - - + From 7e31087de0c92b1a1e8fbaab447ae5ed3bce9c3d Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 2 Jul 2026 16:06:54 +0100 Subject: [PATCH 027/116] Integrate camera visualizer and update for Spinnaker frame input --- src/Extensions/CameraPreviewVisualizer.bonsai | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Extensions/CameraPreviewVisualizer.bonsai b/src/Extensions/CameraPreviewVisualizer.bonsai index 13b3ccc1..ca939bfb 100644 --- a/src/Extensions/CameraPreviewVisualizer.bonsai +++ b/src/Extensions/CameraPreviewVisualizer.bonsai @@ -142,7 +142,7 @@ CurrentStream - Value + Value.Image FlipState From 0b0582836d9ca4d58295b5ac7742e5ee548907f0 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 2 Jul 2026 16:22:28 +0100 Subject: [PATCH 028/116] Integrate metadata visualizer and update with control subjects --- src/Extensions/MetadataVisualizer.bonsai | 26 ++- src/main.bonsai | 276 +++++++++++++++++++++++ 2 files changed, 300 insertions(+), 2 deletions(-) diff --git a/src/Extensions/MetadataVisualizer.bonsai b/src/Extensions/MetadataVisualizer.bonsai index 589fb728..fe4b64b1 100644 --- a/src/Extensions/MetadataVisualizer.bonsai +++ b/src/Extensions/MetadataVisualizer.bonsai @@ -11,6 +11,8 @@ + + MetadataVisualizer @@ -182,6 +184,13 @@ true START + + + + + + StartExperimentShortcut + true @@ -189,6 +198,13 @@ true STOP + + + + + + EndExperiment + @@ -201,7 +217,7 @@ - + @@ -228,7 +244,13 @@ - + + + + + + + diff --git a/src/main.bonsai b/src/main.bonsai index d6cd141e..f7ae449a 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -1790,6 +1790,280 @@ + + TriggeredCamerasStream + + + Camera + + + SessionSchema + + + MetadataVisualizer + + + + Source1 + + + + + + + + MetadataVisualizer + + + + Source1 + + + CurrentMetadata + + + + + + Metadata + + + true + + + true + 7 + None + + 0 + 0 + + 0 + + + true + + + CurrentMetadata + + + Experimenter + + + + + + Source1 + + + Count + + + + 0 + + + + + + + + + + + + + + 0 + + + + + + + + + true + Expo + + + true + + + CurrentMetadata + + + Subject + + + + + + + + true + Plimbo + + + true + + + CurrentMetadata + + + SessionName + + + + + + + + true + Stage1 + + + true + + + CurrentMetadata + + + Experiment + + + + + + + + true + Task6 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Habituation + + + true + + + Habituation + true + None + 0 + 0 + 0 + + + + + + true + + + true + START + + + + + + + StartExperimentShortcut + + + true + + + true + STOP + + + + + + + EndExperiment + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1797,6 +2071,8 @@ + + From 532bb2eb59ba3721b0fec2a6f648fd1f77683a44 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 2 Jul 2026 16:33:47 +0100 Subject: [PATCH 029/116] Integrate inter session visualizer and define ui controls --- src/Extensions/InterSessionVisualizer.bonsai | 68 ++++- src/main.bonsai | 300 ++++++++----------- 2 files changed, 180 insertions(+), 188 deletions(-) diff --git a/src/Extensions/InterSessionVisualizer.bonsai b/src/Extensions/InterSessionVisualizer.bonsai index cef93000..f9e91047 100644 --- a/src/Extensions/InterSessionVisualizer.bonsai +++ b/src/Extensions/InterSessionVisualizer.bonsai @@ -9,6 +9,10 @@ + + + + InterSessionVisualizer @@ -51,6 +55,13 @@ true Give Left + + + + + + UiGiveLeft + true @@ -59,6 +70,13 @@ true Give Right + + + + + + UiGiveRight + @@ -80,6 +98,13 @@ true Move Left + + + + + + UiMoveLeft + true @@ -88,6 +113,13 @@ true Move Right + + + + + + UiMoveRight + @@ -116,26 +148,38 @@ - - + + - + - + - - + + - + - - - + + - + + + - + + + + + + + + + + + + diff --git a/src/main.bonsai b/src/main.bonsai index f7ae449a..b9f2e8e4 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -1575,6 +1575,26 @@ + + OutputControl + + + + UiMoveLeft + + + UiGiveRight + + + UiGiveLeft + + + UiMoveRight + + + + + VisualizerStructure @@ -1799,41 +1819,36 @@ SessionSchema + + Metadata + StartExperimentShortcut + EndExperiment + - MetadataVisualizer + InterSessionVisualizer - - Source1 - - - + + + + - - MetadataVisualizer + + InterSessionVisualizer - - Source1 - - - CurrentMetadata - - Metadata - - - true + InterSession true - 7 - None + 3 + Borders 0 0 @@ -1843,105 +1858,48 @@ true - - CurrentMetadata - - - Experimenter - - - - - - Source1 - - - Count - - - - 0 - - - - - - - - - - - - - - 0 - - - - - - - - + true - Expo + 2 + None + + 0 + 0 + + 0 true - - CurrentMetadata - - - Subject - - - - - - - - true - Plimbo - - + + GiveLeft true + Give Left - - CurrentMetadata - - - SessionName - - - - - + + + - - true - Stage1 + + UiGiveLeft true - - CurrentMetadata - - - Experiment + + GiveRight + true + Give Right - - - - + + + - - true - Task6 + + UiGiveRight - - true + + true @@ -1956,111 +1914,101 @@ true - - true - Habituation - - + + MoveLeft true + Move Left - - Habituation - true - None - 0 - 0 - 0 + + + - - + + UiMoveLeft true + MoveRight true - START + Move Right - + - StartExperimentShortcut + UiMoveRight + + + + + + true - + + SessionInfo true - STOP + Session Info - - - + + true - - EndExperiment + + Notes + true + Notes + 16384 + + + + + - - - - - - - - - - + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - + - - - - - - - + + @@ -2068,11 +2016,11 @@ - - - - - + + + + + From 4f2fb7e8e855d3f9962b0558b7774970a329ddc1 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 2 Jul 2026 16:35:30 +0100 Subject: [PATCH 030/116] Update metadata visualizer control signal routing --- src/Extensions/MetadataVisualizer.bonsai | 33 ++- src/main.bonsai | 284 +++++++++++++++-------- 2 files changed, 208 insertions(+), 109 deletions(-) diff --git a/src/Extensions/MetadataVisualizer.bonsai b/src/Extensions/MetadataVisualizer.bonsai index fe4b64b1..0f36140f 100644 --- a/src/Extensions/MetadataVisualizer.bonsai +++ b/src/Extensions/MetadataVisualizer.bonsai @@ -13,6 +13,7 @@ + MetadataVisualizer @@ -174,6 +175,12 @@ 0 0 + + + + + UiHabituationTimeUpdate + @@ -216,8 +223,8 @@ - - + + @@ -240,17 +247,19 @@ - + - - - - - - - - - + + + + + + + + + + + diff --git a/src/main.bonsai b/src/main.bonsai index b9f2e8e4..7f5edd37 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -1591,6 +1591,9 @@ UiMoveRight + + UiHabituationTimeUpdate + @@ -1819,48 +1822,40 @@ SessionSchema - - Metadata - StartExperimentShortcut - EndExperiment - - InterSessionVisualizer + MetadataVisualizer + + Source1 + - - - - + + - - InterSessionVisualizer + + MetadataVisualizer + + Source1 + + + CurrentMetadata + - InterSession - - - true - 3 - Borders - - 0 - 0 - - 0 + Metadata true true - 2 + 7 None 0 @@ -1871,35 +1866,105 @@ true - - GiveLeft + + CurrentMetadata + + + Experimenter + + + + + + Source1 + + + Count + + + + 0 + + + + + + + + + + + + + + 0 + + + + + + + + true - Give Left + Expo - - - + + true - - UiGiveLeft + + CurrentMetadata + + + Subject + + + + + + + + true + Plimbo true - - GiveRight + + CurrentMetadata + + + SessionName + + + + + + + true - Give Right + Stage1 - - - + + true - - UiGiveRight + + CurrentMetadata - - + + Experiment + + + + + + + + true + Task6 + + + true true @@ -1914,104 +1979,129 @@ true - - MoveLeft + true - Move Left + Habituation + + + true + + + Habituation + true + None + 0 + 0 + 0 - - + - UiMoveLeft + UiHabituationTimeUpdate + + + true - MoveRight true - Move Right + START - + - UiMoveRight - - - - - - + StartExperimentShortcut true - - SessionInfo + true - Session Info + STOP - - true + + + - - Notes - true - Notes - 16384 + + EndExperiment - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + - - + + + + + + InterSession + UiGiveLeft + UiGiveRight + UiMoveLeft + UiMoveRight + From 8c1d28a3ad00e3aea399bcad5ba70fb985b8399a Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 2 Jul 2026 17:03:49 +0100 Subject: [PATCH 031/116] Integrate pre-session visualizer --- src/Extensions/PreSessionVisualizer.bonsai | 325 ++++++++++++++++----- src/main.bonsai | 277 +----------------- 2 files changed, 261 insertions(+), 341 deletions(-) diff --git a/src/Extensions/PreSessionVisualizer.bonsai b/src/Extensions/PreSessionVisualizer.bonsai index ba8e4a09..05bd7db7 100644 --- a/src/Extensions/PreSessionVisualizer.bonsai +++ b/src/Extensions/PreSessionVisualizer.bonsai @@ -8,6 +8,23 @@ + + + + + + + + + + + + + + + + + PreSessionVisualizer @@ -50,16 +67,37 @@ true Keep Left Open + + + + + + UiKeepLeftOpen + KeepRightOpen true Keep Right Open + + + + + + UiKeepRightOpen + KeepBothOpen true Keep Both Open + + + + + + UiKeepBothOpen + @@ -71,16 +109,37 @@ true Drain 5ml Left + + + + + + UiDrainLeft + Drain Right true Drain 5ml Right + + + + + + UiDrainRight + Drain Both true Drain 5ml Both + + + + + + UiDrainBoth + @@ -134,21 +193,49 @@ true Move Left + + + + + + UiManipulatorLeft + ForwardLeft true Forward Left + + + + + + UiManipulatorForwardLeft + ForwardRight true Forward Right + + + + + + UiManipulatorForwardRight + Up true Up + + + + + + UiManipulatorUp + @@ -160,21 +247,49 @@ true Move Right + + + + + + UiManipulatorRight + BackLeft true Back Left + + + + + + UiManipulatorBackLeft + BackRight true Back Right + + + + + + UiManipulatorBackRight + Down true Down + + + + + + UiManipulatorDown + @@ -189,16 +304,37 @@ true STOP + + + + + + UiManipulatorStop + Home true Home + + + + + + UiManipulatorHome + Initialize true Initialize + + + + + + UiManipulatorInitialize + @@ -308,90 +444,141 @@ - + - + - - - - - - + + + + + + - - - - - - - - - - + + + + + + + + - + + - - - - - - - - - - - + + + + + + + - - - - - - - - - + + + + + - - - - - - + + + + + + + + + + + - - - - - - - - - - - - + + + - - - - + + + + + + - - - + + + + - - + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main.bonsai b/src/main.bonsai index 7f5edd37..688ad795 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -1822,278 +1822,11 @@ SessionSchema - - MetadataVisualizer - - - - Source1 - - - - - - - - MetadataVisualizer - - - - Source1 - - - CurrentMetadata - - - - - - Metadata - - - true - - - true - 7 - None - - 0 - 0 - - 0 - - - true - - - CurrentMetadata - - - Experimenter - - - - - - Source1 - - - Count - - - - 0 - - - - - - - - - - - - - - 0 - - - - - - - - - true - Expo - - - true - - - CurrentMetadata - - - Subject - - - - - - - - true - Plimbo - - - true - - - CurrentMetadata - - - SessionName - - - - - - - - true - Stage1 - - - true - - - CurrentMetadata - - - Experiment - - - - - - - - true - Task6 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - Habituation - - - true - - - Habituation - true - None - 0 - 0 - 0 - - - - - - UiHabituationTimeUpdate - - - - - - true - - - true - START - - - - - - - StartExperimentShortcut - - - true - - - true - STOP - - - - - - - EndExperiment - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Metadata + StartExperimentShortcut + EndExperiment + UiHabituationTimeUpdate InterSession From 8fbad110a5f2a9ff31aea53253d7b18b4b5b0628 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 2 Jul 2026 17:09:27 +0100 Subject: [PATCH 032/116] Add remaining UI signal subjects --- src/main.bonsai | 75 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index 688ad795..88a78dbd 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -1579,6 +1579,9 @@ OutputControl + + UiHabituationTimeUpdate + UiMoveLeft @@ -1591,8 +1594,56 @@ UiMoveRight - - UiHabituationTimeUpdate + + UiKeepLeftOpen + + + UiKeepRightOpen + + + UiKeepBothOpen + + + UiDrainLeft + + + UiDrainRight + + + UiDrainBoth + + + UiManipulatorLeft + + + UiManipulatorForwardLeft + + + UiManipulatorForwardRight + + + UiManipulatorUp + + + UiManipulatorRight + + + UiManipulatorBackRight + + + UiManipulatorBackLeft + + + UiManipulatorDown + + + UiManipulatorStop + + + UiManipulatorHome + + + UiManipulatorInitialize @@ -1828,6 +1879,26 @@ EndExperiment UiHabituationTimeUpdate + + PreSession + UiKeepLeftOpen + UiKeepRightOpen + UiKeepBothOpen + UiDrainLeft + UiDrainRight + UiDrainBoth + UiManipulatorLeft + UiManipulatorForwardLeft + UiManipulatorForwardRight + UiManipulatorUp + UiManipulatorRight + UiManipulatorBackLeft + UiManipulatorBackRight + UiManipulatorDown + UiManipulatorStop + UiManipulatorHome + UiManipulatorInitialize + InterSession UiGiveLeft From 18a1ccf95a75f15d686c5fe8662105bf009e5ddb Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Fri, 3 Jul 2026 16:30:29 +0100 Subject: [PATCH 033/116] Populate ethogram event plotters --- src/main.bonsai | 178 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 158 insertions(+), 20 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index 88a78dbd..25b4a41c 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -1538,6 +1538,104 @@ SoftwareEvent + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + LickRight + + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + + + LickLeft + + + + GiveRewardRight + + + + + + Source1 + + + + + + + + + + + WaterRight + + + + GiveRewardRight + + + + + + + Source1 + + + + + + + + + + + WaterLeft + + + + + HarpTimestampSource @@ -1567,11 +1665,25 @@ - + - + + + + + + + + + + + + + + + @@ -1824,43 +1936,69 @@ 200 - TrialOutcome - CornflowerBlue + QuiescentPeriod + Gold 0.3 - RewardPeriod - Crimson + ResponsePeriod + SandyBrown 0.3 - ITI - Cyan + RewardConsumptionPeriod + RosyBrown + 0.3 + + + ItiPeriod + Green 0.3 - - TrialOutcome - SaddleBrown - 0.5 - 2 - Circle - LickLeft Red - 0.8 - 2 + 0.9 + 6 Down LickRight - DodgerBlue - 0.2 - 2 + Blue + 0.1 + 6 Up + + IsRightTriggerQuickRetract + DarkCyan + 0.5 + 6 + Plus + + + DeliverSecondaryReinforcer + Sienna + 0.5 + 6 + Plus + + + WaterRight + Blue + 0.2 + 6 + Circle + + + WaterLft + Red + 0.8 + 6 + Circle + From 4b35fcaf2de6e254b435dbecddd9a5c7d9e0257b Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Fri, 3 Jul 2026 16:35:29 +0100 Subject: [PATCH 034/116] Update behavior visualizer to plot metadata PReward --- src/Extensions/BehaviorVisualizer.bonsai | 8 +- src/main.bonsai | 577 ++++++++++++++++++++++- 2 files changed, 577 insertions(+), 8 deletions(-) diff --git a/src/Extensions/BehaviorVisualizer.bonsai b/src/Extensions/BehaviorVisualizer.bonsai index 4d231097..be105b06 100644 --- a/src/Extensions/BehaviorVisualizer.bonsai +++ b/src/Extensions/BehaviorVisualizer.bonsai @@ -92,6 +92,8 @@ West None + + @@ -107,6 +109,8 @@ West None + + @@ -440,7 +444,7 @@ 1000 Seconds - Value.Trial.PRewardLeft + Value.Trial.Metadata.PRewardLeft ContinuousPlot @@ -461,7 +465,7 @@ 1000 Seconds - Value.Trial.PRewardRight + Value.Trial.Metadata.PRewardRight ContinuousPlot diff --git a/src/main.bonsai b/src/main.bonsai index 25b4a41c..4846b12c 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -15,6 +15,9 @@ xmlns:ui="clr-namespace:Bonsai.Design;assembly=Bonsai.Design" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" + xmlns:implot="clr-namespace:Bonsai.ImPlot;assembly=Bonsai.ImPlot" + xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" + xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -1906,12 +1909,574 @@ - - Behavior1 - LickLeft - LickRight - TimedTrial - Behavior + + BehaviorVisualizer + + + + + + + + + + + BehaviorPlot + + + + + + + Behavior + + + + + + Behavior1 + true + 1 + None + + 0 + 0 + + 0 + + + true + + + EventPlot + true + + -1 + 150 + + NoTitle + AutoFit + RangeFit + + + EventPlot + + + true + + + ContinuousPlot + true + + -1 + 150 + + NoTitle + AutoFit + None + + + ContinuousPlot + + + + EventPlot + + + + + 0 + 1 + + + R + L + + West + None + + + + + + + ContinuousPlot + + + + + 0 + 1 + + + West + None + + + + + + + + + LickLeft + + + Value + + + + 0.9 + + + + new(it as LickLeft) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickLeft + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + + + + LickRight + + + Value + + + + 0.1 + + + + new(it as LickRight) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickRight + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + + + + TimedTrial + + + + + + Value.ChoiceCategory + + + NoChoice + + + + Source1 + + + + NoChoice + + + + + + + + + + + + + 0.5 + + + + LeftChoice + + + + Source1 + + + + LeftChoice + + + + + + + + + + + + + 0.85 + + + + RightChoice + + + + Source1 + + + + RightChoice + + + + + + + + + + + + + 0.15 + + + + + + + new ( + it as Choice +) + + + Seconds + + + + + + + + + 1000 + Seconds + Value.Choice + + + EventPlot + + + + Circle + 3 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + + + + true + None + + + Value.TrialCategory + + + LeftRewarded + + + + Source1 + + + + LeftRewarded + + + + + + + + + + + + + 0.8 + + + + RightRewarded + + + + Source1 + + + + RightRewarded + + + + + + + + + + + + + 0.2 + + + + + + + new ( + it as Choice +) + + + + + + + + + 1000 + Seconds + Value.Choice + + + EventPlot + + + + Circle + 3 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 1 + 1 + + + + true + None + + + TimedTrial + + + 1000 + Seconds + Value.Trial.Metadata.PRewardLeft + + + ContinuousPlot + + + + 1 + 0 + 0 + 1 + 2 + + + + true + None + + + 1000 + Seconds + Value.Trial.Metadata.PRewardRight + + + ContinuousPlot + + + + 0 + 0 + 1 + 1 + 2 + + + + true + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Bias From 0482e14018b24816df07972c966684049a13d016 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 7 Jul 2026 00:04:13 +0400 Subject: [PATCH 035/116] Add tab bar for manual vs. cue reward --- src/main.bonsai | 583 +--------------------------- src/test_behavior_visualizer.bonsai | 449 +++++++++++++++++++-- 2 files changed, 420 insertions(+), 612 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index 4846b12c..1ed6d812 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -15,9 +15,6 @@ xmlns:ui="clr-namespace:Bonsai.Design;assembly=Bonsai.Design" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" - xmlns:implot="clr-namespace:Bonsai.ImPlot;assembly=Bonsai.ImPlot" - xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" - xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -1909,574 +1906,12 @@ - - BehaviorVisualizer - - - - - - - - - - - BehaviorPlot - - - - - - - Behavior - - - - - - Behavior1 - true - 1 - None - - 0 - 0 - - 0 - - - true - - - EventPlot - true - - -1 - 150 - - NoTitle - AutoFit - RangeFit - - - EventPlot - - - true - - - ContinuousPlot - true - - -1 - 150 - - NoTitle - AutoFit - None - - - ContinuousPlot - - - - EventPlot - - - - - 0 - 1 - - - R - L - - West - None - - - - - - - ContinuousPlot - - - - - 0 - 1 - - - West - None - - - - - - - - - LickLeft - - - Value - - - - 0.9 - - - - new(it as LickLeft) - - - Seconds - - - - - - 1000 - Item2 - Item1.LickLeft - - - EventPlot - - - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - - - - LickRight - - - Value - - - - 0.1 - - - - new(it as LickRight) - - - Seconds - - - - - - 1000 - Item2 - Item1.LickRight - - - EventPlot - - - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - - - - TimedTrial - - - - - - Value.ChoiceCategory - - - NoChoice - - - - Source1 - - - - NoChoice - - - - - - - - - - - - - 0.5 - - - - LeftChoice - - - - Source1 - - - - LeftChoice - - - - - - - - - - - - - 0.85 - - - - RightChoice - - - - Source1 - - - - RightChoice - - - - - - - - - - - - - 0.15 - - - - - - - new ( - it as Choice -) - - - Seconds - - - - - - - - - 1000 - Seconds - Value.Choice - - - EventPlot - - - - Circle - 3 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - 1 - 1 - - - - true - None - - - Value.TrialCategory - - - LeftRewarded - - - - Source1 - - - - LeftRewarded - - - - - - - - - - - - - 0.8 - - - - RightRewarded - - - - Source1 - - - - RightRewarded - - - - - - - - - - - - - 0.2 - - - - - - - new ( - it as Choice -) - - - - - - - - - 1000 - Seconds - Value.Choice - - - EventPlot - - - - Circle - 3 - 0 - 1 - 0 - 1 - 0 - 1 - 0 - 1 - 1 - - - - true - None - - - TimedTrial - - - 1000 - Seconds - Value.Trial.Metadata.PRewardLeft - - - ContinuousPlot - - - - 1 - 0 - 0 - 1 - 2 - - - - true - None - - - 1000 - Seconds - Value.Trial.Metadata.PRewardRight - - - ContinuousPlot - - - - 0 - 0 - 1 - 1 - 2 - - - - true - None - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Behavior1 + LickLeft + LickRight + TimedTrial + Behavior Bias @@ -2573,6 +2008,9 @@ Camera + + Camera + SessionSchema @@ -2617,7 +2055,8 @@ - + + diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index e2b1935c..0177a513 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -16,6 +16,8 @@ xmlns:cv="clr-namespace:Bonsai.Vision;assembly=Bonsai.Vision" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" + xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:p7="clr-namespace:System.Reactive;assembly=System.Reactive.Core" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -63,7 +65,7 @@ - PT0.56S + PT2.795S @@ -115,7 +117,7 @@ - PT2.592S + PT2.452S @@ -186,7 +188,7 @@ - PT0.034S + PT0.123S @@ -605,7 +607,7 @@ - false + true @@ -693,7 +695,7 @@ - PT0.689S + PT0.937S @@ -1124,16 +1126,106 @@ - - Behavior1 - LickLeft - LickRight - TimedTrial - Behavior + + + Behavior1 + LickLeft + LickRight + TimedTrial + Behavior + + + + + Bias + TimedBias + - - Bias - TimedBias + + OutputControl + + + + UiHabituationTimeUpdate + + + UiMoveLeft + + + UiGiveRight + + + UiGiveLeft + + + UiMoveRight + + + UiKeepLeftOpen + + + UiKeepRightOpen + + + UiKeepBothOpen + + + UiDrainLeft + + + UiDrainRight + + + UiDrainBoth + + + UiManipulatorLeft + + + UiManipulatorForwardLeft + + + UiManipulatorForwardRight + + + UiManipulatorUp + + + UiManipulatorRight + + + UiManipulatorBackRight + + + UiManipulatorBackLeft + + + UiManipulatorDown + + + UiManipulatorStop + + + UiManipulatorHome + + + UiManipulatorInitialize + + + StartExperimentShortcut + + + EndExperiment + + + UiCueGiveRight + + + UiCueGiveLeft + + + + Ethogram @@ -1157,14 +1249,6 @@ - - - - - - - - Break 200 @@ -1210,37 +1294,322 @@ - - TriggeredCamerasStream + + + TriggeredCamerasStream + - - Camera + + + Camera + - - Camera + + + Camera + - - SessionInfo + + + SessionInfo + - - Metadata + + + Metadata + StartExperimentShortcut + EndExperiment + UiHabituationTimeUpdate + PreSession + UiKeepLeftOpen + UiKeepRightOpen + UiKeepBothOpen + UiDrainLeft + UiDrainRight + UiDrainBoth + UiManipulatorLeft + UiManipulatorForwardLeft + UiManipulatorForwardRight + UiManipulatorUp + UiManipulatorRight + UiManipulatorBackLeft + UiManipulatorBackRight + UiManipulatorDown + UiManipulatorStop + UiManipulatorHome + UiManipulatorInitialize - - InterSession + + InterSessionVisualizer + + + + + + + + + + + InterSessionVisualizer + + + + + + + InterSession + + + true + 3 + Borders + + 0 + 0 + + 0 + + + true + + + true + None + + + true + Manual + None + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + GiveLeft + true + Give Left + + + + + + + UiGiveLeft + + + true + + + GiveRight + true + Give Right + + + + + + + UiGiveRight + + + true + Go Cue + None + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + GiveLeftCue + true + Give Left Cue + + + + + + + UiCueGiveLeft + + + true + + + GiveRightCue + true + Give Right Cue + + + + + + + UiCueGiveRight + + + + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + MoveLeft + true + Move Left + + + + + + + UiMoveLeft + + + true + + + MoveRight + true + Move Right + + + + + + + UiMoveRight + + + + + + + + + true + + + SessionInfo + true + Session Info + + + true + + + Notes + true + Notes + 16384 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + \ No newline at end of file From 11a9c10d47f08d7af7bb7208da1f52d20f0b5618 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 7 Jul 2026 00:05:40 +0400 Subject: [PATCH 036/116] Add extra subjects for inter session visualizer --- src/Extensions/InterSessionVisualizer.bonsai | 118 +++++++++++++++---- src/main.bonsai | 6 + 2 files changed, 100 insertions(+), 24 deletions(-) diff --git a/src/Extensions/InterSessionVisualizer.bonsai b/src/Extensions/InterSessionVisualizer.bonsai index f9e91047..db335979 100644 --- a/src/Extensions/InterSessionVisualizer.bonsai +++ b/src/Extensions/InterSessionVisualizer.bonsai @@ -37,6 +37,15 @@ true + + true + None + + + true + Manual + None + true 2 @@ -77,6 +86,51 @@ UiGiveRight + + true + Go Cue + None + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + GiveLeftCue + true + Give Left Cue + + + + + + + UiCueGiveLeft + + + true + + + GiveRightCue + true + Give Right Cue + + + + + + + UiCueGiveRight + @@ -148,38 +202,54 @@ - - + + - + - + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - + + + + + + + + + - + + + + + + + + + + + + + + + + diff --git a/src/main.bonsai b/src/main.bonsai index 1ed6d812..e7196507 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -1757,6 +1757,12 @@ UiManipulatorInitialize + + UiCueGiveRight + + + UiCueGiveLeft + From 83237a917add8aac7a48a3800826657ded5e403c Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 7 Jul 2026 00:43:04 +0400 Subject: [PATCH 037/116] Add manipulator position feedback to pre-session --- src/main.bonsai | 677 +++++++++++++++++++++++++++- src/test_behavior_visualizer.bonsai | 17 +- 2 files changed, 669 insertions(+), 25 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index e7196507..768bacda 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -2026,25 +2026,664 @@ EndExperiment UiHabituationTimeUpdate - - PreSession - UiKeepLeftOpen - UiKeepRightOpen - UiKeepBothOpen - UiDrainLeft - UiDrainRight - UiDrainBoth - UiManipulatorLeft - UiManipulatorForwardLeft - UiManipulatorForwardRight - UiManipulatorUp - UiManipulatorRight - UiManipulatorBackLeft - UiManipulatorBackRight - UiManipulatorDown - UiManipulatorStop - UiManipulatorHome - UiManipulatorInitialize + + PreSessionVisualizer + + + + + + + + + + + + + + + + + + + + + + + + PreSessionVisualizer + + + + + + + PreSession + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + KeepLeftOpen + true + Keep Left Open + + + + + + + UiKeepLeftOpen + + + KeepRightOpen + true + Keep Right Open + + + + + + + UiKeepRightOpen + + + KeepBothOpen + true + Keep Both Open + + + + + + + UiKeepBothOpen + + + + + + true + + + DrainLeft + true + Drain 5ml Left + + + + + + + UiDrainLeft + + + Drain Right + true + Drain 5ml Right + + + + + + + UiDrainRight + + + Drain Both + true + Drain 5ml Both + + + + + + + UiDrainBoth + + + + + + + + + true + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + MoveLeft + true + Move Left + + + + + + + UiManipulatorLeft + + + ForwardLeft + true + Forward Left + + + + + + + UiManipulatorForwardLeft + + + ForwardRight + true + Forward Right + + + + + + + UiManipulatorForwardRight + + + Up + true + Up + + + + + + + UiManipulatorUp + + + + + + true + + + MoveRight + true + Move Right + + + + + + + UiManipulatorRight + + + BackLeft + true + Back Left + + + + + + + UiManipulatorBackLeft + + + BackRight + true + Back Right + + + + + + + UiManipulatorBackRight + + + Down + true + Down + + + + + + + UiManipulatorDown + + + + + + + + + true + + + STOP + true + STOP + + + + + + + UiManipulatorStop + + + Home + true + Home + + + + + + + UiManipulatorHome + + + Initialize + true + Initialize + + + + + + + UiManipulatorInitialize + + + + + + + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + x1: + + + true + + + + + + ManipulatorPosition + + + X + + + {0:F2}mm + it + + + + + + + + true + 0.00mm + + + + + + true + + + true + y1: + + + true + + + Y1 + + + {0:F2}mm + it + + + + + + + + true + 0.00mm + + + + + + true + + + true + y2: + + + true + + + Y2 + + + {0:F2}mm + it + + + + + + + + true + 0.00mm + + + + + + true + + + true + z: + + + true + + + Z + + + {0:F2}mm + it + + + + + + + + true + 0.00mm + + + + + + true + + + true + step: + + + true + + + true + 0.25mm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + InterSession diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 0177a513..e80bfb52 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -65,7 +65,7 @@ - PT2.795S + PT0.553S @@ -117,7 +117,7 @@ - PT2.452S + PT2.008S @@ -188,7 +188,7 @@ - PT0.123S + PT2.284S @@ -607,7 +607,7 @@ - true + false @@ -669,7 +669,7 @@ false - false + true @@ -695,7 +695,7 @@ - PT0.937S + PT0.289S @@ -1249,6 +1249,11 @@ + + + + + Break 200 From 2e34d2828efbeb986c5171c372a9f094ba87df08 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 7 Jul 2026 01:02:29 +0400 Subject: [PATCH 038/116] Add Ui manipulator command logic --- src/main.bonsai | 402 ++++++++++++++++-- src/test_behavior_visualizer.bonsai | 629 ++++++++++++++++++++++++++-- 2 files changed, 962 insertions(+), 69 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index 768bacda..f5510f0d 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -15,6 +15,7 @@ xmlns:ui="clr-namespace:Bonsai.Design;assembly=Bonsai.Design" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" + xmlns:p7="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -1691,6 +1692,355 @@ OutputControl + + Manipulator + + + + UiManipulatorLeft + + + MoveRelative + + + + Source1 + + + + -1 + 0 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorRight + + + MoveRelative + + + + Source1 + + + + 1 + 0 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorForwardLeft + + + MoveRelative + + + + Source1 + + + + -1 + 1 + 1 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorForwardRight + + + MoveRelative + + + + Source1 + + + + 1 + 1 + 1 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorBackLeft + + + MoveRelative + + + + Source1 + + + + -1 + -1 + -1 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorBackRight + + + MoveRelative + + + + Source1 + + + + 1 + -1 + -1 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorUp + + + MoveRelative + + + + Source1 + + + + 0 + 0 + 0 + 1 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorDown + + + MoveRelative + + + + Source1 + + + + 0 + 0 + 0 + -1 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorStop + + + UiManipulatorHome + + + UiManipulatorInitialize + + + OffsetGain + + + + + + + + + + + + + + UiHabituationTimeUpdate @@ -1724,39 +2074,6 @@ UiDrainBoth - - UiManipulatorLeft - - - UiManipulatorForwardLeft - - - UiManipulatorForwardRight - - - UiManipulatorUp - - - UiManipulatorRight - - - UiManipulatorBackRight - - - UiManipulatorBackLeft - - - UiManipulatorDown - - - UiManipulatorStop - - - UiManipulatorHome - - - UiManipulatorInitialize - UiCueGiveRight @@ -2510,9 +2827,18 @@ true - + true - 0.25mm + None + 0.25 + 0 + 0 + + + + + + OffsetGain @@ -2671,9 +2997,11 @@ - + - + + + diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index e80bfb52..80b01672 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -65,7 +65,7 @@ - PT0.553S + PT2.934S @@ -117,7 +117,7 @@ - PT2.008S + PT1.238S @@ -188,7 +188,7 @@ - PT2.284S + PT2.397S @@ -502,7 +502,7 @@ - false + true @@ -668,7 +668,7 @@ - false + true true @@ -695,7 +695,7 @@ - PT0.289S + PT0.281S @@ -1247,13 +1247,6 @@ - - - - - - - Break 200 @@ -1327,25 +1320,597 @@ UiHabituationTimeUpdate - - PreSession - UiKeepLeftOpen - UiKeepRightOpen - UiKeepBothOpen - UiDrainLeft - UiDrainRight - UiDrainBoth - UiManipulatorLeft - UiManipulatorForwardLeft - UiManipulatorForwardRight - UiManipulatorUp - UiManipulatorRight - UiManipulatorBackLeft - UiManipulatorBackRight - UiManipulatorDown - UiManipulatorStop - UiManipulatorHome - UiManipulatorInitialize + + PreSessionVisualizer + + + + + + + + + + + + + + + + + + + + + + + + PreSessionVisualizer + + + + + + + PreSession + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + KeepLeftOpen + true + Keep Left Open + + + + + + + UiKeepLeftOpen + + + KeepRightOpen + true + Keep Right Open + + + + + + + UiKeepRightOpen + + + KeepBothOpen + true + Keep Both Open + + + + + + + UiKeepBothOpen + + + + + + true + + + DrainLeft + true + Drain 5ml Left + + + + + + + UiDrainLeft + + + Drain Right + true + Drain 5ml Right + + + + + + + UiDrainRight + + + Drain Both + true + Drain 5ml Both + + + + + + + UiDrainBoth + + + + + + + + + true + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + MoveLeft + true + Move Left + + + + + + + UiManipulatorLeft + + + ForwardLeft + true + Forward Left + + + + + + + UiManipulatorForwardLeft + + + ForwardRight + true + Forward Right + + + + + + + UiManipulatorForwardRight + + + Up + true + Up + + + + + + + UiManipulatorUp + + + + + + true + + + MoveRight + true + Move Right + + + + + + + UiManipulatorRight + + + BackLeft + true + Back Left + + + + + + + UiManipulatorBackLeft + + + BackRight + true + Back Right + + + + + + + UiManipulatorBackRight + + + Down + true + Down + + + + + + + UiManipulatorDown + + + + + + + + + true + + + STOP + true + STOP + + + + + + + UiManipulatorStop + + + Home + true + Home + + + + + + + UiManipulatorHome + + + Initialize + true + Initialize + + + + + + + UiManipulatorInitialize + + + + + + + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + x1: + + + true + + + true + 0.00mm + + + + + + true + + + true + y1: + + + true + + + true + 0.00mm + + + + + + true + + + true + y2: + + + true + + + true + 0.00mm + + + + + + true + + + true + z: + + + true + + + true + 0.00mm + + + + + + true + + + true + step: + + + true + + + true + {0}mm + None + 0 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + InterSessionVisualizer From 0edc8177a6d01e0ba62d6a2d46caa048a7c63f55 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 7 Jul 2026 11:53:45 +0400 Subject: [PATCH 039/116] Add saturation visualizer / control to camera preview --- src/Extensions/CameraPreviewVisualizer.bonsai | 352 ++++----- src/Extensions/SaturationThreshold.cs | 77 ++ src/test_behavior_visualizer.bonsai | 727 +++++++++++++++++- 3 files changed, 935 insertions(+), 221 deletions(-) create mode 100644 src/Extensions/SaturationThreshold.cs diff --git a/src/Extensions/CameraPreviewVisualizer.bonsai b/src/Extensions/CameraPreviewVisualizer.bonsai index ca939bfb..70a8186f 100644 --- a/src/Extensions/CameraPreviewVisualizer.bonsai +++ b/src/Extensions/CameraPreviewVisualizer.bonsai @@ -4,6 +4,7 @@ xmlns:p1="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" + xmlns:p2="clr-namespace:;assembly=Extensions" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:cv="clr-namespace:Bonsai.Vision;assembly=Bonsai.Vision" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" @@ -144,6 +145,37 @@ Value.Image + + MinSaturation + + + + + + + + MaxSaturation + + + + + + + + OverlayAlpha + + + + + + + + + 26 + 217 + 0.47200000286102295 + + FlipState @@ -320,12 +352,33 @@ 1 + + + 2 + + + + FlipState + Table true + + true + 1 + None + + 0 + 0 + + 0 + + + true + true 2 @@ -339,163 +392,63 @@ true - - FlipHorizontal + true - Flip Horizontal - false + Min true - - FlipVertical + + MinSaturation true - Flip Vertical - false + 0 + 255 + None + 0 + + + MinSaturation - - Horizontal - - - - Source1 - - - Item1 - - - Item2 - - - - - - - - - - - - - - - - - - - - - - 1 - + + true - - Vertical - - - - Source1 - - - Item1 - - - - Item2 - - - - - - - - - - - - - - - - - + + true + 2 + None + + 0 + 0 + + 0 - - - 0 - + + true - - Both - - - - Source1 - - - - - - - - - + + true + Max - - - -1 - + + true - - Neither - - - - Source1 - - - Item1 - - - - Item2 - - - - - - - - - - - - - - - - - - - + + MaxSaturation + true + 0 + 255 + None + 255 - - - 2 - + + MaxSaturation - - - - FlipState - - - Table + true @@ -513,38 +466,34 @@ true - - RotateCCW + true - << - - - - 90 - + Alpha true - - RotateCW + true - >> + 0 + 1 + None + 0.5 + + + OverlayAlpha - - -90 - + + + + 0 - - - - @@ -656,75 +605,82 @@ - + - - - - - + + + - - + - - - - - - + + + + + + + + + - + - - + + - - + + + - + - - - - + + - - - - - + - + + + - + + - + - - + + + - + - + - - + + + - + + - - + + + + + + + + diff --git a/src/Extensions/SaturationThreshold.cs b/src/Extensions/SaturationThreshold.cs new file mode 100644 index 00000000..4859d73a --- /dev/null +++ b/src/Extensions/SaturationThreshold.cs @@ -0,0 +1,77 @@ +using Bonsai; +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Reactive.Linq; +using OpenCV.Net; + +[Combinator] +[Description("Overlays a saturation warning on a grayscale image: pixels at or above MaxSaturation are tinted red (over-exposed), pixels at or below MinSaturation are tinted blue (under-exposed).")] +[WorkflowElementCategory(ElementCategory.Transform)] +public class SaturationThreshold +{ + [Description("Intensity at or below which a pixel is marked blue (under-exposed).")] + public double MinSaturation { get; set; } + + [Description("Intensity at or above which a pixel is marked red (over-exposed).")] + public double MaxSaturation { get; set; } + + [Description("Blend strength of the overlay tint in the range [0, 1]. 1 = solid, 0 = invisible.")] + public double Alpha { get; set; } + + public IObservable Process(IObservable source) + { + return source.Select(input => + { + // The saturation test operates on a single intensity channel, matching the + // fragment shader's use of texColor.r on a grayscale feed. + var gray = input.Channels == 1 ? input : ExtractGray(input); + + // Build the two saturation masks (255 where the condition holds, else 0). + var overMask = new IplImage(gray.Size, IplDepth.U8, 1); // r >= MaxSaturation + var underMask = new IplImage(gray.Size, IplDepth.U8, 1); // r <= MinSaturation + CV.Threshold(gray, overMask, MaxSaturation, 255, ThresholdTypes.Binary); + CV.Threshold(gray, underMask, MinSaturation, 255, ThresholdTypes.BinaryInv); + + // The shader uses "else if", so red takes priority over blue. + // Remove any overlap from the blue mask (a no-op when Min < Max). + CV.Sub(underMask, overMask, underMask); + + // Colorize the grayscale image, then paint the overlays over it. + var output = new IplImage(gray.Size, IplDepth.U8, 3); + CV.CvtColor(gray, output, ColorConversion.Gray2Bgr); + + var alpha = Math.Max(0.0, Math.Min(1.0, Alpha)); + ApplyOverlay(output, overMask, new Scalar(0, 0, 255, 0), alpha); // BGR red + ApplyOverlay(output, underMask, new Scalar(255, 0, 0, 0), alpha); // BGR blue + return output; + }); + } + + static IplImage ExtractGray(IplImage input) + { + var gray = new IplImage(input.Size, IplDepth.U8, 1); + CV.CvtColor(input, gray, ColorConversion.Bgr2Gray); + return gray; + } + + // Reproduces mix(texColor, overlay, overlay.a): result = texColor * (1 - alpha) + + // overlayColor * alpha, applied only on the masked pixels. + static void ApplyOverlay(IplImage image, IplImage mask, Scalar color, double alpha) + { + if (alpha >= 1.0) + { + image.Set(color, mask); // fully opaque: just paint the tint + return; + } + + var solid = new IplImage(image.Size, image.Depth, image.Channels); + solid.SetZero(); + solid.Set(color); + + var blended = new IplImage(image.Size, image.Depth, image.Channels); + CV.AddWeighted(image, 1 - alpha, solid, alpha, 0, blended); + CV.Copy(blended, image, mask); // write the blended result back only where the mask is set + } +} diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 80b01672..d48a2db7 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -18,6 +18,7 @@ xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:p7="clr-namespace:System.Reactive;assembly=System.Reactive.Core" + xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -65,7 +66,7 @@ - PT2.934S + PT2.098S @@ -117,7 +118,7 @@ - PT1.238S + PT1.144S @@ -188,7 +189,7 @@ - PT2.397S + PT2.943S @@ -502,7 +503,7 @@ - true + false @@ -607,7 +608,7 @@ - false + true @@ -668,7 +669,7 @@ - true + false true @@ -695,7 +696,7 @@ - PT0.281S + PT0.447S @@ -1292,20 +1293,702 @@ - - - TriggeredCamerasStream - - - - - Camera - + + TriggeredCamerasStream - - - Camera - + + CameraPreviewVisualizer + + + + Source1 + + + Key + + + + + + ToArray + + + + Source1 + + + + 1 + + + + List + + + List + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CameraPreview + + + + Source1 + + + Item1 + + + CameraList + + + Item2 + + + + + + CameraFeeds + + + + + + + Camera + + + true + 1 + None + + 0 + 0 + + 0 + + + Table + + + Table + + + true + + + CameraList + + + + + + + + SelectCameraStream + true + + Camera1 + Camera2 + + + + SelectedControllerCamera + + + Table + + + true + + + CurrentStream + + + Value.Image + + + MinSaturation + + + + + + + + MaxSaturation + + + + + + + + OverlayAlpha + + + + + + + + + 26 + 217 + 0.47200000286102295 + + + + FlipState + + + + + + Flipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + Item1 + + + Item2 + + + + + + + + + Vertical + + + + NotFlipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + + + Item1 + + + + + + new ( + it.Size.Width / 2 as X, + it.Size.Height / 2 as Y +) + + + + + + + + + + 320 + 240 + + + + + + + + + Rotation + + + + + + + + + + 320 + 240 + + + 0 + 0 + + 0 + + 1 + 1 + + + + + + + + + + + 1,0,0;0,1,0 + Linear + + 0 + 0 + 0 + 0 + + + + + Table + + + + Rgba + Repeat + Repeat + Linear + Linear + + + + + + + + + PreviewImage + true + + 320 + 320 + + + 0 + 0 + + + 1 + 1 + + + + + 2 + + + + FlipState + + + Table + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Min + + + true + + + MinSaturation + true + 0 + 255 + None + 0 + + + MinSaturation + + + + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Max + + + true + + + MaxSaturation + true + 0 + 255 + None + 255 + + + MaxSaturation + + + + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Alpha + + + true + + + true + 0 + 1 + None + 0.5 + + + OverlayAlpha + + + + + + + + + + 0 + + + + + + + Rotation + + + SelectedControllerCamera + + + CameraList + + + + 0 + + + + + + + GetStream + + + + Source1 + + + + 1 + + + + Camera + + + CameraFeeds + + + Camera + + + + + + + + + + + Source1 + + + Key + + + + + + + Camera1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CurrentStream + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1752,7 +2435,6 @@ true - {0}mm None 0 0 @@ -2178,8 +2860,7 @@ - - + \ No newline at end of file From abf19519ee37682b6bcb361b1259075a84f87b92 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 8 Jul 2026 12:29:58 +0400 Subject: [PATCH 040/116] Add remaining manipulator control logic --- src/main.bonsai | 2115 ++++++++++++++++++++++++----------------------- 1 file changed, 1086 insertions(+), 1029 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index f5510f0d..760afa15 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -404,1028 +404,1022 @@ Visualizers - - - - 0 - - + + + 0 + - - - - - - TrialPlots - - - - GlobalTrialOutcome - - - 16 - - - - SoftwareEvent - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - LickRight - - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - - - LickLeft - - - - GiveRewardRight - - - - - - Source1 - - - - - - - - - - - WaterRight - - - - GiveRewardRight - - - - - - - Source1 - - - - - - - - - - - WaterLeft - - - - - - - 16 - 20 - - - QuiscentPeriod - Gold - 0.3 - - - ResponsePeriod - SandyBrown - 0.3 - - - RewardConsumptionPeriod - RosyBrown - 0.3 - - - ItiPeriod - Green - 0.3 - - - - - LickLeft - Red - 0.9 - 6 - Down - - - LickRight - Blue - 0.1 - 6 - Up - - - IsRightTriggerQuickRetract - DarkCyan - 0.5 - 6 - Plus - - - DeliverSecondaryReinforcer - Sienna - 0.5 - 6 - Plus - - - WaterRight - Blue - 0.2 - 6 - Circle - - - WaterLeft - Red - 0.8 - 6 - Circle - - - - 5 - - - - true - true - 1 - 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ManualOverrides - - - - OffsetControl - - - - - 0.05 - - - - - 1 - - - - BumpSize - - - ManipulatorBiasTracker - - - {0:F2} - - - - - - - - true - true - Microsoft Sans Serif, 20.25pt - 0.00 - - - - Left - true - true - Microsoft Sans Serif, 15.75pt - ◀️ - - - BumpLeft - - - - Source1 - - - BumpSize - - - - - - Item2 - - - - -1 - - - - ManualSpoutDelta - - - - - - - - - - - - - - - - Right - true - true - Microsoft Sans Serif, 15.75pt - - - - BumpRight - - - - Source1 - - - BumpSize - - - - - - Item2 - - - ManualSpoutDelta - - - - - - - - - - - - - - - true - true - 2 - 1 - - - - - - - ExperimentState - - - - - - - - false - true - Microsoft Sans Serif, 22.125pt - 1 - 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Spout offset - true - true - Microsoft Sans Serif, 15.75pt - Spout offset - - - - GiveWaterUI - - - - Left - true - true - 💧◀ - - - TriggerLeft - - - - Source1 - - - - false - - - - GiveManualWaterRight - - - - - - - - - - - - - Right - true - true - 💧▶ - - - TriggerRight - - - - Source1 - - - - true - - - - GiveManualWaterRight - - - - - - - - - - - - - ManualWater - true - true - 2 - 1 - - - Percent - 0.5 - - - Percent - 0.5 - - - - - - - - GiveManualWaterRight - - - GiveManualWaterRight - - - GiveRewardRight - - - - - - - - - - - - - - - - - - 💧 - true - true - Microsoft Sans Serif, 8.25pt - - - - - ForceAutoWater - - - - GlobalAutoWaterState - - - !it.IsLeft - - - - - - - - SetLeft - true - true - 🎣◀ - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetLeft() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - - GlobalAutoWaterState - - - !it.IsRight - - - - - - - - SetRight - true - true - 🎣▶ - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetRight() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - - GlobalAutoWaterState - - - it.HasValue - - - - - - - - Reset - false - true - - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.Reset() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - - ForceAutoWater - true - true - 3 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 🎣 - true - true - Microsoft Sans Serif, 8.25pt - - - - - true - true - Microsoft Sans Serif, 15.75pt - - - - Manual Control - true - true - Microsoft Sans Serif, 36pt - 1 - 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - LauncherControl - - - - - - - - ExperimentState - - - - - - - - - Start - true - true - Start Experiment - - - StartExperimentToggleButton - - - - End - true - true - End Experiment - - - EndExperimentButton - - - - LauncherControl - true - true - Microsoft Sans Serif, 26pt - 2 - 4 - - - - - - - - - - - StartExperimentToggleButton - - - - 1 - - - - - StartExperimentShortcut - - - EndExperimentButton - - - - 1 - - - - - EndExperiment - - - StartExperiment - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - true - - - - - true - true - 1 - 2 - - - - - - - - true - true - 3 - 1 - - - - - - - - - TriggeredCamerasStream - - - - - - - - - - - true - true - 2 - 1 - - - - - - - true - true - 1 - 2 - - - Percent - 0.75 - - - Percent - 0.25 - - - - - - - - GlobalTrial - - - 2 - 16 - - - - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + TrialPlots + + + + GlobalTrialOutcome + + + 16 + + + + SoftwareEvent + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + LickRight + + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + + + LickLeft + + + + GiveRewardRight + + + + + + Source1 + + + + + + + + + + + WaterRight + + + + GiveRewardRight + + + + + + + Source1 + + + + + + + + + + + WaterLeft + + + + + + + 16 + 20 + + + QuiscentPeriod + Gold + 0.3 + + + ResponsePeriod + SandyBrown + 0.3 + + + RewardConsumptionPeriod + RosyBrown + 0.3 + + + ItiPeriod + Green + 0.3 + + + + + LickLeft + Red + 0.9 + 6 + Down + + + LickRight + Blue + 0.1 + 6 + Up + + + IsRightTriggerQuickRetract + DarkCyan + 0.5 + 6 + Plus + + + DeliverSecondaryReinforcer + Sienna + 0.5 + 6 + Plus + + + WaterRight + Blue + 0.2 + 6 + Circle + + + WaterLeft + Red + 0.8 + 6 + Circle + + + + 5 + + + + true + true + 1 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ManualOverrides + + + + OffsetControl + + + + + 0.05 + + + + + 1 + + + + BumpSize + + + ManipulatorBiasTracker + + + {0:F2} + + + + + + + + true + true + Microsoft Sans Serif, 20.25pt + 0.00 + + + + Left + true + true + Microsoft Sans Serif, 15.75pt + ◀️ + + + BumpLeft + + + + Source1 + + + BumpSize + + + + + + Item2 + + + + -1 + + + + ManualSpoutDelta + + + + + + + + + + + + + + + + Right + true + true + Microsoft Sans Serif, 15.75pt + + + + BumpRight + + + + Source1 + + + BumpSize + + + + + + Item2 + + + ManualSpoutDelta + + + + + + + + + + + + + + + true + true + 2 + 1 + + + + + + + ExperimentState + + + + + + + + false + true + Microsoft Sans Serif, 22.125pt + 1 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Spout offset + true + true + Microsoft Sans Serif, 15.75pt + Spout offset + + + + GiveWaterUI + + + + Left + true + true + 💧◀ + + + TriggerLeft + + + + Source1 + + + + false + + + + GiveManualWaterRight + + + + + + + + + + + + + Right + true + true + 💧▶ + + + TriggerRight + + + + Source1 + + + + true + + + + GiveManualWaterRight + + + + + + + + + + + + + ManualWater + true + true + 2 + 1 + + + Percent + 0.5 + + + Percent + 0.5 + + + + + + + + GiveManualWaterRight + + + GiveManualWaterRight + + + GiveRewardRight + + + + + + + + + + + + + + + + + + 💧 + true + true + Microsoft Sans Serif, 8.25pt + + + + + ForceAutoWater + + + + GlobalAutoWaterState + + + !it.IsLeft + + + + + + + + SetLeft + true + true + 🎣◀ + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetLeft() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + + GlobalAutoWaterState + + + !it.IsRight + + + + + + + + SetRight + true + true + 🎣▶ + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetRight() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + + GlobalAutoWaterState + + + it.HasValue + + + + + + + + Reset + false + true + + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.Reset() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + + ForceAutoWater + true + true + 3 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 🎣 + true + true + Microsoft Sans Serif, 8.25pt + + + + + true + true + Microsoft Sans Serif, 15.75pt + + + + Manual Control + true + true + Microsoft Sans Serif, 36pt + 1 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + LauncherControl + + + + + + + + ExperimentState + + + + + + + + + Start + true + true + Start Experiment + + + StartExperimentToggleButton + + + + End + true + true + End Experiment + + + EndExperimentButton + + + + LauncherControl + true + true + Microsoft Sans Serif, 26pt + 2 + 4 + + + + + + + + + + + StartExperimentToggleButton + + + + 1 + + + + + StartExperimentShortcut + + + EndExperimentButton + + + + 1 + + + + + EndExperiment + + + StartExperiment + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + + + + + true + true + 1 + 2 + + + + + + + + true + true + 3 + 1 + + + + + + + + + TriggeredCamerasStream + + + + + + + + + + + true + true + 2 + 1 + + + + + + + true + true + 1 + 2 + + + Percent + 0.75 + + + Percent + 0.25 + + + + + + + + GlobalTrial + + + 2 + 16 + + + + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - DynamicForaging - true - - - Maximized - + + DynamicForaging + true + + + Maximized ImGuiContext @@ -2017,14 +2011,74 @@ - UiManipulatorStop + UiManipulatorHome + + + Home + + + + Source1 + + + + HomeMotors + + + + + + + + + - UiManipulatorHome + UiManipulatorStop + + + StopMotors + + + + Source1 + + + + StopMotors + + + + + + + + + UiManipulatorInitialize + + GoToInitialPosition + + + + Source1 + + + + GoToInitialPosition + + + + + + + + + + OffsetGain @@ -2038,6 +2092,9 @@ + + + @@ -2047,6 +2104,9 @@ UiMoveLeft + + UiMoveRight + UiGiveRight @@ -2054,7 +2114,10 @@ UiGiveLeft - UiMoveRight + UiCueGiveLeft + + + UiCueGiveRight UiKeepLeftOpen @@ -2074,12 +2137,6 @@ UiDrainBoth - - UiCueGiveRight - - - UiCueGiveLeft - From 5fd5f3df74a34c5cdcd6615f288bdbb5dd7f8676 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 8 Jul 2026 12:51:20 +0400 Subject: [PATCH 041/116] Add water manual overrides --- src/main.bonsai | 146 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 143 insertions(+), 3 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index 760afa15..b28508b6 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -2110,15 +2110,139 @@ UiGiveRight - - UiGiveLeft + + TriggerRight + + + + Source1 + + + + true + + + + GiveManualWaterRight + + + + + + + + + UiCueGiveLeft + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetLeft() + + + GlobalAutoWaterState + + + + + + + + + + + + + + UiCueGiveRight + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetRight() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + UiGiveLeft + + + TriggerLeft + + + + Source1 + + + + false + + + + GiveManualWaterRight + + + + + + + + + + UiKeepLeftOpen @@ -2137,8 +2261,24 @@ UiDrainBoth + + GiveManualWaterRight + + + GiveManualWaterRight + + + GiveRewardRight + - + + + + + + + + From 52c7a8550c6785a976c7f77b834b646781c67a55 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 8 Jul 2026 12:56:46 +0400 Subject: [PATCH 042/116] Add Ui bump controls --- src/main.bonsai | 72 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index b28508b6..ad369554 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -2104,9 +2104,75 @@ UiMoveLeft + + BumpLeft + + + + Source1 + + + BumpSize + + + + + + Item2 + + + + -1 + + + + ManualSpoutDelta + + + + + + + + + + + + + UiMoveRight + + BumpRight + + + + Source1 + + + BumpSize + + + + + + Item2 + + + ManualSpoutDelta + + + + + + + + + + + + UiGiveRight @@ -2272,12 +2338,14 @@ + - - + + + From d2b27eecf7a0e06f93419779c487b099455d6ff9 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 8 Jul 2026 18:24:07 +0100 Subject: [PATCH 043/116] And bump value --- src/main.bonsai | 2063 ++++++++++++++++++++++++----------------------- 1 file changed, 1042 insertions(+), 1021 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index ad369554..ba24474b 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -404,1022 +404,1028 @@ Visualizers - - - 0 - + + + + 0 + + - - - - - TrialPlots - - - - GlobalTrialOutcome - - - 16 - - - - SoftwareEvent - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - LickRight - - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - - - LickLeft - - - - GiveRewardRight - - - - - - Source1 - - - - - - - - - - - WaterRight - - - - GiveRewardRight - - - - - - - Source1 - - - - - - - - - - - WaterLeft - - - - - - - 16 - 20 - - - QuiscentPeriod - Gold - 0.3 - - - ResponsePeriod - SandyBrown - 0.3 - - - RewardConsumptionPeriod - RosyBrown - 0.3 - - - ItiPeriod - Green - 0.3 - - - - - LickLeft - Red - 0.9 - 6 - Down - - - LickRight - Blue - 0.1 - 6 - Up - - - IsRightTriggerQuickRetract - DarkCyan - 0.5 - 6 - Plus - - - DeliverSecondaryReinforcer - Sienna - 0.5 - 6 - Plus - - - WaterRight - Blue - 0.2 - 6 - Circle - - - WaterLeft - Red - 0.8 - 6 - Circle - - - - 5 - - - - true - true - 1 - 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ManualOverrides - - - - OffsetControl - - - - - 0.05 - - - - - 1 - - - - BumpSize - - - ManipulatorBiasTracker - - - {0:F2} - - - - - - - - true - true - Microsoft Sans Serif, 20.25pt - 0.00 - - - - Left - true - true - Microsoft Sans Serif, 15.75pt - ◀️ - - - BumpLeft - - - - Source1 - - - BumpSize - - - - - - Item2 - - - - -1 - - - - ManualSpoutDelta - - - - - - - - - - - - - - - - Right - true - true - Microsoft Sans Serif, 15.75pt - - - - BumpRight - - - - Source1 - - - BumpSize - - - - - - Item2 - - - ManualSpoutDelta - - - - - - - - - - - - - - - true - true - 2 - 1 - - - - - - - ExperimentState - - - - - - - - false - true - Microsoft Sans Serif, 22.125pt - 1 - 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Spout offset - true - true - Microsoft Sans Serif, 15.75pt - Spout offset - - - - GiveWaterUI - - - - Left - true - true - 💧◀ - - - TriggerLeft - - - - Source1 - - - - false - - - - GiveManualWaterRight - - - - - - - - - - - - - Right - true - true - 💧▶ - - - TriggerRight - - - - Source1 - - - - true - - - - GiveManualWaterRight - - - - - - - - - - - - - ManualWater - true - true - 2 - 1 - - - Percent - 0.5 - - - Percent - 0.5 - - - - - - - - GiveManualWaterRight - - - GiveManualWaterRight - - - GiveRewardRight - - - - - - - - - - - - - - - - - - 💧 - true - true - Microsoft Sans Serif, 8.25pt - - - - - ForceAutoWater - - - - GlobalAutoWaterState - - - !it.IsLeft - - - - - - - - SetLeft - true - true - 🎣◀ - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetLeft() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - - GlobalAutoWaterState - - - !it.IsRight - - - - - - - - SetRight - true - true - 🎣▶ - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetRight() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - - GlobalAutoWaterState - - - it.HasValue - - - - - - - - Reset - false - true - - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.Reset() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - - ForceAutoWater - true - true - 3 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 🎣 - true - true - Microsoft Sans Serif, 8.25pt - - - - - true - true - Microsoft Sans Serif, 15.75pt - - - - Manual Control - true - true - Microsoft Sans Serif, 36pt - 1 - 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - LauncherControl - - - - - - - - ExperimentState - - - - - - - - - Start - true - true - Start Experiment - - - StartExperimentToggleButton - - - - End - true - true - End Experiment - - - EndExperimentButton - - - - LauncherControl - true - true - Microsoft Sans Serif, 26pt - 2 - 4 - - - - - - - - - - - StartExperimentToggleButton - - - - 1 - - - - - StartExperimentShortcut - - - EndExperimentButton - - - - 1 - - - - - EndExperiment - - - StartExperiment - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - true - - - - - true - true - 1 - 2 - - - - - - - - true - true - 3 - 1 - - - - - - - - - TriggeredCamerasStream - - - - - - - - - - - true - true - 2 - 1 - - - - - - - true - true - 1 - 2 - - - Percent - 0.75 - - - Percent - 0.25 - - - - - - - - GlobalTrial - - - 2 - 16 - - - - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + TrialPlots + + + + GlobalTrialOutcome + + + 16 + + + + SoftwareEvent + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + LickRight + + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + + + LickLeft + + + + GiveRewardRight + + + + + + Source1 + + + + + + + + + + + WaterRight + + + + GiveRewardRight + + + + + + + Source1 + + + + + + + + + + + WaterLeft + + + + + + + 16 + 20 + + + QuiscentPeriod + Gold + 0.3 + + + ResponsePeriod + SandyBrown + 0.3 + + + RewardConsumptionPeriod + RosyBrown + 0.3 + + + ItiPeriod + Green + 0.3 + + + + + LickLeft + Red + 0.9 + 6 + Down + + + LickRight + Blue + 0.1 + 6 + Up + + + IsRightTriggerQuickRetract + DarkCyan + 0.5 + 6 + Plus + + + DeliverSecondaryReinforcer + Sienna + 0.5 + 6 + Plus + + + WaterRight + Blue + 0.2 + 6 + Circle + + + WaterLeft + Red + 0.8 + 6 + Circle + + + + 5 + + + + true + true + 1 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ManualOverrides + + + + OffsetControl + + + + + 0.05 + + + + + 1 + + + + BumpSize + + + ManipulatorBiasTracker + + + {0:F2} + + + + + + + + true + true + Microsoft Sans Serif, 20.25pt + 0.00 + + + + Left + true + true + Microsoft Sans Serif, 15.75pt + ◀️ + + + BumpLeft + + + + Source1 + + + BumpSize + + + + + + Item2 + + + + -1 + + + + ManualSpoutDelta + + + + + + + + + + + + + + + + Right + true + true + Microsoft Sans Serif, 15.75pt + + + + BumpRight + + + + Source1 + + + BumpSize + + + + + + Item2 + + + ManualSpoutDelta + + + + + + + + + + + + + + + true + true + 2 + 1 + + + + + + + ExperimentState + + + + + + + + false + true + Microsoft Sans Serif, 22.125pt + 1 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Spout offset + true + true + Microsoft Sans Serif, 15.75pt + Spout offset + + + + GiveWaterUI + + + + Left + true + true + 💧◀ + + + TriggerLeft + + + + Source1 + + + + false + + + + GiveManualWaterRight + + + + + + + + + + + + + Right + true + true + 💧▶ + + + TriggerRight + + + + Source1 + + + + true + + + + GiveManualWaterRight + + + + + + + + + + + + + ManualWater + true + true + 2 + 1 + + + Percent + 0.5 + + + Percent + 0.5 + + + + + + + + GiveManualWaterRight + + + GiveManualWaterRight + + + GiveRewardRight + + + + + + + + + + + + + + + + + + 💧 + true + true + Microsoft Sans Serif, 8.25pt + + + + + ForceAutoWater + + + + GlobalAutoWaterState + + + !it.IsLeft + + + + + + + + SetLeft + true + true + 🎣◀ + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetLeft() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + + GlobalAutoWaterState + + + !it.IsRight + + + + + + + + SetRight + true + true + 🎣▶ + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetRight() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + + GlobalAutoWaterState + + + it.HasValue + + + + + + + + Reset + false + true + + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.Reset() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + + ForceAutoWater + true + true + 3 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 🎣 + true + true + Microsoft Sans Serif, 8.25pt + + + + + true + true + Microsoft Sans Serif, 15.75pt + + + + Manual Control + true + true + Microsoft Sans Serif, 36pt + 1 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + LauncherControl + + + + + + + + ExperimentState + + + + + + + + + Start + true + true + Start Experiment + + + StartExperimentToggleButton + + + + End + true + true + End Experiment + + + EndExperimentButton + + + + LauncherControl + true + true + Microsoft Sans Serif, 26pt + 2 + 4 + + + + + + + + + + + StartExperimentToggleButton + + + + 1 + + + + + StartExperimentShortcut + + + EndExperimentButton + + + + 1 + + + + + EndExperiment + + + StartExperiment + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + + + + + true + true + 1 + 2 + + + + + + + + true + true + 3 + 1 + + + + + + + + + TriggeredCamerasStream + + + + + + + + + + + true + true + 2 + 1 + + + + + + + true + true + 1 + 2 + + + Percent + 0.75 + + + Percent + 0.25 + + + + + + + + GlobalTrial + + + 2 + 16 + + + + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - DynamicForaging - true - - - Maximized + + + DynamicForaging + true + + + Maximized + ImGuiContext @@ -2101,6 +2107,19 @@ UiHabituationTimeUpdate + + + 0.05 + + + + + 1 + + + + BumpSize + UiMoveLeft @@ -2339,13 +2358,15 @@ - - - - - - - + + + + + + + + + From 38efddd3aca3f5d0426f15dd6b2ff340b70a1359 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Mon, 13 Jul 2026 18:43:18 +0100 Subject: [PATCH 044/116] Refactor camera visualizer to use named cameras And allow for externalized properties for rotation, flip etc. --- src/Extensions/CameraPreviewVisualizer.bonsai | 481 ++++------------ src/main.bonsai | 16 +- src/test_behavior_visualizer.bonsai | 526 +++++------------- 3 files changed, 239 insertions(+), 784 deletions(-) diff --git a/src/Extensions/CameraPreviewVisualizer.bonsai b/src/Extensions/CameraPreviewVisualizer.bonsai index 70a8186f..8787cdcf 100644 --- a/src/Extensions/CameraPreviewVisualizer.bonsai +++ b/src/Extensions/CameraPreviewVisualizer.bonsai @@ -1,94 +1,31 @@  Source1 - - Key - - - - - - ToArray - - - - Source1 - - - - 1 - - - - List - - - List - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + CameraPreview - - Source1 - - - Item1 - - - CameraList - - - Item2 - - - - - - CameraFeeds - - @@ -108,30 +45,47 @@ Table - - Table - - - true + + - CameraList + TriggeredCamerasStream - - - - + + - - SelectCameraStream - true - - Camera1 - Camera2 - + + + + + Source1 + + + Key + + + + + + + Camera1 + + + + + + + + + + + - - SelectedControllerCamera + + + + + CameraStream Table @@ -140,45 +94,40 @@ true - CurrentStream + CameraStream Value.Image - MinSaturation + OverlayAlpha - + - - MaxSaturation + + - - - - + + - - OverlayAlpha + + + 53 + 215 + 0.5 + - - - - + + - - 26 - 217 - 0.47200000286102295 + + 2 - - FlipState - @@ -277,13 +226,8 @@ - - Rotation - - - - - + + @@ -352,14 +296,6 @@ 1 - - - 2 - - - - FlipState - Table @@ -392,80 +328,6 @@ true - - true - Min - - - true - - - MinSaturation - true - 0 - 255 - None - 0 - - - MinSaturation - - - - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - Max - - - true - - - MaxSaturation - true - 0 - 255 - None - 255 - - - MaxSaturation - - - - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - true Alpha @@ -489,217 +351,74 @@ - - - 0 - - - - - - - Rotation - - - SelectedControllerCamera - - - CameraList - - - - 0 - - - - - - - GetStream - - - - Source1 - - - - 1 - - - - Camera - - - CameraFeeds - - - Camera - - - - - - - - - - - Source1 - - - Key - - - - - - - Camera1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CurrentStream - - - + - + + - + - + - - - - - - + + + + + + + + + - + + - - - - - - - - - + + + + + + - - - - - + + + + + - - - + + + - + + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + + - - - - - - \ No newline at end of file diff --git a/src/main.bonsai b/src/main.bonsai index ba24474b..0a8a2d3f 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -2611,14 +2611,24 @@ - - TriggeredCamerasStream - + Camera + Camera1 + 53 + 215 + 2 + 0 + TriggeredCamerasStream Camera + Camera2 + 53 + 215 + 2 + 0 + TriggeredCamerasStream SessionSchema diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index d48a2db7..65170cc9 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -66,7 +66,7 @@ - PT2.098S + PT0.317S @@ -118,7 +118,7 @@ - PT1.144S + PT2.928S @@ -189,7 +189,7 @@ - PT2.943S + PT1.988S @@ -503,7 +503,7 @@ - false + true @@ -669,7 +669,7 @@ - false + true true @@ -696,7 +696,7 @@ - PT0.447S + PT0.537S @@ -866,6 +866,15 @@ CameraFeed + + + 1 + + + + + CameraFeed2 + Camera1 @@ -956,15 +965,16 @@ - - - - - - - - - + + + + + + + + + + @@ -1244,10 +1254,6 @@ true - - - - Break 200 @@ -1293,9 +1299,7 @@ - - TriggeredCamerasStream - + CameraPreviewVisualizer @@ -1303,79 +1307,19 @@ Source1 - - Key - - - - - - ToArray - - - - Source1 - - - - 1 - - - - List - - - List - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + CameraPreview - - Source1 - - - Item1 - - - CameraList - - - Item2 - - - - - - CameraFeeds - - @@ -1395,30 +1339,47 @@ Table - - Table - - - true + + - CameraList + TriggeredCamerasStream - - - - + + - - SelectCameraStream - true - - Camera1 - Camera2 - + + + + + Source1 + + + Key + + + + + + + Camera1 + + + + + + + + + + + - - SelectedControllerCamera + + + + + CameraStream Table @@ -1427,26 +1388,10 @@ true - CurrentStream + CameraStream - Value.Image - - - MinSaturation - - - - - - - - MaxSaturation - - - - - + Value OverlayAlpha @@ -1456,15 +1401,26 @@ + + + + + + - 26 - 217 - 0.47200000286102295 + 53 + 215 + 0.5 - - FlipState + + + + + + 2 + @@ -1564,13 +1520,8 @@ - - Rotation - - - - - + + @@ -1639,14 +1590,6 @@ 1 - - - 2 - - - - FlipState - Table @@ -1679,80 +1622,6 @@ true - - true - Min - - - true - - - MinSaturation - true - 0 - 255 - None - 0 - - - MinSaturation - - - - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - Max - - - true - - - MaxSaturation - true - 0 - 255 - None - 255 - - - MaxSaturation - - - - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - true Alpha @@ -1776,217 +1645,74 @@ - - - 0 - - - - - - - Rotation - - - SelectedControllerCamera - - - CameraList - - - - 0 - - - - - - - GetStream - - - - Source1 - - - - 1 - - - - Camera - - - CameraFeeds - - - Camera - - - - - - - - - - - Source1 - - - Key - - - - - - - Camera1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CurrentStream - - - + - + + - + - + - - - - - - + + + + + + + + + - + + - - - - - - - - - + + + + + + - - - - - + + + + + - - - + + + - + + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + + - - - - - - From ca2c804e6184a65d6ba3135f8ab5ec8513af9b13 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 14 Jul 2026 09:29:23 +0100 Subject: [PATCH 045/116] forward/backward left/right should move individual l/r spouts --- src/main.bonsai | 16 +- src/test_behavior_visualizer.bonsai | 475 ++++++++++++++++++++++++++-- 2 files changed, 455 insertions(+), 36 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index 0a8a2d3f..82c74b11 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -1788,9 +1788,9 @@ - -1 + 0 1 - 1 + 0 0 @@ -1828,8 +1828,8 @@ - 1 - 1 + 0 + 0 1 0 @@ -1868,9 +1868,9 @@ - -1 + 0 -1 - -1 + 0 0 @@ -1908,8 +1908,8 @@ - 1 - -1 + 0 + 0 -1 0 diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 65170cc9..52949ac7 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -66,7 +66,7 @@ - PT0.317S + PT1.644S @@ -118,7 +118,7 @@ - PT2.928S + PT0.057S @@ -189,7 +189,7 @@ - PT1.988S + PT1.2S @@ -503,7 +503,7 @@ - true + false @@ -608,7 +608,7 @@ - true + false @@ -669,7 +669,7 @@ - true + false true @@ -696,7 +696,7 @@ - PT0.537S + PT0.316S @@ -866,15 +866,6 @@ CameraFeed - - - 1 - - - - - CameraFeed2 - Camera1 @@ -965,16 +956,15 @@ - - - - - - - - - - + + + + + + + + + @@ -1254,6 +1244,18 @@ true + + + + + + + + + + + + Break 200 @@ -1411,7 +1413,423 @@ 53 215 - 0.5 + 0.33700001239776611 + + + + + + + + 2 + + + + + + + Flipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + Item1 + + + Item2 + + + + + + + + + Vertical + + + + NotFlipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + + + Item1 + + + + + + new ( + it.Size.Width / 2 as X, + it.Size.Height / 2 as Y +) + + + + + + + + + + 320 + 240 + + + + + + + + + + + + + + 320 + 240 + + + 0 + 0 + + 0 + + 1 + 1 + + + + + + + + + + + 1,0,0;0,1,0 + Linear + + 0 + 0 + 0 + 0 + + + + + Table + + + + Rgba + Repeat + Repeat + Linear + Linear + + + + + + + + + PreviewImage + true + + 320 + 320 + + + 0 + 0 + + + 1 + 1 + + + + Table + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Alpha + + + true + + + true + 0 + 1 + None + 0.5 + + + OverlayAlpha + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CameraPreviewVisualizer + + + + Source1 + + + + + + + + + + + + CameraPreview + + + + + + + Camera + + + true + 1 + None + + 0 + 0 + + 0 + + + Table + + + + + + TriggeredCamerasStream + + + + + + + + + Source1 + + + Key + + + + + + + Camera1 + + + + + + + + + + + + + + + + + CameraStream + + + Table + + + true + + + CameraStream + + + Value + + + OverlayAlpha + + + + + + + + + + + + + + + 53 + 215 + 0.26100000739097595 @@ -2586,7 +3004,8 @@ - + + \ No newline at end of file From e37cfd69c04bfa76946a1cf1ac0d021f8dbbc63e Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 14 Jul 2026 09:35:12 +0100 Subject: [PATCH 046/116] Fix typo in x position label Should be x not x1 --- src/main.bonsai | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.bonsai b/src/main.bonsai index 82c74b11..5607257c 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -2996,7 +2996,7 @@ true - x1: + x: true From 08fe849be09f79b49cde05533214b7def53f85bb Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 14 Jul 2026 09:45:28 +0100 Subject: [PATCH 047/116] Ensure right water shown in trial viz And fix incorrect colors in point plotter for left vs. right --- src/main.bonsai | 60 ++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index 5607257c..d7dca964 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -2219,6 +2219,33 @@ + + UiGiveLeft + + + TriggerLeft + + + + Source1 + + + + false + + + + GiveManualWaterRight + + + + + + + + + + UiCueGiveLeft @@ -2301,33 +2328,6 @@ - - UiGiveLeft - - - TriggerLeft - - - - Source1 - - - - false - - - - GiveManualWaterRight - - - - - - - - - - UiKeepLeftOpen @@ -2596,14 +2596,14 @@ WaterRight - Blue + Red 0.2 6 Circle - WaterLft - Red + WaterLeft + Blue 0.8 6 Circle From e35e817dc05a5442fd08a8b523e6d24e30bf8963 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 14 Jul 2026 09:51:46 +0100 Subject: [PATCH 048/116] Fix inter/intra session typo --- ...r.bonsai => IntraSessionVisualizer.bonsai} | 2 +- src/main.bonsai | 10 +- src/test_behavior_visualizer.bonsai | 285 +----------------- 3 files changed, 16 insertions(+), 281 deletions(-) rename src/Extensions/{InterSessionVisualizer.bonsai => IntraSessionVisualizer.bonsai} (99%) diff --git a/src/Extensions/InterSessionVisualizer.bonsai b/src/Extensions/IntraSessionVisualizer.bonsai similarity index 99% rename from src/Extensions/InterSessionVisualizer.bonsai rename to src/Extensions/IntraSessionVisualizer.bonsai index db335979..695505c9 100644 --- a/src/Extensions/InterSessionVisualizer.bonsai +++ b/src/Extensions/IntraSessionVisualizer.bonsai @@ -22,7 +22,7 @@ - InterSession + IntraSession true diff --git a/src/main.bonsai b/src/main.bonsai index d7dca964..b6d98485 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -2469,13 +2469,13 @@ PreSession - InterSession + IntraSession true - inter-session + intra-session None - InterSession + IntraSession @@ -3309,8 +3309,8 @@ - - InterSession + + IntraSession UiGiveLeft UiGiveRight UiMoveLeft diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 52949ac7..ecd2674a 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -1081,13 +1081,13 @@ PreSession - InterSession + IntraSession true - inter-session + intra-session None - InterSession + IntraSession @@ -1242,21 +1242,7 @@ true - - - - - - - - - - - - - - - + Break 200 @@ -2738,263 +2724,12 @@ - - InterSessionVisualizer - - - - - - - - - - - InterSessionVisualizer - - - - - - - InterSession - - - true - 3 - Borders - - 0 - 0 - - 0 - - - true - - - true - None - - - true - Manual - None - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - GiveLeft - true - Give Left - - - - - - - UiGiveLeft - - - true - - - GiveRight - true - Give Right - - - - - - - UiGiveRight - - - true - Go Cue - None - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - GiveLeftCue - true - Give Left Cue - - - - - - - UiCueGiveLeft - - - true - - - GiveRightCue - true - Give Right Cue - - - - - - - UiCueGiveRight - - - - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - MoveLeft - true - Move Left - - - - - - - UiMoveLeft - - - true - - - MoveRight - true - Move Right - - - - - - - UiMoveRight - - - - - - - - - true - - - SessionInfo - true - Session Info - - - true - - - Notes - true - Notes - 16384 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + IntraSession + UiGiveLeft + UiGiveRight + UiMoveLeft + UiMoveRight From 14776db3bfe31174ec3e7d0bf0f86411d4246e20 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 14 Jul 2026 10:00:59 +0100 Subject: [PATCH 049/116] Add not null filter to bias value in bias visualizer --- src/Extensions/BiasVisualizer.bonsai | 32 +-- src/main.bonsai | 282 ++++++++++++++++++++++++++- 2 files changed, 296 insertions(+), 18 deletions(-) diff --git a/src/Extensions/BiasVisualizer.bonsai b/src/Extensions/BiasVisualizer.bonsai index 4753cce7..3517e930 100644 --- a/src/Extensions/BiasVisualizer.bonsai +++ b/src/Extensions/BiasVisualizer.bonsai @@ -22,7 +22,7 @@ - Frame + Bias BiasPlot @@ -117,6 +117,7 @@ Value.Bias + BiasPlot @@ -236,9 +237,9 @@ - - - + + + @@ -246,30 +247,31 @@ - - + + - - - - - - - - + + + + + + + + - + + diff --git a/src/main.bonsai b/src/main.bonsai index b6d98485..8c52f8fb 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -16,6 +16,9 @@ xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" xmlns:p7="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" + xmlns:implot="clr-namespace:Bonsai.ImPlot;assembly=Bonsai.ImPlot" + xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" + xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -2522,9 +2525,282 @@ TimedTrial Behavior - - Bias - TimedBias + + BiasVisualizer + + + + + + + + BiasVisualizer + + + + + + + Bias + + + BiasPlot + true + + -1 + 150 + + NoTitle + AutoFit + None + + + BiasPlot + + + + BiasPlot + + + + + -1 + 1 + + + R + L + + West + None + 1.1 + -1.1 + + + + + + + TimedBias + + + 1000 + Seconds + Value.Bias + + + BiasPlot + + + + 0 + 0 + 0 + 1 + 2 + + + + true + None + + + 1 + Seconds + Value.Bias + + + BiasPlot + + + + Circle + 5 + 0 + 1 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + + true + None + + + + Value.Bias + + + + BiasPlot + + + {0:N2} + it + + + + + + + + Seconds + + + + + + + + + + + + + + true + 0.86 + 38.60000000000089 + 0.861054598987593 + + 0 + -10 + + None + + + + + 1 + + + + new (it as LeftBias) + + + + + + + + + 1000 + Seconds + Value.LeftBias + + + BiasPlot + + + + 1 + 0 + 0 + 0.7 + 1 + + + + true + None + + + + -1 + + + + new (it as RightBias) + + + + + + + + + 1000 + Seconds + Value.RightBias + + + BiasPlot + + + + 0 + 0 + 1 + 0.7 + 1 + + + + true + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Ethogram From d2c2470cf7e2a5b07535448a7a2e23be553c9bc3 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 14 Jul 2026 10:36:25 +0100 Subject: [PATCH 050/116] Add an enableable imgui button control to extensions --- src/Extensions/EnableableButtonBuilder.cs | 56 + src/main.bonsai | 282 +- src/test_behavior_visualizer.bonsai | 3708 +++++++++++---------- 3 files changed, 2056 insertions(+), 1990 deletions(-) create mode 100644 src/Extensions/EnableableButtonBuilder.cs diff --git a/src/Extensions/EnableableButtonBuilder.cs b/src/Extensions/EnableableButtonBuilder.cs new file mode 100644 index 00000000..2252416c --- /dev/null +++ b/src/Extensions/EnableableButtonBuilder.cs @@ -0,0 +1,56 @@ +using System; +using System.ComponentModel; +using System.Reactive; +using System.Reactive.Linq; +using Bonsai.ImGui; +using ImGui = Hexa.NET.ImGui.ImGui; + +/// +/// Represents an operator that draws a button control and generates +/// a sequence of notifications whenever the button is clicked. +/// +[Description("Draws a button control and generates a sequence of notifications whenever the button is clicked.")] +public class EnableableButtonBuilder : TextControlBuilder +{ + public bool Enabled {get; set;} + + /// + protected override IObservable Generate(IObservable source) + { + return Observable.Create(observer => + { + var capturedName = Name; + var capturedText = Text; + var idSuffix = "##" + capturedName; + var label = capturedText + idSuffix; + var output = capturedName ?? capturedText; + var sourceObserver = Observer.Create( + _ => + { + var text = Text; + if (text != capturedText) + { + capturedText = text; + label = text + idSuffix; + output = capturedName ?? text; + } + if (Visible) + { + if (Enabled) + { + if (ImGui.Button(label)) + observer.OnNext(output); + } else + { + ImGui.BeginDisabled(); + ImGui.Button(label); + ImGui.EndDisabled(); + } + } + }, + observer.OnError, + observer.OnCompleted); + return source.SubscribeSafe(sourceObserver); + }); + } +} \ No newline at end of file diff --git a/src/main.bonsai b/src/main.bonsai index 8c52f8fb..b6d98485 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -16,9 +16,6 @@ xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" xmlns:p7="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" - xmlns:implot="clr-namespace:Bonsai.ImPlot;assembly=Bonsai.ImPlot" - xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" - xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -2525,282 +2522,9 @@ TimedTrial Behavior - - BiasVisualizer - - - - - - - - BiasVisualizer - - - - - - - Bias - - - BiasPlot - true - - -1 - 150 - - NoTitle - AutoFit - None - - - BiasPlot - - - - BiasPlot - - - - - -1 - 1 - - - R - L - - West - None - 1.1 - -1.1 - - - - - - - TimedBias - - - 1000 - Seconds - Value.Bias - - - BiasPlot - - - - 0 - 0 - 0 - 1 - 2 - - - - true - None - - - 1 - Seconds - Value.Bias - - - BiasPlot - - - - Circle - 5 - 0 - 1 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - - true - None - - - - Value.Bias - - - - BiasPlot - - - {0:N2} - it - - - - - - - - Seconds - - - - - - - - - - - - - - true - 0.86 - 38.60000000000089 - 0.861054598987593 - - 0 - -10 - - None - - - - - 1 - - - - new (it as LeftBias) - - - - - - - - - 1000 - Seconds - Value.LeftBias - - - BiasPlot - - - - 1 - 0 - 0 - 0.7 - 1 - - - - true - None - - - - -1 - - - - new (it as RightBias) - - - - - - - - - 1000 - Seconds - Value.RightBias - - - BiasPlot - - - - 0 - 0 - 1 - 0.7 - 1 - - - - true - None - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Bias + TimedBias Ethogram diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index ecd2674a..58ab679b 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -66,7 +66,7 @@ - PT1.644S + PT1.539S @@ -118,7 +118,7 @@ - PT0.057S + PT0.917S @@ -189,7 +189,7 @@ - PT1.2S + PT1.55S @@ -503,7 +503,7 @@ - false + true @@ -669,7 +669,7 @@ - false + true true @@ -696,7 +696,7 @@ - PT0.316S + PT0.778S @@ -982,150 +982,163 @@ Frame - - VisualizerStructure - - - - - - - Frame - - - true - - - true - 2 - Borders - - 0 - 0 - - 0 - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - Behavior - - - true - - - Bias - - - true - - - Ethogram - - - - - - true - - - Camera - - - - - - true - - - true - 1 - Borders - - 0 - 0 - - 0 - - - Metadata - - - true - - - true - None - - - PreSession - true - pre-session - None - - - PreSession - - - IntraSession - true - intra-session - None - - - IntraSession - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Frame + + + true + + + true + EnableableButton + true + + + + VisualizerStructure + + + + + + + Frame + + + true + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + Behavior + + + true + + + Bias + + + true + + + Ethogram + + + + + + true + + + Camera + + + + + + true + + + true + 1 + Borders + + 0 + 0 + + 0 + + + Metadata + + + true + + + true + None + + + PreSession + true + pre-session + None + + + PreSession + + + IntraSession + true + intra-session + None + + + IntraSession + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1142,983 +1155,999 @@ TimedBias - - OutputControl - - - - UiHabituationTimeUpdate - - - UiMoveLeft - - - UiGiveRight - - - UiGiveLeft - - - UiMoveRight - - - UiKeepLeftOpen - - - UiKeepRightOpen - - - UiKeepBothOpen - - - UiDrainLeft - - - UiDrainRight - - - UiDrainBoth - - - UiManipulatorLeft - - - UiManipulatorForwardLeft - - - UiManipulatorForwardRight - - - UiManipulatorUp - - - UiManipulatorRight - - - UiManipulatorBackRight - - - UiManipulatorBackLeft - - - UiManipulatorDown - - - UiManipulatorStop - - - UiManipulatorHome - - - UiManipulatorInitialize - - - StartExperimentShortcut - - - EndExperiment - - - UiCueGiveRight - - - UiCueGiveLeft - - - - + + + OutputControl + + + + UiHabituationTimeUpdate + + + UiMoveLeft + + + UiGiveRight + + + UiGiveLeft + + + UiMoveRight + + + UiKeepLeftOpen + + + UiKeepRightOpen + + + UiKeepBothOpen + + + UiDrainLeft + + + UiDrainRight + + + UiDrainBoth + + + UiManipulatorLeft + + + UiManipulatorForwardLeft + + + UiManipulatorForwardRight + + + UiManipulatorUp + + + UiManipulatorRight + + + UiManipulatorBackRight + + + UiManipulatorBackLeft + + + UiManipulatorDown + + + UiManipulatorStop + + + UiManipulatorHome + + + UiManipulatorInitialize + + + StartExperimentShortcut + + + EndExperiment + + + UiCueGiveRight + + + UiCueGiveLeft + + + + + - - Ethogram + + + Ethogram + - - SoftwareEventHistory + + + SoftwareEventHistory + - - - - + + + + + + - - - true - - Break - 200 - - - TrialOutcome - CornflowerBlue - 0.3 - - - RewardPeriod - Crimson - 0.3 - - - ITI - Cyan - 0.3 - - - - - TrialOutcome - SaddleBrown - 0.5 - 2 - Circle - - - LickLeft - Red - 0.8 - 2 - Down - - - LickRight - DodgerBlue - 0.2 - 2 - Up - - - + + + + true + + Break + 200 + + + TrialOutcome + CornflowerBlue + 0.3 + + + RewardPeriod + Crimson + 0.3 + + + ITI + Cyan + 0.3 + + + + + TrialOutcome + SaddleBrown + 0.5 + 2 + Circle + + + LickLeft + Red + 0.8 + 2 + Down + + + LickRight + DodgerBlue + 0.2 + 2 + Up + + + + - - - CameraPreviewVisualizer - - - - Source1 - - - - - - - - - - - - CameraPreview - - - - - - - Camera - - - true - 1 - None - - 0 - 0 - - 0 - - - Table - - - - - - TriggeredCamerasStream - - - - - - - - - Source1 - - - Key - - - - - - - Camera1 - - - - - - - - - - - - - - - - - CameraStream - - - Table - - - true - - - CameraStream - - - Value - - - OverlayAlpha - - - - - - - - - - - - - - - 53 - 215 - 0.33700001239776611 - - - - - - - - 2 - - - - - - - Flipped - - - - Source1 - - - Item2 - - - - 2 - - - - - - - - - - - - - Item1 - - - Item2 - - - - - - - - - Vertical - - - - NotFlipped - - - - Source1 - - - Item2 - - - - 2 - - - - - - - - - - - - - - - Item1 - - - - - - new ( + + + + + + CameraPreviewVisualizer + + + + Source1 + + + + + + + + + + + + CameraPreview + + + + + + + Camera + + + true + 1 + None + + 0 + 0 + + 0 + + + Table + + + + + + TriggeredCamerasStream + + + + + + + + + Source1 + + + Key + + + + + + + Camera1 + + + + + + + + + + + + + + + + + CameraStream + + + Table + + + true + + + CameraStream + + + Value + + + OverlayAlpha + + + + + + + + + + + + + + + 53 + 215 + 0.33700001239776611 + + + + + + + + 2 + + + + + + + Flipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + Item1 + + + Item2 + + + + + + + + + Vertical + + + + NotFlipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + + + Item1 + + + + + + new ( it.Size.Width / 2 as X, it.Size.Height / 2 as Y ) - - - - - - - - - - 320 - 240 - - - - - - - - - - - - - + + + + + + + + + 320 240 - - - 0 - 0 - - 0 - - 1 - 1 - - - - - - - - - - - 1,0,0;0,1,0 - Linear - - 0 - 0 - 0 - 0 - - - - - Table - - - - Rgba - Repeat - Repeat - Linear - Linear - - - - - - - - - PreviewImage - true - - 320 - 320 - - - 0 - 0 - - - 1 - 1 - - - - Table - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - Alpha - - - true - - - true - 0 - 1 - None - 0.5 - - - OverlayAlpha - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + 320 + 240 + + + 0 + 0 + + 0 + + 1 + 1 + + + + + + + + + + + 1,0,0;0,1,0 + Linear + + 0 + 0 + 0 + 0 + + + + + Table + + + + Rgba + Repeat + Repeat + Linear + Linear + + + + + + + + + PreviewImage + true + + 320 + 320 + + + 0 + 0 + + + 1 + 1 + + + + Table + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Alpha + + + true + + + true + 0 + 1 + None + 0.5 + + + OverlayAlpha + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - CameraPreviewVisualizer - - - - Source1 - - - - - - - - - - - - CameraPreview - - - - - - - Camera - - - true - 1 - None - - 0 - 0 - - 0 - - - Table - - - - - - TriggeredCamerasStream - - - - - - - - - Source1 - - - Key - - - - - - - Camera1 - - - - - - - - - - - - - - - - - CameraStream - - - Table - - - true - - - CameraStream - - - Value - - - OverlayAlpha - - - - - - - - - - - - - - - 53 - 215 - 0.26100000739097595 - - - - - - - - 2 - - - - - - - Flipped - - - - Source1 - - - Item2 - - - - 2 - - - - - - - - - - - - - Item1 - - - Item2 - - - - - - - - - Vertical - - - - NotFlipped - - - - Source1 - - - Item2 - - - - 2 - - - - - - - - - - - - - - - Item1 - - - - - - new ( + + + CameraPreviewVisualizer + + + + Source1 + + + + + + + + + + + + CameraPreview + + + + + + + Camera + + + true + 1 + None + + 0 + 0 + + 0 + + + Table + + + + + + TriggeredCamerasStream + + + + + + + + + Source1 + + + Key + + + + + + + Camera1 + + + + + + + + + + + + + + + + + CameraStream + + + Table + + + true + + + CameraStream + + + Value + + + OverlayAlpha + + + + + + + + + + + + + + + 53 + 215 + 0.26100000739097595 + + + + + + + + 2 + + + + + + + Flipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + Item1 + + + Item2 + + + + + + + + + Vertical + + + + NotFlipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + + + Item1 + + + + + + new ( it.Size.Width / 2 as X, it.Size.Height / 2 as Y ) - - - - - - - - - - 320 - 240 - - - - - - - - - - - - - + + + + + + + + + 320 240 - - - 0 - 0 - - 0 - - 1 - 1 - - - - - - - - - - - 1,0,0;0,1,0 - Linear - - 0 - 0 - 0 - 0 - - - - - Table - - - - Rgba - Repeat - Repeat - Linear - Linear - - - - - - - - - PreviewImage - true - - 320 - 320 - - - 0 - 0 - - - 1 - 1 - - - - Table - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - Alpha - - - true - - - true - 0 - 1 - None - 0.5 - - - OverlayAlpha - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + 320 + 240 + + + 0 + 0 + + 0 + + 1 + 1 + + + + + + + + + + + 1,0,0;0,1,0 + Linear + + 0 + 0 + 0 + 0 + + + + + Table + + + + Rgba + Repeat + Repeat + Linear + Linear + + + + + + + + + PreviewImage + true + + 320 + 320 + + + 0 + 0 + + + 1 + 1 + + + + Table + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Alpha + + + true + + + true + 0 + 1 + None + 0.5 + + + OverlayAlpha + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2133,614 +2162,871 @@ UiHabituationTimeUpdate - - PreSessionVisualizer - - - - - - - - - - - - - - - - - - - - - - - - PreSessionVisualizer - - - - - - - PreSession - - - true - 2 - Borders - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - KeepLeftOpen - true - Keep Left Open - - - - - - - UiKeepLeftOpen - - - KeepRightOpen - true - Keep Right Open - - - - - - - UiKeepRightOpen - - - KeepBothOpen - true - Keep Both Open - - - - - - - UiKeepBothOpen - - - - - - true - - - DrainLeft - true - Drain 5ml Left - - - - - - - UiDrainLeft - - - Drain Right - true - Drain 5ml Right - - - - - - - UiDrainRight - - - Drain Both - true - Drain 5ml Both - - - - - - - UiDrainBoth - - - - - - - - - true - - - true - 2 - Borders - - 0 - 0 - - 0 - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - MoveLeft - true - Move Left - - - - - - - UiManipulatorLeft - - - ForwardLeft - true - Forward Left - - - - - - - UiManipulatorForwardLeft - - - ForwardRight - true - Forward Right - - - - - - - UiManipulatorForwardRight - - - Up - true - Up - - - - - - - UiManipulatorUp - - - - - - true - - - MoveRight - true - Move Right - - - - - - - UiManipulatorRight - - - BackLeft - true - Back Left - - - - - - - UiManipulatorBackLeft - - - BackRight - true - Back Right - - - - - - - UiManipulatorBackRight - - - Down - true - Down - - - - - - - UiManipulatorDown - - - - - - - - - true - - - STOP - true - STOP - - - - - - - UiManipulatorStop - - - Home - true - Home - - - - - - - UiManipulatorHome - - - Initialize - true - Initialize - - - - - - - UiManipulatorInitialize - - - - - - - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - x1: - - - true - - - true - 0.00mm - - - - - - true - - - true - y1: - - - true - - - true - 0.00mm - - - - - - true - - - true - y2: - - - true - - - true - 0.00mm - - - - - - true - - - true - z: - - - true - - - true - 0.00mm - - - - - - true - - - true - step: - - - true - - - true - None - 0 - 0 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + PreSessionVisualizer + + + + + + + + + + + + + + + + + + + + + + + + PreSessionVisualizer + + + + + + + PreSession + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + KeepLeftOpen + true + Keep Left Open + + + + + + + UiKeepLeftOpen + + + KeepRightOpen + true + Keep Right Open + + + + + + + UiKeepRightOpen + + + KeepBothOpen + true + Keep Both Open + + + + + + + UiKeepBothOpen + + + + + + true + + + DrainLeft + true + Drain 5ml Left + + + + + + + UiDrainLeft + + + Drain Right + true + Drain 5ml Right + + + + + + + UiDrainRight + + + Drain Both + true + Drain 5ml Both + + + + + + + UiDrainBoth + + + + + + + + + true + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + MoveLeft + true + Move Left + + + + + + + UiManipulatorLeft + + + ForwardLeft + true + Forward Left + + + + + + + UiManipulatorForwardLeft + + + ForwardRight + true + Forward Right + + + + + + + UiManipulatorForwardRight + + + Up + true + Up + + + + + + + UiManipulatorUp + + + + + + true + + + MoveRight + true + Move Right + + + + + + + UiManipulatorRight + + + BackLeft + true + Back Left + + + + + + + UiManipulatorBackLeft + + + BackRight + true + Back Right + + + + + + + UiManipulatorBackRight + + + Down + true + Down + + + + + + + UiManipulatorDown + + + + + + + + + true + + + STOP + true + STOP + + + + + + + UiManipulatorStop + + + Home + true + Home + + + + + + + UiManipulatorHome + + + Initialize + true + Initialize + + + + + + + UiManipulatorInitialize + + + + + + + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + x1: + + + true + + + true + 0.00mm + + + + + + true + + + true + y1: + + + true + + + true + 0.00mm + + + + + + true + + + true + y2: + + + true + + + true + 0.00mm + + + + + + true + + + true + z: + + + true + + + true + 0.00mm + + + + + + true + + + true + step: + + + true + + + true + None + 0 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - IntraSession - UiGiveLeft - UiGiveRight - UiMoveLeft - UiMoveRight + + + IntraSessionVisualizer + + + + + + + + + + + InterSessionVisualizer + + + + + + + IntraSession + + + true + 3 + Borders + + 0 + 0 + + 0 + + + true + + + true + None + + + true + Manual + None + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + GiveLeft + true + Give Left + + + + + + + UiGiveLeft + + + true + + + GiveRight + true + Give Right + + + + + + + UiGiveRight + + + true + Go Cue + None + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + GiveLeftCue + true + Give Left Cue + + + + + + + UiCueGiveLeft + + + true + + + GiveRightCue + true + Give Right Cue + + + + + + + UiCueGiveRight + + + + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + MoveLeft + true + Move Left + + + + + + + UiMoveLeft + + + true + + + MoveRight + true + Move Right + + + + + + + UiMoveRight + + + + + + + + + true + + + SessionInfo + true + Session Info + + + true + + + Notes + true + Notes + 16384 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - + + + \ No newline at end of file From e6fb1a341222db5c63bc50e4f932f0812329c524 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 14 Jul 2026 10:56:54 +0100 Subject: [PATCH 051/116] Update water on cue buttons to be enabled/disabled according to auto --- src/main.bonsai | 293 +++++++++++++++++++++++++++- src/test_behavior_visualizer.bonsai | 53 ++++- 2 files changed, 330 insertions(+), 16 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index b6d98485..a1ea1bb3 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -3309,12 +3309,293 @@ - - IntraSession - UiGiveLeft - UiGiveRight - UiMoveLeft - UiMoveRight + + IntraSessionVisualizer + + + + + + + + + + + InterSessionVisualizer + + + + + + + IntraSession + + + true + 3 + Borders + + 0 + 0 + + 0 + + + true + + + true + None + + + true + Manual + None + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + GiveLeft + true + Give Left + + + + + + + UiGiveLeft + + + true + + + GiveRight + true + Give Right + + + + + + + UiGiveRight + + + true + Go Cue + None + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + GlobalAutoWaterState + + + it == null + + + + + + + + GiveLeftCue + true + Give Left Cue + false + + + + + + + UiCueGiveLeft + + + true + + + GlobalAutoWaterState + + + it == null + + + + + + + + GiveRightCue + true + Give Right Cue + false + + + + + + + UiCueGiveRight + + + + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + MoveLeft + true + Move Left + + + + + + + UiMoveLeft + + + true + + + MoveRight + true + Move Right + + + + + + + UiMoveRight + + + + + + + + + true + + + SessionInfo + true + Session Info + + + true + + + Notes + true + Notes + 16384 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 58ab679b..83368369 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -66,7 +66,7 @@ - PT1.539S + PT0.444S @@ -118,7 +118,7 @@ - PT0.917S + PT2.823S @@ -189,7 +189,7 @@ - PT1.55S + PT0.509S @@ -696,7 +696,7 @@ - PT0.778S + PT0.687S @@ -988,6 +988,33 @@ true + + + None + false + + + + + 1 + + + + + + 2 + + + + + 0 + + + + + + + true EnableableButton @@ -3020,13 +3047,19 @@ - - - - - - + + + + + + + + + + + + \ No newline at end of file From 93df5e1d53983a35642487bdcee82c743c3d8a92 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 14 Jul 2026 10:57:34 +0100 Subject: [PATCH 052/116] Save session visualizers as include workflows --- src/Extensions/IntraSessionVisualizer.bonsai | 97 +++++++++----- src/Extensions/PreSessionVisualizer.bonsai | 126 +++++++++++++++---- 2 files changed, 168 insertions(+), 55 deletions(-) diff --git a/src/Extensions/IntraSessionVisualizer.bonsai b/src/Extensions/IntraSessionVisualizer.bonsai index 695505c9..cd8233db 100644 --- a/src/Extensions/IntraSessionVisualizer.bonsai +++ b/src/Extensions/IntraSessionVisualizer.bonsai @@ -3,6 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" + xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns:p1="clr-namespace:;assembly=Extensions" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -104,10 +105,22 @@ true - - GiveLeftCue - true - Give Left Cue + + GlobalAutoWaterState + + + it == null + + + + + + + + GiveLeftCue + true + Give Left Cue + false @@ -119,10 +132,22 @@ true - - GiveRightCue - true - Give Right Cue + + GlobalAutoWaterState + + + it == null + + + + + + + + GiveRightCue + true + Give Right Cue + false @@ -202,10 +227,10 @@ - - + + - + @@ -215,41 +240,47 @@ - + - + - - + + - + - - - - - - - - - + + + + + + + + - - - - + + + + + - - + + - + + - + + + + + + diff --git a/src/Extensions/PreSessionVisualizer.bonsai b/src/Extensions/PreSessionVisualizer.bonsai index 05bd7db7..80e02700 100644 --- a/src/Extensions/PreSessionVisualizer.bonsai +++ b/src/Extensions/PreSessionVisualizer.bonsai @@ -359,11 +359,29 @@ true - x1: + x: true + + + + + ManipulatorPosition + + + X + + + {0:F2}mm + it + + + + + + true 0.00mm @@ -381,6 +399,18 @@ true + + Y1 + + + {0:F2}mm + it + + + + + + true 0.00mm @@ -398,6 +428,18 @@ true + + Y2 + + + {0:F2}mm + it + + + + + + true 0.00mm @@ -415,6 +457,18 @@ true + + Z + + + {0:F2}mm + it + + + + + + true 0.00mm @@ -432,9 +486,18 @@ true - + true - 0.25mm + None + 0.25 + 0 + 0 + + + + + + OffsetGain @@ -551,34 +614,53 @@ - - - - + - + + + + - - - + + + + + + + - - + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + From 5a4c8b1bf531bb0274f4589dbd3ee0e23d0ec6df Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 14 Jul 2026 11:28:22 +0100 Subject: [PATCH 053/116] Add flushing control to OutputControl --- src/main.bonsai | 1349 +++------ src/test_behavior_visualizer.bonsai | 4034 +++++++++++++-------------- 2 files changed, 2371 insertions(+), 3012 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index a1ea1bb3..a1860a30 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -2340,12 +2340,44 @@ UiDrainLeft + + + true + + + + IsFlushingValveLeft + UiDrainRight + + + true + + + + IsFlushingValveLeft + UiDrainBoth + + + true + + + + IsFlushingValveLeft + + + + true + + + + IsFlushingValveLeft + GiveManualWaterRight @@ -2355,6 +2387,328 @@ GiveRewardRight + + IsFlushingValveLeft + + + Flush + + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + false + + + + + 500 + + + + + + + SetIsRightValveMs + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + + PT0.5S + + + + + 5000 + + + + RigSchema + + + Calibration.WaterValveLeft + + + + + + RewardToTime + ((Item1 * 0.001) - Item2.Offset) / Item2.Slope + + + ToMilliseconds + + + + + 1000 + + + + DivideByEachOpen + Math.Ceiling(it / 500) + + + + + + + + + 300 + + + + + + + + false + + + + IsFlushingValveLeft + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IsFlushingValveRight + + + Flush + + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + true + + + + + 500 + + + + + + + SetIsRightValveMs + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + + PT0.5S + + + + + 5000 + + + + RigSchema + + + Calibration.WaterValveRight + + + + + + RewardToTime + ((Item1 * 0.001) - Item2.Offset) / Item2.Slope + + + ToMilliseconds + + + + + 1000 + + + + DivideByEachOpen + Math.Ceiling(it / 500) + + + + + + + + + 300 + + + + + + + + false + + + + IsFlushingValveRight + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2365,8 +2719,20 @@ + + + + + + + + + + + + @@ -2639,963 +3005,32 @@ EndExperiment UiHabituationTimeUpdate - - PreSessionVisualizer - - - - - - - - - - - - - - - - - - - - - - - - PreSessionVisualizer - - - - - - - PreSession - - - true - 2 - Borders - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - KeepLeftOpen - true - Keep Left Open - - - - - - - UiKeepLeftOpen - - - KeepRightOpen - true - Keep Right Open - - - - - - - UiKeepRightOpen - - - KeepBothOpen - true - Keep Both Open - - - - - - - UiKeepBothOpen - - - - - - true - - - DrainLeft - true - Drain 5ml Left - - - - - - - UiDrainLeft - - - Drain Right - true - Drain 5ml Right - - - - - - - UiDrainRight - - - Drain Both - true - Drain 5ml Both - - - - - - - UiDrainBoth - - - - - - - - - true - - - true - 2 - Borders - - 0 - 0 - - 0 - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - MoveLeft - true - Move Left - - - - - - - UiManipulatorLeft - - - ForwardLeft - true - Forward Left - - - - - - - UiManipulatorForwardLeft - - - ForwardRight - true - Forward Right - - - - - - - UiManipulatorForwardRight - - - Up - true - Up - - - - - - - UiManipulatorUp - - - - - - true - - - MoveRight - true - Move Right - - - - - - - UiManipulatorRight - - - BackLeft - true - Back Left - - - - - - - UiManipulatorBackLeft - - - BackRight - true - Back Right - - - - - - - UiManipulatorBackRight - - - Down - true - Down - - - - - - - UiManipulatorDown - - - - - - - - - true - - - STOP - true - STOP - - - - - - - UiManipulatorStop - - - Home - true - Home - - - - - - - UiManipulatorHome - - - Initialize - true - Initialize - - - - - - - UiManipulatorInitialize - - - - - - - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - x: - - - true - - - - - - ManipulatorPosition - - - X - - - {0:F2}mm - it - - - - - - - - true - 0.00mm - - - - - - true - - - true - y1: - - - true - - - Y1 - - - {0:F2}mm - it - - - - - - - - true - 0.00mm - - - - - - true - - - true - y2: - - - true - - - Y2 - - - {0:F2}mm - it - - - - - - - - true - 0.00mm - - - - - - true - - - true - z: - - - true - - - Z - - - {0:F2}mm - it - - - - - - - - true - 0.00mm - - - - - - true - - - true - step: - - - true - - - true - None - 0.25 - 0 - 0 - - - - - - OffsetGain - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IntraSessionVisualizer - - - - - - - - - - - InterSessionVisualizer - - - - - - - IntraSession - - - true - 3 - Borders - - 0 - 0 - - 0 - - - true - - - true - None - - - true - Manual - None - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - GiveLeft - true - Give Left - - - - - - - UiGiveLeft - - - true - - - GiveRight - true - Give Right - - - - - - - UiGiveRight - - - true - Go Cue - None - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - GlobalAutoWaterState - - - it == null - - - - - - - - GiveLeftCue - true - Give Left Cue - false - - - - - - - UiCueGiveLeft - - - true - - - GlobalAutoWaterState - - - it == null - - - - - - - - GiveRightCue - true - Give Right Cue - false - - - - - - - UiCueGiveRight - - - - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - MoveLeft - true - Move Left - - - - - - - UiMoveLeft - - - true - - - MoveRight - true - Move Right - - - - - - - UiMoveRight - - - - - - - - - true - - - SessionInfo - true - Session Info - - - true - - - Notes - true - Notes - 16384 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + PreSession + UiKeepLeftOpen + UiKeepRightOpen + UiKeepBothOpen + UiDrainLeft + UiDrainRight + UiDrainBoth + UiManipulatorLeft + UiManipulatorForwardLeft + UiManipulatorForwardRight + UiManipulatorUp + UiManipulatorRight + UiManipulatorBackLeft + UiManipulatorBackRight + UiManipulatorDown + UiManipulatorStop + UiManipulatorHome + UiManipulatorInitialize + + + IntraSession + UiGiveLeft + UiGiveRight + UiMoveLeft + UiMoveRight diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 83368369..045dc659 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -982,2084 +982,2008 @@ Frame - - Frame + + VisualizerStructure + + + + + + + Frame + + + true + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + Behavior + + + true + + + Bias + + + true + + + Ethogram + + + + + + true + + + Camera + + + + + + true + + + true + 1 + Borders + + 0 + 0 + + 0 + + + Metadata + + + true + + + true + None + + + PreSession + true + pre-session + None + + + PreSession + + + IntraSession + true + intra-session + None + + + IntraSession + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - true + + Behavior1 + LickLeft + LickRight + TimedTrial + Behavior - - - None - false - + + Bias + TimedBias - - - 1 - + + OutputControl + + + + UiHabituationTimeUpdate + + + UiMoveLeft + + + UiGiveRight + + + UiGiveLeft + + + UiMoveRight + + + UiKeepLeftOpen + + + UiKeepRightOpen + + + UiKeepBothOpen + + + UiDrainLeft + + + UiDrainRight + + + UiDrainBoth + + + UiManipulatorLeft + + + UiManipulatorForwardLeft + + + UiManipulatorForwardRight + + + UiManipulatorUp + + + UiManipulatorRight + + + UiManipulatorBackRight + + + UiManipulatorBackLeft + + + UiManipulatorDown + + + UiManipulatorStop + + + UiManipulatorHome + + + UiManipulatorInitialize + + + StartExperimentShortcut + + + EndExperiment + + + UiCueGiveRight + + + UiCueGiveLeft + + + + - - - - 2 - + + Ethogram - - - 0 - + + SoftwareEventHistory - + - - true - EnableableButton - true - - - - VisualizerStructure - - - - - - - Frame - - - true - - - true - 2 - Borders - - 0 - 0 - - 0 - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - Behavior - - - true - - - Bias - - - true - - - Ethogram - - - - - - true - - - Camera - - - - - - true - - - true - 1 - Borders - - 0 - 0 - - 0 - - - Metadata - - - true - - - true - None - - - PreSession - true - pre-session - None - - - PreSession - - - IntraSession - true - intra-session - None - - - IntraSession - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Behavior1 - LickLeft - LickRight - TimedTrial - Behavior - - - - - Bias - TimedBias - - - - - OutputControl - - - - UiHabituationTimeUpdate - - - UiMoveLeft - - - UiGiveRight - - - UiGiveLeft - - - UiMoveRight - - - UiKeepLeftOpen - - - UiKeepRightOpen - - - UiKeepBothOpen - - - UiDrainLeft - - - UiDrainRight - - - UiDrainBoth - - - UiManipulatorLeft - - - UiManipulatorForwardLeft - - - UiManipulatorForwardRight - - - UiManipulatorUp - - - UiManipulatorRight - - - UiManipulatorBackRight - - - UiManipulatorBackLeft - - - UiManipulatorDown - - - UiManipulatorStop - - - UiManipulatorHome - - - UiManipulatorInitialize - - - StartExperimentShortcut - - - EndExperiment - - - UiCueGiveRight - - - UiCueGiveLeft - - - - - - - - - Ethogram - - - - - SoftwareEventHistory - - - - - - - - - - - - - true - - Break - 200 - - - TrialOutcome - CornflowerBlue - 0.3 - - - RewardPeriod - Crimson - 0.3 - - - ITI - Cyan - 0.3 - - - - - TrialOutcome - SaddleBrown - 0.5 - 2 - Circle - - - LickLeft - Red - 0.8 - 2 - Down - - - LickRight - DodgerBlue - 0.2 - 2 - Up - - - - - - - - - - - CameraPreviewVisualizer - - - - Source1 - - - - - - - - - - - - CameraPreview - - - - - - - Camera - - - true - 1 - None - - 0 - 0 - - 0 - - - Table - - - - - - TriggeredCamerasStream - - - - - - - - - Source1 - - - Key - - - - - - - Camera1 - - - - - - - - - - - - - - - - - CameraStream - - - Table - - - true - - - CameraStream - - - Value - - - OverlayAlpha - - - - - - - - - - - - - - - 53 - 215 - 0.33700001239776611 - - - - - - - - 2 - - - - - - - Flipped - - - - Source1 - - - Item2 - - - - 2 - - - - - - - - - - - - - Item1 - - - Item2 - - - - - - - - - Vertical - - - - NotFlipped - - - - Source1 - - - Item2 - - - - 2 - - - - - - - - - - - - - - - Item1 - - - - - - new ( - it.Size.Width / 2 as X, - it.Size.Height / 2 as Y -) - - - - - - - - - - 320 - 240 - - - - - - - - - - - - - - 320 - 240 - - - 0 - 0 - - 0 - - 1 - 1 - - - - - - - - - - - 1,0,0;0,1,0 - Linear - - 0 - 0 - 0 - 0 - - - - - Table - - - - Rgba - Repeat - Repeat - Linear - Linear - - - - - - - - - PreviewImage - true - - 320 - 320 - - - 0 - 0 - - - 1 - 1 - - - - Table - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - Alpha - - - true - - - true - 0 - 1 - None - 0.5 - - - OverlayAlpha - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + true + + Break + 200 + + + TrialOutcome + CornflowerBlue + 0.3 + + + RewardPeriod + Crimson + 0.3 + + + ITI + Cyan + 0.3 + + + + + TrialOutcome + SaddleBrown + 0.5 + 2 + Circle + + + LickLeft + Red + 0.8 + 2 + Down + + + LickRight + DodgerBlue + 0.2 + 2 + Up + + + - - - CameraPreviewVisualizer - - - - Source1 - - - - - - - - - - - - CameraPreview - - - - - - - Camera - - - true - 1 - None - - 0 - 0 - - 0 - - - Table - - - - - - TriggeredCamerasStream - - - - - - - - - Source1 - - - Key - - - - - - - Camera1 - - - - - - - - - - - - - - - - - CameraStream - - - Table - - - true - - - CameraStream - - - Value - - - OverlayAlpha - - - - - - - - - - - - - - - 53 - 215 - 0.26100000739097595 - - - - - - - - 2 - - - - - - - Flipped - - - - Source1 - - - Item2 - - - - 2 - - - - - - - - - - - - - Item1 - - - Item2 - - - - - - - - - Vertical - - - - NotFlipped - - - - Source1 - - - Item2 - - - - 2 - - - - - - - - - - - - - - - Item1 - - - - - - new ( + + + CameraPreviewVisualizer + + + + Source1 + + + + + + + + + + + + CameraPreview + + + + + + + Camera + + + true + 1 + None + + 0 + 0 + + 0 + + + Table + + + + + + TriggeredCamerasStream + + + + + + + + + Source1 + + + Key + + + + + + + Camera1 + + + + + + + + + + + + + + + + + CameraStream + + + Table + + + true + + + CameraStream + + + Value + + + OverlayAlpha + + + + + + + + + + + + + + + 53 + 215 + 0.33700001239776611 + + + + + + + + 2 + + + + + + + Flipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + Item1 + + + Item2 + + + + + + + + + Vertical + + + + NotFlipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + + + Item1 + + + + + + new ( it.Size.Width / 2 as X, it.Size.Height / 2 as Y ) - - - - - - - - - + + + + + + + + + + 320 + 240 + + + + + + + + + + + + + 320 240 - - - - - - - - - - - - - - 320 - 240 - - - 0 - 0 - - 0 - - 1 - 1 - - - - - - - - - - - 1,0,0;0,1,0 - Linear - - 0 - 0 - 0 - 0 - - - - - Table - - - - Rgba - Repeat - Repeat - Linear - Linear - - - - - - - - - PreviewImage - true - - 320 - 320 - - - 0 - 0 - - - 1 - 1 - - - - Table - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - Alpha - - - true - - - true - 0 - 1 - None - 0.5 - - - OverlayAlpha - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SessionInfo - - - - - Metadata - StartExperimentShortcut - EndExperiment - UiHabituationTimeUpdate - - - - - PreSessionVisualizer - - - - - - - - - - - - - - - - - - - - - - - - PreSessionVisualizer - - - - - - - PreSession - - - true - 2 - Borders - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - KeepLeftOpen - true - Keep Left Open - - - - - - - UiKeepLeftOpen - - - KeepRightOpen - true - Keep Right Open - - - - - - - UiKeepRightOpen - - - KeepBothOpen - true - Keep Both Open - - - - - - - UiKeepBothOpen - - - - - - true - - - DrainLeft - true - Drain 5ml Left - - - - - - - UiDrainLeft - - - Drain Right - true - Drain 5ml Right - - - - - - - UiDrainRight - - - Drain Both - true - Drain 5ml Both - - - - - - - UiDrainBoth - - - - - - - - - true - - - true - 2 - Borders - - 0 - 0 - - 0 - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - MoveLeft - true - Move Left - - - - - - - UiManipulatorLeft - - - ForwardLeft - true - Forward Left - - - - - - - UiManipulatorForwardLeft - - - ForwardRight - true - Forward Right - - - - - - - UiManipulatorForwardRight - - - Up - true - Up - - - - - - - UiManipulatorUp - - - - - - true - - - MoveRight - true - Move Right - - - - - - - UiManipulatorRight - - - BackLeft - true - Back Left - - - - - - - UiManipulatorBackLeft - - - BackRight - true - Back Right - - - - - - - UiManipulatorBackRight - - - Down - true - Down - - - - - - - UiManipulatorDown - - - - - - - - - true - - - STOP - true - STOP - - - - - - - UiManipulatorStop - - - Home - true - Home - - - - - - - UiManipulatorHome - - - Initialize - true - Initialize - - - - - - - UiManipulatorInitialize - - - - - - - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - x1: - - - true - - - true - 0.00mm - - - - - - true - - - true - y1: - - - true - - - true - 0.00mm - - - - - - true - - - true - y2: - - - true - - - true - 0.00mm - - - - - - true - - - true - z: - - - true - - - true - 0.00mm - - - - - - true - - - true - step: - - - true - - - true - None - 0 - 0 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + 0 + 0 + + 0 + + 1 + 1 + + + + + + + + + + + 1,0,0;0,1,0 + Linear + + 0 + 0 + 0 + 0 + + + + + Table + + + + Rgba + Repeat + Repeat + Linear + Linear + + + + + + + + + PreviewImage + true + + 320 + 320 + + + 0 + 0 + + + 1 + 1 + + + + Table + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Alpha + + + true + + + true + 0 + 1 + None + 0.5 + + + OverlayAlpha + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - IntraSessionVisualizer - - - - - - - - - - - InterSessionVisualizer - - - - - - - IntraSession - - - true - 3 - Borders - - 0 - 0 - - 0 - - - true - - - true - None - - - true - Manual - None - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - GiveLeft - true - Give Left - - - - - - - UiGiveLeft - - - true - - - GiveRight - true - Give Right - - - - - - - UiGiveRight - - - true - Go Cue - None - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - GiveLeftCue - true - Give Left Cue - - - - - - - UiCueGiveLeft - - - true - - - GiveRightCue - true - Give Right Cue - - - - - - - UiCueGiveRight - - - - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - MoveLeft - true - Move Left - - - - - - - UiMoveLeft - - - true - - - MoveRight - true - Move Right - - - - - - - UiMoveRight - - - - - - - - - true - - - SessionInfo - true - Session Info - - - true - - - Notes - true - Notes - 16384 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + CameraPreviewVisualizer + + + + Source1 + + + + + + + + + + + + CameraPreview + + + + + + + Camera + + + true + 1 + None + + 0 + 0 + + 0 + + + Table + + + + + + TriggeredCamerasStream + + + + + + + + + Source1 + + + Key + + + + + + + Camera1 + + + + + + + + + + + + + + + + + CameraStream + + + Table + + + true + + + CameraStream + + + Value + + + OverlayAlpha + + + + + + + + + + + + + + + 53 + 215 + 0.26100000739097595 + + + + + + + + 2 + + + + + + + Flipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + Item1 + + + Item2 + + + + + + + + + Vertical + + + + NotFlipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + + + Item1 + + + + + + new ( + it.Size.Width / 2 as X, + it.Size.Height / 2 as Y +) + + + + + + + + + + 320 + 240 + + + + + + + + + + + + + + 320 + 240 + + + 0 + 0 + + 0 + + 1 + 1 + + + + + + + + + + + 1,0,0;0,1,0 + Linear + + 0 + 0 + 0 + 0 + + + + + Table + + + + Rgba + Repeat + Repeat + Linear + Linear + + + + + + + + + PreviewImage + true + + 320 + 320 + + + 0 + 0 + + + 1 + 1 + + + + Table + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Alpha + + + true + + + true + 0 + 1 + None + 0.5 + + + OverlayAlpha + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SessionInfo + + + Metadata + StartExperimentShortcut + EndExperiment + UiHabituationTimeUpdate + + + PreSessionVisualizer + + + + + + + + + + + + + + + + + + + + + + + + PreSessionVisualizer + + + + + + + PreSession + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + KeepLeftOpen + true + Keep Left Open + + + + + + + UiKeepLeftOpen + + + KeepRightOpen + true + Keep Right Open + + + + + + + UiKeepRightOpen + + + KeepBothOpen + true + Keep Both Open + + + + + + + UiKeepBothOpen + + + + + + true + + + DrainLeft + true + Drain 5ml Left + + + + + + + UiDrainLeft + + + Drain Right + true + Drain 5ml Right + + + + + + + UiDrainRight + + + Drain Both + true + Drain 5ml Both + + + + + + + UiDrainBoth + + + + + + + + + true + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + MoveLeft + true + Move Left + + + + + + + UiManipulatorLeft + + + ForwardLeft + true + Forward Left + + + + + + + UiManipulatorForwardLeft + + + ForwardRight + true + Forward Right + + + + + + + UiManipulatorForwardRight + + + Up + true + Up + + + + + + + UiManipulatorUp + + + + + + true + + + MoveRight + true + Move Right + + + + + + + UiManipulatorRight + + + BackLeft + true + Back Left + + + + + + + UiManipulatorBackLeft + + + BackRight + true + Back Right + + + + + + + UiManipulatorBackRight + + + Down + true + Down + + + + + + + UiManipulatorDown + + + + + + + + + true + + + STOP + true + STOP + + + + + + + UiManipulatorStop + + + Home + true + Home + + + + + + + UiManipulatorHome + + + Initialize + true + Initialize + + + + + + + UiManipulatorInitialize + + + + + + + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + x1: + + + true + + + true + 0.00mm + + + + + + true + + + true + y1: + + + true + + + true + 0.00mm + + + + + + true + + + true + y2: + + + true + + + true + 0.00mm + + + + + + true + + + true + z: + + + true + + + true + 0.00mm + + + + + + true + + + true + step: + + + true + + + true + None + 0 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IntraSessionVisualizer + + + + + + + + + + + InterSessionVisualizer + + + + + + + IntraSession + + + true + 3 + Borders + + 0 + 0 + + 0 + + + true + + + true + None + + + true + Manual + None + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + GiveLeft + true + Give Left + + + + + + + UiGiveLeft + + + true + + + GiveRight + true + Give Right + + + + + + + UiGiveRight + + + true + Go Cue + None + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + GiveLeftCue + true + Give Left Cue + + + + + + + UiCueGiveLeft + + + true + + + GiveRightCue + true + Give Right Cue + + + + + + + UiCueGiveRight + + + + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + MoveLeft + true + Move Left + + + + + + + UiMoveLeft + + + true + + + MoveRight + true + Move Right + + + + + + + UiMoveRight + + + + + + + + + true + + + SessionInfo + true + Session Info + + + true + + + Notes + true + Notes + 16384 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + - - - - - - - - + + + + \ No newline at end of file From c7682c979fa0a4dcc238fb34e97aa6053d49e43d Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Mon, 20 Jul 2026 15:07:47 +0100 Subject: [PATCH 054/116] Ui logic for keep open left/right/both --- src/Extensions/ToggleButtonBuilder.cs | 54 ++ src/test_behavior_visualizer.bonsai | 966 ++++++++++++++++++++++---- 2 files changed, 867 insertions(+), 153 deletions(-) create mode 100644 src/Extensions/ToggleButtonBuilder.cs diff --git a/src/Extensions/ToggleButtonBuilder.cs b/src/Extensions/ToggleButtonBuilder.cs new file mode 100644 index 00000000..96cf0119 --- /dev/null +++ b/src/Extensions/ToggleButtonBuilder.cs @@ -0,0 +1,54 @@ +using System; +using System.ComponentModel; +using System.Reactive; +using System.Reactive.Linq; +using Bonsai.ImGui; +using ImGui = Hexa.NET.ImGui.ImGui; + +/// +/// Represents an operator that draws a button control and generates +/// a sequence of notifications whenever the button is clicked. +/// +[Description("Draws a button control and generates a sequence of notifications whenever the button is clicked.")] +public class ToggleButtonBuilder : TextControlBuilder +{ + private bool Toggled; + + public string ToggledOffText {get; set;} + public string ToggledOnText {get; set;} + public bool Enabled {get; set;} + + /// + protected override IObservable Generate(IObservable source) + { + Toggled = false; + return Observable.Create(observer => + { + observer.OnNext(Toggled); + var sourceObserver = Observer.Create( + _ => + { + if (Visible) + { + var label = Toggled ? ToggledOnText : ToggledOffText; + if (Enabled) + { + if (ImGui.Button(label)) + { + observer.OnNext(!Toggled); + Toggled = !Toggled; + } + } else + { + ImGui.BeginDisabled(); + ImGui.Button(label); + ImGui.EndDisabled(); + } + } + }, + observer.OnError, + observer.OnCompleted); + return source.SubscribeSafe(sourceObserver); + }); + } +} \ No newline at end of file diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 045dc659..6bc898f9 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -16,9 +16,10 @@ xmlns:cv="clr-namespace:Bonsai.Vision;assembly=Bonsai.Vision" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" + xmlns:implot="clr-namespace:Bonsai.ImPlot;assembly=Bonsai.ImPlot" + xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:p7="clr-namespace:System.Reactive;assembly=System.Reactive.Core" - xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -66,7 +67,7 @@ - PT0.444S + PT0.839S @@ -118,7 +119,7 @@ - PT2.823S + PT2.05S @@ -189,7 +190,7 @@ - PT0.509S + PT1.374S @@ -503,7 +504,7 @@ - true + false @@ -608,7 +609,7 @@ - false + true @@ -669,7 +670,7 @@ - true + false true @@ -696,7 +697,7 @@ - PT0.687S + PT0.904S @@ -1127,12 +1128,588 @@ - - Behavior1 - LickLeft - LickRight - TimedTrial - Behavior + + BehaviorVisualizer + + + + + + + + + + + + + BehaviorPlot + + + + + + + Behavior + + + + + + Behavior1 + true + 1 + None + + 0 + 0 + + 0 + + + true + + + EventPlot + true + + -1 + 150 + + NoTitle + AutoFit + RangeFit + + + EventPlot + + + true + + + ContinuousPlot + true + + -1 + 150 + + NoTitle + AutoFit + None + + + ContinuousPlot + + + + EventPlot + + + + + 0 + 1 + + + R + L + + West + None + + + + + + + ContinuousPlot + + + + + 0 + 1 + + + West + None + + + + + + + + + LickLeft + + + Value + + + + 0.9 + + + + new(it as LickLeft) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickLeft + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + + + + LickRight + + + Value + + + + 0.1 + + + + new(it as LickRight) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickRight + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + + + + TimedTrial + + + + + + Value.ChoiceCategory + + + NoChoice + + + + Source1 + + + + NoChoice + + + + + + + + + + + + + 0.5 + + + + LeftChoice + + + + Source1 + + + + LeftChoice + + + + + + + + + + + + + 0.85 + + + + RightChoice + + + + Source1 + + + + RightChoice + + + + + + + + + + + + + 0.15 + + + + + + + new ( + it as Choice +) + + + Seconds + + + + + + + + + 1000 + Seconds + Value.Choice + + + EventPlot + + + + Circle + 3 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + + + + true + None + + + Value.TrialCategory + + + LeftRewarded + + + + Source1 + + + + LeftRewarded + + + + + + + + + + + + + 0.8 + + + + RightRewarded + + + + Source1 + + + + RightRewarded + + + + + + + + + + + + + 0.2 + + + + + + + new ( + it as Choice +) + + + + + + + + + 1000 + Seconds + Value.Choice + + + EventPlot + + + + Circle + 3 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 1 + 1 + + + + true + None + + + TimedTrial + + + 1000 + Seconds + Value.Trial.Metadata.PRewardLeft + + + + ContinuousPlot + + + + + + 1 + 0 + 0 + 1 + 2 + + + + + + true + None + + + + 1000 + Seconds + Value.Trial.Metadata.PRewardRight + + + + ContinuousPlot + + + + + + 0 + 0 + 1 + 1 + 2 + + + + + + true + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Bias @@ -1238,7 +1815,19 @@ true - + + + + + + + + + + + + + Break 200 @@ -1395,7 +1984,7 @@ 53 215 - 0.33700001239776611 + 0.5 @@ -1811,7 +2400,7 @@ 53 215 - 0.26100000739097595 + 0.5 @@ -2153,6 +2742,15 @@ PreSessionVisualizer + + LeftOpenState + + + RightOpenState + + + BothOpenState + @@ -2185,10 +2783,25 @@ true - - KeepLeftOpen - true - Keep Left Open + + BothOpenState + + + + + + + + + KeepLeftOpen + true + KeepLeftOpen + Open Left + Close Left + true + + + LeftOpenState @@ -2197,10 +2810,21 @@ UiKeepLeftOpen - - KeepRightOpen - true - Keep Right Open + + + + + + + KeepRightOpen + true + KeepRightOpen + Open Right + Close Right + true + + + RightOpenState @@ -2209,10 +2833,32 @@ UiKeepRightOpen - - KeepBothOpen - true - Keep Both Open + + LeftOpenState + + + RightOpenState + + + + + + + + + + + + + KeepBothOpen + true + KeepBothOpen + Open Both + Close Both + true + + + BothOpenState @@ -2567,144 +3213,158 @@ - - - - - - - + - - - + + + + + + - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + - + + - + + - - - - - + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 186fe0d5ecebc79bf09ad0e61e0642f488bb2e1f Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Mon, 20 Jul 2026 15:44:48 +0100 Subject: [PATCH 055/116] Add operation control for holding valves open --- src/Extensions/OperationControl.bonsai | 328 ++- src/Extensions/PreSessionVisualizer.bonsai | 404 ++-- src/main.bonsai | 2231 ++++++++++++++++++-- src/test_behavior_visualizer.bonsai | 278 ++- 4 files changed, 2613 insertions(+), 628 deletions(-) diff --git a/src/Extensions/OperationControl.bonsai b/src/Extensions/OperationControl.bonsai index 7931b7d4..f5602844 100644 --- a/src/Extensions/OperationControl.bonsai +++ b/src/Extensions/OperationControl.bonsai @@ -7,14 +7,15 @@ xmlns:beh="clr-namespace:Harp.Behavior;assembly=Harp.Behavior" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns:sys="clr-namespace:System;assembly=mscorlib" - xmlns:p2="clr-namespace:Harp.StepperDriver;assembly=Harp.StepperDriver" - xmlns:p3="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" - xmlns:p4="clr-namespace:;assembly=Extensions" - xmlns:p5="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" - xmlns:p6="clr-namespace:Harp.SoundCard;assembly=Harp.SoundCard" - xmlns:p7="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" + xmlns:p2="clr-namespace:System.Reactive;assembly=System.Reactive.Core" + xmlns:p3="clr-namespace:Harp.StepperDriver;assembly=Harp.StepperDriver" + xmlns:p4="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" + xmlns:p5="clr-namespace:;assembly=Extensions" + xmlns:p6="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" + xmlns:p7="clr-namespace:Harp.SoundCard;assembly=Harp.SoundCard" + xmlns:p8="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp" - xmlns:p8="clr-namespace:Bonsai.Numerics.Distributions;assembly=Bonsai.Numerics" + xmlns:p9="clr-namespace:Bonsai.Numerics.Distributions;assembly=Bonsai.Numerics" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -343,10 +344,20 @@ GiveRewardRight + + SetRewardAmount + + + + + SetRewardAmount + + Source1 + TaskLogicParameters @@ -427,28 +438,28 @@ - - - - - - - - - + + + + + + + + - - - - - - - - - + + + + + + + + + + @@ -605,29 +616,208 @@ HarpBehaviorCommands + + SetRightOpen + + + SetOpen + + + + Source1 + + + + + + + + + + Write + + None + + + + Write + + SupplyPort1 + + + + + + + SetClosed + + + + Source1 + + + + + + + + + + + + Write + + SupplyPort1 + + + + Write + + SupplyPort1 + + + + + + + + + + HarpBehaviorCommands + + + + SetRewardAmount + + + SetLeftOpen + + + SetOpen + + + + Source1 + + + + + + + + + + Write + + None + + + + Write + + SupplyPort0 + + + + + + + SetClosed + + + + Source1 + + + + + + + + + + + + Write + + SupplyPort0 + + + + Write + + SupplyPort0 + + + + + + + + + + HarpBehaviorCommands + + + + SetRewardAmount + - - - - + + + + - + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -642,9 +832,9 @@ it ? 2 : 4 - + Write - + StepperDriverCommands @@ -673,8 +863,8 @@ InitialManipulatorPosition - - InitialManipulatorPosition + + InitialManipulatorPosition @@ -700,8 +890,8 @@ - - 5 + + 5 @@ -819,11 +1009,11 @@ - - 0 - 0 - 0 - 0 + + 0 + 0 + 0 + 0 @@ -833,8 +1023,8 @@ ManipulatorBiasTracker - - ManipulatorBiasTracker + + ManipulatorBiasTracker @@ -1190,10 +1380,10 @@ - + Write - - 4 + + 4 @@ -1261,7 +1451,7 @@ WaveformType - + Sine @@ -1369,11 +1559,11 @@ - - - 4 - 13000 - SampleRate96000Hz + + + 4 + 13000 + SampleRate96000Hz @@ -1416,7 +1606,7 @@ WaveformType - + WhiteNoise @@ -1447,9 +1637,9 @@ waveformSpec - - -2147483646 - 2147483646 + + -2147483646 + 2147483646 @@ -1479,8 +1669,8 @@ - - 9600 + + 9600 @@ -1525,11 +1715,11 @@ - - - 4 - 13000 - SampleRate96000Hz + + + 4 + 13000 + SampleRate96000Hz diff --git a/src/Extensions/PreSessionVisualizer.bonsai b/src/Extensions/PreSessionVisualizer.bonsai index 80e02700..909baf70 100644 --- a/src/Extensions/PreSessionVisualizer.bonsai +++ b/src/Extensions/PreSessionVisualizer.bonsai @@ -2,7 +2,9 @@ @@ -30,6 +32,15 @@ PreSessionVisualizer + + LeftOpenState + + + RightOpenState + + + BothOpenState + @@ -62,36 +73,81 @@ true - - KeepLeftOpen - true - Keep Left Open + + BothOpenState + + + + + + + + + KeepLeftOpen + true + KeepLeftOpen + Open Left + Close Left + true + + + LeftOpenState - UiKeepLeftOpen - - KeepRightOpen - true - Keep Right Open + + + + + + + KeepRightOpen + true + KeepRightOpen + Open Right + Close Right + true + + + RightOpenState - UiKeepRightOpen - - KeepBothOpen - true - Keep Both Open + + LeftOpenState + + + RightOpenState + + + + + + + + + + + + + KeepBothOpen + true + KeepBothOpen + Open Both + Close Both + true + + + BothOpenState - @@ -359,29 +415,11 @@ true - x: + x1: true - - - - - ManipulatorPosition - - - X - - - {0:F2}mm - it - - - - - - true 0.00mm @@ -399,18 +437,6 @@ true - - Y1 - - - {0:F2}mm - it - - - - - - true 0.00mm @@ -428,18 +454,6 @@ true - - Y2 - - - {0:F2}mm - it - - - - - - true 0.00mm @@ -457,18 +471,6 @@ true - - Z - - - {0:F2}mm - it - - - - - - true 0.00mm @@ -489,178 +491,164 @@ true None - 0.25 + 0 0 0 - - - - - OffsetGain - - - - - - - - + - - - + + + + + + - - - - - + + + + + + - - - - - - + + + + - + - + - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - + + + - - - - - + + + + + - - - + + + + + - - - - + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - + - - - - + + + + + + + + + + + + + - - + + - - - - - - - - - - + + + + + + + + + - - - - - - - + + + + diff --git a/src/main.bonsai b/src/main.bonsai index a1860a30..01aff360 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -7,15 +7,22 @@ xmlns:p2="clr-namespace:;assembly=Extensions" xmlns:p3="clr-namespace:System.Reactive;assembly=System.Reactive.Core" xmlns:p4="clr-namespace:AllenNeuralDynamics.AindBehaviorServices.DataTypes;assembly=AllenNeuralDynamics.AindBehaviorServices" + xmlns:p5="clr-namespace:AllenNeuralDynamics.LicketySplit;assembly=AllenNeuralDynamics.LicketySplit" + xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" + xmlns:beh="clr-namespace:Harp.Behavior;assembly=Harp.Behavior" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" - xmlns:p5="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" - xmlns:gui="clr-namespace:Bonsai.Gui;assembly=Bonsai.Gui" xmlns:sys="clr-namespace:System;assembly=mscorlib" - xmlns:p6="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" + xmlns:p6="clr-namespace:Harp.StepperDriver;assembly=Harp.StepperDriver" + xmlns:p7="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" + xmlns:p8="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" + xmlns:p9="clr-namespace:Harp.SoundCard;assembly=Harp.SoundCard" + xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp" + xmlns:p10="clr-namespace:Bonsai.Numerics.Distributions;assembly=Bonsai.Numerics" + xmlns:gui="clr-namespace:Bonsai.Gui;assembly=Bonsai.Gui" + xmlns:p11="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" xmlns:ui="clr-namespace:Bonsai.Design;assembly=Bonsai.Design" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" - xmlns:p7="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -194,155 +201,1961 @@ - EndExperiment - - - - 1 - - - - - false - - - - - - - ExperimentState - - - - -5 - - - - - 5 - - - - - - - - 1 - - - - BiasOffsetBounds - - - - - - - - - - - - - - - - - - - - - - - - - - - - - StartupLogic - - - - StartExperimentShortcut - - - - IsWaveformUploadDone - - - - - - - - Source1 - - - - - - - - - - - - - PT10S - - - - - - - 1 - - - - - - - - - - - 1 - - - - - StartLogging + EndExperiment + + + + 1 + + + + + false + + + + + + + ExperimentState + + + + -5 + + + + + 5 + + + + + + + + 1 + + + + BiasOffsetBounds + + + + + + + + + + + + + + + + + + + + + + + + + + + + + StartupLogic + + + + StartExperimentShortcut + + + + IsWaveformUploadDone + + + + + + + + Source1 + + + + + + + + + + + + + PT10S + + + + + + + 1 + + + + + + + + + + + 1 + + + + + StartLogging + + + + PT2S + + + + StartExperiment + + + + + + + + + + + + + + + + + + + + + + + OperationControl + + + + Lickometers + + + + LicketySplitLeft + + + + HarpLickometerLeftEvents + + + + + + Value + + + + Channel0 + + + + + + + + + + Source1 + + + + + + + + + + + Seconds + + + + + + + + + + + + + + + + + + + + + + RigSchema + + + HarpLickometerLeft + + + + + + + BehaviorBoardDIPort0 + + + + HarpBehaviorEvents + + + + + + Value + + + + DIPort0 + + + + + + + + + + Source1 + + + + + + + + + + + Seconds + + + + + + + + + + + + + + + + + + + + + + RigSchema + + + HarpLickometerLeft + + + isnull + it == null + + + + + + + + + LicketySplitRight + + + + HarpLickometerRightEvents + + + + + + Value + + + + Channel0 + + + + + + + + + + Source1 + + + + + + + + + + Seconds + + + + + + + + + + + + + + + + + + + + + RigSchema + + + HarpLickometerRight + + + + + + + BehaviorBoardDIPort1 + + + + HarpBehaviorEvents + + + + + + Value + + + + DIPort1 + + + + + + + + + + Source1 + + + + + + + + + + Seconds + + + + + + + + + + + + + + + + + + + + + RigSchema + + + HarpLickometerRight + + + isnull + it == null + + + + + + + + + + + + + + + IsRightLickEvent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RewardDelivery + + + + GiveRewardRight + + + SetRewardAmount + + + + + + + SetRewardAmount + + + + Source1 + + + TaskLogicParameters + + + RewardSize.LeftValueVolume + + + RigSchema + + + Calibration.WaterValveLeft + + + + + + RewardToTime + ((Item1 * 0.001) - Item2.Offset) / Item2.Slope + + + ToMilliseconds + + + + + 1000 + + + + + false + + + + + + + SetIsRightValveMs + + + TaskLogicParameters + + + RewardSize.RightValueVolume + + + RigSchema + + + Calibration.WaterValveRight + + + + + + RewardToTime + ((Item1 * 0.001) - Item2.Offset) / Item2.Slope + + + ToMilliseconds + + + + + 1000 + + + + + true + + + + + + + SetIsRightValveMs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + HarpBehaviorEvents + + + + + + GiveRewardRight + + + + + + Source1 + + + + + + + + + + Write + + SupplyPort1 + + + + + + + + Source1 + + + + + + + + + + Write + + SupplyPort0 + + + + + + + HarpBehaviorCommands + + + SetIsRightValveMs + + + + + + Source1 + + + Item1 + + + + + + + + + + + Item2 + + + gt0 + + + + Source1 + + + + 0 + + + + + + + + + + + + Write + + + + + + + Source1 + + + Item1 + + + + + + + + + + + + + Item2 + + + gt0 + + + + Source1 + + + + 0 + + + + + + + + + + + + Write + + + + + + + HarpBehaviorCommands + + + SetRightOpen + + + SetOpen + + + + Source1 + + + + + + + + + + Write + + None + + + + Write + + SupplyPort1 + + + + + + + SetClosed + + + + Source1 + + + + + + + + + + + + Write + + SupplyPort1 + + + + Write + + SupplyPort1 + + + + + + + + + + HarpBehaviorCommands + + + + SetRewardAmount + + + SetLeftOpen + + + SetOpen + + + + Source1 + + + + + + + + + + Write + + None + + + + Write + + SupplyPort0 + + + + + + + SetClosed + + + + Source1 + + + + + + + + + + + + Write + + SupplyPort0 + + + + Write + + SupplyPort0 + + + + + + + + + + HarpBehaviorCommands + + + + SetRewardAmount + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ManipulatorTask + + + + IsRightTriggerQuickRetract + + + + it ? 2 : 4 + + + Write + + + + StepperDriverCommands + + + SpoutAvailableState + + + StartExperiment + + + ManipulatorPosition + + + + + + + 1 + + + + Item2 + + + InitialManipulatorPosition + + + + InitialManipulatorPosition + + + + SoftwareEvent + + + SpoutAvailableState + + + CalculatePositions + + + + InitialManipulatorPosition + + + ManipulatorPosition + + + + + + + + + + 5 + + + + + 1 + + + + + + + + + + + + + + + + + + + DetermineDirection + it.Item1 ? it.Item2.Extended : it.Item2.Retracted + + + MoveTo + + + ManualSpoutDelta + + + ManualSpoutDelta + + + AutomaticSpoutDelta + + + + + + Drop0s + + + + Source1 + + + + 0 + + + + + + + + + + + + + 0 + + + + + + + Source1 + + + Accumulation,Value + + + + BiasOffsetBounds + + + + + + Clamp + Math.Min(Math.Max(Item1, Item2.Item1), Item2.Item2) + + + + + + + + + + + + + + + ManipulatorBiasTracker + + + InitialManipulatorPosition + + + X + + + + + + + + + + + + + 0 + 0 + 0 + 0 + + + + SingleAxisMoveTo + + + ManipulatorBiasTracker + + + + ManipulatorBiasTracker + + + + SoftwareEvent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + StartExperiment + + + + + + ManipulatorInitialization + + + + + 0 + + + + + PT0.5S + + + + + This is a publish subject! + + + + HomeMotors + + + WaitForHomed + + + + IsHomed + + + + PT0.2S + + + + + + + Source1 + + + + + + + + + + + + + + PT10S + + + + + 1 + + + + + + + + + + + + + + + + GoToInit + + + + Source1 + + + + GoToInitialPosition + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + CameraControl + + + + HarpBehaviorEvents + + + TriggeredCamerasReady + + + + + + Source1 + + + + + + + + + + + + + + 1 + + + + + PT0.5S + + + + + true + + + + CameraState + + + CameraState + + + + + + Source1 + + + + + + + + + + Write + + CameraOutput1 + + + + + + + + Source1 + + + + + + + + + + Write + + CameraOutput1 + + + + + + + HarpBehaviorCommands + + + StartLogging + + + + 1 + + + + + false + + + + CameraState + + + StartExperiment + + + + 1 + + + + + true + + + + CameraState + + + EndExperiment + + + + 1 + + + + + false + + + + CameraState + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SoundBoard + + + + PlayGoCue + + + PlayGoCue + + + RigSchema + + + HarpSoundCard.Calibration + + + GoCue + + + Index + + + + + + + + Write + + 4 + + + + HarpSoundCardCommands + + + + RigSchema + + + + + HarpSoundCard.Calibration + + + + + GoCue + + + + + RigSchema + + + + + HarpSoundCard.Calibration + + + + + CsPlus + + + + + RigSchema + + + + + HarpSoundCard.Calibration + + + + + CsMinus + + + + + + + + + + IsSine + + + + Source1 + + + WaveformType + + + + Sine + + + + + + + + + + + + + + + UploadTone + + + + Source1 + + + + 1 + + + + waveformSpec + + + waveformSpec + + + Frequency.Value + + + + + + + + + 96000 + + + + waveformSpec + + + Duration + + + + + + + + + 0 + + + + + + + + + + 9600 + 13000 + Sine + 96000 + S32 + 2147483647 + 0 + 0 + + + + + 1 + + + + waveformSpec + + + Index + + + + + + + + waveformSpec + + + Frequency.Value + + + + + + + + + + + 4 + 13000 + SampleRate96000Hz + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IsWhiteNoise + + + + Source1 + + + WaveformType + + + + WhiteNoise + + + + + + + + + + + + + + + UploadWhiteNoise + + + + Source1 + + + + 1 + + + + waveformSpec + + + + -2147483646 + 2147483646 + + + + + 96000 + + + + waveformSpec + + + Duration + + + + + + + + + 0 + + + + + + + + + + 9600 + + + + + + 0 + 0 + + S32 + 1 + + + + + 1 + + + + waveformSpec + + + Index + + + + + + + + waveformSpec + + + Index + + + whitenoise_{0} + it + + + + + + + + + + 4 + 13000 + SampleRate96000Hz + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + IsWaveformUploadDone + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + HarpBehaviorEvents - - PT2S - - - - StartExperiment + - - - - - - - - - - + + + + - - - - - - isNull @@ -450,8 +2263,8 @@ - - LickRight + + LickRight @@ -477,8 +2290,8 @@ - - LickLeft + + LickLeft @@ -498,8 +2311,8 @@ - - WaterRight + + WaterRight @@ -520,8 +2333,8 @@ - - WaterLeft + + WaterLeft @@ -1197,7 +3010,7 @@ - + @@ -1560,8 +3373,8 @@ - - LickRight + + LickRight @@ -1587,8 +3400,8 @@ - - LickLeft + + LickLeft @@ -1608,8 +3421,8 @@ - - WaterRight + + WaterRight @@ -1630,8 +3443,8 @@ - - WaterLeft + + WaterLeft @@ -1641,13 +3454,13 @@ HarpTimestampSource - + - + EthogramEvents @@ -1707,11 +3520,11 @@ Source1 - - -1 - 0 - 0 - 0 + + -1 + 0 + 0 + 0 @@ -1747,11 +3560,11 @@ Source1 - - 1 - 0 - 0 - 0 + + 1 + 0 + 0 + 0 @@ -1787,11 +3600,11 @@ Source1 - - 0 - 1 - 0 - 0 + + 0 + 1 + 0 + 0 @@ -1827,11 +3640,11 @@ Source1 - - 0 - 0 - 1 - 0 + + 0 + 0 + 1 + 0 @@ -1867,11 +3680,11 @@ Source1 - - 0 - -1 - 0 - 0 + + 0 + -1 + 0 + 0 @@ -1907,11 +3720,11 @@ Source1 - - 0 - 0 - -1 - 0 + + 0 + 0 + -1 + 0 @@ -1947,11 +3760,11 @@ Source1 - - 0 - 0 - 0 - 1 + + 0 + 0 + 0 + 1 @@ -1987,11 +3800,11 @@ Source1 - - 0 - 0 - 0 - -1 + + 0 + 0 + 0 + -1 @@ -2328,15 +4141,15 @@ - + + UiKeepBothOpen + + UiKeepLeftOpen - + UiKeepRightOpen - - UiKeepBothOpen - UiDrainLeft diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 6bc898f9..df26d6e0 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -1734,15 +1734,6 @@ UiMoveRight - - UiKeepLeftOpen - - - UiKeepRightOpen - - - UiKeepBothOpen - UiDrainLeft @@ -1797,6 +1788,15 @@ UiCueGiveLeft + + UiKeepLeftOpen + + + UiKeepRightOpen + + + UiKeepBothOpen + @@ -2803,7 +2803,6 @@ LeftOpenState - @@ -2826,7 +2825,6 @@ RightOpenState - @@ -2860,7 +2858,6 @@ BothOpenState - @@ -3216,155 +3213,152 @@ - + - + - - + + - + - - - - - - - - - - - - + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + - - - + + + - - - + + + - - - + + + - - - - - + + + From 8c4319c7241ac22acb60ad24756a9c4c57c3a460 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Mon, 20 Jul 2026 15:49:42 +0100 Subject: [PATCH 056/116] Add output control for set open This should allow UI to directly open and close left/right/both valves but requires testing on hardware --- src/main.bonsai | 2441 +++++++---------------------------------------- 1 file changed, 322 insertions(+), 2119 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index 01aff360..a3960c60 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -7,22 +7,15 @@ xmlns:p2="clr-namespace:;assembly=Extensions" xmlns:p3="clr-namespace:System.Reactive;assembly=System.Reactive.Core" xmlns:p4="clr-namespace:AllenNeuralDynamics.AindBehaviorServices.DataTypes;assembly=AllenNeuralDynamics.AindBehaviorServices" - xmlns:p5="clr-namespace:AllenNeuralDynamics.LicketySplit;assembly=AllenNeuralDynamics.LicketySplit" - xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" - xmlns:beh="clr-namespace:Harp.Behavior;assembly=Harp.Behavior" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" - xmlns:sys="clr-namespace:System;assembly=mscorlib" - xmlns:p6="clr-namespace:Harp.StepperDriver;assembly=Harp.StepperDriver" - xmlns:p7="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" - xmlns:p8="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" - xmlns:p9="clr-namespace:Harp.SoundCard;assembly=Harp.SoundCard" - xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp" - xmlns:p10="clr-namespace:Bonsai.Numerics.Distributions;assembly=Bonsai.Numerics" + xmlns:p5="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" xmlns:gui="clr-namespace:Bonsai.Gui;assembly=Bonsai.Gui" - xmlns:p11="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" + xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:p6="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" xmlns:ui="clr-namespace:Bonsai.Design;assembly=Bonsai.Design" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" + xmlns:p7="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -103,2059 +96,253 @@ - - - Init - - - - - ../.venv - ./Extensions\bonsai.py - - - - - false - - - - - 1 - - - - IsWaveformUploadDone - - - - - - - - - 1 - - - - GlobalAutoWaterState - - - StartExperiment - - - - TriggerHarpReadDump - - - StartLogging - - - StartExperiment - - - EndExperiment - - - SoftwareEvent - - - GlobalTrialOutcome - - - GlobalTrial - - - GlobalTrialMetrics - - - TaskLogicParameters - - - RngSeed - - - RngSeedValue - - - - false - - - - - 1 - - - - StartExperiment - - - - 1 - - - - - true - - - - EndExperiment - - - - 1 - - - - - false - - - - - - - ExperimentState - - - - -5 - - - - - 5 - - - - - - - - 1 - - - - BiasOffsetBounds - - - - - - - - - - - - - - - - - - - - - - - - - - - - - StartupLogic - - - - StartExperimentShortcut - - - - IsWaveformUploadDone - - - - - - - - Source1 - - - - - - - - - - - - - PT10S - - - - - - - 1 - - - - - - - - - - - 1 - - - - - StartLogging - - - - PT2S - - - - StartExperiment - - - - - - - - - - - - - - - - - - - - - - - OperationControl - - - - Lickometers - - - - LicketySplitLeft - - - - HarpLickometerLeftEvents - - - - - - Value - - - - Channel0 - - - - - - - - - - Source1 - - - - - - - - - - - Seconds - - - - - - - - - - - - - - - - - - - - - - RigSchema - - - HarpLickometerLeft - - - - - - - BehaviorBoardDIPort0 - - - - HarpBehaviorEvents - - - - - - Value - - - - DIPort0 - - - - - - - - - - Source1 - - - - - - - - - - - Seconds - - - - - - - - - - - - - - - - - - - - - - RigSchema - - - HarpLickometerLeft - - - isnull - it == null - - - - - - - - - LicketySplitRight - - - - HarpLickometerRightEvents - - - - - - Value - - - - Channel0 - - - - - - - - - - Source1 - - - - - - - - - - Seconds - - - - - - - - - - - - - - - - - - - - - RigSchema - - - HarpLickometerRight - - - - - - - BehaviorBoardDIPort1 - - - - HarpBehaviorEvents - - - - - - Value - - - - DIPort1 - - - - - - - - - - Source1 - - - - - - - - - - Seconds - - - - - - - - - - - - - - - - - - - - - RigSchema - - - HarpLickometerRight - - - isnull - it == null - - - - - - - - - - - - - - - IsRightLickEvent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RewardDelivery - - - - GiveRewardRight - - - SetRewardAmount - - - - - - - SetRewardAmount - - - - Source1 - - - TaskLogicParameters - - - RewardSize.LeftValueVolume - - - RigSchema - - - Calibration.WaterValveLeft - - - - - - RewardToTime - ((Item1 * 0.001) - Item2.Offset) / Item2.Slope - - - ToMilliseconds - - - - - 1000 - - - - - false - - - - - - - SetIsRightValveMs - - - TaskLogicParameters - - - RewardSize.RightValueVolume - - - RigSchema - - - Calibration.WaterValveRight - - - - - - RewardToTime - ((Item1 * 0.001) - Item2.Offset) / Item2.Slope - - - ToMilliseconds - - - - - 1000 - - - - - true - - - - - - - SetIsRightValveMs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HarpBehaviorEvents - - - - - - GiveRewardRight - - - - - - Source1 - - - - - - - - - - Write - - SupplyPort1 - - - - - - - - Source1 - - - - - - - - - - Write - - SupplyPort0 - - - - - - - HarpBehaviorCommands - - - SetIsRightValveMs - - - - - - Source1 - - - Item1 - - - - - - - - - - - Item2 - - - gt0 - - - - Source1 - - - - 0 - - - - - - - - - - - - Write - - - - - - - Source1 - - - Item1 - - - - - - - - - - - - - Item2 - - - gt0 - - - - Source1 - - - - 0 - - - - - - - - - - - - Write - - - - - - - HarpBehaviorCommands - - - SetRightOpen - - - SetOpen - - - - Source1 - - - - - - - - - - Write - - None - - - - Write - - SupplyPort1 - - - - - - - SetClosed - - - - Source1 - - - - - - - - - - - - Write - - SupplyPort1 - - - - Write - - SupplyPort1 - - - - - - - - - - HarpBehaviorCommands - - - - SetRewardAmount - - - SetLeftOpen - - - SetOpen - - - - Source1 - - - - - - - - - - Write - - None - - - - Write - - SupplyPort0 - - - - - - - SetClosed - - - - Source1 - - - - - - - - - - - - Write - - SupplyPort0 - - - - Write - - SupplyPort0 - - - - - - - - - - HarpBehaviorCommands - - - - SetRewardAmount - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ManipulatorTask - - - - IsRightTriggerQuickRetract - - - - it ? 2 : 4 - - - Write - - - - StepperDriverCommands - - - SpoutAvailableState - - - StartExperiment - - - ManipulatorPosition - - - - - - - 1 - - - - Item2 - - - InitialManipulatorPosition - - - - InitialManipulatorPosition - - - - SoftwareEvent - - - SpoutAvailableState - - - CalculatePositions - - - - InitialManipulatorPosition - - - ManipulatorPosition - - - - - - - - - - 5 - - - - - 1 - - - - - - - - - - - - - - - - - - - DetermineDirection - it.Item1 ? it.Item2.Extended : it.Item2.Retracted - - - MoveTo - - - ManualSpoutDelta - - - ManualSpoutDelta - - - AutomaticSpoutDelta - - - - - - Drop0s - - - - Source1 - - - - 0 - - - - - - - - - - - - - 0 - - - - - - - Source1 - - - Accumulation,Value - - - - BiasOffsetBounds - - - - - - Clamp - Math.Min(Math.Max(Item1, Item2.Item1), Item2.Item2) - - - - - - - - - - - - - - - ManipulatorBiasTracker - - - InitialManipulatorPosition - - - X - - - - - - - - - - - - - 0 - 0 - 0 - 0 - - - - SingleAxisMoveTo - - - ManipulatorBiasTracker - - - - ManipulatorBiasTracker - - - - SoftwareEvent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - StartExperiment - - - - - - ManipulatorInitialization - - - - - 0 - - - - - PT0.5S - - - - - This is a publish subject! - - - - HomeMotors - - - WaitForHomed - - - - IsHomed - - - - PT0.2S - - - - - - - Source1 - - - - - - - - - - - - - - PT10S - - - - - 1 - - - - - - - - - - - - - - - - GoToInit - - - - Source1 - - - - GoToInitialPosition - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - CameraControl - - - - HarpBehaviorEvents - - - TriggeredCamerasReady - - - - - - Source1 - - - - - - - - - - - - - - 1 - - - - - PT0.5S - - - - - true - - - - CameraState - - - CameraState - - - - - - Source1 - - - - - - - - - - Write - - CameraOutput1 - - - - - - - - Source1 - - - - - - - - - - Write - - CameraOutput1 - - - - - - - HarpBehaviorCommands - - - StartLogging - - - - 1 - - - - - false - - - - CameraState - - - StartExperiment - - - - 1 - - - - - true - - - - CameraState - - - EndExperiment - - - - 1 - - - - - false - - - - CameraState - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SoundBoard - - - - PlayGoCue - - - PlayGoCue - - - RigSchema - - - HarpSoundCard.Calibration - - - GoCue - - - Index - - - - - - - - Write - - 4 - - - - HarpSoundCardCommands - - - - RigSchema - - - - - HarpSoundCard.Calibration - - - - - GoCue - - - - - RigSchema - - - - - HarpSoundCard.Calibration - - - - - CsPlus - - - - - RigSchema - - - - - HarpSoundCard.Calibration - - - - - CsMinus - - - - - - - - - - IsSine - - - - Source1 - - - WaveformType - - - - Sine - - - - - - - - - - - - - - - UploadTone - - - - Source1 - - - - 1 - - - - waveformSpec - - - waveformSpec - - - Frequency.Value - - - - - - - - - 96000 - - - - waveformSpec - - - Duration - - - - - - - - - 0 - - - - - - - - - - 9600 - 13000 - Sine - 96000 - S32 - 2147483647 - 0 - 0 - - - - - 1 - - - - waveformSpec - - - Index - - - - - - - - waveformSpec - - - Frequency.Value - - - - - - - - - - - 4 - 13000 - SampleRate96000Hz - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IsWhiteNoise - - - - Source1 - - - WaveformType - - - - WhiteNoise - - - - - - - - - - - - - - - UploadWhiteNoise - - - - Source1 - - - - 1 - - - - waveformSpec - - - - -2147483646 - 2147483646 - - - - - 96000 - - - - waveformSpec - - - Duration - - - - - - - - - 0 - - - - - - - - - - 9600 - - - - - - 0 - 0 - - S32 - 1 - - - - - 1 - - - - waveformSpec - - - Index - - - - - - - - waveformSpec - - - Index - - - whitenoise_{0} - it - - - - - - - - - - 4 - 13000 - SampleRate96000Hz - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - IsWaveformUploadDone - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + Init + + + + + ../.venv + ./Extensions\bonsai.py + + + + + false + + + + + 1 + + + + IsWaveformUploadDone + + + + + + + + + 1 + + + + GlobalAutoWaterState + + + StartExperiment + + + + TriggerHarpReadDump + + + StartLogging + + + StartExperiment + + + EndExperiment + + + SoftwareEvent + + + GlobalTrialOutcome + + + GlobalTrial + + + GlobalTrialMetrics - HarpBehaviorEvents + TaskLogicParameters + + + RngSeed + + + RngSeedValue + + + + false + + + + + 1 + + + + StartExperiment + + + + 1 + + + + + true + + + + EndExperiment + + + + 1 + + + + + false + + + + + + + ExperimentState + + + + -5 + + + + + 5 + + + + + + + + 1 + + + + BiasOffsetBounds + + + + + + + + + + + + + + + + + + + + + + + + + + + + + StartupLogic + + + + StartExperimentShortcut + + + + IsWaveformUploadDone + + + + + + + + Source1 + + + + + + + + + + + + + PT10S + + + + + + + 1 + + + + + + + + + + + 1 + + + + + StartLogging - + + PT2S + + + + StartExperiment - - - - + + + + + + + + + + + + + + + + isNull @@ -2263,8 +450,8 @@ - - LickRight + + LickRight @@ -2290,8 +477,8 @@ - - LickLeft + + LickLeft @@ -2311,8 +498,8 @@ - - WaterRight + + WaterRight @@ -2333,8 +520,8 @@ - - WaterLeft + + WaterLeft @@ -3010,7 +1197,7 @@ - + @@ -3373,8 +1560,8 @@ - - LickRight + + LickRight @@ -3400,8 +1587,8 @@ - - LickLeft + + LickLeft @@ -3421,8 +1608,8 @@ - - WaterRight + + WaterRight @@ -3443,8 +1630,8 @@ - - WaterLeft + + WaterLeft @@ -3454,13 +1641,13 @@ HarpTimestampSource - + - + EthogramEvents @@ -3520,11 +1707,11 @@ Source1 - - -1 - 0 - 0 - 0 + + -1 + 0 + 0 + 0 @@ -3560,11 +1747,11 @@ Source1 - - 1 - 0 - 0 - 0 + + 1 + 0 + 0 + 0 @@ -3600,11 +1787,11 @@ Source1 - - 0 - 1 - 0 - 0 + + 0 + 1 + 0 + 0 @@ -3640,11 +1827,11 @@ Source1 - - 0 - 0 - 1 - 0 + + 0 + 0 + 1 + 0 @@ -3680,11 +1867,11 @@ Source1 - - 0 - -1 - 0 - 0 + + 0 + -1 + 0 + 0 @@ -3720,11 +1907,11 @@ Source1 - - 0 - 0 - -1 - 0 + + 0 + 0 + -1 + 0 @@ -3760,11 +1947,11 @@ Source1 - - 0 - 0 - 0 - 1 + + 0 + 0 + 0 + 1 @@ -3800,11 +1987,11 @@ Source1 - - 0 - 0 - 0 - -1 + + 0 + 0 + 0 + -1 @@ -4144,12 +2331,24 @@ UiKeepBothOpen + + SetRightOpen + UiKeepLeftOpen + + SetLeftOpen + UiKeepRightOpen + + SetRightOpen + + + SetLeftOpen + UiDrainLeft @@ -4532,20 +2731,24 @@ - + + - + - + - + - + - + + + + From f1d6fdfa06f65768fc63e80ed4c3268e4ae391e7 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 21 Jul 2026 17:02:26 +0100 Subject: [PATCH 057/116] Update presession visualizer with manipulator position feedback --- src/Extensions/IntraSessionVisualizer.bonsai | 97 +- src/Extensions/PreSessionVisualizer.bonsai | 115 ++- src/test_behavior_visualizer.bonsai | 953 +------------------ 3 files changed, 156 insertions(+), 1009 deletions(-) diff --git a/src/Extensions/IntraSessionVisualizer.bonsai b/src/Extensions/IntraSessionVisualizer.bonsai index cd8233db..695505c9 100644 --- a/src/Extensions/IntraSessionVisualizer.bonsai +++ b/src/Extensions/IntraSessionVisualizer.bonsai @@ -3,7 +3,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" - xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns:p1="clr-namespace:;assembly=Extensions" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -105,22 +104,10 @@ true - - GlobalAutoWaterState - - - it == null - - - - - - - - GiveLeftCue - true - Give Left Cue - false + + GiveLeftCue + true + Give Left Cue @@ -132,22 +119,10 @@ true - - GlobalAutoWaterState - - - it == null - - - - - - - - GiveRightCue - true - Give Right Cue - false + + GiveRightCue + true + Give Right Cue @@ -227,10 +202,10 @@ - - + + - + @@ -240,47 +215,41 @@ - + - + - - + + - + - - - - - - - - + + + + + + + + + - - - - + + + + - - - + + - - + - - - - - - + diff --git a/src/Extensions/PreSessionVisualizer.bonsai b/src/Extensions/PreSessionVisualizer.bonsai index 909baf70..236c8940 100644 --- a/src/Extensions/PreSessionVisualizer.bonsai +++ b/src/Extensions/PreSessionVisualizer.bonsai @@ -415,11 +415,29 @@ true - x1: + x: true + + + + + ManipulatorPosition + + + X + + + {0:N2} + it + + + + + + true 0.00mm @@ -437,6 +455,18 @@ true + + Y1 + + + {0:N2} + it + + + + + + true 0.00mm @@ -454,6 +484,18 @@ true + + Y2 + + + {0:N2} + it + + + + + + true 0.00mm @@ -471,6 +513,18 @@ true + + Z + + + {0:N2} + it + + + + + + true 0.00mm @@ -495,6 +549,9 @@ 0 0 + + OffsetGain + @@ -621,34 +678,52 @@ - - - - + - + + + + - - - + + + + + + + - - + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index df26d6e0..1eba92af 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -1815,19 +1815,7 @@ true - - - - - - - - - - - - - + Break 200 @@ -2714,919 +2702,34 @@ EndExperiment UiHabituationTimeUpdate - - PreSessionVisualizer - - - - - - - - - - - - - - - - - - - - - - - - PreSessionVisualizer - - - - LeftOpenState - - - RightOpenState - - - BothOpenState - - - - - - PreSession - - - true - 2 - Borders - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - BothOpenState - - - - - - - - - KeepLeftOpen - true - KeepLeftOpen - Open Left - Close Left - true - - - LeftOpenState - - - - - - UiKeepLeftOpen - - - - - - - - KeepRightOpen - true - KeepRightOpen - Open Right - Close Right - true - - - RightOpenState - - - - - - UiKeepRightOpen - - - LeftOpenState - - - RightOpenState - - - - - - - - - - - - - KeepBothOpen - true - KeepBothOpen - Open Both - Close Both - true - - - BothOpenState - - - - - - UiKeepBothOpen - - - - - - true - - - DrainLeft - true - Drain 5ml Left - - - - - - - UiDrainLeft - - - Drain Right - true - Drain 5ml Right - - - - - - - UiDrainRight - - - Drain Both - true - Drain 5ml Both - - - - - - - UiDrainBoth - - - - - - - - - true - - - true - 2 - Borders - - 0 - 0 - - 0 - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - MoveLeft - true - Move Left - - - - - - - UiManipulatorLeft - - - ForwardLeft - true - Forward Left - - - - - - - UiManipulatorForwardLeft - - - ForwardRight - true - Forward Right - - - - - - - UiManipulatorForwardRight - - - Up - true - Up - - - - - - - UiManipulatorUp - - - - - - true - - - MoveRight - true - Move Right - - - - - - - UiManipulatorRight - - - BackLeft - true - Back Left - - - - - - - UiManipulatorBackLeft - - - BackRight - true - Back Right - - - - - - - UiManipulatorBackRight - - - Down - true - Down - - - - - - - UiManipulatorDown - - - - - - - - - true - - - STOP - true - STOP - - - - - - - UiManipulatorStop - - - Home - true - Home - - - - - - - UiManipulatorHome - - - Initialize - true - Initialize - - - - - - - UiManipulatorInitialize - - - - - - - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - x1: - - - true - - - true - 0.00mm - - - - - - true - - - true - y1: - - - true - - - true - 0.00mm - - - - - - true - - - true - y2: - - - true - - - true - 0.00mm - - - - - - true - - - true - z: - - - true - - - true - 0.00mm - - - - - - true - - - true - step: - - - true - - - true - None - 0 - 0 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + PreSession + UiKeepLeftOpen + UiKeepRightOpen + UiKeepBothOpen + UiDrainLeft + UiDrainRight + UiDrainBoth + UiManipulatorLeft + UiManipulatorForwardLeft + UiManipulatorForwardRight + UiManipulatorUp + UiManipulatorRight + UiManipulatorBackLeft + UiManipulatorBackRight + UiManipulatorDown + UiManipulatorStop + UiManipulatorHome + UiManipulatorInitialize + - - IntraSessionVisualizer - - - - - - - - - - - InterSessionVisualizer - - - - - - - IntraSession - - - true - 3 - Borders - - 0 - 0 - - 0 - - - true - - - true - None - - - true - Manual - None - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - GiveLeft - true - Give Left - - - - - - - UiGiveLeft - - - true - - - GiveRight - true - Give Right - - - - - - - UiGiveRight - - - true - Go Cue - None - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - GiveLeftCue - true - Give Left Cue - - - - - - - UiCueGiveLeft - - - true - - - GiveRightCue - true - Give Right Cue - - - - - - - UiCueGiveRight - - - - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - MoveLeft - true - Move Left - - - - - - - UiMoveLeft - - - true - - - MoveRight - true - Move Right - - - - - - - UiMoveRight - - - - - - - - - true - - - SessionInfo - true - Session Info - - - true - - - Notes - true - Notes - 16384 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + IntraSession + UiGiveLeft + UiGiveRight + UiMoveLeft + UiMoveRight From 4e8489df47a45b52cb94b0e8136d1c8cfe9dff57 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Tue, 28 Jul 2026 12:27:08 +0100 Subject: [PATCH 058/116] Disable intra-session controls before experiment start --- src/Extensions/IntraSessionVisualizer.bonsai | 213 +++++++--- src/test_behavior_visualizer.bonsai | 395 ++++++++++++++++++- 2 files changed, 533 insertions(+), 75 deletions(-) diff --git a/src/Extensions/IntraSessionVisualizer.bonsai b/src/Extensions/IntraSessionVisualizer.bonsai index 695505c9..70382824 100644 --- a/src/Extensions/IntraSessionVisualizer.bonsai +++ b/src/Extensions/IntraSessionVisualizer.bonsai @@ -18,6 +18,28 @@ InterSessionVisualizer + + + + + StartExperiment + + + + true + + + + + false + + + + + + + ExperimentStarted + @@ -59,10 +81,19 @@ true - - GiveLeft - true - Give Left + + ExperimentStarted + + + + + + + + GiveLeft + true + Give Left + false @@ -74,10 +105,19 @@ true - - GiveRight - true - Give Right + + ExperimentStarted + + + + + + + + GiveRight + true + Give Right + false @@ -104,10 +144,19 @@ true - - GiveLeftCue - true - Give Left Cue + + ExperimentStarted + + + + + + + + GiveLeftCue + true + Give Left Cue + false @@ -119,10 +168,19 @@ true - - GiveRightCue - true - Give Right Cue + + ExperimentStarted + + + + + + + + GiveRightCue + true + Give Right Cue + false @@ -147,10 +205,19 @@ true - - MoveLeft - true - Move Left + + ExperimentStarted + + + + + + + + MoveLeft + true + Move Left + false @@ -162,10 +229,19 @@ true - - MoveRight - true - Move Right + + ExperimentStarted + + + + + + + + MoveRight + true + Move Right + false @@ -201,55 +277,72 @@ - - - - - + + - - - - - - + + + + + + + - - + + + - - - - - - - + + + + + + - - - - - - - + + + + + + + + - - + - - + + - - - + + + - - + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 1eba92af..3f116ccc 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -67,7 +67,7 @@ - PT0.839S + PT0.89S @@ -119,7 +119,7 @@ - PT2.05S + PT1.824S @@ -190,7 +190,7 @@ - PT1.374S + PT0.06S @@ -504,7 +504,7 @@ - false + true @@ -670,8 +670,8 @@ - false - true + true + false @@ -697,7 +697,7 @@ - PT0.904S + PT0.12S @@ -1779,6 +1779,9 @@ StartExperimentShortcut + + StartExperiment + EndExperiment @@ -1798,7 +1801,9 @@ UiKeepBothOpen - + + + @@ -1815,7 +1820,23 @@ true - + + + + + + + + + + + + + + + + + Break 200 @@ -2724,12 +2745,356 @@ UiManipulatorInitialize - - IntraSession - UiGiveLeft - UiGiveRight - UiMoveLeft - UiMoveRight + + IntraSessionVisualizer + + + + + + + + + + + InterSessionVisualizer + + + + + + + StartExperiment + + + + true + + + + + false + + + + + + + ExperimentStarted + + + + + + IntraSession + + + true + 3 + Borders + + 0 + 0 + + 0 + + + true + + + true + None + + + true + Manual + None + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + ExperimentStarted + + + + + + + + GiveLeft + true + Give Left + false + + + + + + + UiGiveLeft + + + true + + + ExperimentStarted + + + + + + + + GiveRight + true + Give Right + false + + + + + + + UiGiveRight + + + true + Go Cue + None + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + ExperimentStarted + + + + + + + + GiveLeftCue + true + Give Left Cue + false + + + + + + + UiCueGiveLeft + + + true + + + ExperimentStarted + + + + + + + + GiveRightCue + true + Give Right Cue + false + + + + + + + UiCueGiveRight + + + + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + ExperimentStarted + + + + + + + + MoveLeft + true + Move Left + false + + + + + + + UiMoveLeft + + + true + + + ExperimentStarted + + + + + + + + MoveRight + true + Move Right + false + + + + + + + UiMoveRight + + + + + + + + + true + + + SessionInfo + true + Session Info + + + true + + + Notes + true + Notes + 16384 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From e845fc3fee70293433adc67a00ee811c65d491a5 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 29 Jul 2026 10:28:26 +0100 Subject: [PATCH 059/116] Initial session information visualizer --- src/Extensions/SessionInfoVisualizer.cs | 61 +++++++ src/test_behavior_visualizer.bonsai | 228 ++++++++++++++++++------ 2 files changed, 234 insertions(+), 55 deletions(-) create mode 100644 src/Extensions/SessionInfoVisualizer.cs diff --git a/src/Extensions/SessionInfoVisualizer.cs b/src/Extensions/SessionInfoVisualizer.cs new file mode 100644 index 00000000..ca9a3905 --- /dev/null +++ b/src/Extensions/SessionInfoVisualizer.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Numerics; +using System.Reactive; +using System.Reactive.Linq; +using System.Xml.Serialization; +using Bonsai; +using Hexa.NET.ImGui; + +[Combinator] +public class SessionInfoVisualizer +{ + public bool Visible {get; set;} + [XmlIgnore] + public Dictionary SessionInfo {get; set;} + + public IObservable Process(IObservable source) + { + return Observable.Create(observer => + { + var sourceObserver = Observer.Create( + value => + { + if (Visible) + { + var tableFlags = ImGuiTableFlags.Borders | ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingStretchSame; + + ImGui.Text("Session Info"); + if (ImGui.BeginTable("Session Info", 2, tableFlags)) + { + ImGui.TableSetupColumn("Field"); + ImGui.TableSetupColumn("Value"); + + var r = 0; + foreach (var field in SessionInfo) + { + ImGui.TableNextRow(); + + ImGui.TableSetColumnIndex(0); + ImGui.Text(field.Key); + + ImGui.TableSetColumnIndex(1); + ImGui.Text(field.Value); + + r++; + } + + ImGui.EndTable(); + } + observer.OnNext(value); + } + }, + observer.OnError, + observer.OnCompleted); + return source.SubscribeSafe(sourceObserver); + }); + } +} + diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 3f116ccc..59cb1316 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -67,7 +67,7 @@ - PT0.89S + PT1.094S @@ -119,7 +119,7 @@ - PT1.824S + PT2.369S @@ -190,7 +190,7 @@ - PT0.06S + PT1.656S @@ -343,6 +343,98 @@ SessionInfo + + + TimeElapsed + + + + + PT0S + PT1S + + + + + 1 + + + + + Convert.ToString(it) + + + + + + + CurrentTrial + + + + TimedTrial + + + + + + Index + + + Convert.ToString(it) + + + + + + + + + + + + Source1 + + + Item1 + + + Item2 + + + + + + + 2 + + + + Item1 + Item2 + + + + 1 + + + + + + + + + + + + + + + + + + SessionMetadata + TimedTrial @@ -697,7 +789,7 @@ - PT0.12S + PT0.342S @@ -771,85 +863,99 @@ - - - + + - - - + + + - - - - + + + + + - - + + + + - - + + + - + - + - - - - - + - - + - + - - + + - + - - - - + + - + + - - - + + - + - - + + - - - + + + + + - - - + + + + + + + + + + + + + + + + + + + @@ -1836,6 +1942,8 @@ + + Break 200 @@ -3001,10 +3109,18 @@ true - - SessionInfo - true - Session Info + + SessionMetadata + + + + + + + + + true + true @@ -3026,7 +3142,7 @@ - + @@ -3083,8 +3199,10 @@ - - + + + + From fd5ac523d8c659612d71be6dd7f8114ef3f61aef Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 29 Jul 2026 10:41:39 +0100 Subject: [PATCH 060/116] Update intra session visualizer as IncludeWorkflow --- src/Extensions/IntraSessionVisualizer.bonsai | 24 ++++++++++++++------ src/test_behavior_visualizer.bonsai | 24 ++++++-------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Extensions/IntraSessionVisualizer.bonsai b/src/Extensions/IntraSessionVisualizer.bonsai index 70382824..5197ca59 100644 --- a/src/Extensions/IntraSessionVisualizer.bonsai +++ b/src/Extensions/IntraSessionVisualizer.bonsai @@ -259,10 +259,18 @@ true - - SessionInfo - true - Session Info + + SessionMetadata + + + + + + + + + true + true @@ -284,7 +292,7 @@ - + @@ -341,8 +349,10 @@ - - + + + + diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 59cb1316..331bc612 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -67,7 +67,7 @@ - PT1.094S + PT2.303S @@ -119,7 +119,7 @@ - PT2.369S + PT1.304S @@ -190,7 +190,7 @@ - PT1.656S + PT0.969S @@ -789,7 +789,7 @@ - PT0.342S + PT0.793S @@ -1934,16 +1934,6 @@ - - - - - - - - - - Break 200 @@ -2101,7 +2091,7 @@ 53 215 - 0.5 + 0.34099999070167542 @@ -2468,7 +2458,7 @@ - Camera1 + Camera2 @@ -2517,7 +2507,7 @@ 53 215 - 0.5 + 0.5130000114440918 From f025941640cb1dca3f21f53c56b882c50607942d Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 29 Jul 2026 10:51:17 +0100 Subject: [PATCH 061/116] Add additional null filtering to bias visualizer --- src/Extensions/BiasVisualizer.bonsai | 34 +- src/test_behavior_visualizer.bonsai | 687 ++++++++++++--------------- 2 files changed, 334 insertions(+), 387 deletions(-) diff --git a/src/Extensions/BiasVisualizer.bonsai b/src/Extensions/BiasVisualizer.bonsai index 3517e930..faa66f10 100644 --- a/src/Extensions/BiasVisualizer.bonsai +++ b/src/Extensions/BiasVisualizer.bonsai @@ -133,6 +133,7 @@ Seconds + @@ -146,9 +147,9 @@ true - 0.86 - 38.60000000000089 - 0.861054598987593 + 1.00 + 32.0100000000022 + 1 0 -10 @@ -165,7 +166,7 @@ new (it as LeftBias) - + @@ -200,7 +201,7 @@ new (it as RightBias) - + @@ -238,8 +239,8 @@ - - + + @@ -249,29 +250,30 @@ - - + + - + - - - - - + + + + + - + + diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 331bc612..ceb4a88c 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -67,7 +67,7 @@ - PT2.303S + PT0.028S @@ -119,7 +119,7 @@ - PT1.304S + PT1.587S @@ -190,7 +190,7 @@ - PT0.969S + PT1.989S @@ -596,7 +596,7 @@ - true + false @@ -762,7 +762,7 @@ - true + false false @@ -789,7 +789,7 @@ - PT0.793S + PT0.658S @@ -1817,9 +1817,284 @@ - - Bias - TimedBias + + BiasVisualizer + + + + + + + + BiasVisualizer + + + + + + + Bias + + + BiasPlot + true + + -1 + 150 + + NoTitle + AutoFit + None + + + BiasPlot + + + + BiasPlot + + + + + -1 + 1 + + + R + L + + West + None + 1.1 + -1.1 + + + + + + + TimedBias + + + 1000 + Seconds + Value.Bias + + + BiasPlot + + + + 0 + 0 + 0 + 1 + 2 + + + + true + None + + + 1 + Seconds + Value.Bias + + + BiasPlot + + + + Circle + 5 + 0 + 1 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + + true + None + + + + Value.Bias + + + + BiasPlot + + + {0:N2} + it + + + + + + + + Seconds + + + + + + + + + + + + + + + true + 1.00 + 32.0100000000022 + 1 + + 0 + -10 + + None + + + + + 1 + + + + new (it as LeftBias) + + + + + + + + + 1000 + Seconds + Value.LeftBias + + + BiasPlot + + + + 1 + 0 + 0 + 0.7 + 1 + + + + true + None + + + + -1 + + + + new (it as RightBias) + + + + + + + + + 1000 + Seconds + Value.RightBias + + + BiasPlot + + + + 0 + 0 + 1 + 0.7 + 1 + + + + true + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OutputControl @@ -1934,6 +2209,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + Break 200 @@ -2091,7 +2390,7 @@ 53 215 - 0.34099999070167542 + 0.5 @@ -2507,7 +2806,7 @@ 53 215 - 0.5130000114440918 + 0.5 @@ -2843,366 +3142,12 @@ UiManipulatorInitialize - - IntraSessionVisualizer - - - - - - - - - - - InterSessionVisualizer - - - - - - - StartExperiment - - - - true - - - - - false - - - - - - - ExperimentStarted - - - - - - IntraSession - - - true - 3 - Borders - - 0 - 0 - - 0 - - - true - - - true - None - - - true - Manual - None - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - ExperimentStarted - - - - - - - - GiveLeft - true - Give Left - false - - - - - - - UiGiveLeft - - - true - - - ExperimentStarted - - - - - - - - GiveRight - true - Give Right - false - - - - - - - UiGiveRight - - - true - Go Cue - None - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - ExperimentStarted - - - - - - - - GiveLeftCue - true - Give Left Cue - false - - - - - - - UiCueGiveLeft - - - true - - - ExperimentStarted - - - - - - - - GiveRightCue - true - Give Right Cue - false - - - - - - - UiCueGiveRight - - - - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - ExperimentStarted - - - - - - - - MoveLeft - true - Move Left - false - - - - - - - UiMoveLeft - - - true - - - ExperimentStarted - - - - - - - - MoveRight - true - Move Right - false - - - - - - - UiMoveRight - - - - - - - - - true - - - SessionMetadata - - - - - - - - - true - - - - true - - - Notes - true - Notes - 16384 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + IntraSession + UiGiveLeft + UiGiveRight + UiMoveLeft + UiMoveRight From a7af360679383e0ce22fcd813be9eaae21621760 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 29 Jul 2026 13:13:14 +0100 Subject: [PATCH 062/116] Expose remaining subjects for intra session visualizer --- src/Extensions/IntraSessionVisualizer.bonsai | 16 +- src/test_behavior_visualizer.bonsai | 2175 ++++++++++++------ 2 files changed, 1503 insertions(+), 688 deletions(-) diff --git a/src/Extensions/IntraSessionVisualizer.bonsai b/src/Extensions/IntraSessionVisualizer.bonsai index 5197ca59..1dd4a1d9 100644 --- a/src/Extensions/IntraSessionVisualizer.bonsai +++ b/src/Extensions/IntraSessionVisualizer.bonsai @@ -13,6 +13,10 @@ + + + + InterSessionVisualizer @@ -259,6 +263,9 @@ true + + + SessionMetadata @@ -292,7 +299,7 @@ - + @@ -349,10 +356,11 @@ - + - - + + + diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index ceb4a88c..fcf43116 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -3,23 +3,24 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wie="clr-namespace:Bonsai.Windows.Input;assembly=Bonsai.Windows.Input" xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" - xmlns:p1="clr-namespace:Bonsai.Numerics.Distributions;assembly=Bonsai.Numerics" - xmlns:p2="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" - xmlns:p3="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" - xmlns:p4="clr-namespace:AllenNeuralDynamics.AindBehaviorServices.DataTypes;assembly=AllenNeuralDynamics.AindBehaviorServices" + xmlns:p1="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" + xmlns:p2="clr-namespace:Bonsai.Numerics.Distributions;assembly=Bonsai.Numerics" + xmlns:p3="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" + xmlns:p4="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" + xmlns:p5="clr-namespace:AllenNeuralDynamics.AindBehaviorServices.DataTypes;assembly=AllenNeuralDynamics.AindBehaviorServices" xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" - xmlns:p5="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" + xmlns:p6="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns:num="clr-namespace:Bonsai.Numerics;assembly=Bonsai.Numerics" xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp" - xmlns:p6="clr-namespace:;assembly=Extensions" + xmlns:p7="clr-namespace:;assembly=Extensions" xmlns:cv="clr-namespace:Bonsai.Vision;assembly=Bonsai.Vision" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" xmlns:implot="clr-namespace:Bonsai.ImPlot;assembly=Bonsai.ImPlot" xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns:sys="clr-namespace:System;assembly=mscorlib" - xmlns:p7="clr-namespace:System.Reactive;assembly=System.Reactive.Core" + xmlns:p8="clr-namespace:System.Reactive;assembly=System.Reactive.Core" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -40,6 +41,25 @@ LickLeft + + + 0 + 0 + 0 + 0 + + + + ManipulatorPosition + + + + 0 + + + + OffsetGain + PT1S @@ -49,16 +69,16 @@ - - 0 - 3 + + 0 + 3 - + - + @@ -67,7 +87,7 @@ - PT0.028S + PT1.609S @@ -76,8 +96,8 @@ - - ResponsePeriod + + ResponsePeriod @@ -101,16 +121,16 @@ - - 0 - 3 + + 0 + 3 - + - + @@ -119,7 +139,7 @@ - PT1.587S + PT1.732S @@ -128,8 +148,8 @@ - - RewardPeriod + + RewardPeriod @@ -155,14 +175,14 @@ - - - false + + + false - - TrialOutcome + + TrialOutcome @@ -172,16 +192,16 @@ - - 0 - 3 + + 0 + 3 - + - + @@ -190,7 +210,7 @@ - PT1.989S + PT2.251S @@ -199,8 +219,8 @@ - - ITI + + ITI @@ -226,8 +246,8 @@ - - Break + + Break @@ -236,7 +256,7 @@ - + SoftwareEvent @@ -249,13 +269,13 @@ - + - + SoftwareEventHistory @@ -284,15 +304,15 @@ - - 0.13.5 - 0.13.5 - Task6 - 0001-01-01T00:00:00.0000000+00:00 - Stage1 - Plimbo - false - false + + 0.13.5 + 0.13.5 + Task6 + 0001-01-01T00:00:00.0000000+00:00 + Stage1 + Plimbo + false + false @@ -323,15 +343,15 @@ - - 0.13.5 - 0.13.5 - Task7 - 0001-01-01T00:00:00.0000000+00:00 - Stage2 - Plimbo - false - false + + 0.13.5 + 0.13.5 + Task7 + 0001-01-01T00:00:00.0000000+00:00 + Stage2 + Plimbo + false + false @@ -448,7 +468,7 @@ Item2 - + @@ -491,9 +511,9 @@ - - 0.1 - 1 + + 0.1 + 1 @@ -505,9 +525,9 @@ - - -0.1 - 0.1 + + -0.1 + 0.1 @@ -529,14 +549,14 @@ TimeBase - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -571,14 +591,14 @@ (it +1) * 0.5 - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -595,19 +615,19 @@ - - false + + true - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -616,8 +636,8 @@ - - + + @@ -648,14 +668,14 @@ (it +1) * 0.5 - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -679,14 +699,14 @@ - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -700,24 +720,24 @@ - - true + + false - - + + - - 0 - 1 + + 0 + 1 - - 500 + + 500 @@ -743,16 +763,16 @@ - - 0.59164587077011477 - 0.40913708100521279 - 5 - 0 - 5 - 0.5 - 5 - - 0 + + 0.59164587077011477 + 0.40913708100521279 + 5 + 0 + 5 + 0.5 + 5 + + 0 @@ -761,9 +781,9 @@ - - false - false + + true + false @@ -777,7 +797,7 @@ Random - + TimeSpan.FromSeconds(it) @@ -789,7 +809,7 @@ - PT0.658S + PT0.555S @@ -831,9 +851,7 @@ - - @@ -841,121 +859,125 @@ - - + + + - - - + + + - - + - + - + - - + + + - - - - + + + - - - - + + + + - - - + + + - - - + + + - - + + - + + - + - + - - + - - + + - + - + - - + - + - + + - + - - - - - - - + + + + + - - + + + + - - + - - - + + + + - - - - + + + + - - + + + + + + @@ -1310,19 +1332,19 @@ EventPlot - - - 0 - 1 - - - R - L - - West - None - - + + + 0 + 1 + + + R + L + + West + None + + @@ -1330,16 +1352,16 @@ ContinuousPlot - - - 0 - 1 - - - West - None - - + + + 0 + 1 + + + West + None + + @@ -1374,18 +1396,18 @@ EventPlot - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 @@ -1424,18 +1446,18 @@ EventPlot - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 @@ -1449,7 +1471,7 @@ TimedTrial - + Value.ChoiceCategory @@ -1462,7 +1484,7 @@ Source1 - + NoChoice @@ -1487,7 +1509,7 @@ Source1 - + LeftChoice @@ -1512,7 +1534,7 @@ Source1 - + RightChoice @@ -1555,18 +1577,18 @@ EventPlot - - Circle - 3 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - 1 - 1 + + Circle + 3 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 @@ -1584,7 +1606,7 @@ Source1 - + LeftRewarded @@ -1609,7 +1631,7 @@ Source1 - + RightRewarded @@ -1649,18 +1671,18 @@ EventPlot - - Circle - 3 - 0 - 1 - 0 - 1 - 0 - 1 - 0 - 1 - 1 + + Circle + 3 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 1 + 1 @@ -1682,12 +1704,12 @@ - - 1 - 0 - 0 - 1 - 2 + + 1 + 0 + 0 + 1 + 2 @@ -1709,12 +1731,12 @@ - - 0 - 0 - 1 - 1 - 2 + + 0 + 0 + 1 + 1 + 2 @@ -1817,284 +1839,9 @@ - - BiasVisualizer - - - - - - - - BiasVisualizer - - - - - - - Bias - - - BiasPlot - true - - -1 - 150 - - NoTitle - AutoFit - None - - - BiasPlot - - - - BiasPlot - - - - - -1 - 1 - - - R - L - - West - None - 1.1 - -1.1 - - - - - - - TimedBias - - - 1000 - Seconds - Value.Bias - - - BiasPlot - - - - 0 - 0 - 0 - 1 - 2 - - - - true - None - - - 1 - Seconds - Value.Bias - - - BiasPlot - - - - Circle - 5 - 0 - 1 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - - true - None - - - - Value.Bias - - - - BiasPlot - - - {0:N2} - it - - - - - - - - Seconds - - - - - - - - - - - - - - - true - 1.00 - 32.0100000000022 - 1 - - 0 - -10 - - None - - - - - 1 - - - - new (it as LeftBias) - - - - - - - - - 1000 - Seconds - Value.LeftBias - - - BiasPlot - - - - 1 - 0 - 0 - 0.7 - 1 - - - - true - None - - - - -1 - - - - new (it as RightBias) - - - - - - - - - 1000 - Seconds - Value.RightBias - - - BiasPlot - - - - 0 - 0 - 1 - 0.7 - 1 - - - - true - None - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Bias + TimedBias OutputControl @@ -2103,73 +1850,73 @@ UiHabituationTimeUpdate - + UiMoveLeft - + UiGiveRight - + UiGiveLeft - + UiMoveRight - + UiDrainLeft - + UiDrainRight - + UiDrainBoth - + UiManipulatorLeft - + UiManipulatorForwardLeft - + UiManipulatorForwardRight - + UiManipulatorUp - + UiManipulatorRight - + UiManipulatorBackRight - + UiManipulatorBackLeft - + UiManipulatorDown - + UiManipulatorStop - + UiManipulatorHome - + UiManipulatorInitialize - + StartExperimentShortcut StartExperiment - + EndExperiment - + UiCueGiveRight - + UiCueGiveLeft @@ -2199,83 +1946,72 @@ - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Break - 200 - - - TrialOutcome - CornflowerBlue - 0.3 - - - RewardPeriod - Crimson - 0.3 - - - ITI - Cyan - 0.3 - - - - - TrialOutcome - SaddleBrown - 0.5 - 2 - Circle - - - LickLeft - Red - 0.8 - 2 - Down - - - LickRight - DodgerBlue - 0.2 - 2 - Up - - + + true + + + + + + + + + + + + + + + + + + + + + + + Break + 200 + + + TrialOutcome + CornflowerBlue + 0.3 + + + RewardPeriod + Crimson + 0.3 + + + ITI + Cyan + 0.3 + + + + + TrialOutcome + SaddleBrown + 0.5 + 2 + Circle + + + LickLeft + Red + 0.8 + 2 + Down + + + LickRight + DodgerBlue + 0.2 + 2 + Up + + @@ -2387,10 +2123,10 @@ - - 53 - 215 - 0.5 + + 53 + 215 + 0.5 @@ -2803,10 +2539,10 @@ - - 53 - 215 - 0.5 + + 53 + 215 + 0.5 @@ -3120,34 +2856,1105 @@ EndExperiment UiHabituationTimeUpdate - - - PreSession - UiKeepLeftOpen - UiKeepRightOpen - UiKeepBothOpen - UiDrainLeft - UiDrainRight - UiDrainBoth - UiManipulatorLeft - UiManipulatorForwardLeft - UiManipulatorForwardRight - UiManipulatorUp - UiManipulatorRight - UiManipulatorBackLeft - UiManipulatorBackRight - UiManipulatorDown - UiManipulatorStop - UiManipulatorHome - UiManipulatorInitialize - - - - IntraSession - UiGiveLeft - UiGiveRight - UiMoveLeft - UiMoveRight + + PreSessionVisualizer + + + + + + + + + + + + + + + + + + + + + + + + PreSessionVisualizer + + + + LeftOpenState + + + RightOpenState + + + BothOpenState + + + + + + PreSession + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + BothOpenState + + + + + + + + + KeepLeftOpen + true + KeepLeftOpen + Open Left + Close Left + true + + + LeftOpenState + + + + + + UiKeepLeftOpen + + + + + + + + KeepRightOpen + true + KeepRightOpen + Open Right + Close Right + true + + + RightOpenState + + + + + + UiKeepRightOpen + + + LeftOpenState + + + RightOpenState + + + + + + + + + + + + + KeepBothOpen + true + KeepBothOpen + Open Both + Close Both + true + + + BothOpenState + + + + + + UiKeepBothOpen + + + + + + true + + + DrainLeft + true + Drain 5ml Left + + + + + + + UiDrainLeft + + + Drain Right + true + Drain 5ml Right + + + + + + + UiDrainRight + + + Drain Both + true + Drain 5ml Both + + + + + + + UiDrainBoth + + + + + + + + + true + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + MoveLeft + true + Move Left + + + + + + + UiManipulatorLeft + + + ForwardLeft + true + Forward Left + + + + + + + UiManipulatorForwardLeft + + + ForwardRight + true + Forward Right + + + + + + + UiManipulatorForwardRight + + + Up + true + Up + + + + + + + UiManipulatorUp + + + + + + true + + + MoveRight + true + Move Right + + + + + + + UiManipulatorRight + + + BackLeft + true + Back Left + + + + + + + UiManipulatorBackLeft + + + BackRight + true + Back Right + + + + + + + UiManipulatorBackRight + + + Down + true + Down + + + + + + + UiManipulatorDown + + + + + + + + + true + + + STOP + true + STOP + + + + + + + UiManipulatorStop + + + Home + true + Home + + + + + + + UiManipulatorHome + + + Initialize + true + Initialize + + + + + + + UiManipulatorInitialize + + + + + + + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + x: + + + true + + + + + + ManipulatorPosition + + + X + + + {0:N2} + it + + + + + + + + true + 0.00 + + + + + + true + + + true + y1: + + + true + + + Y1 + + + {0:N2} + it + + + + + + + + true + 0.00 + + + + + + true + + + true + y2: + + + true + + + Y2 + + + {0:N2} + it + + + + + + + + true + 0.00 + + + + + + true + + + true + z: + + + true + + + Z + + + {0:N2} + it + + + + + + + + true + 0.00 + + + + + + true + + + true + step: + + + true + + + true + None + 0 + 0 + 0 + + + OffsetGain + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IntraSessionVisualizer + + + + + + + + + + + + + + + InterSessionVisualizer + + + + + + + StartExperiment + + + + true + + + + + false + + + + + + + ExperimentStarted + + + + + + IntraSession + + + true + 3 + Borders + + 0 + 0 + + 0 + + + true + + + true + None + + + true + Manual + None + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + ExperimentStarted + + + + + + + + GiveLeft + true + Give Left + false + + + + + + + UiGiveLeft + + + true + + + ExperimentStarted + + + + + + + + GiveRight + true + Give Right + false + + + + + + + UiGiveRight + + + true + Go Cue + None + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + ExperimentStarted + + + + + + + + GiveLeftCue + true + Give Left Cue + false + + + + + + + UiCueGiveLeft + + + true + + + ExperimentStarted + + + + + + + + GiveRightCue + true + Give Right Cue + false + + + + + + + UiCueGiveRight + + + + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + ExperimentStarted + + + + + + + + MoveLeft + true + Move Left + false + + + + + + + UiMoveLeft + + + true + + + ExperimentStarted + + + + + + + + MoveRight + true + Move Right + false + + + + + + + UiMoveRight + + + + + + + + + true + + + + + + SessionMetadata + + + + + + + + + true + + + + true + + + Notes + true + Notes + 16384 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a0714d7cbff6a242dfa99256c13d9540cb090d96 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 29 Jul 2026 13:18:24 +0100 Subject: [PATCH 063/116] Add placeholder for session information --- src/main.bonsai | 88 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 6 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index a3960c60..6fbd1d02 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -2908,6 +2908,77 @@ Bias TimedBias + + PLACEHOLDER + + + + SessionInfo + + + + TimedTrial + + + Value.Trial.Metadata.Extra + + + + + + + + + + + + AsDictionary + + + + Source1 + + + + 1 + + + + Item1 + Item2 + + + + 1 + + + + + + + + + + + + + + SessionMetadata + + + + + + + + + + + + + + + Ethogram @@ -3047,17 +3118,22 @@ UiGiveRight UiMoveLeft UiMoveRight + SessionMetadata + StartExperiment + UiCueGiveLeft + UiCueGiveRight - - - - - - + + + + + + + From b936dabe699d9def999addf8ff1188defd8cd07c Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 29 Jul 2026 13:25:54 +0100 Subject: [PATCH 064/116] Fix flip for keep right/keep both open --- src/main.bonsai | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index 6fbd1d02..fb8599c4 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -2334,6 +2334,9 @@ SetRightOpen + + SetLeftOpen + UiKeepLeftOpen @@ -2346,9 +2349,6 @@ SetRightOpen - - SetLeftOpen - UiDrainLeft @@ -2732,8 +2732,8 @@ - - + + From 367a05c70d488967534bede5d4453d61de2c3c5b Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 29 Jul 2026 13:46:36 +0100 Subject: [PATCH 065/116] Refactor drain logic to be toggleable --- src/Extensions/PreSessionVisualizer.bonsai | 18 +- src/main.bonsai | 67 +- src/test_behavior_visualizer.bonsai | 1127 +------------------- 3 files changed, 67 insertions(+), 1145 deletions(-) diff --git a/src/Extensions/PreSessionVisualizer.bonsai b/src/Extensions/PreSessionVisualizer.bonsai index 236c8940..6eb16b3b 100644 --- a/src/Extensions/PreSessionVisualizer.bonsai +++ b/src/Extensions/PreSessionVisualizer.bonsai @@ -165,7 +165,11 @@ true Drain 5ml Left - + + + true + + @@ -177,7 +181,11 @@ true Drain 5ml Right - + + + true + + @@ -189,7 +197,11 @@ true Drain 5ml Both - + + + true + + diff --git a/src/main.bonsai b/src/main.bonsai index fb8599c4..7866f3ab 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -2349,39 +2349,6 @@ SetRightOpen - - UiDrainLeft - - - - true - - - - IsFlushingValveLeft - - - UiDrainRight - - - - true - - - - IsFlushingValveLeft - - - UiDrainBoth - - - - true - - - - IsFlushingValveLeft - true @@ -2402,6 +2369,18 @@ IsFlushingValveLeft + + IsFlushingValveRight + + + UiDrainLeft + + + UiDrainBoth + + + + Flush @@ -2560,8 +2539,11 @@ - - IsFlushingValveRight + + UiDrainRight + + + Flush @@ -2736,19 +2718,16 @@ - + - - - - + + + - + + - - - diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index fcf43116..85b7c907 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -2856,1105 +2856,36 @@ EndExperiment UiHabituationTimeUpdate - - PreSessionVisualizer - - - - - - - - - - - - - - - - - - - - - - - - PreSessionVisualizer - - - - LeftOpenState - - - RightOpenState - - - BothOpenState - - - - - - PreSession - - - true - 2 - Borders - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - BothOpenState - - - - - - - - - KeepLeftOpen - true - KeepLeftOpen - Open Left - Close Left - true - - - LeftOpenState - - - - - - UiKeepLeftOpen - - - - - - - - KeepRightOpen - true - KeepRightOpen - Open Right - Close Right - true - - - RightOpenState - - - - - - UiKeepRightOpen - - - LeftOpenState - - - RightOpenState - - - - - - - - - - - - - KeepBothOpen - true - KeepBothOpen - Open Both - Close Both - true - - - BothOpenState - - - - - - UiKeepBothOpen - - - - - - true - - - DrainLeft - true - Drain 5ml Left - - - - - - - UiDrainLeft - - - Drain Right - true - Drain 5ml Right - - - - - - - UiDrainRight - - - Drain Both - true - Drain 5ml Both - - - - - - - UiDrainBoth - - - - - - - - - true - - - true - 2 - Borders - - 0 - 0 - - 0 - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - MoveLeft - true - Move Left - - - - - - - UiManipulatorLeft - - - ForwardLeft - true - Forward Left - - - - - - - UiManipulatorForwardLeft - - - ForwardRight - true - Forward Right - - - - - - - UiManipulatorForwardRight - - - Up - true - Up - - - - - - - UiManipulatorUp - - - - - - true - - - MoveRight - true - Move Right - - - - - - - UiManipulatorRight - - - BackLeft - true - Back Left - - - - - - - UiManipulatorBackLeft - - - BackRight - true - Back Right - - - - - - - UiManipulatorBackRight - - - Down - true - Down - - - - - - - UiManipulatorDown - - - - - - - - - true - - - STOP - true - STOP - - - - - - - UiManipulatorStop - - - Home - true - Home - - - - - - - UiManipulatorHome - - - Initialize - true - Initialize - - - - - - - UiManipulatorInitialize - - - - - - - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - x: - - - true - - - - - - ManipulatorPosition - - - X - - - {0:N2} - it - - - - - - - - true - 0.00 - - - - - - true - - - true - y1: - - - true - - - Y1 - - - {0:N2} - it - - - - - - - - true - 0.00 - - - - - - true - - - true - y2: - - - true - - - Y2 - - - {0:N2} - it - - - - - - - - true - 0.00 - - - - - - true - - - true - z: - - - true - - - Z - - - {0:N2} - it - - - - - - - - true - 0.00 - - - - - - true - - - true - step: - - - true - - - true - None - 0 - 0 - 0 - - - OffsetGain - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + PreSession + UiKeepLeftOpen + UiKeepRightOpen + UiKeepBothOpen + UiDrainLeft + UiDrainRight + UiDrainBoth + UiManipulatorLeft + UiManipulatorForwardLeft + UiManipulatorForwardRight + UiManipulatorUp + UiManipulatorRight + UiManipulatorBackLeft + UiManipulatorBackRight + UiManipulatorDown + UiManipulatorStop + UiManipulatorHome + UiManipulatorInitialize - - IntraSessionVisualizer - - - - - - - - - - - - - - - InterSessionVisualizer - - - - - - - StartExperiment - - - - true - - - - - false - - - - - - - ExperimentStarted - - - - - - IntraSession - - - true - 3 - Borders - - 0 - 0 - - 0 - - - true - - - true - None - - - true - Manual - None - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - ExperimentStarted - - - - - - - - GiveLeft - true - Give Left - false - - - - - - - UiGiveLeft - - - true - - - ExperimentStarted - - - - - - - - GiveRight - true - Give Right - false - - - - - - - UiGiveRight - - - true - Go Cue - None - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - ExperimentStarted - - - - - - - - GiveLeftCue - true - Give Left Cue - false - - - - - - - UiCueGiveLeft - - - true - - - ExperimentStarted - - - - - - - - GiveRightCue - true - Give Right Cue - false - - - - - - - UiCueGiveRight - - - - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - ExperimentStarted - - - - - - - - MoveLeft - true - Move Left - false - - - - - - - UiMoveLeft - - - true - - - ExperimentStarted - - - - - - - - MoveRight - true - Move Right - false - - - - - - - UiMoveRight - - - - - - - - - true - - - - - - SessionMetadata - - - - - - - - - true - - - - true - - - Notes - true - Notes - 16384 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + IntraSession + UiGiveLeft + UiGiveRight + UiMoveLeft + UiMoveRight + SessionMetadata + StartExperiment + UiCueGiveLeft + UiCueGiveRight From 5b3762e57d0d97aa898bd2029bd241d7d6a04327 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 29 Jul 2026 14:58:08 +0100 Subject: [PATCH 066/116] Add toggling for drain buttons --- src/test_behavior_visualizer.bonsai | 809 ++++++++++++++++++++++++++-- 1 file changed, 774 insertions(+), 35 deletions(-) diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 85b7c907..8d7e1faa 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -87,7 +87,7 @@ - PT1.609S + PT2.215S @@ -139,7 +139,7 @@ - PT1.732S + PT0.3S @@ -210,7 +210,7 @@ - PT2.251S + PT0.281S @@ -616,7 +616,7 @@ - true + false @@ -771,7 +771,7 @@ 5 0.5 5 - + false 0 @@ -782,7 +782,7 @@ - true + false false @@ -809,7 +809,7 @@ - PT0.555S + PT0.901S @@ -1862,15 +1862,6 @@ UiMoveRight - - UiDrainLeft - - - UiDrainRight - - - UiDrainBoth - UiManipulatorLeft @@ -1883,6 +1874,15 @@ UiManipulatorUp + + UiDrainLeft + + + UiDrainBoth + + + UiDrainRight + UiManipulatorRight @@ -1969,6 +1969,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Break 200 @@ -2856,25 +2881,739 @@ EndExperiment UiHabituationTimeUpdate - - PreSession - UiKeepLeftOpen - UiKeepRightOpen - UiKeepBothOpen - UiDrainLeft - UiDrainRight - UiDrainBoth - UiManipulatorLeft - UiManipulatorForwardLeft - UiManipulatorForwardRight - UiManipulatorUp - UiManipulatorRight - UiManipulatorBackLeft - UiManipulatorBackRight - UiManipulatorDown - UiManipulatorStop - UiManipulatorHome - UiManipulatorInitialize + + PreSessionVisualizer + + + + + + + + + + + + + + + + + + + + + + + + PreSessionVisualizer + + + + LeftOpenState + + + RightOpenState + + + BothOpenState + + + + + + PreSession + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + BothOpenState + + + + + + + + + KeepLeftOpen + true + KeepLeftOpen + Open Left + Close Left + true + + + LeftOpenState + + + + + + UiKeepLeftOpen + + + + + + + + KeepRightOpen + true + KeepRightOpen + Open Right + Close Right + true + + + RightOpenState + + + + + + UiKeepRightOpen + + + LeftOpenState + + + RightOpenState + + + + + + + + + + + + + KeepBothOpen + true + KeepBothOpen + Open Both + Close Both + true + + + BothOpenState + + + + + + UiKeepBothOpen + + + + + + true + + + DrainLeft + true + Drain Left + Drain Left + Cancel Drain Left + true + + + + + + UiDrainLeft + + + DrainRight + true + Drain Right + Drain Right + Cancel Drain Right + true + + + + + + UiDrainRight + + + DrainBoth + true + Drain Both + Drain Both + Cancel Drain Both + true + + + + + + UiDrainBoth + + + + + + + + + true + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + MoveLeft + true + Move Left + + + + + + + UiManipulatorLeft + + + ForwardLeft + true + Forward Left + + + + + + + UiManipulatorForwardLeft + + + ForwardRight + true + Forward Right + + + + + + + UiManipulatorForwardRight + + + Up + true + Up + + + + + + + UiManipulatorUp + + + + + + true + + + MoveRight + true + Move Right + + + + + + + UiManipulatorRight + + + BackLeft + true + Back Left + + + + + + + UiManipulatorBackLeft + + + BackRight + true + Back Right + + + + + + + UiManipulatorBackRight + + + Down + true + Down + + + + + + + UiManipulatorDown + + + + + + + + + true + + + STOP + true + STOP + + + + + + + UiManipulatorStop + + + Home + true + Home + + + + + + + UiManipulatorHome + + + Initialize + true + Initialize + + + + + + + UiManipulatorInitialize + + + + + + + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + x: + + + true + + + + + + ManipulatorPosition + + + X + + + {0:N2} + it + + + + + + + + true + 0.00 + + + + + + true + + + true + y1: + + + true + + + Y1 + + + {0:N2} + it + + + + + + + + true + 0.00 + + + + + + true + + + true + y2: + + + true + + + Y2 + + + {0:N2} + it + + + + + + + + true + 0.00 + + + + + + true + + + true + z: + + + true + + + Z + + + {0:N2} + it + + + + + + + + true + 0.00 + + + + + + true + + + true + step: + + + true + + + true + None + 0 + 0 + 0 + + + OffsetGain + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IntraSession From 7199ac3dcee6a9d020983b49703dd8c4d6f476e5 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 29 Jul 2026 15:00:37 +0100 Subject: [PATCH 067/116] Update pre session visualizer IncludeWorkflow --- src/Extensions/PreSessionVisualizer.bonsai | 299 ++++++++++----------- 1 file changed, 145 insertions(+), 154 deletions(-) diff --git a/src/Extensions/PreSessionVisualizer.bonsai b/src/Extensions/PreSessionVisualizer.bonsai index 6eb16b3b..515132b2 100644 --- a/src/Extensions/PreSessionVisualizer.bonsai +++ b/src/Extensions/PreSessionVisualizer.bonsai @@ -160,15 +160,13 @@ true - - DrainLeft - true - Drain 5ml Left - - - - true - + + DrainLeft + true + Drain Left + Drain Left + Cancel Drain Left + true @@ -176,15 +174,13 @@ UiDrainLeft - - Drain Right - true - Drain 5ml Right - - - - true - + + DrainRight + true + Drain Right + Drain Right + Cancel Drain Right + true @@ -192,15 +188,13 @@ UiDrainRight - - Drain Both - true - Drain 5ml Both - - - - true - + + DrainBoth + true + Drain Both + Drain Both + Cancel Drain Both + true @@ -452,7 +446,7 @@ true - 0.00mm + 0.00 @@ -481,7 +475,7 @@ true - 0.00mm + 0.00 @@ -510,7 +504,7 @@ true - 0.00mm + 0.00 @@ -539,7 +533,7 @@ true - 0.00mm + 0.00 @@ -572,7 +566,7 @@ - + @@ -602,140 +596,137 @@ - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + - - - - - - - - + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - + From 6c9df3bc8b2ad1411c2fc970402ca09b46501761 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 29 Jul 2026 15:53:54 +0100 Subject: [PATCH 068/116] Refactor keep open / drain logic Avoids switching valve set mode at Harp level --- src/Extensions/OperationControl.bonsai | 328 ++++++------------------- src/main.bonsai | 264 +++++++++++++++++--- src/test_behavior_visualizer.bonsai | 48 +--- 3 files changed, 304 insertions(+), 336 deletions(-) diff --git a/src/Extensions/OperationControl.bonsai b/src/Extensions/OperationControl.bonsai index f5602844..7931b7d4 100644 --- a/src/Extensions/OperationControl.bonsai +++ b/src/Extensions/OperationControl.bonsai @@ -7,15 +7,14 @@ xmlns:beh="clr-namespace:Harp.Behavior;assembly=Harp.Behavior" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns:sys="clr-namespace:System;assembly=mscorlib" - xmlns:p2="clr-namespace:System.Reactive;assembly=System.Reactive.Core" - xmlns:p3="clr-namespace:Harp.StepperDriver;assembly=Harp.StepperDriver" - xmlns:p4="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" - xmlns:p5="clr-namespace:;assembly=Extensions" - xmlns:p6="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" - xmlns:p7="clr-namespace:Harp.SoundCard;assembly=Harp.SoundCard" - xmlns:p8="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" + xmlns:p2="clr-namespace:Harp.StepperDriver;assembly=Harp.StepperDriver" + xmlns:p3="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" + xmlns:p4="clr-namespace:;assembly=Extensions" + xmlns:p5="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" + xmlns:p6="clr-namespace:Harp.SoundCard;assembly=Harp.SoundCard" + xmlns:p7="clr-namespace:AindDynamicForagingDataSchema;assembly=Extensions" xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp" - xmlns:p9="clr-namespace:Bonsai.Numerics.Distributions;assembly=Bonsai.Numerics" + xmlns:p8="clr-namespace:Bonsai.Numerics.Distributions;assembly=Bonsai.Numerics" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -344,20 +343,10 @@ GiveRewardRight - - SetRewardAmount - - - - - SetRewardAmount - - Source1 - TaskLogicParameters @@ -438,28 +427,28 @@ - - - - - - - + + + + + + + + + - - - - - - - - - + + + + + + + + + - - @@ -616,208 +605,29 @@ HarpBehaviorCommands - - SetRightOpen - - - SetOpen - - - - Source1 - - - - - - - - - - Write - - None - - - - Write - - SupplyPort1 - - - - - - - SetClosed - - - - Source1 - - - - - - - - - - - - Write - - SupplyPort1 - - - - Write - - SupplyPort1 - - - - - - - - - - HarpBehaviorCommands - - - - SetRewardAmount - - - SetLeftOpen - - - SetOpen - - - - Source1 - - - - - - - - - - Write - - None - - - - Write - - SupplyPort0 - - - - - - - SetClosed - - - - Source1 - - - - - - - - - - - - Write - - SupplyPort0 - - - - Write - - SupplyPort0 - - - - - - - - - - HarpBehaviorCommands - - - - SetRewardAmount - - - - + + + + - - + - - + + + - - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -832,9 +642,9 @@ it ? 2 : 4 - + Write - + StepperDriverCommands @@ -863,8 +673,8 @@ InitialManipulatorPosition - - InitialManipulatorPosition + + InitialManipulatorPosition @@ -890,8 +700,8 @@ - - 5 + + 5 @@ -1009,11 +819,11 @@ - - 0 - 0 - 0 - 0 + + 0 + 0 + 0 + 0 @@ -1023,8 +833,8 @@ ManipulatorBiasTracker - - ManipulatorBiasTracker + + ManipulatorBiasTracker @@ -1380,10 +1190,10 @@ - + Write - - 4 + + 4 @@ -1451,7 +1261,7 @@ WaveformType - + Sine @@ -1559,11 +1369,11 @@ - - - 4 - 13000 - SampleRate96000Hz + + + 4 + 13000 + SampleRate96000Hz @@ -1606,7 +1416,7 @@ WaveformType - + WhiteNoise @@ -1637,9 +1447,9 @@ waveformSpec - - -2147483646 - 2147483646 + + -2147483646 + 2147483646 @@ -1669,8 +1479,8 @@ - - 9600 + + 9600 @@ -1715,11 +1525,11 @@ - - - 4 - 13000 - SampleRate96000Hz + + + 4 + 13000 + SampleRate96000Hz diff --git a/src/main.bonsai b/src/main.bonsai index 7866f3ab..f9cc285a 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -2328,27 +2328,6 @@ - - UiKeepBothOpen - - - SetRightOpen - - - SetLeftOpen - - - UiKeepLeftOpen - - - SetLeftOpen - - - UiKeepRightOpen - - - SetRightOpen - true @@ -2372,6 +2351,227 @@ IsFlushingValveRight + + UiKeepLeftOpen + + + UiKeepBothOpen + + + + + + KeepOpen + + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + false + + + + + 500 + + + + + + + SetIsRightValveMs + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + + PT0.5S + + + + + + + + false + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UiKeepRightOpen + + + + + + KeepOpen + + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + true + + + + + 500 + + + + + + + SetIsRightValveMs + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + + PT0.5S + + + + + + + + false + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + UiDrainLeft @@ -2714,20 +2914,24 @@ - + - - + + + - - - - - + + + + + + + - + + diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 8d7e1faa..cb677294 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -1948,53 +1948,7 @@ true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Break 200 From d2641421a93a2abbc26e90232c3f59aa1d94c9c8 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 30 Jul 2026 14:16:12 +0100 Subject: [PATCH 069/116] Create extension table builder for etho/camera viz Also generally makes it easier to set column styling and resize options --- src/Extensions/TableBuilder.cs | 88 +++++++++++++++++++++++ src/test_behavior_visualizer.bonsai | 58 ++++++++++----- src/test_table_sizing.bonsai | 107 ++++++++++++++++++++++++++++ 3 files changed, 235 insertions(+), 18 deletions(-) create mode 100644 src/Extensions/TableBuilder.cs create mode 100644 src/test_table_sizing.bonsai diff --git a/src/Extensions/TableBuilder.cs b/src/Extensions/TableBuilder.cs new file mode 100644 index 00000000..7f64c115 --- /dev/null +++ b/src/Extensions/TableBuilder.cs @@ -0,0 +1,88 @@ +using Bonsai; +using Bonsai.ImGui; +using Hexa.NET.ImGui; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Numerics; +using System.Reactive; +using System.Reactive.Linq; + +using ImGui = Hexa.NET.ImGui.ImGui; + +/// +/// Represents an operator that begins drawing a table and provides +/// a sequence of notifications for drawing table contents. +/// +[WorkflowElementIcon("Bonsai:ElementIcon.Visualizer")] +[Description("Begins drawing a table and provides a sequence of notifications for drawing table contents.")] +public class TableBuilder : ControlBuilder +{ + // /// + // /// Gets or sets the number of columns in the table. + // /// + // [Description("The number of columns in the table.")] + // public int Columns { get; set; } = 1; + + public List Columns {get; set;} + + /// + /// Gets or sets the table configuration flags. + /// + [Description("The table configuration flags.")] + public ImGuiTableFlags Flags { get; set; } + + /// + /// Gets or sets the explicit outer size of the table. + /// + /// + /// The meaning of this property depends on the table configuration flags. + /// + [TypeConverter(typeof(NumericRecordConverter))] + [Description("The explicit outer size of the table.")] + public Vector2 OuterSize { get; set; } + + /// + /// Gets or sets the optional total width to layout columns for horizontal scrolling. + /// + /// + /// This value is ignored when is disabled. + /// + [Description("The optional total width to layout columns for horizontal scrolling.")] + public float InnerWidth { get; set; } + + /// + protected override IObservable Generate(IObservable source) + { + return Observable.Create(observer => + { + var label = "##" + Name; + var sourceObserver = Observer.Create( + _ => + { + if (Visible && ImGui.BeginTable(label, Columns.Count, Flags, OuterSize, InnerWidth)) + { + foreach (var col in Columns) + { + ImGui.TableSetupColumn(col.Name, col.Flags, col.InitValue); + } + ImGui.TableHeadersRow(); + + observer.OnNext(label); + ImGui.EndTable(); + } + }, + observer.OnError, + observer.OnCompleted); + return source.SubscribeSafe(sourceObserver); + }); + } +} + +[Serializable] +public class ColumnStyling +{ + public string Name {get; set;} + public ImGuiTableColumnFlags Flags {get; set;} + public float InitValue {get; set;} +} \ No newline at end of file diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index cb677294..056da217 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -87,7 +87,7 @@ - PT2.215S + PT2.635S @@ -139,7 +139,7 @@ - PT0.3S + PT1.225S @@ -210,7 +210,7 @@ - PT0.281S + PT0.184S @@ -616,7 +616,7 @@ - false + true @@ -721,7 +721,7 @@ - false + true @@ -771,7 +771,7 @@ 5 0.5 5 - false + 0 @@ -782,7 +782,7 @@ - false + false @@ -809,7 +809,7 @@ - PT0.901S + PT0.385S @@ -1124,15 +1124,26 @@ true - - true - 2 - Borders - - 0 - 0 - - 0 + + true + + + Etho + WidthStretch + 0 + + + Camera + WidthFixed + 320 + + + Resizable BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit + + 0 + 0 + + 0 true @@ -1948,7 +1959,18 @@ true - + + + + + + + + + + + + Break 200 diff --git a/src/test_table_sizing.bonsai b/src/test_table_sizing.bonsai new file mode 100644 index 00000000..b150d170 --- /dev/null +++ b/src/test_table_sizing.bonsai @@ -0,0 +1,107 @@ + + + + + + + Frame + + + Frame + + + true + + + AAA + WidthStretch + 0 + + + BBB + WidthFixed + 0 + + + Resizable BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit + + 0 + 0 + + 0 + + + true + + + true + TESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTEST + + + true + + + true + TEST + + + + Frame + + + + + true + 2 + Borders + + 0 + 0 + + 0 + + + + + true + + + + + true + TEST + + + + + true + + + + + true + TESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTEST + + + + + + + + + + + + + + + + + + \ No newline at end of file From e8c45d61307e98f93d055ece98aa8c6ca1b473ae Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 30 Jul 2026 14:57:26 +0100 Subject: [PATCH 070/116] Update metadata visualizer with new table styling --- src/Extensions/MetadataVisualizer.bonsai | 92 ++- src/Extensions/TableBuilder.cs | 7 +- src/test_behavior_visualizer.bonsai | 838 ++++++----------------- 3 files changed, 308 insertions(+), 629 deletions(-) diff --git a/src/Extensions/MetadataVisualizer.bonsai b/src/Extensions/MetadataVisualizer.bonsai index 0f36140f..9253b98d 100644 --- a/src/Extensions/MetadataVisualizer.bonsai +++ b/src/Extensions/MetadataVisualizer.bonsai @@ -3,6 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" + xmlns:p1="clr-namespace:;assembly=Extensions" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -34,15 +35,47 @@ true - - true - 7 - None - - 0 - 0 - - 0 + + true + + + Condition + WidthFixed + 0 + + + Subject + WidthFixed + 0 + + + Session + WidthFixed + 0 + + + Experiment + WidthFixed + 0 + + + Habituation + WidthStretch + 0 + + + Control + WidthStretch + 0 + + + BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit + + 0 + 0 + + 0 + true true @@ -187,6 +220,31 @@ true + + true + + + Start + WidthStretch + 0 + + + Stop + WidthStretch + 0 + + + None + + 0 + 0 + + 0 + false + + + true + true START @@ -224,7 +282,6 @@ - @@ -254,12 +311,15 @@ - - - - - - + + + + + + + + + diff --git a/src/Extensions/TableBuilder.cs b/src/Extensions/TableBuilder.cs index 7f64c115..3547bf21 100644 --- a/src/Extensions/TableBuilder.cs +++ b/src/Extensions/TableBuilder.cs @@ -51,6 +51,8 @@ public class TableBuilder : ControlBuilder [Description("The optional total width to layout columns for horizontal scrolling.")] public float InnerWidth { get; set; } + public bool ShowHeadersRow {get; set; } + /// protected override IObservable Generate(IObservable source) { @@ -66,7 +68,8 @@ protected override IObservable Generate(IObservable so { ImGui.TableSetupColumn(col.Name, col.Flags, col.InitValue); } - ImGui.TableHeadersRow(); + if (ShowHeadersRow) + ImGui.TableHeadersRow(); observer.OnNext(label); ImGui.EndTable(); @@ -79,7 +82,7 @@ protected override IObservable Generate(IObservable so } } -[Serializable] +// [Serializable] public class ColumnStyling { public string Name {get; set;} diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 056da217..a801887c 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -87,7 +87,7 @@ - PT2.635S + PT0.777S @@ -139,7 +139,7 @@ - PT1.225S + PT2.307S @@ -210,7 +210,7 @@ - PT0.184S + PT0.164S @@ -616,7 +616,7 @@ - true + false @@ -782,8 +782,8 @@ - - false + false + true @@ -809,7 +809,7 @@ - PT0.385S + PT0.594S @@ -1128,7 +1128,7 @@ true - Etho + Ethograph WidthStretch 0 @@ -1138,12 +1138,13 @@ 320 - Resizable BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit + BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit 0 0 0 + true true @@ -1970,6 +1971,8 @@ + + Break 200 @@ -2851,241 +2854,179 @@ SessionInfo - - Metadata - StartExperimentShortcut - EndExperiment - UiHabituationTimeUpdate - - PreSessionVisualizer + MetadataVisualizer + + Source1 + - - - - - - - - - - - - - - - - - + + + - - PreSessionVisualizer + + MetadataVisualizer - - LeftOpenState - - - RightOpenState + + Source1 - - BothOpenState + + CurrentMetadata - PreSession - - - true - 2 - Borders - - 0 - 0 - - 0 + Metadata true - - true - 2 - None - - 0 - 0 - - 0 + + true + + + Condition + None + 0 + + + Subject + None + 0 + + + Session + None + 0 + + + Experiment + None + 0 + + + Habituation + None + 0 + + + Control + None + 0 + + + BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit + + 0 + 0 + + 0 + true true - BothOpenState - - - - - - + CurrentMetadata - - KeepLeftOpen - true - KeepLeftOpen - Open Left - Close Left - true - - - LeftOpenState + + Experimenter - - + + + + + Source1 + + + Count + + + + 0 + + + + + + + + + + - - UiKeepLeftOpen + + + 0 + - + - - KeepRightOpen - true - KeepRightOpen - Open Right - Close Right - true - - - RightOpenState - - - - - - UiKeepRightOpen + + true + Expo - - LeftOpenState + + true - RightOpenState + CurrentMetadata - - + + Subject - - - + - - KeepBothOpen - true - KeepBothOpen - Open Both - Close Both - true - - - BothOpenState - - - - - - UiKeepBothOpen - - - + + true + Plimbo true - - DrainLeft - true - Drain Left - Drain Left - Cancel Drain Left - true - - - - - - UiDrainLeft - - - DrainRight - true - Drain Right - Drain Right - Cancel Drain Right - true - - - - - - UiDrainRight - - - DrainBoth - true - Drain Both - Drain Both - Cancel Drain Both - true - - - + + CurrentMetadata - - UiDrainBoth + + SessionName - - + + + + - - + + true + Stage1 true - - true - 2 - Borders - - 0 - 0 - - 0 + + CurrentMetadata - - true + + Experiment - + + + + + + true - 1 - None - - 0 - 0 - - 0 + Task6 true @@ -3103,53 +3044,26 @@ true - - MoveLeft - true - Move Left - - - - - - - UiManipulatorLeft - - - ForwardLeft + true - Forward Left + Habituation - - - - - - UiManipulatorForwardLeft - - - ForwardRight + true - Forward Right - - - - - - - UiManipulatorForwardRight - - Up + + Habituation true - Up + None + 0 + 0 + 0 - - + - UiManipulatorUp + UiHabituationTimeUpdate @@ -3157,440 +3071,142 @@ true - - MoveRight - true - Move Right - - - - - - - UiManipulatorRight - - - BackLeft - true - Back Left - - - - - - - UiManipulatorBackLeft + + true + + + Start + WidthStretch + 0 + + + Stop + WidthStretch + 0 + + + None + + 0 + 0 + + 0 + false - - BackRight + true - Back Right - - - - - - - UiManipulatorBackRight - Down true - Down + START - + - UiManipulatorDown - - - - - - + StartExperimentShortcut true - STOP true STOP - + - UiManipulatorStop - - - Home - true - Home - - - - - - - UiManipulatorHome - - - Initialize - true - Initialize - - - - - - - UiManipulatorInitialize - - - - - - - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - x: - - - true - - - - - - ManipulatorPosition - - - X - - - {0:N2} - it - - - - - - - - true - 0.00 - - - - - - true - - - true - y1: - - - true - - - Y1 - - - {0:N2} - it - - - - - - - - true - 0.00 - - - - - - true - - - true - y2: - - - true - - - Y2 - - - {0:N2} - it - - - - - - - - true - 0.00 - - - - - - true - - - true - z: - - - true - - - Z - - - {0:N2} - it - - - - - - - - true - 0.00 - - - - - - true - - - true - step: - - - true - - - true - None - 0 - 0 - 0 - - - OffsetGain - - - + EndExperiment + + - - + + + + + + - - - - + - - - - - + + + - - - - - - - + + + + + - - - - - + + + + + - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - + + + + + + PreSession + UiKeepLeftOpen + UiKeepRightOpen + UiKeepBothOpen + UiDrainLeft + UiDrainRight + UiDrainBoth + UiManipulatorLeft + UiManipulatorForwardLeft + UiManipulatorForwardRight + UiManipulatorUp + UiManipulatorRight + UiManipulatorBackLeft + UiManipulatorBackRight + UiManipulatorDown + UiManipulatorStop + UiManipulatorHome + UiManipulatorInitialize + IntraSession UiGiveLeft From 26bb07111d22a129d7d9c7619bfb7bd26cb02bf5 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 30 Jul 2026 15:03:24 +0100 Subject: [PATCH 071/116] Update main visualizer layout with new table styling --- src/main.bonsai | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index f9cc285a..e6cce2ef 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -2948,15 +2948,27 @@ true - - true - 2 - Borders - - 0 - 0 - - 0 + + true + + + Ethograph + WidthStretch + 0 + + + Camera + WidthFixed + 320 + + + BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit + + 0 + 0 + + 0 + true true From d1415809b58883c76772663a0371118ea6df13b4 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 30 Jul 2026 15:41:12 +0100 Subject: [PATCH 072/116] Make control buttons more prominent --- src/Extensions/EnableableButtonBuilder.cs | 15 ++++++- src/Extensions/MetadataVisualizer.bonsai | 24 +++++++--- src/test_behavior_visualizer.bonsai | 54 +++++++++++++---------- 3 files changed, 61 insertions(+), 32 deletions(-) diff --git a/src/Extensions/EnableableButtonBuilder.cs b/src/Extensions/EnableableButtonBuilder.cs index 2252416c..33b067d2 100644 --- a/src/Extensions/EnableableButtonBuilder.cs +++ b/src/Extensions/EnableableButtonBuilder.cs @@ -1,8 +1,10 @@ using System; using System.ComponentModel; +using System.Numerics; using System.Reactive; using System.Reactive.Linq; using Bonsai.ImGui; +using OpenCV.Net; using ImGui = Hexa.NET.ImGui.ImGui; /// @@ -13,6 +15,15 @@ public class EnableableButtonBuilder : TextControlBuilder { public bool Enabled {get; set;} + public Size Size {get; set;} + + private Vector2 buttonSize + { + get + { + return new Vector2(Size.Width, Size.Height); + } + } /// protected override IObservable Generate(IObservable source) @@ -38,12 +49,12 @@ protected override IObservable Generate(IObservable so { if (Enabled) { - if (ImGui.Button(label)) + if (ImGui.Button(label, buttonSize)) observer.OnNext(output); } else { ImGui.BeginDisabled(); - ImGui.Button(label); + ImGui.Button(label, buttonSize); ImGui.EndDisabled(); } } diff --git a/src/Extensions/MetadataVisualizer.bonsai b/src/Extensions/MetadataVisualizer.bonsai index 9253b98d..b437e845 100644 --- a/src/Extensions/MetadataVisualizer.bonsai +++ b/src/Extensions/MetadataVisualizer.bonsai @@ -245,9 +245,15 @@ true - - true - START + + StartButton + true + START + true + + 100 + 50 + @@ -259,9 +265,15 @@ true - - true - STOP + + StopButton + true + STOP + true + + 100 + 50 + diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index a801887c..6a9403fa 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -87,7 +87,7 @@ - PT0.777S + PT2.983S @@ -139,7 +139,7 @@ - PT2.307S + PT1.822S @@ -210,7 +210,7 @@ - PT0.164S + PT1.348S @@ -616,7 +616,7 @@ - false + true @@ -782,7 +782,7 @@ - false + true true @@ -809,7 +809,7 @@ - PT0.594S + PT0.824S @@ -1967,12 +1967,6 @@ - - - - - - Break 200 @@ -2891,32 +2885,32 @@ Condition - None + WidthFixed 0 Subject - None + WidthFixed 0 Session - None + WidthFixed 0 Experiment - None + WidthFixed 0 Habituation - None + WidthStretch 0 Control - None + WidthStretch 0 @@ -3096,9 +3090,15 @@ true - - true - START + + StartButton + true + START + true + + 100 + 50 + @@ -3110,9 +3110,15 @@ true - - true - STOP + + StopButton + true + STOP + true + + 100 + 50 + From e5213cee5d259251b7f90adb2fc4fb0e58a07024 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Thu, 30 Jul 2026 16:44:58 +0100 Subject: [PATCH 073/116] Add constructor to TableBuilder ensures column styling collection is initialized when added to a workflow --- src/Extensions/TableBuilder.cs | 6 + src/test_behavior_visualizer.bonsai | 349 +--------------------------- 2 files changed, 11 insertions(+), 344 deletions(-) diff --git a/src/Extensions/TableBuilder.cs b/src/Extensions/TableBuilder.cs index 3547bf21..fc69c3cb 100644 --- a/src/Extensions/TableBuilder.cs +++ b/src/Extensions/TableBuilder.cs @@ -1,6 +1,7 @@ using Bonsai; using Bonsai.ImGui; using Hexa.NET.ImGui; +using Markdig.Extensions.Tables; using System; using System.Collections.Generic; using System.ComponentModel; @@ -53,6 +54,11 @@ public class TableBuilder : ControlBuilder public bool ShowHeadersRow {get; set; } + public TableBuilder() + { + Columns = new List(); + } + /// protected override IObservable Generate(IObservable source) { diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 6a9403fa..a79349d6 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -2848,350 +2848,11 @@ SessionInfo - - MetadataVisualizer - - - - Source1 - - - - - - - - - MetadataVisualizer - - - - Source1 - - - CurrentMetadata - - - - - - Metadata - - - true - - - true - - - Condition - WidthFixed - 0 - - - Subject - WidthFixed - 0 - - - Session - WidthFixed - 0 - - - Experiment - WidthFixed - 0 - - - Habituation - WidthStretch - 0 - - - Control - WidthStretch - 0 - - - BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit - - 0 - 0 - - 0 - true - - - true - - - CurrentMetadata - - - Experimenter - - - - - - Source1 - - - Count - - - - 0 - - - - - - - - - - - - - - 0 - - - - - - - - - true - Expo - - - true - - - CurrentMetadata - - - Subject - - - - - - - - true - Plimbo - - - true - - - CurrentMetadata - - - SessionName - - - - - - - - true - Stage1 - - - true - - - CurrentMetadata - - - Experiment - - - - - - - - true - Task6 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - Habituation - - - true - - - Habituation - true - None - 0 - 0 - 0 - - - - - - UiHabituationTimeUpdate - - - - - - true - - - true - - - Start - WidthStretch - 0 - - - Stop - WidthStretch - 0 - - - None - - 0 - 0 - - 0 - false - - - true - - - StartButton - true - START - true - - 100 - 50 - - - - - - - - StartExperimentShortcut - - - true - - - StopButton - true - STOP - true - - 100 - 50 - - - - - - - - EndExperiment - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Metadata + StartExperimentShortcut + EndExperiment + UiHabituationTimeUpdate PreSession From cc60872fafb737432f712f39f3f536d932d074d8 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 5 Aug 2026 12:14:54 +0100 Subject: [PATCH 074/116] Add placeholder text to avoid intra-session crash --- src/main.bonsai | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index e6cce2ef..7719c731 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -3118,10 +3118,14 @@ Value.Trial.Metadata.Extra - + + Placeholder + - + + Placeholder + From e69696a5676bb1bdd176135651d7e4c7a12f2d3d Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 5 Aug 2026 13:53:22 +0100 Subject: [PATCH 075/116] Add reset logic for draining buttons --- src/Extensions/ToggleButtonBuilder.cs | 2 +- src/main.bonsai | 808 +++++++++++++++++++++++++- src/test_behavior_visualizer.bonsai | 18 +- 3 files changed, 795 insertions(+), 33 deletions(-) diff --git a/src/Extensions/ToggleButtonBuilder.cs b/src/Extensions/ToggleButtonBuilder.cs index 96cf0119..464f2ca9 100644 --- a/src/Extensions/ToggleButtonBuilder.cs +++ b/src/Extensions/ToggleButtonBuilder.cs @@ -12,7 +12,7 @@ [Description("Draws a button control and generates a sequence of notifications whenever the button is clicked.")] public class ToggleButtonBuilder : TextControlBuilder { - private bool Toggled; + public bool Toggled {get; set;} public string ToggledOffText {get; set;} public string ToggledOnText {get; set;} diff --git a/src/main.bonsai b/src/main.bonsai index 7719c731..bd3f32f6 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -2739,6 +2739,9 @@ + + DrainLeftComplete + UiDrainRight @@ -2903,6 +2906,9 @@ + + DrainRightComplete + @@ -2926,12 +2932,14 @@ - + - + + + @@ -3291,25 +3299,783 @@ EndExperiment UiHabituationTimeUpdate - - PreSession - UiKeepLeftOpen - UiKeepRightOpen - UiKeepBothOpen - UiDrainLeft - UiDrainRight - UiDrainBoth - UiManipulatorLeft - UiManipulatorForwardLeft - UiManipulatorForwardRight - UiManipulatorUp - UiManipulatorRight - UiManipulatorBackLeft - UiManipulatorBackRight - UiManipulatorDown - UiManipulatorStop - UiManipulatorHome - UiManipulatorInitialize + + PreSessionVisualizer + + + + + + + + + + + + + + + + + + + + + + + + PreSessionVisualizer + + + + LeftOpenState + + + RightOpenState + + + BothOpenState + + + + + + PreSession + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + BothOpenState + + + + + + + + + KeepLeftOpen + true + KeepLeftOpen + false + Open Left + Close Left + true + + + LeftOpenState + + + + + + UiKeepLeftOpen + + + + + + + + KeepRightOpen + true + KeepRightOpen + false + Open Right + Close Right + true + + + RightOpenState + + + + + + UiKeepRightOpen + + + LeftOpenState + + + RightOpenState + + + + + + + + + + + + + KeepBothOpen + true + KeepBothOpen + false + Open Both + Close Both + true + + + BothOpenState + + + + + + UiKeepBothOpen + + + + + + true + + + DrainLeftComplete + + + + + + + + DrainLeft + true + Drain Left + false + Drain Left + Cancel Drain Left + true + + + + + + UiDrainLeft + + + DrainRightComplete + + + + + + + + DrainRight + true + Drain Right + false + Drain Right + Cancel Drain Right + true + + + + + + UiDrainRight + + + DrainLeftComplete + + + DrainRightComplete + + + + + + + + + + + DrainBoth + true + Drain Both + false + Drain Both + Cancel Drain Both + true + + + + + + UiDrainBoth + + + + + + + + + true + + + true + 2 + Borders + + 0 + 0 + + 0 + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + MoveLeft + true + Move Left + + + + + + + UiManipulatorLeft + + + ForwardLeft + true + Forward Left + + + + + + + UiManipulatorForwardLeft + + + ForwardRight + true + Forward Right + + + + + + + UiManipulatorForwardRight + + + Up + true + Up + + + + + + + UiManipulatorUp + + + + + + true + + + MoveRight + true + Move Right + + + + + + + UiManipulatorRight + + + BackLeft + true + Back Left + + + + + + + UiManipulatorBackLeft + + + BackRight + true + Back Right + + + + + + + UiManipulatorBackRight + + + Down + true + Down + + + + + + + UiManipulatorDown + + + + + + + + + true + + + STOP + true + STOP + + + + + + + UiManipulatorStop + + + Home + true + Home + + + + + + + UiManipulatorHome + + + Initialize + true + Initialize + + + + + + + UiManipulatorInitialize + + + + + + + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + x: + + + true + + + + + + ManipulatorPosition + + + X + + + {0:N2} + it + + + + + + + + true + 0.00 + + + + + + true + + + true + y1: + + + true + + + Y1 + + + {0:N2} + it + + + + + + + + true + 0.00 + + + + + + true + + + true + y2: + + + true + + + Y2 + + + {0:N2} + it + + + + + + + + true + 0.00 + + + + + + true + + + true + z: + + + true + + + Z + + + {0:N2} + it + + + + + + + + true + 0.00 + + + + + + true + + + true + step: + + + true + + + true + None + 0 + 0 + 0 + + + OffsetGain + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IntraSession diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index a79349d6..2c526823 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -87,7 +87,7 @@ - PT2.983S + PT1.074S @@ -139,7 +139,7 @@ - PT1.822S + PT2.031S @@ -210,7 +210,7 @@ - PT1.348S + PT1.039S @@ -721,7 +721,7 @@ - true + false @@ -771,7 +771,7 @@ 5 0.5 5 - + false 0 @@ -783,7 +783,7 @@ true - true + false @@ -809,7 +809,7 @@ - PT0.824S + PT0.994S @@ -1963,10 +1963,6 @@ - - - - Break 200 From 3d45784968844e07014c68c524f786a7af45de67 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 5 Aug 2026 14:00:43 +0100 Subject: [PATCH 076/116] Externalise drain complete subjects for pre session visualizers --- src/Extensions/PreSessionVisualizer.bonsai | 228 +++--- src/main.bonsai | 798 +-------------------- 2 files changed, 159 insertions(+), 867 deletions(-) diff --git a/src/Extensions/PreSessionVisualizer.bonsai b/src/Extensions/PreSessionVisualizer.bonsai index 515132b2..1735d8da 100644 --- a/src/Extensions/PreSessionVisualizer.bonsai +++ b/src/Extensions/PreSessionVisualizer.bonsai @@ -27,6 +27,8 @@ + + PreSessionVisualizer @@ -86,6 +88,7 @@ KeepLeftOpen true KeepLeftOpen + false Open Left Close Left true @@ -108,6 +111,7 @@ KeepRightOpen true KeepRightOpen + false Open Right Close Right true @@ -141,6 +145,7 @@ KeepBothOpen true KeepBothOpen + false Open Both Close Both true @@ -160,10 +165,22 @@ true + + + + + DrainLeftComplete + + + + + + DrainLeft true Drain Left + false Drain Left Cancel Drain Left true @@ -174,10 +191,22 @@ UiDrainLeft + + + + + DrainRightComplete + + + + + + DrainRight true Drain Right + false Drain Right Cancel Drain Right true @@ -188,10 +217,19 @@ UiDrainRight + + + + + + + + DrainBoth true Drain Both + false Drain Both Cancel Drain Both true @@ -566,7 +604,7 @@ - + @@ -596,114 +634,117 @@ - - + - - - - + + + + + + - - - - - - + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + - - - + + + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + - - - - - - - - + + + + - - - - - + + + + + + + + + + + + + + + + + + @@ -723,10 +764,17 @@ - - + + - + + + + + + + + diff --git a/src/main.bonsai b/src/main.bonsai index bd3f32f6..c2692b75 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -3299,783 +3299,27 @@ EndExperiment UiHabituationTimeUpdate - - PreSessionVisualizer - - - - - - - - - - - - - - - - - - - - - - - - PreSessionVisualizer - - - - LeftOpenState - - - RightOpenState - - - BothOpenState - - - - - - PreSession - - - true - 2 - Borders - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - BothOpenState - - - - - - - - - KeepLeftOpen - true - KeepLeftOpen - false - Open Left - Close Left - true - - - LeftOpenState - - - - - - UiKeepLeftOpen - - - - - - - - KeepRightOpen - true - KeepRightOpen - false - Open Right - Close Right - true - - - RightOpenState - - - - - - UiKeepRightOpen - - - LeftOpenState - - - RightOpenState - - - - - - - - - - - - - KeepBothOpen - true - KeepBothOpen - false - Open Both - Close Both - true - - - BothOpenState - - - - - - UiKeepBothOpen - - - - - - true - - - DrainLeftComplete - - - - - - - - DrainLeft - true - Drain Left - false - Drain Left - Cancel Drain Left - true - - - - - - UiDrainLeft - - - DrainRightComplete - - - - - - - - DrainRight - true - Drain Right - false - Drain Right - Cancel Drain Right - true - - - - - - UiDrainRight - - - DrainLeftComplete - - - DrainRightComplete - - - - - - - - - - - DrainBoth - true - Drain Both - false - Drain Both - Cancel Drain Both - true - - - - - - UiDrainBoth - - - - - - - - - true - - - true - 2 - Borders - - 0 - 0 - - 0 - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - MoveLeft - true - Move Left - - - - - - - UiManipulatorLeft - - - ForwardLeft - true - Forward Left - - - - - - - UiManipulatorForwardLeft - - - ForwardRight - true - Forward Right - - - - - - - UiManipulatorForwardRight - - - Up - true - Up - - - - - - - UiManipulatorUp - - - - - - true - - - MoveRight - true - Move Right - - - - - - - UiManipulatorRight - - - BackLeft - true - Back Left - - - - - - - UiManipulatorBackLeft - - - BackRight - true - Back Right - - - - - - - UiManipulatorBackRight - - - Down - true - Down - - - - - - - UiManipulatorDown - - - - - - - - - true - - - STOP - true - STOP - - - - - - - UiManipulatorStop - - - Home - true - Home - - - - - - - UiManipulatorHome - - - Initialize - true - Initialize - - - - - - - UiManipulatorInitialize - - - - - - - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - x: - - - true - - - - - - ManipulatorPosition - - - X - - - {0:N2} - it - - - - - - - - true - 0.00 - - - - - - true - - - true - y1: - - - true - - - Y1 - - - {0:N2} - it - - - - - - - - true - 0.00 - - - - - - true - - - true - y2: - - - true - - - Y2 - - - {0:N2} - it - - - - - - - - true - 0.00 - - - - - - true - - - true - z: - - - true - - - Z - - - {0:N2} - it - - - - - - - - true - 0.00 - - - - - - true - - - true - step: - - - true - - - true - None - 0 - 0 - 0 - - - OffsetGain - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + PreSession + UiKeepLeftOpen + UiKeepRightOpen + UiKeepBothOpen + UiDrainLeft + UiDrainRight + UiDrainBoth + UiManipulatorLeft + UiManipulatorForwardLeft + UiManipulatorForwardRight + UiManipulatorUp + UiManipulatorRight + UiManipulatorBackLeft + UiManipulatorBackRight + UiManipulatorDown + UiManipulatorStop + UiManipulatorHome + UiManipulatorInitialize + DrainLeftComplete + DrainRightComplete IntraSession From 4c0d1a2d80328341c101819c2715d4bbafddd881 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 5 Aug 2026 14:02:34 +0100 Subject: [PATCH 077/116] Ensure that KeepOpen logic stays on indefinitely --- src/main.bonsai | 66 +++++++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 44 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index c2692b75..1fd8bba6 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -2381,6 +2381,12 @@ + + + 1 + + + PT0.1S @@ -2424,39 +2430,22 @@ - - - false - - - - - - - - 1 - - - - - - + + - - + + - - - + @@ -2490,6 +2479,12 @@ + + + 1 + + + PT0.1S @@ -2533,39 +2528,22 @@ - - - false - - - - - - - - 1 - - - - - - + + - - + + - - - + From abaff6fcb520946b8d73019654a04238201ed370 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 5 Aug 2026 15:25:25 +0100 Subject: [PATCH 078/116] Remove previous visualizers completely --- src/main.bonsai | 1041 +---------------------------------------------- 1 file changed, 7 insertions(+), 1034 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index 1fd8bba6..e70e7f65 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -8,14 +8,12 @@ xmlns:p3="clr-namespace:System.Reactive;assembly=System.Reactive.Core" xmlns:p4="clr-namespace:AllenNeuralDynamics.AindBehaviorServices.DataTypes;assembly=AllenNeuralDynamics.AindBehaviorServices" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" - xmlns:p5="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" - xmlns:gui="clr-namespace:Bonsai.Gui;assembly=Bonsai.Gui" - xmlns:sys="clr-namespace:System;assembly=mscorlib" - xmlns:p6="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" - xmlns:ui="clr-namespace:Bonsai.Design;assembly=Bonsai.Design" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" + xmlns:p5="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" + xmlns:p6="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" xmlns:p7="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" + xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -404,1029 +402,6 @@ Visualizers - - - - 0 - - - - - - - - - TrialPlots - - - - GlobalTrialOutcome - - - 16 - - - - SoftwareEvent - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - LickRight - - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - - - LickLeft - - - - GiveRewardRight - - - - - - Source1 - - - - - - - - - - - WaterRight - - - - GiveRewardRight - - - - - - - Source1 - - - - - - - - - - - WaterLeft - - - - - - - 16 - 20 - - - QuiscentPeriod - Gold - 0.3 - - - ResponsePeriod - SandyBrown - 0.3 - - - RewardConsumptionPeriod - RosyBrown - 0.3 - - - ItiPeriod - Green - 0.3 - - - - - LickLeft - Red - 0.9 - 6 - Down - - - LickRight - Blue - 0.1 - 6 - Up - - - IsRightTriggerQuickRetract - DarkCyan - 0.5 - 6 - Plus - - - DeliverSecondaryReinforcer - Sienna - 0.5 - 6 - Plus - - - WaterRight - Blue - 0.2 - 6 - Circle - - - WaterLeft - Red - 0.8 - 6 - Circle - - - - 5 - - - - true - true - 1 - 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ManualOverrides - - - - OffsetControl - - - - - 0.05 - - - - - 1 - - - - BumpSize - - - ManipulatorBiasTracker - - - {0:F2} - - - - - - - - true - true - Microsoft Sans Serif, 20.25pt - 0.00 - - - - Left - true - true - Microsoft Sans Serif, 15.75pt - ◀️ - - - BumpLeft - - - - Source1 - - - BumpSize - - - - - - Item2 - - - - -1 - - - - ManualSpoutDelta - - - - - - - - - - - - - - - - Right - true - true - Microsoft Sans Serif, 15.75pt - - - - BumpRight - - - - Source1 - - - BumpSize - - - - - - Item2 - - - ManualSpoutDelta - - - - - - - - - - - - - - - true - true - 2 - 1 - - - - - - - ExperimentState - - - - - - - - false - true - Microsoft Sans Serif, 22.125pt - 1 - 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Spout offset - true - true - Microsoft Sans Serif, 15.75pt - Spout offset - - - - GiveWaterUI - - - - Left - true - true - 💧◀ - - - TriggerLeft - - - - Source1 - - - - false - - - - GiveManualWaterRight - - - - - - - - - - - - - Right - true - true - 💧▶ - - - TriggerRight - - - - Source1 - - - - true - - - - GiveManualWaterRight - - - - - - - - - - - - - ManualWater - true - true - 2 - 1 - - - Percent - 0.5 - - - Percent - 0.5 - - - - - - - - GiveManualWaterRight - - - GiveManualWaterRight - - - GiveRewardRight - - - - - - - - - - - - - - - - - - 💧 - true - true - Microsoft Sans Serif, 8.25pt - - - - - ForceAutoWater - - - - GlobalAutoWaterState - - - !it.IsLeft - - - - - - - - SetLeft - true - true - 🎣◀ - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetLeft() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - - GlobalAutoWaterState - - - !it.IsRight - - - - - - - - SetRight - true - true - 🎣▶ - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetRight() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - - GlobalAutoWaterState - - - it.HasValue - - - - - - - - Reset - false - true - - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.Reset() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - - ForceAutoWater - true - true - 3 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 🎣 - true - true - Microsoft Sans Serif, 8.25pt - - - - - true - true - Microsoft Sans Serif, 15.75pt - - - - Manual Control - true - true - Microsoft Sans Serif, 36pt - 1 - 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - LauncherControl - - - - - - - - ExperimentState - - - - - - - - - Start - true - true - Start Experiment - - - StartExperimentToggleButton - - - - End - true - true - End Experiment - - - EndExperimentButton - - - - LauncherControl - true - true - Microsoft Sans Serif, 26pt - 2 - 4 - - - - - - - - - - - StartExperimentToggleButton - - - - 1 - - - - - StartExperimentShortcut - - - EndExperimentButton - - - - 1 - - - - - EndExperiment - - - StartExperiment - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - true - - - - - true - true - 1 - 2 - - - - - - - - true - true - 3 - 1 - - - - - - - - - TriggeredCamerasStream - - - - - - - - - - - true - true - 2 - 1 - - - - - - - true - true - 1 - 2 - - - Percent - 0.75 - - - Percent - 0.25 - - - - - - - - GlobalTrial - - - 2 - 16 - - - - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DynamicForaging - true - - - Maximized - - ImGuiContext @@ -3312,15 +2287,13 @@ - - + + - + - + - - From b1cb49c1c9a34dd23d78b21e975bd749877c08d3 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 5 Aug 2026 15:56:46 +0100 Subject: [PATCH 079/116] Rename bonsai env folder to be in line with main Also ensure that test visualizer workflow has drain complete subject placeholders --- {bonsai => .bonsai}/Bonsai.config | 0 {bonsai => .bonsai}/NuGet.config | 0 .../src/test_behavior_visualizer.editor | 37 +++++++++++ .../src/test_behavior_visualizer.layout | 17 +++++ {bonsai => .bonsai}/setup.cmd | 0 {bonsai => .bonsai}/setup.ps1 | 0 src/test_behavior_visualizer.bonsai | 64 +++++++++++++++++-- 7 files changed, 112 insertions(+), 6 deletions(-) rename {bonsai => .bonsai}/Bonsai.config (100%) rename {bonsai => .bonsai}/NuGet.config (100%) create mode 100644 .bonsai/Settings/src/test_behavior_visualizer.editor create mode 100644 .bonsai/Settings/src/test_behavior_visualizer.layout rename {bonsai => .bonsai}/setup.cmd (100%) rename {bonsai => .bonsai}/setup.ps1 (100%) diff --git a/bonsai/Bonsai.config b/.bonsai/Bonsai.config similarity index 100% rename from bonsai/Bonsai.config rename to .bonsai/Bonsai.config diff --git a/bonsai/NuGet.config b/.bonsai/NuGet.config similarity index 100% rename from bonsai/NuGet.config rename to .bonsai/NuGet.config diff --git a/.bonsai/Settings/src/test_behavior_visualizer.editor b/.bonsai/Settings/src/test_behavior_visualizer.editor new file mode 100644 index 00000000..06f2dea6 --- /dev/null +++ b/.bonsai/Settings/src/test_behavior_visualizer.editor @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.bonsai/Settings/src/test_behavior_visualizer.layout b/.bonsai/Settings/src/test_behavior_visualizer.layout new file mode 100644 index 00000000..98c6dd13 --- /dev/null +++ b/.bonsai/Settings/src/test_behavior_visualizer.layout @@ -0,0 +1,17 @@ + + + + + 421 + 76 + + + 821 + 678 + + Bonsai.ImGui.Visualizers.ImPlotVisualizer + + + + + \ No newline at end of file diff --git a/bonsai/setup.cmd b/.bonsai/setup.cmd similarity index 100% rename from bonsai/setup.cmd rename to .bonsai/setup.cmd diff --git a/bonsai/setup.ps1 b/.bonsai/setup.ps1 similarity index 100% rename from bonsai/setup.ps1 rename to .bonsai/setup.ps1 diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 2c526823..649253e6 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -87,7 +87,7 @@ - PT1.074S + PT1.745S @@ -139,7 +139,7 @@ - PT2.031S + PT0.609S @@ -210,7 +210,7 @@ - PT1.039S + PT2.764S @@ -721,7 +721,7 @@ - false + true @@ -771,7 +771,7 @@ 5 0.5 5 - false + 0 @@ -809,7 +809,7 @@ - PT0.994S + PT0.847S @@ -1940,6 +1940,12 @@ UiKeepBothOpen + + DrainLeftComplete + + + DrainRightComplete + @@ -1963,6 +1969,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Break 200 @@ -2869,6 +2919,8 @@ UiManipulatorStop UiManipulatorHome UiManipulatorInitialize + DrainLeftComplete + DrainRightComplete IntraSession From f04defea57cbe4c59c15a2bcce71c04388511af0 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 5 Aug 2026 16:06:24 +0100 Subject: [PATCH 080/116] Save visualizer implementation as IncludeWorkflow This will presumably be necessary for merging with main with minimal merge conflicts --- .bonsai/Settings/src/main.editor | 37 + .bonsai/Settings/src/main.layout | 14 + .../src/test_behavior_visualizer.editor | 10 +- .../src/test_behavior_visualizer.layout | 17 +- src/Extensions/Visualizers.bonsai | 2567 ++++++++---- src/main.bonsai | 1906 +-------- src/test_behavior_visualizer.bonsai | 3599 ++++++++--------- 7 files changed, 3558 insertions(+), 4592 deletions(-) create mode 100644 .bonsai/Settings/src/main.editor create mode 100644 .bonsai/Settings/src/main.layout diff --git a/.bonsai/Settings/src/main.editor b/.bonsai/Settings/src/main.editor new file mode 100644 index 00000000..bbd6dca8 --- /dev/null +++ b/.bonsai/Settings/src/main.editor @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.bonsai/Settings/src/main.layout b/.bonsai/Settings/src/main.layout new file mode 100644 index 00000000..a8dfb7c0 --- /dev/null +++ b/.bonsai/Settings/src/main.layout @@ -0,0 +1,14 @@ + + + + + + + + Bonsai.ImGui.Visualizers.ImPlotVisualizer + + + + + + \ No newline at end of file diff --git a/.bonsai/Settings/src/test_behavior_visualizer.editor b/.bonsai/Settings/src/test_behavior_visualizer.editor index 06f2dea6..a16eb316 100644 --- a/.bonsai/Settings/src/test_behavior_visualizer.editor +++ b/.bonsai/Settings/src/test_behavior_visualizer.editor @@ -4,7 +4,7 @@ - + @@ -19,16 +19,16 @@ - + - + - + - + diff --git a/.bonsai/Settings/src/test_behavior_visualizer.layout b/.bonsai/Settings/src/test_behavior_visualizer.layout index 98c6dd13..0829d87c 100644 --- a/.bonsai/Settings/src/test_behavior_visualizer.layout +++ b/.bonsai/Settings/src/test_behavior_visualizer.layout @@ -1,17 +1,2 @@  - - - - 421 - 76 - - - 821 - 678 - - Bonsai.ImGui.Visualizers.ImPlotVisualizer - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/src/Extensions/Visualizers.bonsai b/src/Extensions/Visualizers.bonsai index b912aca2..e364ea88 100644 --- a/src/Extensions/Visualizers.bonsai +++ b/src/Extensions/Visualizers.bonsai @@ -1,728 +1,667 @@  - - - 0 - + + ImGuiContext + + + + + true + 1 + None + + 0 + 0 + + 0 + + + Frame + + + + + + + + + - + + DataTransformations - - TrialPlots + + GlobalTrialOutcome + + + HarpTimestampSource + + + TimedTrial + + + GlobalTrialMetrics + + + Bias + + + new (it as Bias) + + + HarpTimestampSource + + + TimedBias + + + IsRightLickEvent + + - - GlobalTrialOutcome + + Source1 - - 16 + + Value - - - SoftwareEvent + + + + + + + + + + HarpTimestampSource + + + LickRight + + + IsRightLickEvent + + + + + + Source1 - - IsRightLickEvent + + Value - + + + + + + + + + + + + HarpTimestampSource + + + LickLeft + + + SoftwareEvent + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + LickRight + + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + + + LickLeft + + + + GiveRewardRight + + + + + + Source1 + + + + + + + + + + + WaterRight + + + + GiveRewardRight + + + + + + + Source1 + + + + + + + + + + + WaterLeft + + + + + + + HarpTimestampSource + + + + + + + + + + + + EthogramEvents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OutputControl + + + + Manipulator + + + + UiManipulatorLeft + + + MoveRelative Source1 - - Value + + + -1 + 0 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy - + + + + + - - - LickRight - - - - IsRightLickEvent + + UiManipulatorRight - + + MoveRelative Source1 - - Value + + + 1 + 0 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy - - - + + + + + - - - LickLeft - - - - GiveRewardRight + + UiManipulatorForwardLeft - + + MoveRelative Source1 + + + 0 + 1 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + - - - WaterRight - - - - GiveRewardRight + + UiManipulatorForwardRight - - + + MoveRelative Source1 + + + 0 + 0 + 1 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + - - - WaterLeft - - - - - - - 16 - 20 - - - QuiscentPeriod - Gold - 0.3 - - - ResponsePeriod - SandyBrown - 0.3 - - - RewardConsumptionPeriod - RosyBrown - 0.3 - - - ItiPeriod - Green - 0.3 - - - - - LickLeft - Red - 0.9 - 6 - Down - - - LickRight - Blue - 0.1 - 6 - Up - - - IsRightTriggerQuickRetract - DarkCyan - 0.5 - 6 - Plus - - - DeliverSecondaryReinforcer - Sienna - 0.5 - 6 - Plus - - - WaterRight - Blue - 0.2 - 6 - Circle - - - WaterLeft - Red - 0.8 - 6 - Circle - - - - 5 - - - - true - true - 1 - 2 - - - + + UiManipulatorBackLeft - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ManualOverrides - - - - OffsetControl + + MoveRelative - - - 0.05 - + + Source1 - - 1 + + 0 + -1 + 0 + 0 - - BumpSize - - ManipulatorBiasTracker - - - {0:F2} - - - - - + OffsetGain - - true - true - Microsoft Sans Serif, 20.25pt - 0.00 - - - - Left - true - true - Microsoft Sans Serif, 15.75pt - ◀️ - - - BumpLeft - - - - Source1 - - - BumpSize - - - - - - Item2 - - - - -1 - - - - ManualSpoutDelta - - - - - - - - - - - - - - - - Right - true - true - Microsoft Sans Serif, 15.75pt - - - - BumpRight - - - - Source1 - - - BumpSize - - - - - - Item2 - - - ManualSpoutDelta - - - - - - - - - - - - - - - true - true - 2 - 1 - - - + + - - - ExperimentState - - - - - - - - false - true - Microsoft Sans Serif, 22.125pt - 1 - 2 - - - + + + MoveBy - + + - - - - - - - - - - - - - - - - Spout offset - true - true - Microsoft Sans Serif, 15.75pt - Spout offset - - - - GiveWaterUI + + UiManipulatorBackRight + + + MoveRelative - - Left - true - true - 💧◀ - - - TriggerLeft - - - - Source1 - - - - false - - - - GiveManualWaterRight - - - - - - - - - - - - - Right - true - true - 💧▶ - - - TriggerRight - - - - Source1 - - - - true - - - - GiveManualWaterRight - - - - - - - - - + + Source1 - - - ManualWater - true - true - 2 - 1 - - - Percent - 0.5 - - - Percent - 0.5 - - - - + + + 0 + 0 + -1 + 0 + - - - GiveManualWaterRight + + OffsetGain - - GiveManualWaterRight + + + - GiveRewardRight + MoveBy + - - + + - - - - + - - - 💧 - true - true - Microsoft Sans Serif, 8.25pt - - - - - ForceAutoWater + + UiManipulatorUp + + + MoveRelative - - GlobalAutoWaterState + + Source1 - - !it.IsLeft + + + 0 + 0 + 0 + 1 + - - - - + + OffsetGain - - SetLeft - true - true - 🎣◀ + + - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetLeft() - - - GlobalAutoWaterState - - - - - - - - - - - - - + + + MoveBy - - - GlobalAutoWaterState + + + + + + + + + + + + + + UiManipulatorDown + + + MoveRelative + + + + Source1 - - !it.IsRight + + + 0 + 0 + 0 + -1 + - - - - + + OffsetGain - - SetRight - true - true - 🎣▶ + + - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetRight() - - - GlobalAutoWaterState - - - - - - - - - - - - - + + + MoveBy - - - GlobalAutoWaterState + + + + + + + + + + + + + + UiManipulatorHome + + + Home + + + + Source1 - - it.HasValue + + + HomeMotors - - - - + + + + + + + + + + + UiManipulatorStop + + + StopMotors + + + + Source1 - - Reset - false - true - + + + StopMotors - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.Reset() - - - GlobalAutoWaterState - - - - - - - - - - - - - + + + + + + + + + + + UiManipulatorInitialize + + + GoToInitialPosition + + + + Source1 - - - ForceAutoWater - true - true - 3 - 1 - - - + + + GoToInitialPosition @@ -730,309 +669,1243 @@ - - - - - - - - - - - - - - - - - - - 🎣 - true - true - Microsoft Sans Serif, 8.25pt - - - - - true - true - Microsoft Sans Serif, 15.75pt - - - - Manual Control - true - true - Microsoft Sans Serif, 36pt - 1 - 2 - - - + + OffsetGain - - - - - - - - + + + - - - LauncherControl + + UiHabituationTimeUpdate + + + + 0.05 + + + + + 1 + + + + BumpSize + + + UiMoveLeft + + + BumpLeft - - + + Source1 - - ExperimentState + BumpSize - - - - - + + + + + Item2 - - Start - true - true - Start Experiment - - - StartExperimentToggleButton - - - - End - true - true - End Experiment - - - EndExperimentButton - - - - LauncherControl - true - true - Microsoft Sans Serif, 26pt - 2 - 4 - - - - - - - + + + -1 + + + + ManualSpoutDelta + + + + + + + + + + + + + UiMoveRight + + + BumpRight + + + + Source1 + - StartExperimentToggleButton + BumpSize - - 1 + + + + Item2 + + + ManualSpoutDelta + + + + + + + + + + + + + + UiGiveRight + + + TriggerRight + + + + Source1 + + + + true - - StartExperimentShortcut + GiveManualWaterRight - - EndExperimentButton + + + + + + + + + + + UiGiveLeft + + + TriggerLeft + + + + Source1 - - 1 + + false - - EndExperiment + GiveManualWaterRight + + + + + + + + + + + + UiCueGiveLeft + + + UpdateGlobalState + + + + Source1 - StartExperiment + GlobalAutoWaterState - + + + + Item2 + + + + + + it.SetLeft() + + GlobalAutoWaterState + + - - + + - - + + - - - - - - - - - - - - - - - - - - true - true - - - - - true - true - 1 - 2 - - - - - - - - true - true - 3 - 1 - - - - - - - - - TriggeredCamerasStream - - - - - - - - - - - true - true - 2 - 1 - - - - - - - true - true - 1 - 2 - - - Percent - 0.75 - - - Percent - 0.25 - - - - - - - - GlobalTrial + + UiCueGiveRight - - 2 - 16 + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetRight() + + + GlobalAutoWaterState + + + + + + + + + + + + + - - - true - true + + + true + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + IsFlushingValveLeft + + + GiveManualWaterRight + + + GiveManualWaterRight + + + GiveRewardRight + + + IsFlushingValveLeft + + + IsFlushingValveRight + + + UiKeepLeftOpen + + + UiKeepBothOpen + + + + + + KeepOpen + + + + Source1 + + + + + + + Source1 + + + + + + + + + + + 1 + + + + + + PT0.1S + + + + + + + + false + + + + + 500 + + + + + + + SetIsRightValveMs + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + + PT0.5S + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UiKeepRightOpen + + + + + + KeepOpen + + + + Source1 + + + + + + + Source1 + + + + + + + + + + + 1 + + + + + + PT0.1S + + + + + + + + true + + + + + 500 + + + + + + + SetIsRightValveMs + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + + PT0.5S + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UiDrainLeft + + + UiDrainBoth + + + + + + Flush + + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + false + + + + + 500 + + + + + + + SetIsRightValveMs + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + + PT0.5S + + + + + 5000 + + + + RigSchema + + + Calibration.WaterValveLeft + + + + + + RewardToTime + ((Item1 * 0.001) - Item2.Offset) / Item2.Slope + + + ToMilliseconds + + + + + 1000 + + + + DivideByEachOpen + Math.Ceiling(it / 500) + + + + + + + + + 300 + + + + + + + + false + + + + IsFlushingValveLeft + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DrainLeftComplete + + + UiDrainRight + + + + + + Flush + + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + true + + + + + 500 + + + + + + + SetIsRightValveMs + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + + PT0.5S + + + + + 5000 + + + + RigSchema + + + Calibration.WaterValveRight + + + + + + RewardToTime + ((Item1 * 0.001) - Item2.Offset) / Item2.Slope + + + ToMilliseconds + + + + + 1000 + + + + DivideByEachOpen + Math.Ceiling(it / 500) + + + + + + + + + 300 + + + + + + + + false + + + + IsFlushingValveRight + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DrainRightComplete + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VisualizerStructure + + + + + + + Frame + + + true + + + true + + + Ethograph + WidthStretch + 0 + + + Camera + WidthFixed + 320 + + + BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit + + 0 + 0 + + 0 + true + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + Behavior + + + true + + + Bias + + + true + + + Ethogram + + + + + + true + + + Camera + + + + + + true + + + true + 1 + Borders + + 0 + 0 + + 0 + + + Metadata + + + true + + + true + None + + + PreSession + true + pre-session + None + + + PreSession + + + IntraSession + true + intra-session + None + + + IntraSession + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Behavior1 + LickLeft + LickRight + TimedTrial + Behavior + + + Bias + TimedBias + + + PLACEHOLDER + + + + SessionInfo + + + + TimedTrial + + + Value.Trial.Metadata.Extra + + + + Placeholder + + + + + Placeholder + + + + + + + AsDictionary + + + + Source1 + + + + 1 + + + + Item1 + Item2 + + + + 1 + + + + + + + + + + + + + + SessionMetadata + + + + + + + + + + + + + + + + + Ethogram + + + EthogramEvents + + + + + + + + + true + + Break + 200 + + + QuiescentPeriod + Gold + 0.3 + + + ResponsePeriod + SandyBrown + 0.3 + + + RewardConsumptionPeriod + RosyBrown + 0.3 + + + ItiPeriod + Green + 0.3 + + + + + LickLeft + Red + 0.9 + 6 + Down + + + LickRight + Blue + 0.1 + 6 + Up + + + IsRightTriggerQuickRetract + DarkCyan + 0.5 + 6 + Plus + + + DeliverSecondaryReinforcer + Sienna + 0.5 + 6 + Plus + + + WaterRight + Red + 0.2 + 6 + Circle + + + WaterLeft + Blue + 0.8 + 6 + Circle + + + + + + + Camera + Camera1 + 53 + 215 + 2 + 0 + TriggeredCamerasStream + + + Camera + Camera2 + 53 + 215 + 2 + 0 + TriggeredCamerasStream + + + SessionSchema + + + Metadata + StartExperimentShortcut + EndExperiment + UiHabituationTimeUpdate + + + PreSession + UiKeepLeftOpen + UiKeepRightOpen + UiKeepBothOpen + UiDrainLeft + UiDrainRight + UiDrainBoth + UiManipulatorLeft + UiManipulatorForwardLeft + UiManipulatorForwardRight + UiManipulatorUp + UiManipulatorRight + UiManipulatorBackLeft + UiManipulatorBackRight + UiManipulatorDown + UiManipulatorStop + UiManipulatorHome + UiManipulatorInitialize + DrainLeftComplete + DrainRightComplete - - DynamicForaging - true - - - Maximized + + IntraSession + UiGiveLeft + UiGiveRight + UiMoveLeft + UiMoveRight + SessionMetadata + StartExperiment + UiCueGiveLeft + UiCueGiveRight - - + + + + + + + \ No newline at end of file diff --git a/src/main.bonsai b/src/main.bonsai index e70e7f65..a5e1dbe9 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -8,12 +8,6 @@ xmlns:p3="clr-namespace:System.Reactive;assembly=System.Reactive.Core" xmlns:p4="clr-namespace:AllenNeuralDynamics.AindBehaviorServices.DataTypes;assembly=AllenNeuralDynamics.AindBehaviorServices" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" - xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" - xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" - xmlns:p5="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" - xmlns:p6="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" - xmlns:p7="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" - xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -398,1905 +392,7 @@ - - Visualizers - - - - ImGuiContext - - - - - true - 1 - None - - 0 - 0 - - 0 - - - Frame - - - - - - - - - - - - DataTransformations - - - - GlobalTrialOutcome - - - HarpTimestampSource - - - TimedTrial - - - GlobalTrialMetrics - - - Bias - - - new (it as Bias) - - - HarpTimestampSource - - - TimedBias - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - HarpTimestampSource - - - LickRight - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - - HarpTimestampSource - - - LickLeft - - - SoftwareEvent - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - LickRight - - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - - - LickLeft - - - - GiveRewardRight - - - - - - Source1 - - - - - - - - - - - WaterRight - - - - GiveRewardRight - - - - - - - Source1 - - - - - - - - - - - WaterLeft - - - - - - - HarpTimestampSource - - - - - - - - - - - - EthogramEvents - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OutputControl - - - - Manipulator - - - - UiManipulatorLeft - - - MoveRelative - - - - Source1 - - - - -1 - 0 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorRight - - - MoveRelative - - - - Source1 - - - - 1 - 0 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorForwardLeft - - - MoveRelative - - - - Source1 - - - - 0 - 1 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorForwardRight - - - MoveRelative - - - - Source1 - - - - 0 - 0 - 1 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorBackLeft - - - MoveRelative - - - - Source1 - - - - 0 - -1 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorBackRight - - - MoveRelative - - - - Source1 - - - - 0 - 0 - -1 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorUp - - - MoveRelative - - - - Source1 - - - - 0 - 0 - 0 - 1 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorDown - - - MoveRelative - - - - Source1 - - - - 0 - 0 - 0 - -1 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorHome - - - Home - - - - Source1 - - - - HomeMotors - - - - - - - - - - - - UiManipulatorStop - - - StopMotors - - - - Source1 - - - - StopMotors - - - - - - - - - - - - UiManipulatorInitialize - - - GoToInitialPosition - - - - Source1 - - - - GoToInitialPosition - - - - - - - - - - - - OffsetGain - - - - - - - - - - - - - - - - - - - UiHabituationTimeUpdate - - - - 0.05 - - - - - 1 - - - - BumpSize - - - UiMoveLeft - - - BumpLeft - - - - Source1 - - - BumpSize - - - - - - Item2 - - - - -1 - - - - ManualSpoutDelta - - - - - - - - - - - - - - - UiMoveRight - - - BumpRight - - - - Source1 - - - BumpSize - - - - - - Item2 - - - ManualSpoutDelta - - - - - - - - - - - - - - UiGiveRight - - - TriggerRight - - - - Source1 - - - - true - - - - GiveManualWaterRight - - - - - - - - - - - - UiGiveLeft - - - TriggerLeft - - - - Source1 - - - - false - - - - GiveManualWaterRight - - - - - - - - - - - - UiCueGiveLeft - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetLeft() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - UiCueGiveRight - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetRight() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - - true - - - - IsFlushingValveLeft - - - GiveManualWaterRight - - - GiveManualWaterRight - - - GiveRewardRight - - - IsFlushingValveLeft - - - IsFlushingValveRight - - - UiKeepLeftOpen - - - UiKeepBothOpen - - - - - - KeepOpen - - - - Source1 - - - - - - - Source1 - - - - - - - - - - - 1 - - - - - - PT0.1S - - - - - - - - false - - - - - 500 - - - - - - - SetIsRightValveMs - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - - PT0.5S - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UiKeepRightOpen - - - - - - KeepOpen - - - - Source1 - - - - - - - Source1 - - - - - - - - - - - 1 - - - - - - PT0.1S - - - - - - - - true - - - - - 500 - - - - - - - SetIsRightValveMs - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - - PT0.5S - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UiDrainLeft - - - UiDrainBoth - - - - - - Flush - - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - false - - - - - 500 - - - - - - - SetIsRightValveMs - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - - PT0.5S - - - - - 5000 - - - - RigSchema - - - Calibration.WaterValveLeft - - - - - - RewardToTime - ((Item1 * 0.001) - Item2.Offset) / Item2.Slope - - - ToMilliseconds - - - - - 1000 - - - - DivideByEachOpen - Math.Ceiling(it / 500) - - - - - - - - - 300 - - - - - - - - false - - - - IsFlushingValveLeft - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DrainLeftComplete - - - UiDrainRight - - - - - - Flush - - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - true - - - - - 500 - - - - - - - SetIsRightValveMs - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - - PT0.5S - - - - - 5000 - - - - RigSchema - - - Calibration.WaterValveRight - - - - - - RewardToTime - ((Item1 * 0.001) - Item2.Offset) / Item2.Slope - - - ToMilliseconds - - - - - 1000 - - - - DivideByEachOpen - Math.Ceiling(it / 500) - - - - - - - - - 300 - - - - - - - - false - - - - IsFlushingValveRight - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DrainRightComplete - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - VisualizerStructure - - - - - - - Frame - - - true - - - true - - - Ethograph - WidthStretch - 0 - - - Camera - WidthFixed - 320 - - - BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit - - 0 - 0 - - 0 - true - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - Behavior - - - true - - - Bias - - - true - - - Ethogram - - - - - - true - - - Camera - - - - - - true - - - true - 1 - Borders - - 0 - 0 - - 0 - - - Metadata - - - true - - - true - None - - - PreSession - true - pre-session - None - - - PreSession - - - IntraSession - true - intra-session - None - - - IntraSession - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Behavior1 - LickLeft - LickRight - TimedTrial - Behavior - - - Bias - TimedBias - - - PLACEHOLDER - - - - SessionInfo - - - - TimedTrial - - - Value.Trial.Metadata.Extra - - - - Placeholder - - - - - Placeholder - - - - - - - AsDictionary - - - - Source1 - - - - 1 - - - - Item1 - Item2 - - - - 1 - - - - - - - - - - - - - - SessionMetadata - - - - - - - - - - - - - - - - - Ethogram - - - EthogramEvents - - - - - - - - - true - - Break - 200 - - - QuiescentPeriod - Gold - 0.3 - - - ResponsePeriod - SandyBrown - 0.3 - - - RewardConsumptionPeriod - RosyBrown - 0.3 - - - ItiPeriod - Green - 0.3 - - - - - LickLeft - Red - 0.9 - 6 - Down - - - LickRight - Blue - 0.1 - 6 - Up - - - IsRightTriggerQuickRetract - DarkCyan - 0.5 - 6 - Plus - - - DeliverSecondaryReinforcer - Sienna - 0.5 - 6 - Plus - - - WaterRight - Red - 0.2 - 6 - Circle - - - WaterLeft - Blue - 0.8 - 6 - Circle - - - - - - - Camera - Camera1 - 53 - 215 - 2 - 0 - TriggeredCamerasStream - - - Camera - Camera2 - 53 - 215 - 2 - 0 - TriggeredCamerasStream - - - SessionSchema - - - Metadata - StartExperimentShortcut - EndExperiment - UiHabituationTimeUpdate - - - PreSession - UiKeepLeftOpen - UiKeepRightOpen - UiKeepBothOpen - UiDrainLeft - UiDrainRight - UiDrainBoth - UiManipulatorLeft - UiManipulatorForwardLeft - UiManipulatorForwardRight - UiManipulatorUp - UiManipulatorRight - UiManipulatorBackLeft - UiManipulatorBackRight - UiManipulatorDown - UiManipulatorStop - UiManipulatorHome - UiManipulatorInitialize - DrainLeftComplete - DrainRightComplete - - - IntraSession - UiGiveLeft - UiGiveRight - UiMoveLeft - UiMoveRight - SessionMetadata - StartExperiment - UiCueGiveLeft - UiCueGiveRight - - - - - - - - - - - - - + diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai index 649253e6..92959ee1 100644 --- a/src/test_behavior_visualizer.bonsai +++ b/src/test_behavior_visualizer.bonsai @@ -1,20 +1,20 @@  + + CameraData + + + + + 0 + + + + + CameraFeed + + + + Camera1 + + + + CameraFeed + + + TimeBase + + + + + + + + + + + + + + + + + + + + + + + Camera1 + + + + + + + Camera2 + + + + CameraFeed + + + TimeBase + + + + + + + + + + + + + + + + + + + + + + + Camera2 + + + + + + + + + + Item2 + Item1 + + + TriggeredCamerasStream + + + + + + + + + + + + + + + + + + + TrialData @@ -87,7 +203,7 @@ - PT1.745S + PT2.277S @@ -809,7 +925,7 @@ - PT0.847S + PT0.637S @@ -982,1967 +1098,1812 @@ - CameraData + Visualizer - - - 0 - - + + + true + 1 + None + + 0 + 0 + + 0 - CameraFeed + Frame - - - Camera1 + + VisualizerStructure - - CameraFeed + + - TimeBase + Frame + + + true + + + true + + + Ethograph + WidthStretch + 0 + + + Camera + WidthFixed + 320 + + + BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit + + 0 + 0 + + 0 + true + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + Behavior + + + true + + + Bias + + + true + + + Ethogram - + + + + true + + + Camera - + + + + true + + + true + 1 + Borders + + 0 + 0 + + 0 + + + Metadata + + + true + + + true + None + + + PreSession + true + pre-session + None + + + PreSession + + + IntraSession + true + intra-session + None + + + IntraSession + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - Camera1 - - - - - - - Camera2 + + BehaviorVisualizer - - CameraFeed + + + + + + + + - - TimeBase - - - - - - - - - - - - - - - - - - - - - - - Camera2 - - - - - - - - - - Item2 - Item1 - - - TriggeredCamerasStream - - - - - - - - - - - - - - - - - - - - - - true - 1 - None - - 0 - 0 - - 0 - - - Frame - - - VisualizerStructure - - - - - - - Frame - - - true - - - true - - - Ethograph - WidthStretch - 0 - - - Camera - WidthFixed - 320 - - - BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit - - 0 - 0 - - 0 - true - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - Behavior - - - true - - - Bias - - - true - - - Ethogram - - - - - - true - - - Camera - - - - - - true - - - true - 1 - Borders - - 0 - 0 - - 0 - - - Metadata - - - true - - - true - None - - - PreSession - true - pre-session - None - - - PreSession - - - IntraSession - true - intra-session - None - - - IntraSession - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BehaviorVisualizer - - - - - - - - - - - - - BehaviorPlot - - - - - - - Behavior - - - - - - Behavior1 - true - 1 - None - - 0 - 0 - - 0 - - - true - - - EventPlot - true - - -1 - 150 - - NoTitle - AutoFit - RangeFit - - - EventPlot - - - true - - - ContinuousPlot - true - - -1 - 150 - - NoTitle - AutoFit - None - - - ContinuousPlot - - - - EventPlot - - - - - 0 - 1 - - - R - L - - West - None - - - - - - - ContinuousPlot - - - - - 0 - 1 - - - West - None - - - - - - - - - LickLeft - - - Value - - - - 0.9 - - - - new(it as LickLeft) - - - Seconds - - - - - - 1000 - Item2 - Item1.LickLeft - - - EventPlot - - - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - - - - LickRight - - - Value - - - - 0.1 - - - - new(it as LickRight) - - - Seconds - - - - - - 1000 - Item2 - Item1.LickRight - - - EventPlot - - - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - - - - TimedTrial - - - - - - Value.ChoiceCategory - - - NoChoice + + BehaviorPlot - - Source1 + + - - - NoChoice - + + Behavior - - - - - - - - - - - 0.5 - - - - LeftChoice - - - - Source1 + + - - - LeftChoice - + + Behavior1 + true + 1 + None + + 0 + 0 + + 0 - - - - - - - - - - - 0.85 - - - - RightChoice - - - - Source1 + + true + + + EventPlot + true + + -1 + 150 + + NoTitle + AutoFit + RangeFit + + + EventPlot + + + true + + + ContinuousPlot + true + + -1 + 150 + + NoTitle + AutoFit + None + + + ContinuousPlot + + + + EventPlot + + + + + 0 + 1 + + + R + L + + West + None + + + + + + + ContinuousPlot + + + + + 0 + 1 + + + West + None + + + + + + + + + LickLeft + + + Value + + + + 0.9 + + + + new(it as LickLeft) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickLeft + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + + + + LickRight + + + Value + + + + 0.1 + + + + new(it as LickRight) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickRight + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + - - - RightChoice - + + TimedTrial - - - - - - - - - - - 0.15 - - - - - - - new ( - it as Choice -) - - - Seconds - - - - - - - - - 1000 - Seconds - Value.Choice - - - EventPlot - - - - Circle - 3 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - 1 - 1 - - - - true - None - - - Value.TrialCategory - - - LeftRewarded - - - - Source1 + + - - - LeftRewarded - + + Value.ChoiceCategory - - - - - - - - - - - 0.8 - - - - RightRewarded - - - - Source1 + + NoChoice + + + + Source1 + + + + NoChoice + + + + + + + + + - - - RightRewarded - + + + 0.5 + - - - - - - - - - - - 0.2 - - - - - - - new ( + + LeftChoice + + + + Source1 + + + + LeftChoice + + + + + + + + + + + + + 0.85 + + + + RightChoice + + + + Source1 + + + + RightChoice + + + + + + + + + + + + + 0.15 + + + + + + + new ( it as Choice ) - - - - - - - - - 1000 - Seconds - Value.Choice - - - EventPlot - - - - Circle - 3 - 0 - 1 - 0 - 1 - 0 - 1 - 0 - 1 - 1 - - - - true - None - - - TimedTrial - - - 1000 - Seconds - Value.Trial.Metadata.PRewardLeft - - - - ContinuousPlot - - - - - - 1 - 0 - 0 - 1 - 2 - - - - - - true - None - - - - 1000 - Seconds - Value.Trial.Metadata.PRewardRight - - - - ContinuousPlot - - - - - - 0 - 0 - 1 - 1 - 2 - - - - - - true - None - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bias - TimedBias - - - OutputControl - - - - UiHabituationTimeUpdate - - - UiMoveLeft - - - UiGiveRight - - - UiGiveLeft - - - UiMoveRight - - - UiManipulatorLeft - - - UiManipulatorForwardLeft - - - UiManipulatorForwardRight - - - UiManipulatorUp - - - UiDrainLeft - - - UiDrainBoth - - - UiDrainRight - - - UiManipulatorRight - - - UiManipulatorBackRight - - - UiManipulatorBackLeft - - - UiManipulatorDown - - - UiManipulatorStop - - - UiManipulatorHome - - - UiManipulatorInitialize - - - StartExperimentShortcut - - - StartExperiment - - - EndExperiment - - - UiCueGiveRight - - - UiCueGiveLeft - - - UiKeepLeftOpen - - - UiKeepRightOpen - - - UiKeepBothOpen - - - DrainLeftComplete - - - DrainRightComplete - - - - - - - - - Ethogram - - - SoftwareEventHistory - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Break - 200 - - - TrialOutcome - CornflowerBlue - 0.3 - - - RewardPeriod - Crimson - 0.3 - - - ITI - Cyan - 0.3 - - - - - TrialOutcome - SaddleBrown - 0.5 - 2 - Circle - - - LickLeft - Red - 0.8 - 2 - Down - - - LickRight - DodgerBlue - 0.2 - 2 - Up - - - - - - - CameraPreviewVisualizer - - - - Source1 - - - - - - - - - - - - CameraPreview - - - - - - - Camera - - - true - 1 - None - - 0 - 0 - - 0 - - - Table - - - - - - TriggeredCamerasStream - - - - - - - - - Source1 - Key + Seconds - - - - - - Camera1 - - - - - - - - - - - - - - - - - CameraStream - - - Table - - - true - - - CameraStream - - - Value - - - OverlayAlpha - - - - - - - - - - - - - - - 53 - 215 - 0.5 - - - - - - - - 2 - - - - - - - Flipped - - - - Source1 + + - - Item2 + + - - - 2 - + + 1000 + Seconds + Value.Choice - - - - - - - - - - - Item1 - - - Item2 - - - - - - - - - Vertical - - - - NotFlipped - - - - Source1 + + EventPlot + + + + Circle + 3 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + + + + true + None - Item2 + Value.TrialCategory - - - 2 - + + LeftRewarded + + + + Source1 + + + + LeftRewarded + + + + + + + + + + + + + 0.8 + + + + RightRewarded + + + + Source1 + + + + RightRewarded + + + + + + + + + + + + + 0.2 + + + + + + + new ( + it as Choice +) + + + + + + + + + 1000 + Seconds + Value.Choice + + + EventPlot + + + + Circle + 3 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 1 + 1 + + + + true + None + + + TimedTrial + + + 1000 + Seconds + Value.Trial.Metadata.PRewardLeft + + + + ContinuousPlot + + + + + + 1 + 0 + 0 + 1 + 2 + + + + + + true + None + + + + 1000 + Seconds + Value.Trial.Metadata.PRewardRight + + + + ContinuousPlot + + + + + + 0 + 0 + 1 + 1 + 2 + + + + + + true + None + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - Item1 + + + + + + + + + + Bias + TimedBias + + + OutputControl + + + + UiHabituationTimeUpdate - - + + UiMoveLeft - - new ( - it.Size.Width / 2 as X, - it.Size.Height / 2 as Y -) + + UiGiveRight - - - - - + + UiGiveLeft - - - 320 - 240 - + + UiMoveRight - - - - + + UiManipulatorLeft - - + + UiManipulatorForwardLeft - - - - 320 - 240 - - - 0 - 0 - - 0 - - 1 - 1 - - + + UiManipulatorForwardRight - - - - + + UiManipulatorUp - - - 1,0,0;0,1,0 - Linear - - 0 - 0 - 0 - 0 - - + + UiDrainLeft - - Table + + UiDrainBoth - - - Rgba - Repeat - Repeat - Linear - Linear - + + UiDrainRight - - - - + + UiManipulatorRight - - PreviewImage - true - - 320 - 320 - - - 0 - 0 - - - 1 - 1 - + + UiManipulatorBackRight - - Table + + UiManipulatorBackLeft - - true + + UiManipulatorDown - - true - 1 - None - - 0 - 0 - - 0 + + UiManipulatorStop - - true + + UiManipulatorHome - - true - 2 - None - - 0 - 0 - - 0 + + UiManipulatorInitialize - - true + + StartExperimentShortcut - - true - Alpha + + StartExperiment - - true + + EndExperiment - - true - 0 - 1 - None - 0.5 + + UiCueGiveRight - - OverlayAlpha + + UiCueGiveLeft - - + + UiKeepLeftOpen - - + + UiKeepRightOpen + + + UiKeepBothOpen + + + DrainLeftComplete + + + DrainRightComplete - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Ethogram - - - - - - - - - - CameraPreviewVisualizer - - - - Source1 - - - - - - - - - + + SoftwareEventHistory - - CameraPreview + + + + + + + + true + + Break + 200 + + + TrialOutcome + CornflowerBlue + 0.3 + + + RewardPeriod + Crimson + 0.3 + + + ITI + Cyan + 0.3 + + + + + TrialOutcome + SaddleBrown + 0.5 + 2 + Circle + + + LickLeft + Red + 0.8 + 2 + Down + + + LickRight + DodgerBlue + 0.2 + 2 + Up + + + + + + + CameraPreviewVisualizer - - - - - Camera - - - true - 1 - None - - 0 - 0 - - 0 - - - Table - - - - - - TriggeredCamerasStream + + Source1 - + + + + + + + - + + CameraPreview - - Source1 + + + + + Camera + + + true + 1 + None + + 0 + 0 + + 0 + + + Table + + + + + + TriggeredCamerasStream + + + + + + + + + Source1 + + + Key + + + + + + + Camera1 + + + + + + + + + + + + + + + + + CameraStream + + + Table + + + true + + + CameraStream + + + Value + + + OverlayAlpha + + + + + + + + + + + + + + + 53 + 215 + 0.5 + + + + + + + + 2 + + + + + + + Flipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + Item1 + + + Item2 + + + + + + + + + Vertical + + + + NotFlipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + + + Item1 + + + + + + new ( + it.Size.Width / 2 as X, + it.Size.Height / 2 as Y +) + + + + + + + + + + 320 + 240 + + + + + + + + + + + + + + 320 + 240 + + + 0 + 0 + + 0 + + 1 + 1 + + + + + + + + + + + 1,0,0;0,1,0 + Linear + + 0 + 0 + 0 + 0 + + + + + Table + + + + Rgba + Repeat + Repeat + Linear + Linear + + + + + + + + + PreviewImage + true + + 320 + 320 + + + 0 + 0 + + + 1 + 1 + + + + Table + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 - - Key + + true - - + + true + Alpha + + + true + + + true + 0 + 1 + None + 0.5 - - - Camera2 - + + OverlayAlpha + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - CameraStream - - - Table + - - true - - - CameraStream - - - Value - - - OverlayAlpha - - - - - + + + + + + + + + + CameraPreviewVisualizer + + + + Source1 + + - - + + + - - - 53 - 215 - 0.5 - - - - - - - - 2 - - - - - - - Flipped + + CameraPreview - - Source1 + + + + + Camera + + + true + 1 + None + + 0 + 0 + + 0 + + + Table + + + + + + TriggeredCamerasStream + + + + + + + + + Source1 + + + Key + + + + + + + Camera2 + + + + + + + + + + + + + + + + + CameraStream + + + Table + + + true + + + CameraStream - Item2 + Value + + + OverlayAlpha + + + + + + + + + + + + + + + 53 + 215 + 0.5 + + + + - - + + 2 - + - - - - - - - - - - - Item1 - - - Item2 - - - - - - - - - Vertical - - - - NotFlipped - - - - Source1 + + + + + Flipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + Item1 Item2 - - - 2 - + + + + + + + + Vertical + + + + NotFlipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + + + Item1 + + + + + + new ( + it.Size.Width / 2 as X, + it.Size.Height / 2 as Y +) + + + + + + + + + + 320 + 240 + + + + + + + + + + + + + + 320 + 240 + + + 0 + 0 + + 0 + + 1 + 1 + + + + + + + + + + + 1,0,0;0,1,0 + Linear + + 0 + 0 + 0 + 0 + + + + + Table + + + + Rgba + Repeat + Repeat + Linear + Linear + + + + + + + + + PreviewImage + true + + 320 + 320 + + + 0 + 0 + + + 1 + 1 + + + + Table + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Alpha + + + true + + + true + 0 + 1 + None + 0.5 + + + OverlayAlpha + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - Item1 - - - - - - new ( - it.Size.Width / 2 as X, - it.Size.Height / 2 as Y -) - - - - - - - - - - 320 - 240 - - - - - - - - - - - - - - 320 - 240 - - - 0 - 0 - - 0 - - 1 - 1 - - - - - - - - - - - 1,0,0;0,1,0 - Linear - - 0 - 0 - 0 - 0 - - - - - Table - - - - Rgba - Repeat - Repeat - Linear - Linear - - - - - - - - - PreviewImage - true - - 320 - 320 - - - 0 - 0 - - - 1 - 1 - - - - Table - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - Alpha - - - true - - - true - 0 - 1 - None - 0.5 - - - OverlayAlpha - - - - - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + SessionInfo + + + Metadata + StartExperimentShortcut + EndExperiment + UiHabituationTimeUpdate + + + PreSession + UiKeepLeftOpen + UiKeepRightOpen + UiKeepBothOpen + UiDrainLeft + UiDrainRight + UiDrainBoth + UiManipulatorLeft + UiManipulatorForwardLeft + UiManipulatorForwardRight + UiManipulatorUp + UiManipulatorRight + UiManipulatorBackLeft + UiManipulatorBackRight + UiManipulatorDown + UiManipulatorStop + UiManipulatorHome + UiManipulatorInitialize + DrainLeftComplete + DrainRightComplete + + + IntraSession + UiGiveLeft + UiGiveRight + UiMoveLeft + UiMoveRight + SessionMetadata + StartExperiment + UiCueGiveLeft + UiCueGiveRight - - - + + + + + + + + - - SessionInfo - - - Metadata - StartExperimentShortcut - EndExperiment - UiHabituationTimeUpdate - - - PreSession - UiKeepLeftOpen - UiKeepRightOpen - UiKeepBothOpen - UiDrainLeft - UiDrainRight - UiDrainBoth - UiManipulatorLeft - UiManipulatorForwardLeft - UiManipulatorForwardRight - UiManipulatorUp - UiManipulatorRight - UiManipulatorBackLeft - UiManipulatorBackRight - UiManipulatorDown - UiManipulatorStop - UiManipulatorHome - UiManipulatorInitialize - DrainLeftComplete - DrainRightComplete - - - IntraSession - UiGiveLeft - UiGiveRight - UiMoveLeft - UiMoveRight - SessionMetadata - StartExperiment - UiCueGiveLeft - UiCueGiveRight - - - - - - - - - - - + \ No newline at end of file From 875acf5893fec8edc7f73d6faef8f1f6d8d4cb75 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 5 Aug 2026 16:28:11 +0100 Subject: [PATCH 081/116] Remove redundant test workflows --- .bonsai/Settings/src/test_visualizer.editor | 37 + .bonsai/Settings/src/test_visualizer.layout | 2 + src/test_behavior_visualizer.bonsai | 2909 ----------- src/test_bias_visualizer.bonsai | 641 --- src/test_ethogram.bonsai | 455 -- src/test_table_sizing.bonsai | 107 - src/test_visualizer.bonsai | 5232 ++++++++++--------- 7 files changed, 2933 insertions(+), 6450 deletions(-) create mode 100644 .bonsai/Settings/src/test_visualizer.editor create mode 100644 .bonsai/Settings/src/test_visualizer.layout delete mode 100644 src/test_behavior_visualizer.bonsai delete mode 100644 src/test_bias_visualizer.bonsai delete mode 100644 src/test_ethogram.bonsai delete mode 100644 src/test_table_sizing.bonsai diff --git a/.bonsai/Settings/src/test_visualizer.editor b/.bonsai/Settings/src/test_visualizer.editor new file mode 100644 index 00000000..a16eb316 --- /dev/null +++ b/.bonsai/Settings/src/test_visualizer.editor @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.bonsai/Settings/src/test_visualizer.layout b/.bonsai/Settings/src/test_visualizer.layout new file mode 100644 index 00000000..0829d87c --- /dev/null +++ b/.bonsai/Settings/src/test_visualizer.layout @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/test_behavior_visualizer.bonsai b/src/test_behavior_visualizer.bonsai deleted file mode 100644 index 92959ee1..00000000 --- a/src/test_behavior_visualizer.bonsai +++ /dev/null @@ -1,2909 +0,0 @@ - - - - - - CameraData - - - - - 0 - - - - - CameraFeed - - - - Camera1 - - - - CameraFeed - - - TimeBase - - - - - - - - - - - - - - - - - - - - - - - Camera1 - - - - - - - Camera2 - - - - CameraFeed - - - TimeBase - - - - - - - - - - - - - - - - - - - - - - - Camera2 - - - - - - - - - - Item2 - Item1 - - - TriggeredCamerasStream - - - - - - - - - - - - - - - - - - - - - TrialData - - - - - A - false - - - - - TimeBase - - - LickLeft - - - - 0 - 0 - 0 - 0 - - - - ManipulatorPosition - - - - 0 - - - - OffsetGain - - - - PT1S - - - - - - - - 0 - 3 - - - - - - - - - - - - - - - - PT2.277S - - - - - 0 - - - - - ResponsePeriod - - - - SoftwareEvent - - - - - - - - - - - - - - - - - - - - - 0 - 3 - - - - - - - - - - - - - - - - PT0.609S - - - - - 0 - - - - - RewardPeriod - - - - SoftwareEvent - - - - - - - - - - - - - - - - - - PT2S - - - - - - false - - - - - TrialOutcome - - - - SoftwareEvent - - - - - - - 0 - 3 - - - - - - - - - - - - - - - - PT2.764S - - - - - 0 - - - - - ITI - - - - SoftwareEvent - - - - - - - - - - - - - - - - - - PT0S - - - - - Break - - - - SoftwareEvent - - - - - - SoftwareEvent - - - TimeBase - - - - - - - - - - - - - - - - - - SoftwareEventHistory - - - - PT5S - - - - - Expo - - - - - 1 - - - - - - - - - - - - - 0.13.5 - 0.13.5 - Task6 - 0001-01-01T00:00:00.0000000+00:00 - Stage1 - Plimbo - false - false - - - - - - - - M - false - - - - - Expo - - - - - 1 - - - - - - - - - - - - - 0.13.5 - 0.13.5 - Task7 - 0001-01-01T00:00:00.0000000+00:00 - Stage2 - Plimbo - false - false - - - - - - - - - - SessionInfo - - - - TimeElapsed - - - - - PT0S - PT1S - - - - - 1 - - - - - Convert.ToString(it) - - - - - - - CurrentTrial - - - - TimedTrial - - - - - - Index - - - Convert.ToString(it) - - - - - - - - - - - - Source1 - - - Item1 - - - Item2 - - - - - - - 2 - - - - Item1 - Item2 - - - - 1 - - - - - - - - - - - - - - - - - - SessionMetadata - - - TimedTrial - - - BiasRandom - - - - - - Item2 - - - - - - - it > 1 ? 1 : it - - - it < -1 ? -1 : it - - - new (it as Bias) - - - Seconds - - - - - - - - - TimedBias - - - - S - false - - - - - TimeBase - - - LickRight - - - - - - - - - 0.1 - 1 - - - - Random - - - - - - - - - -0.1 - 0.1 - - - - BiasRandom - - - - PT0S - PT0.01S - - - - - 0.01 - - - - - TimeBase - - - - 0 - 1 - - - - - 500 - - - - - 0.5 - - - - - 0 - 500 - - - - - 0 - 1 - 0 - 0.05 - Linear - - - - - 3.14 - - - - - - - (it +1) * 0.5 - - - - 0 - 1 - - - - - 500 - - - - - 0.5 - - - - it - - - - - - - - - true - - - - - 0 - 1 - - - - - 500 - - - - - 0.9 - - - - - - - - - - - - Item3 ? Item2 : Item1 - - - - 0 - 500 - - - - - 0 - 1 - 0 - 0.05 - Linear - - - - - - - (it +1) * 0.5 - - - - 0 - 1 - - - - - 500 - - - - - 0.5 - - - - - - - - - - - - - - - - - - - - 0 - 1 - - - - - 500 - - - - - 0.5 - - - - - - - - - - true - - - - - - - - - - 0 - 1 - - - - - 500 - - - - - 0.05 - - - - - - - Item3 ? Item1 : Item2 - - - - - - Item2 - - - - - - - - - 0.59164587077011477 - 0.40913708100521279 - 5 - 0 - 5 - 0.5 - 5 - - 0 - - - - - - - - - - true - false - - - - SampleTrial - - - - Source1 - - - Random - - - - - - TimeSpan.FromSeconds(it) - - - - - - - - - PT0.637S - - - - - 1 - - - - - - - - - - - - - - - - - - - - TimeBase - - - - - - - - - TimedTrial - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Visualizer - - - - - true - 1 - None - - 0 - 0 - - 0 - - - Frame - - - VisualizerStructure - - - - - - - Frame - - - true - - - true - - - Ethograph - WidthStretch - 0 - - - Camera - WidthFixed - 320 - - - BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit - - 0 - 0 - - 0 - true - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - Behavior - - - true - - - Bias - - - true - - - Ethogram - - - - - - true - - - Camera - - - - - - true - - - true - 1 - Borders - - 0 - 0 - - 0 - - - Metadata - - - true - - - true - None - - - PreSession - true - pre-session - None - - - PreSession - - - IntraSession - true - intra-session - None - - - IntraSession - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BehaviorVisualizer - - - - - - - - - - - - - BehaviorPlot - - - - - - - Behavior - - - - - - Behavior1 - true - 1 - None - - 0 - 0 - - 0 - - - true - - - EventPlot - true - - -1 - 150 - - NoTitle - AutoFit - RangeFit - - - EventPlot - - - true - - - ContinuousPlot - true - - -1 - 150 - - NoTitle - AutoFit - None - - - ContinuousPlot - - - - EventPlot - - - - - 0 - 1 - - - R - L - - West - None - - - - - - - ContinuousPlot - - - - - 0 - 1 - - - West - None - - - - - - - - - LickLeft - - - Value - - - - 0.9 - - - - new(it as LickLeft) - - - Seconds - - - - - - 1000 - Item2 - Item1.LickLeft - - - EventPlot - - - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - - - - LickRight - - - Value - - - - 0.1 - - - - new(it as LickRight) - - - Seconds - - - - - - 1000 - Item2 - Item1.LickRight - - - EventPlot - - - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - - - - TimedTrial - - - - - - Value.ChoiceCategory - - - NoChoice - - - - Source1 - - - - NoChoice - - - - - - - - - - - - - 0.5 - - - - LeftChoice - - - - Source1 - - - - LeftChoice - - - - - - - - - - - - - 0.85 - - - - RightChoice - - - - Source1 - - - - RightChoice - - - - - - - - - - - - - 0.15 - - - - - - - new ( - it as Choice -) - - - Seconds - - - - - - - - - 1000 - Seconds - Value.Choice - - - EventPlot - - - - Circle - 3 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - 1 - 1 - - - - true - None - - - Value.TrialCategory - - - LeftRewarded - - - - Source1 - - - - LeftRewarded - - - - - - - - - - - - - 0.8 - - - - RightRewarded - - - - Source1 - - - - RightRewarded - - - - - - - - - - - - - 0.2 - - - - - - - new ( - it as Choice -) - - - - - - - - - 1000 - Seconds - Value.Choice - - - EventPlot - - - - Circle - 3 - 0 - 1 - 0 - 1 - 0 - 1 - 0 - 1 - 1 - - - - true - None - - - TimedTrial - - - 1000 - Seconds - Value.Trial.Metadata.PRewardLeft - - - - ContinuousPlot - - - - - - 1 - 0 - 0 - 1 - 2 - - - - - - true - None - - - - 1000 - Seconds - Value.Trial.Metadata.PRewardRight - - - - ContinuousPlot - - - - - - 0 - 0 - 1 - 1 - 2 - - - - - - true - None - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bias - TimedBias - - - OutputControl - - - - UiHabituationTimeUpdate - - - UiMoveLeft - - - UiGiveRight - - - UiGiveLeft - - - UiMoveRight - - - UiManipulatorLeft - - - UiManipulatorForwardLeft - - - UiManipulatorForwardRight - - - UiManipulatorUp - - - UiDrainLeft - - - UiDrainBoth - - - UiDrainRight - - - UiManipulatorRight - - - UiManipulatorBackRight - - - UiManipulatorBackLeft - - - UiManipulatorDown - - - UiManipulatorStop - - - UiManipulatorHome - - - UiManipulatorInitialize - - - StartExperimentShortcut - - - StartExperiment - - - EndExperiment - - - UiCueGiveRight - - - UiCueGiveLeft - - - UiKeepLeftOpen - - - UiKeepRightOpen - - - UiKeepBothOpen - - - DrainLeftComplete - - - DrainRightComplete - - - - - - - - - Ethogram - - - SoftwareEventHistory - - - - - - - - - true - - Break - 200 - - - TrialOutcome - CornflowerBlue - 0.3 - - - RewardPeriod - Crimson - 0.3 - - - ITI - Cyan - 0.3 - - - - - TrialOutcome - SaddleBrown - 0.5 - 2 - Circle - - - LickLeft - Red - 0.8 - 2 - Down - - - LickRight - DodgerBlue - 0.2 - 2 - Up - - - - - - - CameraPreviewVisualizer - - - - Source1 - - - - - - - - - - - - CameraPreview - - - - - - - Camera - - - true - 1 - None - - 0 - 0 - - 0 - - - Table - - - - - - TriggeredCamerasStream - - - - - - - - - Source1 - - - Key - - - - - - - Camera1 - - - - - - - - - - - - - - - - - CameraStream - - - Table - - - true - - - CameraStream - - - Value - - - OverlayAlpha - - - - - - - - - - - - - - - 53 - 215 - 0.5 - - - - - - - - 2 - - - - - - - Flipped - - - - Source1 - - - Item2 - - - - 2 - - - - - - - - - - - - - Item1 - - - Item2 - - - - - - - - - Vertical - - - - NotFlipped - - - - Source1 - - - Item2 - - - - 2 - - - - - - - - - - - - - - - Item1 - - - - - - new ( - it.Size.Width / 2 as X, - it.Size.Height / 2 as Y -) - - - - - - - - - - 320 - 240 - - - - - - - - - - - - - - 320 - 240 - - - 0 - 0 - - 0 - - 1 - 1 - - - - - - - - - - - 1,0,0;0,1,0 - Linear - - 0 - 0 - 0 - 0 - - - - - Table - - - - Rgba - Repeat - Repeat - Linear - Linear - - - - - - - - - PreviewImage - true - - 320 - 320 - - - 0 - 0 - - - 1 - 1 - - - - Table - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - Alpha - - - true - - - true - 0 - 1 - None - 0.5 - - - OverlayAlpha - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CameraPreviewVisualizer - - - - Source1 - - - - - - - - - - - - CameraPreview - - - - - - - Camera - - - true - 1 - None - - 0 - 0 - - 0 - - - Table - - - - - - TriggeredCamerasStream - - - - - - - - - Source1 - - - Key - - - - - - - Camera2 - - - - - - - - - - - - - - - - - CameraStream - - - Table - - - true - - - CameraStream - - - Value - - - OverlayAlpha - - - - - - - - - - - - - - - 53 - 215 - 0.5 - - - - - - - - 2 - - - - - - - Flipped - - - - Source1 - - - Item2 - - - - 2 - - - - - - - - - - - - - Item1 - - - Item2 - - - - - - - - - Vertical - - - - NotFlipped - - - - Source1 - - - Item2 - - - - 2 - - - - - - - - - - - - - - - Item1 - - - - - - new ( - it.Size.Width / 2 as X, - it.Size.Height / 2 as Y -) - - - - - - - - - - 320 - 240 - - - - - - - - - - - - - - 320 - 240 - - - 0 - 0 - - 0 - - 1 - 1 - - - - - - - - - - - 1,0,0;0,1,0 - Linear - - 0 - 0 - 0 - 0 - - - - - Table - - - - Rgba - Repeat - Repeat - Linear - Linear - - - - - - - - - PreviewImage - true - - 320 - 320 - - - 0 - 0 - - - 1 - 1 - - - - Table - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - Alpha - - - true - - - true - 0 - 1 - None - 0.5 - - - OverlayAlpha - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SessionInfo - - - Metadata - StartExperimentShortcut - EndExperiment - UiHabituationTimeUpdate - - - PreSession - UiKeepLeftOpen - UiKeepRightOpen - UiKeepBothOpen - UiDrainLeft - UiDrainRight - UiDrainBoth - UiManipulatorLeft - UiManipulatorForwardLeft - UiManipulatorForwardRight - UiManipulatorUp - UiManipulatorRight - UiManipulatorBackLeft - UiManipulatorBackRight - UiManipulatorDown - UiManipulatorStop - UiManipulatorHome - UiManipulatorInitialize - DrainLeftComplete - DrainRightComplete - - - IntraSession - UiGiveLeft - UiGiveRight - UiMoveLeft - UiMoveRight - SessionMetadata - StartExperiment - UiCueGiveLeft - UiCueGiveRight - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test_bias_visualizer.bonsai b/src/test_bias_visualizer.bonsai deleted file mode 100644 index 828022a0..00000000 --- a/src/test_bias_visualizer.bonsai +++ /dev/null @@ -1,641 +0,0 @@ - - - - - - - Frame - - - CameraData - - - - - 0 - - - - - CameraFeed - - - - Camera1 - - - - CameraFeed - - - TimeBase - - - - - - - - - - - - - - - - - - - - - - - Camera1 - - - - - - - Camera2 - - - - CameraFeed - - - TimeBase - - - - - - - - - - - - - - - - - - - - - - - Camera2 - - - - - - - - - - Item2 - Item1 - - - TriggeredCamerasStream - - - - - - - - - - - - - - - - - - - - - TrialData - - - - - A - false - - - - - TimeBase - - - LickLeft - - - - S - false - - - - - TimeBase - - - LickRight - - - - - - - - - 0.1 - 1 - - - - Random - - - - - - - - - -0.1 - 0.1 - - - - BiasRandom - - - - PT0S - PT0.01S - - - - - 0.01 - - - - - TimeBase - - - - 0 - 1 - - - - - 500 - - - - - 0.5 - - - - - 0 - 500 - - - - - 0 - 1 - 0 - 0.05 - Linear - - - - - 3.14 - - - - - - - (it +1) * 0.5 - - - - 0 - 1 - - - - - 500 - - - - - 0.5 - - - - it - - - - - - - - - false - - - - - 0 - 1 - - - - - 500 - - - - - 0.9 - - - - - - - - - - - - Item3 ? Item2 : Item1 - - - - 0 - 500 - - - - - 0 - 1 - 0 - 0.05 - Linear - - - - - - - (it +1) * 0.5 - - - - 0 - 1 - - - - - 500 - - - - - 0.5 - - - - - - - - - - - - - - - - - - - - 0 - 1 - - - - - 500 - - - - - 0.5 - - - - - - - - - - true - - - - - - - - - - 0 - 1 - - - - - 500 - - - - - 0.05 - - - - - - - Item3 ? Item1 : Item2 - - - - - - Item2 - - - - - - - - - 0.59164587077011477 - 0.40913708100521279 - 5 - 0 - 5 - 0.5 - 5 - - 0 - - - - - - - - - - false - false - - - - SampleTrial - - - - Source1 - - - Random - - - - - - TimeSpan.FromSeconds(it) - - - - - - - - - PT0.151S - - - - - 1 - - - - - - - - - - - - - - - - - - - - TimeBase - - - - - - - - - TimedTrial - - - TimedTrial - - - BiasRandom - - - - - - Item2 - - - - - - - it > 1 ? 1 : it - - - it < -1 ? -1 : it - - - new (it as Bias) - - - Seconds - - - - - - - - - TimedBias - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Frame - TimedBias - - - - - - - \ No newline at end of file diff --git a/src/test_ethogram.bonsai b/src/test_ethogram.bonsai deleted file mode 100644 index dfdccaad..00000000 --- a/src/test_ethogram.bonsai +++ /dev/null @@ -1,455 +0,0 @@ - - - - - - - Frame - - - - PT1S - - - - - - - - 0 - 3 - - - - - - - - - - - - - - - - PT2.266S - - - - - 0 - - - - - ResponsePeriod - - - - SoftwareEvent - - - - - - - - - - - - - - - - - - - - - 0 - 3 - - - - - - - - - - - - - - - - PT1.529S - - - - - 0 - - - - - RewardPeriod - - - - SoftwareEvent - - - - - - - - - - - - - - - - - - PT2S - - - - - - false - - - - - TrialOutcome - - - - SoftwareEvent - - - - - - - 0 - 3 - - - - - - - - - - - - - - - - PT1.415S - - - - - 0 - - - - - ITI - - - - SoftwareEvent - - - - - - - - - - - - - - - - - - PT0S - - - - - Break - - - - SoftwareEvent - - - - - - SoftwareEvent - - - - PT0S - PT0.05S - - - - - 0 - 1 - 0 - 0.1 - Linear - - - - Tick - - - - - - - - - - - - - - - - - - SoftwareEventHistory - - - Frame - - - SoftwareEventHistory - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Break - - - TrialOutcome - CornflowerBlue - 0.3 - - - RewardPeriod - Crimson - 0.3 - - - ITI - Cyan - 0.3 - - - - - TrialOutcome - SaddleBrown - 0.5 - 6 - Circle - - - LickLeft - Red - 0.8 - 6 - Down - - - LickRight - DodgerBlue - 0.2 - 6 - Up - - - - - - - 640 - 480 - On - false - Black - DepthBufferBit ColorBufferBit - true - - Resizable - Normal - Primary - 60 - - - - - 8 - 8 - 8 - 8 - - 16 - 0 - 0 - - 0 - 0 - 0 - 0 - - 2 - false - - - - - - A - - - - - - LickLeft - - - - SoftwareEvent - - - - S - - - - - - LickRight - - - - SoftwareEvent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test_table_sizing.bonsai b/src/test_table_sizing.bonsai deleted file mode 100644 index b150d170..00000000 --- a/src/test_table_sizing.bonsai +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - Frame - - - Frame - - - true - - - AAA - WidthStretch - 0 - - - BBB - WidthFixed - 0 - - - Resizable BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit - - 0 - 0 - - 0 - - - true - - - true - TESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTEST - - - true - - - true - TEST - - - - Frame - - - - - true - 2 - Borders - - 0 - 0 - - 0 - - - - - true - - - - - true - TEST - - - - - true - - - - - true - TESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTEST - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test_visualizer.bonsai b/src/test_visualizer.bonsai index 50e0322e..92959ee1 100644 --- a/src/test_visualizer.bonsai +++ b/src/test_visualizer.bonsai @@ -1,2353 +1,2909 @@  - - - 0 - 1 - - - - - 500 - - - - - 0.5 - - - - - 0 - 500 - - - - - 0 - 1 - 0 - 0.05 - Linear - - - - - 3.14 - - - - - - - (it +1) * 0.5 - - - - 0 - 1 - - - - - 500 - - - - - 0.5 - - - - it - - - - - - - - - true - - - - - 0 - 1 - - - - - 500 - - - - - 0.9 - - - - - - - - - - - - Item3 ? Item2 : Item1 - - - - 0 - 500 - - - - - 0 - 1 - 0 - 0.05 - Linear - - - - - - - (it +1) * 0.5 - - - - 0 - 1 - - - - - 500 - - - - - 0.5 - - - - - - - - - - - - - - - - - - - - 0 - 1 - - - - - 500 - - - - - 0.5 - - - - - - - - - - false - - - - - - - - - - 0 - 1 - - - - - 500 - - - - - 0.05 - - - - - - - Item3 ? Item1 : Item2 - - - - - - Item2 - - - - - - - - - 0.59164587077011477 - 0.40913708100521279 - 5 - 0 - 5 - 0.5 - 5 - - 0 - - - - - - - - - - true - false - - - - - 500 - - - - - - - TrialOutcomes - - - - Frame - - - Frame - - - TrialOutcomes + + CameraData + + + + + 0 + + + + + CameraFeed + + + + Camera1 + + + + CameraFeed + + + TimeBase + + + + + + + + + + + + + + + + + + + + + + + Camera1 + + + + + + + Camera2 + + + + CameraFeed + + + TimeBase + + + + + + + + + + + + + + + + + + + + + + + Camera2 + + + + + + + + + + Item2 + Item1 + + + TriggeredCamerasStream + + + + + + + + + + + + + + + + + + - - - - + + TrialData + + + + + A + false + + + + + TimeBase + + + LickLeft + + + + 0 + 0 + 0 + 0 + + + + ManipulatorPosition + + + + 0 + + + + OffsetGain + + + + PT1S + + + + + + + + 0 + 3 + + + + + + + + + + + + + + + + PT2.277S + + + + + 0 + + + + + ResponsePeriod + + + + SoftwareEvent + + + + + + + + + + + + + + + + + + + + + 0 + 3 + + + + + + + + + + + + + + + + PT0.609S + + + + + 0 + + + + + RewardPeriod + + + + SoftwareEvent + + + + + + + + + + + + + + + + + + PT2S + + + + + + false + + + + + TrialOutcome + + + + SoftwareEvent + + + + + + + 0 + 3 + + + + + + + + + + + + + + + + PT2.764S + + + + + 0 + + + + + ITI + + + + SoftwareEvent + + + + + + + + + + + + + + + + + + PT0S + + + + + Break + + + + SoftwareEvent + + + + + + SoftwareEvent + + + TimeBase + + + + + + + + + + + + + + + + + + SoftwareEventHistory + + + + PT5S + + + + + Expo + + + + + 1 + + + + + + + + + + + + + 0.13.5 + 0.13.5 + Task6 + 0001-01-01T00:00:00.0000000+00:00 + Stage1 + Plimbo + false + false + + + + + + + + M + false + + + + + Expo + + + + + 1 + + + + + + + + + + + + + 0.13.5 + 0.13.5 + Task7 + 0001-01-01T00:00:00.0000000+00:00 + Stage2 + Plimbo + false + false + + + + + + + + + + SessionInfo + + + + TimeElapsed + + + + + PT0S + PT1S + + + + + 1 + + + + + Convert.ToString(it) + + + + + + + CurrentTrial + + + + TimedTrial + + + + + + Index + + + Convert.ToString(it) + + + + + + + + + + + + Source1 + + + Item1 + + + Item2 + + + + + + + 2 + + + + Item1 + Item2 + + + + 1 + + + + + + + + + + + + + + + + + + SessionMetadata + + + TimedTrial + + + BiasRandom + + + + + + Item2 + + + + + + + it > 1 ? 1 : it + + + it < -1 ? -1 : it + + + new (it as Bias) + + + Seconds + + + + + + + + + TimedBias + + + + S + false + + + + + TimeBase + + + LickRight + + + + + + + + + 0.1 + 1 + + + + Random + + + + + + + + + -0.1 + 0.1 + + + + BiasRandom + + + + PT0S + PT0.01S + + + + + 0.01 + + + + + TimeBase + + + + 0 + 1 + + + + + 500 + + + + + 0.5 + + + + + 0 + 500 + + + + + 0 + 1 + 0 + 0.05 + Linear + + + + + 3.14 + + + + + + + (it +1) * 0.5 + + + + 0 + 1 + + + + + 500 + + + + + 0.5 + + + + it + + + + + + + + + true + + + + + 0 + 1 + + + + + 500 + + + + + 0.9 + + + + + + + + + + + + Item3 ? Item2 : Item1 + + + + 0 + 500 + + + + + 0 + 1 + 0 + 0.05 + Linear + + + + + + + (it +1) * 0.5 + + + + 0 + 1 + + + + + 500 + + + + + 0.5 + + + + + + + + + + + + + + + + + + + + 0 + 1 + + + + + 500 + + + + + 0.5 + + + + + + + + + + true + + + + + + + + + + 0 + 1 + + + + + 500 + + + + + 0.05 + + + + + + + Item3 ? Item1 : Item2 + + + + + + Item2 + + + + + + + + + 0.59164587077011477 + 0.40913708100521279 + 5 + 0 + 5 + 0.5 + 5 + + 0 + + + + + + + + + + true + false + + + + SampleTrial + + + + Source1 + + + Random + + + + + + TimeSpan.FromSeconds(it) + + + + + + + + + PT0.637S + + + + + 1 + + + + + + + + + + + + + + + + + + + + TimeBase + + + + + + + + + TimedTrial + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - true - - - true - false - - - false - false - - - false - false - - - true - false - - - true - true - - - true - true - - - true - false - - - false - false - - - false - false - - - true - false - - - true - false - - - false - true - - - false - false - - - false - true - - - true - true - - - true - true - - - false - true - - - true - false - - - false - false - - - false - true - - - false - false - - - false - true - - - true - true - - - true - false - - - true - false - - - true - false - - - true - false - - - true - false - - - true - false - - - - false - - - true - false - - - false - true - - - false - true - - - true - true - - - false - false - - - true - true - - - true - true - - - - true - - - true - true - - - false - false - - - false - true - - - false - true - - - true - true - - - false - false - - - - false - - - false - true - - - true - true - - - false - true - - - false - true - - - false - true - - - false - true - - - false - false - - - false - true - - - false - false - - - false - false - - - true - true - - - false - false - - - true - true - - - - false - - - true - true - - - true - false - - - true - false - - - false - false - - - false - false - - - false - false - - - false - false - - - - false - - - false - true - - - true - true - - - true - true - - - false - true - - - true - false - - - true - true - - - false - true - - - false - true - - - false - true - - - - true - - - true - true - - - true - false - - - true - false - - - false - false - - - true - false - - - true - false - - - true - false - - - true - false - - - false - true - - - false - false - - - - true - - - true - false - - - true - true - - - false - false - - - false - false - - - false - false - - - true - true - - - false - true - - - false - false - - - true - true - - - true - true - - - true - true - - - false - true - - - true - true - - - false - false - - - false - false - - - false - true - - - - false - - - false - true - - - true - true - - - true - true - - - false - false - - - true - true - - - false - true - - - true - true - - - - true - - - false - true - - - true - true - - - - true - - - true - true - - - false - true - - - false - false - - - false - true - - - false - false - - - - false - - - false - true - - - false - false - - - true - false - - - false - false - - - true - true - - - false - true - - - false - true - - - true - true - - - false - true - - - false - false - - - - true - - - true - false - - - true - true - - - true - false - - - false - false - - - true - true - - - true - false - - - true - false - - - true - true - - - false - true - - - false - false - - - false - false - - - true - true - - - - true - - - false - true - - - true - false - - - false - false - - - true - true - - - true - false - - - - true - - - false - false - - - false - false - - - - true - - - false - false - - - true - false - - - false - false - - - true - false - - - true - true - - - false - false - - - false - false - - - false - true - - - true - false - - - false - true - - - - true - - - false - true - - - false - false - - - true - false - - - true - true - - - false - true - - - false - false - - - true - true - - - false - false - - - true - true - - - true - false - - - false - false - - - - false - - - false - true - - - false - true - - - true - true - - - false - false - - - false - true - - - true - false - - - - false - - - true - false - - - true - true - - - false - false - - - true - true - - - true - true - - - true - true - - - false - true - - - false - true - - - true - true - - - false - true - - - false - true - - - false - true - - - false - true - - - false - false - - - true - true - - - false - true - - - false - true - - - - false - - - false - true - - - false - true - - - false - false - - - true - false - - - false - false - - - true - true - - - false - false - - - true - true - - - true - false - - - true - true - - - false - false - - - false - true - - - false - true - - - false - true - - - true - true - - - true - false - - - false - true - - - false - false - - - false - false - - - false - false - - - true - false - - - false - true - - - false - false - - - - false - - - false - false - - - - false - - - true - false - - - true - true - - - true - false - - - - false - - - true - true - - - - true - - - true - false - - - false - true - - - true - true - - - false - false - - - true - true - - - false - false - - - false - true - - - true - true - - - true - true - - - true - true - - - false - true - - - false - false - - - true - false - - - true - true - - - false - false - - - true - true - - - true - false - - - true - true - - - true - true - - - - true - - - false - true - - - - false - - - false - false - - - false - true - - - false - true - - - false - true - - - false - false - - - false - true - - - false - false - - - false - true - - - true - true - - - true - false - - - true - true - - - true - true - - - false - true - - - false - true - - - false - true - - - false - true - - - true - false - - - false - true - - - false - false - - - true - false - - - true - true - - - false - false - - - true - false - - - - false - - - false - false - - - true - false - - - true - false - - - false - false - - - true - true - - - false - true - - - false - false - - - true - false - - - false - false - - - false - true - - - - true - - - true - false - - - false - false - - - true - false - - - true - true - - - true - true - - - false - true - - - false - true - - - true - false - - - false - true - - - false - false - - - false - false - - - false - true - - - false - false - - - - false - - - true - true - - - true - false - - - true - false - - - false - false - - - true - false - - - false - true - - - true - true - - - - true - - - false - true - - - false - true - - - true - true - - - true - true - - - true - true - - - false - false - - - true - false - - - true - true - - - false - true - - - true - true - - - false - false - - - false - false - - - false - true - - - false - false - - - false - false - - - false - true - - - false - true - - - false - true - - - false - true - - - - false - - - true - true - - - - true - - - true - true - - - false - false - - - false - false - - - true - false - - - false - false - - - true - false - - - - false - - - true - true - - - true - true - - - true - true - - - false - false - - - true - true - - - true - false - - - true - true - - - true - false - - - true - false - - - true - false - - - true - true - - - false - false - - - false - true - - - false - false - - - true - true - - - false - true - - - - true - - - true - true - - - false - false - - - false - false - - - false - false - - - true - true - - - true - true - - - false - false - - - false - false - - - false - true - - - true - true - - - false - true - - - false - false - - - true - true - - - false - false - - - false - false - - - true - true - - - false - false - - - true - false - - - true - true - - - false - true - - - true - true - - - true - true - - - true - true - - - true - true - - - false - true - - - false - true - - - false - true - - - false - true - - - false - false - - - false - true - - - false - true - - - false - false - - - false - true - - - false - false - - - - true - - - false - true - - - false - false - - - false - false - - - true - false - - - false - false - - - true - false - - - true - true - - - false - true - - - true - true - - - true - true - - - true - true - - - false - false - - - false - true - - - true - true - - - false - false - - - true - false - - - true - false - - - true - false - - - true - true - - - false - false - - - false - true - - - true - false - - - false - true - - - true - true - - - false - false - - - false - true - - - false - true - - - false - true - - - false - false - - - true - false - - - true - false - - - false - true - - - false - false - - - false - true - - - false - false - - - true - true - - - false - false - - - true - true - - - true - false - - - true - false - - - false - true - - - false - false - - - true - false - - - false - true - - - true - true - - - false - false - - - false - true - - - false - true - - - false - false - - - false - false - - - true - false - - - true - false - - - false - true - - - false - true - - - true - false - - - false - false - - - true - true - - - false - false - - - true - true - - - false - true - - - - true - - - true - true - - - false - false - - - false - false - - - true - false - - - false - false - - - true - false - - - false - false - - - true - true - - - true - false - - - false - false - - - false - false - - - false - true - - - true - true - - - true - false - - - true - false - - - false - false - - - false - true - - - false - true - - - false - false - - - false - true - - - true - true - - - false - true - - - true - true - - - false - true - - - true - false - - - - true - - - - false - - - false - false - - - true - true - - - - false - - - false - true - - - true - false - - - false - true - - - true - true - - - true - true - - - false - true - - - true - true - - - false - false - - - true - true - - - false - true - - - true - true - - - false - false - - - false - true - - - true - false - - - 3 - 1 - 150 - 150 - 2 - 20 - + + Visualizer + + + + + true + 1 + None + + 0 + 0 + + 0 + + + Frame + + + VisualizerStructure + + + + + + + Frame + + + true + + + true + + + Ethograph + WidthStretch + 0 + + + Camera + WidthFixed + 320 + + + BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit + + 0 + 0 + + 0 + true + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + Behavior + + + true + + + Bias + + + true + + + Ethogram + + + + + + true + + + Camera + + + + + + true + + + true + 1 + Borders + + 0 + 0 + + 0 + + + Metadata + + + true + + + true + None + + + PreSession + true + pre-session + None + + + PreSession + + + IntraSession + true + intra-session + None + + + IntraSession + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + BehaviorVisualizer + + + + + + + + + + + + + BehaviorPlot + + + + + + + Behavior + + + + + + Behavior1 + true + 1 + None + + 0 + 0 + + 0 + + + true + + + EventPlot + true + + -1 + 150 + + NoTitle + AutoFit + RangeFit + + + EventPlot + + + true + + + ContinuousPlot + true + + -1 + 150 + + NoTitle + AutoFit + None + + + ContinuousPlot + + + + EventPlot + + + + + 0 + 1 + + + R + L + + West + None + + + + + + + ContinuousPlot + + + + + 0 + 1 + + + West + None + + + + + + + + + LickLeft + + + Value + + + + 0.9 + + + + new(it as LickLeft) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickLeft + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + + + + LickRight + + + Value + + + + 0.1 + + + + new(it as LickRight) + + + Seconds + + + + + + 1000 + Item2 + Item1.LickRight + + + EventPlot + + + + Square + 3 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + + + + TimedTrial + + + + + + Value.ChoiceCategory + + + NoChoice + + + + Source1 + + + + NoChoice + + + + + + + + + + + + + 0.5 + + + + LeftChoice + + + + Source1 + + + + LeftChoice + + + + + + + + + + + + + 0.85 + + + + RightChoice + + + + Source1 + + + + RightChoice + + + + + + + + + + + + + 0.15 + + + + + + + new ( + it as Choice +) + + + Seconds + + + + + + + + + 1000 + Seconds + Value.Choice + + + EventPlot + + + + Circle + 3 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + + + + true + None + + + Value.TrialCategory + + + LeftRewarded + + + + Source1 + + + + LeftRewarded + + + + + + + + + + + + + 0.8 + + + + RightRewarded + + + + Source1 + + + + RightRewarded + + + + + + + + + + + + + 0.2 + + + + + + + new ( + it as Choice +) + + + + + + + + + 1000 + Seconds + Value.Choice + + + EventPlot + + + + Circle + 3 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 1 + 1 + + + + true + None + + + TimedTrial + + + 1000 + Seconds + Value.Trial.Metadata.PRewardLeft + + + + ContinuousPlot + + + + + + 1 + 0 + 0 + 1 + 2 + + + + + + true + None + + + + 1000 + Seconds + Value.Trial.Metadata.PRewardRight + + + + ContinuousPlot + + + + + + 0 + 0 + 1 + 1 + 2 + + + + + + true + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Bias + TimedBias + + + OutputControl + + + + UiHabituationTimeUpdate + + + UiMoveLeft + + + UiGiveRight + + + UiGiveLeft + + + UiMoveRight + + + UiManipulatorLeft + + + UiManipulatorForwardLeft + + + UiManipulatorForwardRight + + + UiManipulatorUp + + + UiDrainLeft + + + UiDrainBoth + + + UiDrainRight + + + UiManipulatorRight + + + UiManipulatorBackRight + + + UiManipulatorBackLeft + + + UiManipulatorDown + + + UiManipulatorStop + + + UiManipulatorHome + + + UiManipulatorInitialize + + + StartExperimentShortcut + + + StartExperiment + + + EndExperiment + + + UiCueGiveRight + + + UiCueGiveLeft + + + UiKeepLeftOpen + + + UiKeepRightOpen + + + UiKeepBothOpen + + + DrainLeftComplete + + + DrainRightComplete + + + + + + + + + Ethogram + + + SoftwareEventHistory + + + + + + + + + true + + Break + 200 + + + TrialOutcome + CornflowerBlue + 0.3 + + + RewardPeriod + Crimson + 0.3 + + + ITI + Cyan + 0.3 + + + + + TrialOutcome + SaddleBrown + 0.5 + 2 + Circle + + + LickLeft + Red + 0.8 + 2 + Down + + + LickRight + DodgerBlue + 0.2 + 2 + Up + + + + + + + CameraPreviewVisualizer + + + + Source1 + + + + + + + + + + + + CameraPreview + + + + + + + Camera + + + true + 1 + None + + 0 + 0 + + 0 + + + Table + + + + + + TriggeredCamerasStream + + + + + + + + + Source1 + + + Key + + + + + + + Camera1 + + + + + + + + + + + + + + + + + CameraStream + + + Table + + + true + + + CameraStream + + + Value + + + OverlayAlpha + + + + + + + + + + + + + + + 53 + 215 + 0.5 + + + + + + + + 2 + + + + + + + Flipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + Item1 + + + Item2 + + + + + + + + + Vertical + + + + NotFlipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + + + Item1 + + + + + + new ( + it.Size.Width / 2 as X, + it.Size.Height / 2 as Y +) + + + + + + + + + + 320 + 240 + + + + + + + + + + + + + + 320 + 240 + + + 0 + 0 + + 0 + + 1 + 1 + + + + + + + + + + + 1,0,0;0,1,0 + Linear + + 0 + 0 + 0 + 0 + + + + + Table + + + + Rgba + Repeat + Repeat + Linear + Linear + + + + + + + + + PreviewImage + true + + 320 + 320 + + + 0 + 0 + + + 1 + 1 + + + + Table + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Alpha + + + true + + + true + 0 + 1 + None + 0.5 + + + OverlayAlpha + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CameraPreviewVisualizer + + + + Source1 + + + + + + + + + + + + CameraPreview + + + + + + + Camera + + + true + 1 + None + + 0 + 0 + + 0 + + + Table + + + + + + TriggeredCamerasStream + + + + + + + + + Source1 + + + Key + + + + + + + Camera2 + + + + + + + + + + + + + + + + + CameraStream + + + Table + + + true + + + CameraStream + + + Value + + + OverlayAlpha + + + + + + + + + + + + + + + 53 + 215 + 0.5 + + + + + + + + 2 + + + + + + + Flipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + Item1 + + + Item2 + + + + + + + + + Vertical + + + + NotFlipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + + + Item1 + + + + + + new ( + it.Size.Width / 2 as X, + it.Size.Height / 2 as Y +) + + + + + + + + + + 320 + 240 + + + + + + + + + + + + + + 320 + 240 + + + 0 + 0 + + 0 + + 1 + 1 + + + + + + + + + + + 1,0,0;0,1,0 + Linear + + 0 + 0 + 0 + 0 + + + + + Table + + + + Rgba + Repeat + Repeat + Linear + Linear + + + + + + + + + PreviewImage + true + + 320 + 320 + + + 0 + 0 + + + 1 + 1 + + + + Table + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Alpha + + + true + + + true + 0 + 1 + None + 0.5 + + + OverlayAlpha + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SessionInfo + + + Metadata + StartExperimentShortcut + EndExperiment + UiHabituationTimeUpdate + + + PreSession + UiKeepLeftOpen + UiKeepRightOpen + UiKeepBothOpen + UiDrainLeft + UiDrainRight + UiDrainBoth + UiManipulatorLeft + UiManipulatorForwardLeft + UiManipulatorForwardRight + UiManipulatorUp + UiManipulatorRight + UiManipulatorBackLeft + UiManipulatorBackRight + UiManipulatorDown + UiManipulatorStop + UiManipulatorHome + UiManipulatorInitialize + DrainLeftComplete + DrainRightComplete + + + IntraSession + UiGiveLeft + UiGiveRight + UiMoveLeft + UiMoveRight + SessionMetadata + StartExperiment + UiCueGiveLeft + UiCueGiveRight + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file From 6cfed3d34a93ab3c28114f602eb4fb21b54d333e Mon Sep 17 00:00:00 2001 From: svc_aind_behavior Date: Fri, 7 Aug 2026 15:28:08 -0700 Subject: [PATCH 082/116] fixes scheam and intrasession bugs --- src/Extensions/CategorizeTrial.cs | 2 +- src/Extensions/IntraSessionVisualizer.bonsai | 38 +- src/Extensions/SessionInfoVisualizer.cs | 62 ++- src/Extensions/Visualizers.bonsai | 398 ++++++++++++------- 4 files changed, 320 insertions(+), 180 deletions(-) diff --git a/src/Extensions/CategorizeTrial.cs b/src/Extensions/CategorizeTrial.cs index c514c752..1235e82b 100644 --- a/src/Extensions/CategorizeTrial.cs +++ b/src/Extensions/CategorizeTrial.cs @@ -18,7 +18,7 @@ public IObservable> Process(IObservable { var trial = value.Value; - bool isAutoResponse = trial.Trial.IsAutoResponseRight.HasValue; + bool isAutoResponse = trial.Trial.IsAutoRewardRight.HasValue; var categorizedTrial = new CategorizedTrial(); if (!trial.IsRightChoice.HasValue) { diff --git a/src/Extensions/IntraSessionVisualizer.bonsai b/src/Extensions/IntraSessionVisualizer.bonsai index 1dd4a1d9..c1b444fa 100644 --- a/src/Extensions/IntraSessionVisualizer.bonsai +++ b/src/Extensions/IntraSessionVisualizer.bonsai @@ -13,10 +13,10 @@ - + InterSessionVisualizer @@ -97,7 +97,11 @@ GiveLeft true Give Left - false + true + + 0 + 0 + @@ -121,7 +125,11 @@ GiveRight true Give Right - false + true + + 0 + 0 + @@ -160,7 +168,11 @@ GiveLeftCue true Give Left Cue - false + true + + 0 + 0 + @@ -184,7 +196,11 @@ GiveRightCue true Give Right Cue - false + true + + 0 + 0 + @@ -221,7 +237,11 @@ MoveLeft true Move Left - false + true + + 0 + 0 + @@ -245,7 +265,11 @@ MoveRight true Move Right - false + true + + 0 + 0 + diff --git a/src/Extensions/SessionInfoVisualizer.cs b/src/Extensions/SessionInfoVisualizer.cs index ca9a3905..df71c2a0 100644 --- a/src/Extensions/SessionInfoVisualizer.cs +++ b/src/Extensions/SessionInfoVisualizer.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; +using System.Linq; using System.Numerics; using System.Reactive; using System.Reactive.Linq; @@ -13,8 +14,34 @@ public class SessionInfoVisualizer { public bool Visible {get; set;} + + private Dictionary _sessionInfo = new Dictionary(); + [XmlIgnore] - public Dictionary SessionInfo {get; set;} + public object SessionInfo + { + get { return _sessionInfo; } + set + { + _sessionInfo = ObjectToStringDict(value); + } + } + + public SessionInfoVisualizer() + { + } + + private static Dictionary ObjectToStringDict(object obj) + { + if (obj == null) return new Dictionary(); + var result = new Dictionary(); + var jo = (Newtonsoft.Json.Linq.JObject)obj; + foreach (var prop in jo.Properties()) + { + result[prop.Name] = prop.Value != null ? prop.Value.ToString() : string.Empty; + } + return result; + } public IObservable Process(IObservable source) { @@ -24,30 +51,29 @@ public IObservable Process(IObservable source) value => { if (Visible) - { - var tableFlags = ImGuiTableFlags.Borders | ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingStretchSame; - - ImGui.Text("Session Info"); - if (ImGui.BeginTable("Session Info", 2, tableFlags)) { - ImGui.TableSetupColumn("Field"); - ImGui.TableSetupColumn("Value"); + var tableFlags = ImGuiTableFlags.Borders | ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingStretchSame; - var r = 0; - foreach (var field in SessionInfo) + ImGui.Text("Session Info"); + if (ImGui.BeginTable("Session Info", 2, tableFlags)) { - ImGui.TableNextRow(); + ImGui.TableSetupColumn("Field"); + ImGui.TableSetupColumn("Value"); - ImGui.TableSetColumnIndex(0); - ImGui.Text(field.Key); + KeyValuePair[] fields; + fields = _sessionInfo.ToArray(); + foreach (var field in fields) + { + ImGui.TableNextRow(); - ImGui.TableSetColumnIndex(1); - ImGui.Text(field.Value); + ImGui.TableSetColumnIndex(0); + ImGui.Text(field.Key); - r++; - } + ImGui.TableSetColumnIndex(1); + ImGui.Text(field.Value); + } - ImGui.EndTable(); + ImGui.EndTable(); } observer.OnNext(value); } diff --git a/src/Extensions/Visualizers.bonsai b/src/Extensions/Visualizers.bonsai index e364ea88..3eff71fd 100644 --- a/src/Extensions/Visualizers.bonsai +++ b/src/Extensions/Visualizers.bonsai @@ -974,6 +974,19 @@ + + + 500 + + + + + 1 + + + + DefaultOpenTime + PT0.1S @@ -987,16 +1000,27 @@ false + + DefaultOpenTime + + + RigSchema + + + Calibration.WaterValveRight + - - 500 - + + + + TimeToReward + ((Item2.Slope*(Item1*0.001)) + Item2.Offset)*1000000 - SetIsRightValveMs + SetIsRightRewardAmount @@ -1023,16 +1047,22 @@ - - - - - - - + + + + + + - + + + + + + + + @@ -1072,6 +1102,19 @@ + + + 500 + + + + + 1 + + + + DefaultOpenTime + PT0.1S @@ -1085,16 +1128,27 @@ true + + DefaultOpenTime + + + RigSchema + + + Calibration.WaterValveRight + - - 500 - + + + + TimeToReward + ((Item2.Slope*(Item1*0.001)) + Item2.Offset)*1000000 - SetIsRightValveMs + SetIsRightRewardAmount @@ -1121,16 +1175,22 @@ - - - - - - - + + + + + + - + + + + + + + + @@ -1150,6 +1210,19 @@ Flush + + + 50 + + + + + 1 + + + + DefaultVolume + Source1 @@ -1180,16 +1253,14 @@ false - - - 500 - + + DefaultVolume - SetIsRightValveMs + SetIsRightRewardAmount @@ -1202,15 +1273,8 @@ GiveRewardRight - - - PT0.5S - - - - - 5000 - + + DefaultVolume RigSchema @@ -1225,18 +1289,25 @@ RewardToTime ((Item1 * 0.001) - Item2.Offset) / Item2.Slope - - ToMilliseconds - + + - - - 1000 - + + + + + + + + PT0.607S + + + + DefaultVolume DivideByEachOpen - Math.Ceiling(it / 500) + Math.Ceiling(5000 / it) @@ -1245,7 +1316,7 @@ - 300 + 100 @@ -1272,32 +1343,35 @@ - - - - - - - - + + + + + + + - - - - + + + + - - + + - + + + + + @@ -1317,6 +1391,19 @@ Flush + + + 50 + + + + + 1 + + + + DefaultVolume + Source1 @@ -1347,16 +1434,14 @@ true - - - 500 - + + DefaultVolume - SetIsRightValveMs + SetIsRightRewardAmount @@ -1369,15 +1454,8 @@ GiveRewardRight - - - PT0.5S - - - - - 5000 - + + DefaultVolume RigSchema @@ -1392,18 +1470,25 @@ RewardToTime ((Item1 * 0.001) - Item2.Offset) / Item2.Slope - - ToMilliseconds - + + - - - 1000 - + + + + + + + + PT0.678S + + + + DefaultVolume DivideByEachOpen - Math.Ceiling(it / 500) + Math.Ceiling(5000 / it) @@ -1412,7 +1497,7 @@ - 300 + 100 @@ -1439,32 +1524,35 @@ - - - - - - - - + + + + + + + - - - - + + + + - - + + - + + + + + @@ -1690,50 +1778,6 @@ Value.Trial.Metadata.Extra - - - Placeholder - - - - - Placeholder - - - - - - - AsDictionary - - - - Source1 - - - - 1 - - - - Item1 - Item2 - - - - 1 - - - - - - - - - - - - SessionMetadata @@ -1742,12 +1786,7 @@ - - - - - - + @@ -1765,7 +1804,58 @@ true - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Break 200 @@ -1839,7 +1929,7 @@ Camera - Camera1 + SideCamera 53 215 2 @@ -1848,7 +1938,7 @@ Camera - Camera2 + BodyCamera 53 215 2 @@ -1892,10 +1982,10 @@ UiGiveRight UiMoveLeft UiMoveRight - SessionMetadata StartExperiment UiCueGiveLeft UiCueGiveRight + SessionMetadata From 45e991cb93aa936cc75d6c0b5a9c77dba37e2c95 Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Tue, 11 Aug 2026 09:01:03 -0700 Subject: [PATCH 083/116] fixes keep right/left open --- .bonsai/Settings/src/main.editor | 2 +- .bonsai/Settings/src/main.layout | 14 +- src/main.bonsai | 1962 +++++++++++++++++++++++++++++- 3 files changed, 1963 insertions(+), 15 deletions(-) diff --git a/.bonsai/Settings/src/main.editor b/.bonsai/Settings/src/main.editor index bbd6dca8..0bbc6ce2 100644 --- a/.bonsai/Settings/src/main.editor +++ b/.bonsai/Settings/src/main.editor @@ -4,7 +4,7 @@ - + diff --git a/.bonsai/Settings/src/main.layout b/.bonsai/Settings/src/main.layout index a8dfb7c0..0829d87c 100644 --- a/.bonsai/Settings/src/main.layout +++ b/.bonsai/Settings/src/main.layout @@ -1,14 +1,2 @@  - - - - - - - Bonsai.ImGui.Visualizers.ImPlotVisualizer - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/src/main.bonsai b/src/main.bonsai index eab4eaaa..b57dcd55 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -9,6 +9,11 @@ xmlns:p4="clr-namespace:AllenNeuralDynamics.AindBehaviorServices.DataTypes;assembly=AllenNeuralDynamics.AindBehaviorServices" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" + xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" + xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" + xmlns:p5="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" + xmlns:p6="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" + xmlns:p7="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -457,7 +462,1962 @@ - + + Visualizers + + + + ImGuiContext + + + + + true + 1 + None + + 0 + 0 + + 0 + + + Frame + + + + + + + + + + + + DataTransformations + + + + GlobalTrialOutcome + + + HarpTimestampSource + + + TimedTrial + + + GlobalTrialMetrics + + + Bias + + + new (it as Bias) + + + HarpTimestampSource + + + TimedBias + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + HarpTimestampSource + + + LickRight + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + + HarpTimestampSource + + + LickLeft + + + SoftwareEvent + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + LickRight + + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + + + LickLeft + + + + GiveRewardRight + + + + + + Source1 + + + + + + + + + + + WaterRight + + + + GiveRewardRight + + + + + + + Source1 + + + + + + + + + + + WaterLeft + + + + + + + HarpTimestampSource + + + + + + + + + + + + EthogramEvents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OutputControl + + + + Manipulator + + + + UiManipulatorLeft + + + MoveRelative + + + + Source1 + + + + -1 + 0 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorRight + + + MoveRelative + + + + Source1 + + + + 1 + 0 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorForwardLeft + + + MoveRelative + + + + Source1 + + + + 0 + 1 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorForwardRight + + + MoveRelative + + + + Source1 + + + + 0 + 0 + 1 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorBackLeft + + + MoveRelative + + + + Source1 + + + + 0 + -1 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorBackRight + + + MoveRelative + + + + Source1 + + + + 0 + 0 + -1 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorUp + + + MoveRelative + + + + Source1 + + + + 0 + 0 + 0 + 1 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorDown + + + MoveRelative + + + + Source1 + + + + 0 + 0 + 0 + -1 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorHome + + + Home + + + + Source1 + + + + HomeMotors + + + + + + + + + + + + UiManipulatorStop + + + StopMotors + + + + Source1 + + + + StopMotors + + + + + + + + + + + + UiManipulatorInitialize + + + GoToInitialPosition + + + + Source1 + + + + GoToInitialPosition + + + + + + + + + + + + OffsetGain + + + + + + + + + + + + + + + + + + + UiHabituationTimeUpdate + + + + 0.05 + + + + + 1 + + + + BumpSize + + + UiMoveLeft + + + BumpLeft + + + + Source1 + + + BumpSize + + + + + + Item2 + + + + -1 + + + + ManualSpoutDelta + + + + + + + + + + + + + + + UiMoveRight + + + BumpRight + + + + Source1 + + + BumpSize + + + + + + Item2 + + + ManualSpoutDelta + + + + + + + + + + + + + + UiGiveRight + + + TriggerRight + + + + Source1 + + + + true + + + + GiveManualWaterRight + + + + + + + + + + + + UiGiveLeft + + + TriggerLeft + + + + Source1 + + + + false + + + + GiveManualWaterRight + + + + + + + + + + + + UiCueGiveLeft + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetLeft() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + UiCueGiveRight + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetRight() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + + true + + + + IsFlushingValveLeft + + + GiveManualWaterRight + + + GiveManualWaterRight + + + GiveRewardRight + + + IsFlushingValveLeft + + + IsFlushingValveRight + + + UiKeepLeftOpen + + + UiKeepBothOpen + + + + + + KeepLeftOpen + + + + + 500 + + + + + 1 + + + + DefaultOpenTime + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + false + + + + DefaultOpenTime + + + RigSchema + + + Calibration.WaterValveRight + + + + + + TimeToReward + ((Item2.Slope*(Item1*0.001)) + Item2.Offset)*1000000 + + + + + + SetIsRightRewardAmount + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + + PT0.5S + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UiKeepRightOpen + + + + + + KeepRightOpen + + + + + 500 + + + + + 1 + + + + DefaultOpenTime + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + true + + + + DefaultOpenTime + + + RigSchema + + + Calibration.WaterValveRight + + + + + + TimeToReward + ((Item2.Slope*(Item1*0.001)) + Item2.Offset)*1000000 + + + + + + SetIsRightRewardAmount + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + + PT0.5S + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UiDrainLeft + + + UiDrainBoth + + + + + + FlushLeft + + + + + 50 + + + + + 1 + + + + DefaultVolume + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + false + + + + DefaultVolume + + + + + + SetIsRightRewardAmount + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + DefaultVolume + + + RigSchema + + + Calibration.WaterValveLeft + + + + + + RewardToTime + ((Item1 * 0.001) - Item2.Offset) / Item2.Slope + + + + + + + + + + + + PT0.607S + + + + DefaultVolume + + + DivideByEachOpen + Math.Ceiling(5000 / it) + + + + + + + + + 100 + + + + + + + + false + + + + IsFlushingValveLeft + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DrainLeftComplete + + + UiDrainRight + + + + + + FlushRight + + + + + 50 + + + + + 1 + + + + DefaultVolume + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + true + + + + DefaultVolume + + + + + + SetIsRightRewardAmount + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + DefaultVolume + + + RigSchema + + + Calibration.WaterValveRight + + + + + + RewardToTime + ((Item1 * 0.001) - Item2.Offset) / Item2.Slope + + + + + + + + + + + + PT0.678S + + + + DefaultVolume + + + DivideByEachOpen + Math.Ceiling(5000 / it) + + + + + + + + + 100 + + + + + + + + false + + + + IsFlushingValveRight + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DrainRightComplete + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VisualizerStructure + + + + + + + Frame + + + true + + + true + + + Ethograph + WidthStretch + 0 + + + Camera + WidthFixed + 320 + + + BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit + + 0 + 0 + + 0 + true + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + Behavior + + + true + + + Bias + + + true + + + Ethogram + + + + + + true + + + Camera + + + + + + true + + + true + 1 + Borders + + 0 + 0 + + 0 + + + Metadata + + + true + + + true + None + + + PreSession + true + pre-session + None + + + PreSession + + + IntraSession + true + intra-session + None + + + IntraSession + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Behavior1 + LickLeft + LickRight + TimedTrial + Behavior + + + Bias + TimedBias + + + PLACEHOLDER + + + + SessionInfo + + + + TimedTrial + + + Value.Trial.Metadata.Extra + + + SessionMetadata + + + + + + + + + + + + Ethogram + + + EthogramEvents + + + + + + + + + true + + Break + 200 + + + QuiescentPeriod + Gold + 0.3 + + + ResponsePeriod + SandyBrown + 0.3 + + + RewardConsumptionPeriod + RosyBrown + 0.3 + + + ItiPeriod + Green + 0.3 + + + + + LickLeft + Red + 0.9 + 6 + Down + + + LickRight + Blue + 0.1 + 6 + Up + + + IsRightTriggerQuickRetract + DarkCyan + 0.5 + 6 + Plus + + + DeliverSecondaryReinforcer + Sienna + 0.5 + 6 + Plus + + + WaterRight + Red + 0.2 + 6 + Circle + + + WaterLeft + Blue + 0.8 + 6 + Circle + + + + + + + Camera + SideCamera + 53 + 215 + 2 + 0 + TriggeredCamerasStream + + + Camera + BodyCamera + 53 + 215 + 2 + 0 + TriggeredCamerasStream + + + SessionSchema + + + Metadata + StartExperimentShortcut + EndExperiment + UiHabituationTimeUpdate + + + PreSession + UiKeepLeftOpen + UiKeepRightOpen + UiKeepBothOpen + UiDrainLeft + UiDrainRight + UiDrainBoth + UiManipulatorLeft + UiManipulatorForwardLeft + UiManipulatorForwardRight + UiManipulatorUp + UiManipulatorRight + UiManipulatorBackLeft + UiManipulatorBackRight + UiManipulatorDown + UiManipulatorStop + UiManipulatorHome + UiManipulatorInitialize + DrainLeftComplete + DrainRightComplete + + + IntraSession + UiGiveLeft + UiGiveRight + UiMoveLeft + UiMoveRight + StartExperiment + UiCueGiveLeft + UiCueGiveRight + SessionMetadata + + + + + + + + + + + + + From c2a74908a338bb89a96cbf7c906003764deff4bb Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Tue, 11 Aug 2026 09:46:47 -0700 Subject: [PATCH 084/116] changes logic to reward base in keep open --- .bonsai/Settings/src/main.editor | 2 +- src/Extensions/Visualizers.bonsai | 217 ++-- src/main.bonsai | 1962 +---------------------------- 3 files changed, 77 insertions(+), 2104 deletions(-) diff --git a/.bonsai/Settings/src/main.editor b/.bonsai/Settings/src/main.editor index 0bbc6ce2..bbd6dca8 100644 --- a/.bonsai/Settings/src/main.editor +++ b/.bonsai/Settings/src/main.editor @@ -4,7 +4,7 @@ - + diff --git a/src/Extensions/Visualizers.bonsai b/src/Extensions/Visualizers.bonsai index 3eff71fd..75d81676 100644 --- a/src/Extensions/Visualizers.bonsai +++ b/src/Extensions/Visualizers.bonsai @@ -948,9 +948,22 @@ - KeepOpen + KeepLeftOpen + + + 50 + + + + + 1 + + + + DefaultRewardAmount + Source1 @@ -968,25 +981,6 @@ - - - 1 - - - - - - 500 - - - - - 1 - - - - DefaultOpenTime - PT0.1S @@ -1001,20 +995,7 @@ - DefaultOpenTime - - - RigSchema - - - Calibration.WaterValveRight - - - - - - TimeToReward - ((Item2.Slope*(Item1*0.001)) + Item2.Offset)*1000000 + DefaultRewardAmount @@ -1041,28 +1022,39 @@ + + + + + + + + + 1 + + + - - - + + + + - - + + - + - + - + - - @@ -1076,9 +1068,22 @@ - KeepOpen + KeepRightOpen + + + 50 + + + + + 1 + + + + DefaultRewardAmount + Source1 @@ -1096,25 +1101,6 @@ - - - 1 - - - - - - 500 - - - - - 1 - - - - DefaultOpenTime - PT0.1S @@ -1129,20 +1115,7 @@ - DefaultOpenTime - - - RigSchema - - - Calibration.WaterValveRight - - - - - - TimeToReward - ((Item2.Slope*(Item1*0.001)) + Item2.Offset)*1000000 + DefaultRewardAmount @@ -1169,28 +1142,39 @@ + + + + + + + + + 1 + + + - - - + + + + - - + + - + - + - + - - @@ -1207,7 +1191,7 @@ - Flush + FlushLeft @@ -1388,7 +1372,7 @@ - Flush + FlushRight @@ -1804,58 +1788,7 @@ true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Break 200 diff --git a/src/main.bonsai b/src/main.bonsai index b57dcd55..eab4eaaa 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -9,11 +9,6 @@ xmlns:p4="clr-namespace:AllenNeuralDynamics.AindBehaviorServices.DataTypes;assembly=AllenNeuralDynamics.AindBehaviorServices" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" - xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" - xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" - xmlns:p5="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" - xmlns:p6="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" - xmlns:p7="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -462,1962 +457,7 @@ - - Visualizers - - - - ImGuiContext - - - - - true - 1 - None - - 0 - 0 - - 0 - - - Frame - - - - - - - - - - - - DataTransformations - - - - GlobalTrialOutcome - - - HarpTimestampSource - - - TimedTrial - - - GlobalTrialMetrics - - - Bias - - - new (it as Bias) - - - HarpTimestampSource - - - TimedBias - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - HarpTimestampSource - - - LickRight - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - - HarpTimestampSource - - - LickLeft - - - SoftwareEvent - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - LickRight - - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - - - LickLeft - - - - GiveRewardRight - - - - - - Source1 - - - - - - - - - - - WaterRight - - - - GiveRewardRight - - - - - - - Source1 - - - - - - - - - - - WaterLeft - - - - - - - HarpTimestampSource - - - - - - - - - - - - EthogramEvents - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OutputControl - - - - Manipulator - - - - UiManipulatorLeft - - - MoveRelative - - - - Source1 - - - - -1 - 0 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorRight - - - MoveRelative - - - - Source1 - - - - 1 - 0 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorForwardLeft - - - MoveRelative - - - - Source1 - - - - 0 - 1 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorForwardRight - - - MoveRelative - - - - Source1 - - - - 0 - 0 - 1 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorBackLeft - - - MoveRelative - - - - Source1 - - - - 0 - -1 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorBackRight - - - MoveRelative - - - - Source1 - - - - 0 - 0 - -1 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorUp - - - MoveRelative - - - - Source1 - - - - 0 - 0 - 0 - 1 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorDown - - - MoveRelative - - - - Source1 - - - - 0 - 0 - 0 - -1 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorHome - - - Home - - - - Source1 - - - - HomeMotors - - - - - - - - - - - - UiManipulatorStop - - - StopMotors - - - - Source1 - - - - StopMotors - - - - - - - - - - - - UiManipulatorInitialize - - - GoToInitialPosition - - - - Source1 - - - - GoToInitialPosition - - - - - - - - - - - - OffsetGain - - - - - - - - - - - - - - - - - - - UiHabituationTimeUpdate - - - - 0.05 - - - - - 1 - - - - BumpSize - - - UiMoveLeft - - - BumpLeft - - - - Source1 - - - BumpSize - - - - - - Item2 - - - - -1 - - - - ManualSpoutDelta - - - - - - - - - - - - - - - UiMoveRight - - - BumpRight - - - - Source1 - - - BumpSize - - - - - - Item2 - - - ManualSpoutDelta - - - - - - - - - - - - - - UiGiveRight - - - TriggerRight - - - - Source1 - - - - true - - - - GiveManualWaterRight - - - - - - - - - - - - UiGiveLeft - - - TriggerLeft - - - - Source1 - - - - false - - - - GiveManualWaterRight - - - - - - - - - - - - UiCueGiveLeft - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetLeft() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - UiCueGiveRight - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetRight() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - - true - - - - IsFlushingValveLeft - - - GiveManualWaterRight - - - GiveManualWaterRight - - - GiveRewardRight - - - IsFlushingValveLeft - - - IsFlushingValveRight - - - UiKeepLeftOpen - - - UiKeepBothOpen - - - - - - KeepLeftOpen - - - - - 500 - - - - - 1 - - - - DefaultOpenTime - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - false - - - - DefaultOpenTime - - - RigSchema - - - Calibration.WaterValveRight - - - - - - TimeToReward - ((Item2.Slope*(Item1*0.001)) + Item2.Offset)*1000000 - - - - - - SetIsRightRewardAmount - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - - PT0.5S - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UiKeepRightOpen - - - - - - KeepRightOpen - - - - - 500 - - - - - 1 - - - - DefaultOpenTime - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - true - - - - DefaultOpenTime - - - RigSchema - - - Calibration.WaterValveRight - - - - - - TimeToReward - ((Item2.Slope*(Item1*0.001)) + Item2.Offset)*1000000 - - - - - - SetIsRightRewardAmount - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - - PT0.5S - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UiDrainLeft - - - UiDrainBoth - - - - - - FlushLeft - - - - - 50 - - - - - 1 - - - - DefaultVolume - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - false - - - - DefaultVolume - - - - - - SetIsRightRewardAmount - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - DefaultVolume - - - RigSchema - - - Calibration.WaterValveLeft - - - - - - RewardToTime - ((Item1 * 0.001) - Item2.Offset) / Item2.Slope - - - - - - - - - - - - PT0.607S - - - - DefaultVolume - - - DivideByEachOpen - Math.Ceiling(5000 / it) - - - - - - - - - 100 - - - - - - - - false - - - - IsFlushingValveLeft - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DrainLeftComplete - - - UiDrainRight - - - - - - FlushRight - - - - - 50 - - - - - 1 - - - - DefaultVolume - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - true - - - - DefaultVolume - - - - - - SetIsRightRewardAmount - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - DefaultVolume - - - RigSchema - - - Calibration.WaterValveRight - - - - - - RewardToTime - ((Item1 * 0.001) - Item2.Offset) / Item2.Slope - - - - - - - - - - - - PT0.678S - - - - DefaultVolume - - - DivideByEachOpen - Math.Ceiling(5000 / it) - - - - - - - - - 100 - - - - - - - - false - - - - IsFlushingValveRight - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DrainRightComplete - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - VisualizerStructure - - - - - - - Frame - - - true - - - true - - - Ethograph - WidthStretch - 0 - - - Camera - WidthFixed - 320 - - - BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit - - 0 - 0 - - 0 - true - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - Behavior - - - true - - - Bias - - - true - - - Ethogram - - - - - - true - - - Camera - - - - - - true - - - true - 1 - Borders - - 0 - 0 - - 0 - - - Metadata - - - true - - - true - None - - - PreSession - true - pre-session - None - - - PreSession - - - IntraSession - true - intra-session - None - - - IntraSession - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Behavior1 - LickLeft - LickRight - TimedTrial - Behavior - - - Bias - TimedBias - - - PLACEHOLDER - - - - SessionInfo - - - - TimedTrial - - - Value.Trial.Metadata.Extra - - - SessionMetadata - - - - - - - - - - - - Ethogram - - - EthogramEvents - - - - - - - - - true - - Break - 200 - - - QuiescentPeriod - Gold - 0.3 - - - ResponsePeriod - SandyBrown - 0.3 - - - RewardConsumptionPeriod - RosyBrown - 0.3 - - - ItiPeriod - Green - 0.3 - - - - - LickLeft - Red - 0.9 - 6 - Down - - - LickRight - Blue - 0.1 - 6 - Up - - - IsRightTriggerQuickRetract - DarkCyan - 0.5 - 6 - Plus - - - DeliverSecondaryReinforcer - Sienna - 0.5 - 6 - Plus - - - WaterRight - Red - 0.2 - 6 - Circle - - - WaterLeft - Blue - 0.8 - 6 - Circle - - - - - - - Camera - SideCamera - 53 - 215 - 2 - 0 - TriggeredCamerasStream - - - Camera - BodyCamera - 53 - 215 - 2 - 0 - TriggeredCamerasStream - - - SessionSchema - - - Metadata - StartExperimentShortcut - EndExperiment - UiHabituationTimeUpdate - - - PreSession - UiKeepLeftOpen - UiKeepRightOpen - UiKeepBothOpen - UiDrainLeft - UiDrainRight - UiDrainBoth - UiManipulatorLeft - UiManipulatorForwardLeft - UiManipulatorForwardRight - UiManipulatorUp - UiManipulatorRight - UiManipulatorBackLeft - UiManipulatorBackRight - UiManipulatorDown - UiManipulatorStop - UiManipulatorHome - UiManipulatorInitialize - DrainLeftComplete - DrainRightComplete - - - IntraSession - UiGiveLeft - UiGiveRight - UiMoveLeft - UiMoveRight - StartExperiment - UiCueGiveLeft - UiCueGiveRight - SessionMetadata - - - - - - - - - - - - - + From 6563393a7ae89353e95bf4e0e492da3ca4a210fc Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Tue, 11 Aug 2026 10:12:33 -0700 Subject: [PATCH 085/116] adds stage name to metadata bar --- src/Extensions/Visualizers.bonsai | 382 +++++++++++++++++++++++++++++- 1 file changed, 376 insertions(+), 6 deletions(-) diff --git a/src/Extensions/Visualizers.bonsai b/src/Extensions/Visualizers.bonsai index 75d81676..aa691b0b 100644 --- a/src/Extensions/Visualizers.bonsai +++ b/src/Extensions/Visualizers.bonsai @@ -1881,11 +1881,379 @@ SessionSchema - - Metadata - StartExperimentShortcut - EndExperiment - UiHabituationTimeUpdate + + TaskLogicSchema + + + + + + MetadataVisualizer + + + + Source1 + + + + + + + + + MetadataVisualizer + + + + Source1 + + + CurrentMetadata + + + + + + Metadata + + + true + + + true + + + Condition + WidthFixed + 0 + + + Subject + WidthFixed + 0 + + + Session + WidthFixed + 0 + + + Experiment + WidthFixed + 0 + + + Habituation + WidthStretch + 0 + + + Control + WidthStretch + 0 + + + BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit + + 0 + 0 + + 0 + true + + + true + + + CurrentMetadata + + + Item2.StageName + + + + + + + + true + Stage + + + true + + + CurrentMetadata + + + Item1.Experimenter + + + + + + Source1 + + + Count + + + + 0 + + + + + + + + + + + + + + 0 + + + + + + + + + true + Expo + + + true + + + CurrentMetadata + + + Item1.Subject + + + + + + + + true + Plimbo + + + true + + + CurrentMetadata + + + Item1.SessionName + + + + + + + + true + Stage1 + + + true + + + CurrentMetadata + + + Item1.Experiment + + + + + + + + true + Task6 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Habituation + + + true + + + Habituation + true + None + 0 + 0 + 0 + + + + + + UiHabituationTimeUpdate + + + + + + true + + + true + + + Start + WidthStretch + 0 + + + Stop + WidthStretch + 0 + + + None + + 0 + 0 + + 0 + false + + + true + + + StartButton + true + START + true + + 100 + 50 + + + + + + + + StartExperimentShortcut + + + true + + + StopButton + true + STOP + true + + 100 + 50 + + + + + + + + EndExperiment + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PreSession @@ -1928,7 +2296,9 @@ - + + + \ No newline at end of file From 2767cbdc633d9deecd25b7c7f254c24f3c31d718 Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Wed, 12 Aug 2026 08:14:52 -0700 Subject: [PATCH 086/116] adds stage to metadata bar --- src/Extensions/Visualizers.bonsai | 65 ++++++++++--------------------- 1 file changed, 21 insertions(+), 44 deletions(-) diff --git a/src/Extensions/Visualizers.bonsai b/src/Extensions/Visualizers.bonsai index aa691b0b..e09a9f86 100644 --- a/src/Extensions/Visualizers.bonsai +++ b/src/Extensions/Visualizers.bonsai @@ -1923,17 +1923,17 @@ true - Condition + Stage WidthFixed 0 - Subject + Experimenter WidthFixed 0 - Session + Subject WidthFixed 0 @@ -1977,7 +1977,7 @@ true - Stage + final true @@ -2023,7 +2023,7 @@ true - Expo + Test true @@ -2041,25 +2041,7 @@ true - Plimbo - - - true - - - CurrentMetadata - - - Item1.SessionName - - - - - - - - true - Stage1 + Test true @@ -2077,7 +2059,7 @@ true - Task6 + asdgfadgdafgdfhgsghsfghsfghshdfghsfghsfghsfghahsfgh true @@ -2195,8 +2177,7 @@ - - + @@ -2215,30 +2196,26 @@ - + + - - - - - - + + + + + - - - - - - + + + + + + - - - - From 8eae7bce56dc165731e4451383a43423d6f24f40 Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Wed, 12 Aug 2026 08:57:59 -0700 Subject: [PATCH 087/116] uses trial index for bias --- src/Extensions/BiasVisualizer.bonsai | 43 +++++++++------------- src/Extensions/TaskEngine.bonsai | 54 ++++++++++++++++++++-------- src/Extensions/Visualizers.bonsai | 48 +++++++++++++------------ src/main.bonsai | 45 ++++++++++++----------- 4 files changed, 107 insertions(+), 83 deletions(-) diff --git a/src/Extensions/BiasVisualizer.bonsai b/src/Extensions/BiasVisualizer.bonsai index faa66f10..bfa02df3 100644 --- a/src/Extensions/BiasVisualizer.bonsai +++ b/src/Extensions/BiasVisualizer.bonsai @@ -6,7 +6,6 @@ xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns:p1="clr-namespace:;assembly=Extensions" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" - xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -62,12 +61,12 @@ - TimedBias + TrialIndexedBias 1000 - Seconds - Value.Bias + TrialIndex + Bias BiasPlot @@ -87,8 +86,8 @@ 1 - Seconds - Value.Bias + TrialIndex + Bias BiasPlot @@ -115,7 +114,7 @@ - Value.Bias + Bias @@ -131,7 +130,7 @@ - Seconds + TrialIndex @@ -147,9 +146,9 @@ true - 1.00 - 32.0100000000022 - 1 + 0.00 + 13 + 0 0 -10 @@ -168,13 +167,10 @@ - - - 1000 - Seconds - Value.LeftBias + Item2 + Item1.LeftBias BiasPlot @@ -203,13 +199,10 @@ - - - 1000 - Seconds - Value.RightBias + Item2 + Item1.RightBias BiasPlot @@ -240,7 +233,7 @@ - + @@ -257,7 +250,7 @@ - + @@ -266,14 +259,12 @@ - + - - diff --git a/src/Extensions/TaskEngine.bonsai b/src/Extensions/TaskEngine.bonsai index be8d4dba..9f4779ed 100644 --- a/src/Extensions/TaskEngine.bonsai +++ b/src/Extensions/TaskEngine.bonsai @@ -19,6 +19,14 @@ ThisTrial + + + 0 + + + + TrialIndex + ThisTrial @@ -291,7 +299,7 @@ - PT0S + PT0.5S @@ -485,7 +493,7 @@ - PT0S + PT1S @@ -1136,7 +1144,7 @@ - PT0S + PT3S @@ -1271,7 +1279,7 @@ - PT5S + PT8.824S @@ -1522,6 +1530,20 @@ SoftwareEvent + + TrialIndex + + + + 1 + + + + it + 1 + + + TrialIndex + @@ -1560,6 +1582,9 @@ + + + @@ -1606,30 +1631,31 @@ - + - - + - + - + - + - + - + - + + - + + diff --git a/src/Extensions/Visualizers.bonsai b/src/Extensions/Visualizers.bonsai index e09a9f86..3c6756a3 100644 --- a/src/Extensions/Visualizers.bonsai +++ b/src/Extensions/Visualizers.bonsai @@ -60,14 +60,17 @@ Bias - - new (it as Bias) + + TrialIndex - - HarpTimestampSource + + + + + new (it.Item1 as Bias, it.Item2 as TrialIndex) - TimedBias + TrialIndexedBias IsRightLickEvent @@ -244,34 +247,35 @@ - - + + - + - + - - + + - - + + - - + + - - + + - - + + + @@ -1283,7 +1287,7 @@ - PT0.607S + PT1.288S @@ -1464,7 +1468,7 @@ - PT0.678S + PT0.888S @@ -1746,7 +1750,7 @@ Bias - TimedBias + TrialIndexedBias PLACEHOLDER diff --git a/src/main.bonsai b/src/main.bonsai index eab4eaaa..aff9f4df 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -18,9 +18,9 @@ - C:\git\Aind.Behavior.DynamicForaging\local\DynamicForaging_AindDynamicForagingTaskLogic.json - c:\git\Aind.Behavior.DynamicForaging\local\AindDynamicForagingRig.json - c:\git\Aind.Behavior.DynamicForaging\local\Session.json + C:\git\Aind.Behavior.DynamicForaging\local\AindDynamicForagingTaskLogic.json + C:\git\Aind.Behavior.DynamicForaging\local\AindDynamicForagingRig.json + C:\git\Aind.Behavior.DynamicForaging\local\Session.json LoadSchemas @@ -157,6 +157,9 @@ GlobalTrialMetrics + + TrialIndex + TaskLogicParameters @@ -287,31 +290,31 @@ - - - - + + + - - + + - - - + + + - + - - - + + + - - - - - + + + + + + From a7c9035f1a3c1aefc69107a437e6d95fc6efacdf Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Wed, 12 Aug 2026 09:28:05 -0700 Subject: [PATCH 088/116] removes end experiment subject to stop crashing --- src/Extensions/Visualizers.bonsai | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Extensions/Visualizers.bonsai b/src/Extensions/Visualizers.bonsai index 3c6756a3..047a22bd 100644 --- a/src/Extensions/Visualizers.bonsai +++ b/src/Extensions/Visualizers.bonsai @@ -1901,7 +1901,6 @@ - @@ -2164,9 +2163,6 @@ - - - EndExperiment @@ -2218,8 +2214,7 @@ - - + From 60f292717e6b4c65363a0a17b83a57a46992b937 Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Wed, 12 Aug 2026 10:12:26 -0700 Subject: [PATCH 089/116] move legends in graphs --- src/Extensions/BehaviorVisualizer.bonsai | 82 ++++++++++++------------ src/Extensions/BiasVisualizer.bonsai | 30 ++++----- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/Extensions/BehaviorVisualizer.bonsai b/src/Extensions/BehaviorVisualizer.bonsai index be105b06..320c9a30 100644 --- a/src/Extensions/BehaviorVisualizer.bonsai +++ b/src/Extensions/BehaviorVisualizer.bonsai @@ -90,8 +90,8 @@ R L - West - None + East + Outside @@ -107,8 +107,8 @@ 1 - West - None + East + Outside @@ -127,19 +127,19 @@ 0.9 - - new(it as LickLeft) - Seconds + + new(it.Item1 as LickLeft, it.Item2) + 1000 Item2 - Item1.LickLeft + LickLeft EventPlot @@ -177,19 +177,19 @@ 0.1 - - new(it as LickRight) - Seconds + + new(it.Item1 as LickRight, it.Item2) + 1000 Item2 - Item1.LickRight + LickRight EventPlot @@ -303,11 +303,6 @@ - - new ( - it as Choice -) - Seconds @@ -317,10 +312,13 @@ + + new(it.Seconds, it.Value as Choice) + 1000 Seconds - Value.Choice + Choice EventPlot @@ -400,21 +398,19 @@ - - new ( - it as Choice -) - + + new(it.Seconds, it.Value as Choice) + 1000 Seconds - Value.Choice + Choice EventPlot @@ -441,10 +437,13 @@ TimedTrial + + new(it.Seconds, it.Value.Trial.Metadata.PRewardLeft as PRewardLeft, it.Value.Trial.Metadata.PRewardRight as PRewardRight ) + 1000 Seconds - Value.Trial.Metadata.PRewardLeft + PRewardLeft ContinuousPlot @@ -465,7 +464,7 @@ 1000 Seconds - Value.Trial.Metadata.PRewardRight + PRewardRight ContinuousPlot @@ -500,22 +499,22 @@ - + - - - + + + - + - - - + + + @@ -523,7 +522,7 @@ - + @@ -535,10 +534,10 @@ - - - - + + + + @@ -558,13 +557,14 @@ - + - + + diff --git a/src/Extensions/BiasVisualizer.bonsai b/src/Extensions/BiasVisualizer.bonsai index bfa02df3..76b1cd5a 100644 --- a/src/Extensions/BiasVisualizer.bonsai +++ b/src/Extensions/BiasVisualizer.bonsai @@ -51,8 +51,8 @@ R L - West - None + East + Outside 1.1 -1.1 @@ -147,7 +147,7 @@ true 0.00 - 13 + 22 0 0 @@ -161,16 +161,16 @@ 1 - - new (it as LeftBias) - + + new (it.Item1 as LeftBias, it.Item2 as TrialIndex) + 1000 - Item2 - Item1.LeftBias + TrialIndex + LeftBias BiasPlot @@ -193,16 +193,16 @@ -1 - - new (it as RightBias) - + + new (it.Item1 as RightBias, it.Item2 as TrialIndex) + 1000 - Item2 - Item1.RightBias + TrialIndex + RightBias BiasPlot @@ -249,8 +249,8 @@ - - + + From ec8e1e5f5c4691e1da457560bec5b813a6ded48b Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Wed, 12 Aug 2026 13:20:33 -0700 Subject: [PATCH 090/116] fixes camera crashing --- src/Extensions/CameraPreviewVisualizer.bonsai | 78 ++++++++++--------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/src/Extensions/CameraPreviewVisualizer.bonsai b/src/Extensions/CameraPreviewVisualizer.bonsai index 8787cdcf..2a99a9bf 100644 --- a/src/Extensions/CameraPreviewVisualizer.bonsai +++ b/src/Extensions/CameraPreviewVisualizer.bonsai @@ -68,7 +68,7 @@ - Camera1 + SideCamera @@ -96,6 +96,12 @@ CameraStream + + EndExperiment + + + + Value.Image @@ -362,52 +368,54 @@ - - - + + + - - - - - - - + + + + + + + - - - - + + + - - - - - - - + + + + + + + + - - - + + + - + - - - - + + + + - - + + - - - + + + + + From 6f90b8b19cbbafcebd0f228b9ac9854bfac55721 Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Thu, 13 Aug 2026 10:18:58 -0700 Subject: [PATCH 091/116] allow none for metadata --- src/Extensions/MetadataVisualizer.bonsai | 125 ++++----- src/Extensions/Visualizers.bonsai | 343 +---------------------- 2 files changed, 66 insertions(+), 402 deletions(-) diff --git a/src/Extensions/MetadataVisualizer.bonsai b/src/Extensions/MetadataVisualizer.bonsai index b437e845..92b8123c 100644 --- a/src/Extensions/MetadataVisualizer.bonsai +++ b/src/Extensions/MetadataVisualizer.bonsai @@ -13,7 +13,6 @@ - @@ -39,17 +38,17 @@ true - Condition + Stage WidthFixed 0 - Subject + Experimenter WidthFixed 0 - Session + Subject WidthFixed 0 @@ -83,8 +82,27 @@ CurrentMetadata + + + Item2.StageName + + + + + + + + true + + + + true + + + CurrentMetadata + - Experimenter + Item1.Experimenter @@ -121,7 +139,7 @@ true - Expo + true @@ -130,7 +148,7 @@ CurrentMetadata - Subject + Item1.Subject @@ -139,7 +157,7 @@ true - Plimbo + true @@ -148,8 +166,9 @@ CurrentMetadata - SessionName + Item1.Experiment + @@ -157,25 +176,7 @@ true - Stage1 - - - true - - - CurrentMetadata - - - Experiment - - - - - - - - true - Task6 + true @@ -276,9 +277,6 @@ - - - EndExperiment @@ -289,49 +287,50 @@ - - - - - - + + + + + + - - - + + + - - - + + + - - - + + + - - - - + + + - + + - - - - - - + + + + + - - - - - - + + + + + + + + diff --git a/src/Extensions/Visualizers.bonsai b/src/Extensions/Visualizers.bonsai index 047a22bd..95aec580 100644 --- a/src/Extensions/Visualizers.bonsai +++ b/src/Extensions/Visualizers.bonsai @@ -1891,345 +1891,10 @@ - - MetadataVisualizer - - - - Source1 - - - - - - - - MetadataVisualizer - - - - Source1 - - - CurrentMetadata - - - - - - Metadata - - - true - - - true - - - Stage - WidthFixed - 0 - - - Experimenter - WidthFixed - 0 - - - Subject - WidthFixed - 0 - - - Experiment - WidthFixed - 0 - - - Habituation - WidthStretch - 0 - - - Control - WidthStretch - 0 - - - BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit - - 0 - 0 - - 0 - true - - - true - - - CurrentMetadata - - - Item2.StageName - - - - - - - - true - final - - - true - - - CurrentMetadata - - - Item1.Experimenter - - - - - - Source1 - - - Count - - - - 0 - - - - - - - - - - - - - - 0 - - - - - - - - - true - Test - - - true - - - CurrentMetadata - - - Item1.Subject - - - - - - - - true - Test - - - true - - - CurrentMetadata - - - Item1.Experiment - - - - - - - - true - asdgfadgdafgdfhgsghsfghsfghshdfghsfghsfghsfghahsfgh - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - Habituation - - - true - - - Habituation - true - None - 0 - 0 - 0 - - - - - - UiHabituationTimeUpdate - - - - - - true - - - true - - - Start - WidthStretch - 0 - - - Stop - WidthStretch - 0 - - - None - - 0 - 0 - - 0 - false - - - true - - - StartButton - true - START - true - - 100 - 50 - - - - - - - - StartExperimentShortcut - - - true - - - StopButton - true - STOP - true - - 100 - 50 - - - - - EndExperiment - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Metadata + StartExperimentShortcut + UiHabituationTimeUpdate PreSession From 05fae1b2355d6a35687e0d8e8295409a59aceb00 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Fri, 21 Aug 2026 12:22:35 +0100 Subject: [PATCH 092/116] Initial outline for shader pass operator --- src/Extensions/ShaderPass.cs | 101 +++++++++++++++++++++++++++++++++++ src/test_shader_pass.bonsai | 76 ++++++++++++++++++++++++++ 2 files changed, 177 insertions(+) create mode 100644 src/Extensions/ShaderPass.cs create mode 100644 src/test_shader_pass.bonsai diff --git a/src/Extensions/ShaderPass.cs b/src/Extensions/ShaderPass.cs new file mode 100644 index 00000000..aec91943 --- /dev/null +++ b/src/Extensions/ShaderPass.cs @@ -0,0 +1,101 @@ +using Bonsai; +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Reactive.Linq; +using Hexa.NET.ImGui; +using OpenTK.Graphics.OpenGL4; +using System.Runtime.Remoting.Contexts; + + +public class ShaderPass : Combinator +{ + const string VertexShaderSource = @" + #version 330 core + layout(location = 0) in vec2 vertexPosition; + layout(location = 1) in vec2 vertexTexCoords; + + out vec2 TexCoords; + + void main() + { + TexCoords = vec2(.5, -.5) * (vertexPosition.xy + 1); + gl_Position = vec4(vertexPosition.xy, 0.0, 1.0); + } + "; + + const string DefaultFragmentShader = @" + #version 330 + uniform sampler2D tex0; + uniform vec2 iResolution; + in vec2 texCoord; + out vec4 fragColor; + + void main() + { + fragColor = vec4(1.0, 0.0, 0.0, 1.0); + } + "; + + public override IObservable Process(IObservable source) + { + return Observable.Defer(() => + { + int shaderProgram = 0; + return source.Select(texture => + { + var currentContext = ImGui.GetCurrentContext(); + var sourceTexture = (int)(ulong)texture.GetTexID(); + + if (shaderProgram == 0) + { + shaderProgram = CreateProgram(VertexShaderSource, DefaultFragmentShader); + } + + // GL.UseProgram(shaderProgram); + + // GL.ActiveTexture(TextureUnit.Texture0); + // GL.BindTexture(TextureTarget.Texture2D, sourceTexture); + + // GL.UseProgram(0); + + return texture; + }); + }); + } + + static int CreateProgram(string vertexCode, string fragmentCode) + { + var vertexShader = CompileShader(ShaderType.VertexShader, vertexCode); + var fragmentShader = CompileShader(ShaderType.FragmentShader, fragmentCode); + int status; + + var program = GL.CreateProgram(); + GL.AttachShader(program, vertexShader); + GL.AttachShader(program, fragmentShader); + GL.LinkProgram(program); + GL.DetachShader(program, vertexShader); + GL.DetachShader(program, fragmentShader); + GL.GetProgram(program, GetProgramParameterName.LinkStatus, out status); + + if (status == 0) + { + var infoLog = GL.GetProgramInfoLog(program); + GL.DeleteProgram(program); + Console.WriteLine(infoLog); + throw new InvalidOperationException("Failed to link the shader program."); + } + + GL.DeleteShader(vertexShader); + GL.DeleteShader(fragmentShader); + + return program; + } + + static int CompileShader(ShaderType type, string source) + { + var shader = GL.CreateShader(type); + return shader; + } +} diff --git a/src/test_shader_pass.bonsai b/src/test_shader_pass.bonsai new file mode 100644 index 00000000..a866392f --- /dev/null +++ b/src/test_shader_pass.bonsai @@ -0,0 +1,76 @@ + + + + + + + Frame + + + Frame + + + + 0 + + + + + Frame + + + + Rgba + Repeat + Repeat + Linear + Linear + + + + + + + + + + + + true + + 640 + 480 + + + 0 + 0 + + + 1 + 1 + + + + + + + + + + + + + + + + + + \ No newline at end of file From 95079ed24c276d46356b621a5e4a78e97a8b59bc Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Fri, 21 Aug 2026 12:38:03 +0100 Subject: [PATCH 093/116] Fix shader compilation method --- src/Extensions/ShaderPass.cs | 31 ++++++++++++++++++++++--------- src/test_shader_pass.bonsai | 6 ++++-- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/Extensions/ShaderPass.cs b/src/Extensions/ShaderPass.cs index aec91943..7d6125c9 100644 --- a/src/Extensions/ShaderPass.cs +++ b/src/Extensions/ShaderPass.cs @@ -1,4 +1,4 @@ -using Bonsai; +using Bonsai; using System; using System.ComponentModel; using System.Collections.Generic; @@ -16,17 +16,17 @@ public class ShaderPass : Combinator layout(location = 0) in vec2 vertexPosition; layout(location = 1) in vec2 vertexTexCoords; - out vec2 TexCoords; + out vec2 texCoord; void main() { - TexCoords = vec2(.5, -.5) * (vertexPosition.xy + 1); + texCoord = vec2(.5, -.5) * (vertexPosition.xy + 1); gl_Position = vec4(vertexPosition.xy, 0.0, 1.0); } "; const string DefaultFragmentShader = @" - #version 330 + #version 330 core uniform sampler2D tex0; uniform vec2 iResolution; in vec2 texCoord; @@ -53,12 +53,12 @@ public override IObservable Process(IObservable sour shaderProgram = CreateProgram(VertexShaderSource, DefaultFragmentShader); } - // GL.UseProgram(shaderProgram); + GL.UseProgram(shaderProgram); - // GL.ActiveTexture(TextureUnit.Texture0); - // GL.BindTexture(TextureTarget.Texture2D, sourceTexture); + GL.ActiveTexture(TextureUnit.Texture0); + GL.BindTexture(TextureTarget.Texture2D, sourceTexture); - // GL.UseProgram(0); + GL.UseProgram(0); return texture; }); @@ -84,7 +84,7 @@ static int CreateProgram(string vertexCode, string fragmentCode) var infoLog = GL.GetProgramInfoLog(program); GL.DeleteProgram(program); Console.WriteLine(infoLog); - throw new InvalidOperationException("Failed to link the shader program."); + throw new InvalidOperationException(string.Format("Failed to link the shader program: {0}", infoLog)); } GL.DeleteShader(vertexShader); @@ -95,7 +95,20 @@ static int CreateProgram(string vertexCode, string fragmentCode) static int CompileShader(ShaderType type, string source) { + int status; + var shader = GL.CreateShader(type); + GL.ShaderSource(shader, source); + GL.CompileShader(shader); + GL.GetShader(shader, ShaderParameter.CompileStatus, out status); + + if (status == 0) + { + var infoLog = GL.GetShaderInfoLog(shader); + GL.DeleteShader(shader); + throw new InvalidOperationException(string.Format("Failed to compile the {0}.", infoLog)); + } + return shader; } } diff --git a/src/test_shader_pass.bonsai b/src/test_shader_pass.bonsai index a866392f..fd80d657 100644 --- a/src/test_shader_pass.bonsai +++ b/src/test_shader_pass.bonsai @@ -58,8 +58,10 @@ 1 - - + + + + From ee7980dcffd6efdeb00ca1ab8fdf50f9e4f3549b Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Fri, 21 Aug 2026 10:57:26 -0700 Subject: [PATCH 094/116] fixes quiescent software event misspelling --- src/Extensions/TaskEngine.bonsai | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Extensions/TaskEngine.bonsai b/src/Extensions/TaskEngine.bonsai index 9f4779ed..1a31ebd5 100644 --- a/src/Extensions/TaskEngine.bonsai +++ b/src/Extensions/TaskEngine.bonsai @@ -357,7 +357,7 @@ - QuiscentPeriod + QuiescentPeriod From 495f781cdd2a27ca50ceed901d1e71f1f7614613 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Sat, 22 Aug 2026 11:49:06 +0100 Subject: [PATCH 095/116] Working basic shader pass --- src/Extensions/ShaderPass.cs | 77 ++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 3 deletions(-) diff --git a/src/Extensions/ShaderPass.cs b/src/Extensions/ShaderPass.cs index 7d6125c9..36a6b955 100644 --- a/src/Extensions/ShaderPass.cs +++ b/src/Extensions/ShaderPass.cs @@ -20,7 +20,7 @@ public class ShaderPass : Combinator void main() { - texCoord = vec2(.5, -.5) * (vertexPosition.xy + 1); + texCoord = vec2(.5, .5) * (vertexPosition.xy + 1); gl_Position = vec4(vertexPosition.xy, 0.0, 1.0); } "; @@ -38,33 +38,105 @@ void main() } "; + static readonly float[] QuadVertices = new float[] { -1f, -1f, 1f, -1f, -1f, 1f, 1f, 1f }; + public override IObservable Process(IObservable source) { return Observable.Defer(() => { int shaderProgram = 0; + int vertexArray = 0; + int framebuffer = 0; + int targetTexture = 0; + int targetWidth = 0; + int targetHeight = 0; + var targetRef = default(ImTextureRef); return source.Select(texture => { var currentContext = ImGui.GetCurrentContext(); var sourceTexture = (int)(ulong)texture.GetTexID(); + if (sourceTexture == 0) return texture; if (shaderProgram == 0) { shaderProgram = CreateProgram(VertexShaderSource, DefaultFragmentShader); + vertexArray = CreateQuad(); + framebuffer = GL.GenFramebuffer(); + } + + // The pass renders into a texture of the same size as the incoming one. + int width, height; + GL.BindTexture(TextureTarget.Texture2D, sourceTexture); + GL.GetTexLevelParameter(TextureTarget.Texture2D, 0, GetTextureParameter.TextureWidth, out width); + GL.GetTexLevelParameter(TextureTarget.Texture2D, 0, GetTextureParameter.TextureHeight, out height); + if (width != targetWidth || height != targetHeight) + { + targetTexture = CreateTarget(targetTexture, width, height); + targetRef = CreateTextureRef(targetTexture); + targetWidth = width; + targetHeight = height; + GL.BindFramebuffer(FramebufferTarget.Framebuffer, framebuffer); + GL.FramebufferTexture2D( + FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, + TextureTarget.Texture2D, targetTexture, 0); + GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); } + var viewport = new int[4]; + GL.GetInteger(GetPName.Viewport, viewport); + GL.BindFramebuffer(FramebufferTarget.Framebuffer, framebuffer); + GL.Viewport(0, 0, width, height); GL.UseProgram(shaderProgram); GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, sourceTexture); + GL.BindVertexArray(vertexArray); + GL.DrawArrays(PrimitiveType.TriangleStrip, 0, 4); + + GL.BindVertexArray(0); GL.UseProgram(0); + GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); + GL.Viewport(viewport[0], viewport[1], viewport[2], viewport[3]); - return texture; + return targetRef; }); }); } + static int CreateQuad() + { + var vertexArray = GL.GenVertexArray(); + GL.BindVertexArray(vertexArray); + GL.BindBuffer(BufferTarget.ArrayBuffer, GL.GenBuffer()); + GL.BufferData( + BufferTarget.ArrayBuffer, QuadVertices.Length * sizeof(float), + QuadVertices, BufferUsageHint.StaticDraw); + GL.EnableVertexAttribArray(0); + GL.VertexAttribPointer(0, 2, VertexAttribPointerType.Float, false, 0, 0); + GL.BindVertexArray(0); + return vertexArray; + } + + static int CreateTarget(int texture, int width, int height) + { + if (texture == 0) texture = GL.GenTexture(); + GL.BindTexture(TextureTarget.Texture2D, texture); + GL.TexImage2D( + TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, width, height, 0, + PixelFormat.Rgba, PixelType.UnsignedByte, IntPtr.Zero); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); + return texture; + } + + static ImTextureRef CreateTextureRef(int texture) + { + var textureRef = default(ImTextureRef); + textureRef.TexID = new ImTextureID((IntPtr)texture); + return textureRef; + } + static int CreateProgram(string vertexCode, string fragmentCode) { var vertexShader = CompileShader(ShaderType.VertexShader, vertexCode); @@ -83,7 +155,6 @@ static int CreateProgram(string vertexCode, string fragmentCode) { var infoLog = GL.GetProgramInfoLog(program); GL.DeleteProgram(program); - Console.WriteLine(infoLog); throw new InvalidOperationException(string.Format("Failed to link the shader program: {0}", infoLog)); } From 906b05b80a4f842fec0c3fcf41b704376cc54af0 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Mon, 24 Aug 2026 11:22:23 +0100 Subject: [PATCH 096/116] Test with saturation overlay --- src/Extensions/ShaderPass.cs | 13 ++++++++++-- src/test_shader_pass.bonsai | 39 +++++++++++++++++++++++++++--------- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/Extensions/ShaderPass.cs b/src/Extensions/ShaderPass.cs index 36a6b955..fb202e7a 100644 --- a/src/Extensions/ShaderPass.cs +++ b/src/Extensions/ShaderPass.cs @@ -29,12 +29,21 @@ void main() #version 330 core uniform sampler2D tex0; uniform vec2 iResolution; + uniform float minSaturation = 0.1; + uniform float maxSaturation = 0.9; + uniform float alpha = 0.5; in vec2 texCoord; out vec4 fragColor; - void main() + void main() { - fragColor = vec4(1.0, 0.0, 0.0, 1.0); + vec4 texColor = texture(tex0, texCoord); + vec4 overlay = vec4(0,0,0,0); + + if (texColor.r >= maxSaturation) overlay = vec4(1,0,0,alpha); + else if (texColor.r <= minSaturation) overlay = vec4(0,0,1,alpha); + + fragColor = mix(texColor, overlay, overlay.a); } "; diff --git a/src/test_shader_pass.bonsai b/src/test_shader_pass.bonsai index fd80d657..6b28a7b2 100644 --- a/src/test_shader_pass.bonsai +++ b/src/test_shader_pass.bonsai @@ -17,12 +17,27 @@ Frame + + + PT0S + PT0.004S + + 0 + + + + + + + + Item2 + Frame @@ -58,21 +73,27 @@ 1 - - - - + + + + + Interval.TotalSeconds - - + + - - + - + + + + + + + \ No newline at end of file From d6c26ece33bed7146dd21f7ca0c1f5321d2017de Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Mon, 24 Aug 2026 11:31:18 +0100 Subject: [PATCH 097/116] Implement uniform adjustment via property --- src/Extensions/ShaderPass.cs | 5 +++++ src/test_shader_pass.bonsai | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Extensions/ShaderPass.cs b/src/Extensions/ShaderPass.cs index fb202e7a..48e29b75 100644 --- a/src/Extensions/ShaderPass.cs +++ b/src/Extensions/ShaderPass.cs @@ -11,6 +11,8 @@ public class ShaderPass : Combinator { + public float Alpha { get; set; } + const string VertexShaderSource = @" #version 330 core layout(location = 0) in vec2 vertexPosition; @@ -60,6 +62,7 @@ public override IObservable Process(IObservable sour int targetWidth = 0; int targetHeight = 0; var targetRef = default(ImTextureRef); + int alphaLocation = 0; return source.Select(texture => { var currentContext = ImGui.GetCurrentContext(); @@ -71,6 +74,7 @@ public override IObservable Process(IObservable sour shaderProgram = CreateProgram(VertexShaderSource, DefaultFragmentShader); vertexArray = CreateQuad(); framebuffer = GL.GenFramebuffer(); + alphaLocation = GL.GetUniformLocation(shaderProgram, "alpha"); } // The pass renders into a texture of the same size as the incoming one. @@ -99,6 +103,7 @@ public override IObservable Process(IObservable sour GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, sourceTexture); + GL.Uniform1(alphaLocation, Alpha); GL.BindVertexArray(vertexArray); GL.DrawArrays(PrimitiveType.TriangleStrip, 0, 4); diff --git a/src/test_shader_pass.bonsai b/src/test_shader_pass.bonsai index 6b28a7b2..e948bf78 100644 --- a/src/test_shader_pass.bonsai +++ b/src/test_shader_pass.bonsai @@ -51,7 +51,9 @@ - + + 0.4 + From c485c1daacf69a903a305d4aef06cdfd0928924c Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Mon, 24 Aug 2026 11:37:02 +0100 Subject: [PATCH 098/116] Implement adjustment of other uniforms --- src/Extensions/ShaderPass.cs | 8 ++++++++ src/test_shader_pass.bonsai | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Extensions/ShaderPass.cs b/src/Extensions/ShaderPass.cs index 48e29b75..c8a84202 100644 --- a/src/Extensions/ShaderPass.cs +++ b/src/Extensions/ShaderPass.cs @@ -12,6 +12,8 @@ public class ShaderPass : Combinator { public float Alpha { get; set; } + public float MinSaturation {get; set;} + public float MaxSaturation {get; set;} const string VertexShaderSource = @" #version 330 core @@ -63,6 +65,8 @@ public override IObservable Process(IObservable sour int targetHeight = 0; var targetRef = default(ImTextureRef); int alphaLocation = 0; + int minSaturation = 0; + int maxSaturation = 0; return source.Select(texture => { var currentContext = ImGui.GetCurrentContext(); @@ -75,6 +79,8 @@ public override IObservable Process(IObservable sour vertexArray = CreateQuad(); framebuffer = GL.GenFramebuffer(); alphaLocation = GL.GetUniformLocation(shaderProgram, "alpha"); + maxSaturation = GL.GetUniformLocation(shaderProgram, "maxSaturation"); + minSaturation = GL.GetUniformLocation(shaderProgram, "minSaturation"); } // The pass renders into a texture of the same size as the incoming one. @@ -104,6 +110,8 @@ public override IObservable Process(IObservable sour GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, sourceTexture); GL.Uniform1(alphaLocation, Alpha); + GL.Uniform1(maxSaturation, MaxSaturation); + GL.Uniform1(minSaturation, MinSaturation); GL.BindVertexArray(vertexArray); GL.DrawArrays(PrimitiveType.TriangleStrip, 0, 4); diff --git a/src/test_shader_pass.bonsai b/src/test_shader_pass.bonsai index e948bf78..727e440f 100644 --- a/src/test_shader_pass.bonsai +++ b/src/test_shader_pass.bonsai @@ -52,7 +52,9 @@ - 0.4 + 1 + 0.3 + 0.7 From a2f6a8847c847c18d6c98e8740a498c121ec66cf Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Mon, 24 Aug 2026 12:01:36 +0100 Subject: [PATCH 099/116] Refactor name of shader pass Reflects that in this case it's always a saturation shader pass rather than a generic shader pass --- src/Extensions/{ShaderPass.cs => SaturationShaderPass.cs} | 6 +++--- src/test_shader_pass.bonsai | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) rename src/Extensions/{ShaderPass.cs => SaturationShaderPass.cs} (98%) diff --git a/src/Extensions/ShaderPass.cs b/src/Extensions/SaturationShaderPass.cs similarity index 98% rename from src/Extensions/ShaderPass.cs rename to src/Extensions/SaturationShaderPass.cs index c8a84202..770896c1 100644 --- a/src/Extensions/ShaderPass.cs +++ b/src/Extensions/SaturationShaderPass.cs @@ -9,7 +9,7 @@ using System.Runtime.Remoting.Contexts; -public class ShaderPass : Combinator +public class SaturationShaderPass : Combinator { public float Alpha { get; set; } public float MinSaturation {get; set;} @@ -29,7 +29,7 @@ void main() } "; - const string DefaultFragmentShader = @" + const string SaturationFragmentShader = @" #version 330 core uniform sampler2D tex0; uniform vec2 iResolution; @@ -75,7 +75,7 @@ public override IObservable Process(IObservable sour if (shaderProgram == 0) { - shaderProgram = CreateProgram(VertexShaderSource, DefaultFragmentShader); + shaderProgram = CreateProgram(VertexShaderSource, SaturationFragmentShader); vertexArray = CreateQuad(); framebuffer = GL.GenFramebuffer(); alphaLocation = GL.GetUniformLocation(shaderProgram, "alpha"); diff --git a/src/test_shader_pass.bonsai b/src/test_shader_pass.bonsai index 727e440f..c411dd9a 100644 --- a/src/test_shader_pass.bonsai +++ b/src/test_shader_pass.bonsai @@ -51,10 +51,10 @@ - - 1 - 0.3 - 0.7 + + 0.5 + 0.2 + 0.8 From 0a7dc36e36879b89e96faea2bc05fdbfea93f310 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Wed, 26 Aug 2026 16:24:05 +0100 Subject: [PATCH 100/116] Update camera preview visualizer to use saturation shader pass --- src/Extensions/CameraPreviewVisualizer.bonsai | 109 ++++++------ src/test_saturation_visualizer.bonsai | 157 ++++++++++++++++++ src/test_shader_pass.bonsai | 35 ++-- src/test_visualizer.bonsai | 7 +- 4 files changed, 223 insertions(+), 85 deletions(-) create mode 100644 src/test_saturation_visualizer.bonsai diff --git a/src/Extensions/CameraPreviewVisualizer.bonsai b/src/Extensions/CameraPreviewVisualizer.bonsai index 2a99a9bf..074c598e 100644 --- a/src/Extensions/CameraPreviewVisualizer.bonsai +++ b/src/Extensions/CameraPreviewVisualizer.bonsai @@ -3,10 +3,10 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" - xmlns:p1="clr-namespace:;assembly=Extensions" xmlns:cv="clr-namespace:Bonsai.Vision;assembly=Bonsai.Vision" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" + xmlns:p1="clr-namespace:;assembly=Extensions" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -30,7 +30,7 @@ - Camera + Frame true @@ -68,7 +68,7 @@ - SideCamera + Camera1 @@ -105,27 +105,6 @@ Value.Image - - OverlayAlpha - - - - - - - - - - - - - - - 53 - 215 - 0.5 - - @@ -223,8 +202,8 @@ - 320 - 240 + 720 + 540 @@ -238,8 +217,8 @@ - 320 - 240 + 720 + 540 0 @@ -281,6 +260,25 @@ Linear + + OverlayAlpha + + + + + + + + + + + + + 0.5 + 0.1 + 0.3 + + @@ -368,54 +366,53 @@ - + - + + - - - + + + + + - - - + - - - - - + + + + - - + + - + - - + + - - + + - - - + + + + - - - + + - + - diff --git a/src/test_saturation_visualizer.bonsai b/src/test_saturation_visualizer.bonsai new file mode 100644 index 00000000..5ffcd588 --- /dev/null +++ b/src/test_saturation_visualizer.bonsai @@ -0,0 +1,157 @@ + + + + + + + Frame + + + + PT0S + PT0.01S + + + + + 0.01 + + + + TimeBase + + + + + 25224819 + Default + + + + CameraFeed + + + EndExperiment + + + Camera1 + + + + CameraFeed + + + TimeBase + + + + + + + + + + + + + + + + + + + + + + + Camera1 + + + + + + + Camera2 + + + + CameraFeed + + + TimeBase + + + + + + + + + + + + + + + + + + + + + + + Camera2 + + + + + + + + + + Item2 + Item1 + + + TriggeredCamerasStream + + + + + Frame + Camera1 + 0.1 + 0.3 + 2 + 0 + TriggeredCamerasStream + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test_shader_pass.bonsai b/src/test_shader_pass.bonsai index c411dd9a..43f97e59 100644 --- a/src/test_shader_pass.bonsai +++ b/src/test_shader_pass.bonsai @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" - xmlns:cv="clr-namespace:Bonsai.Vision;assembly=Bonsai.Vision" + xmlns:spk="clr-namespace:Bonsai.Spinnaker;assembly=Bonsai.Spinnaker" xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns:p1="clr-namespace:;assembly=Extensions" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" @@ -18,25 +18,13 @@ Frame - - PT0S - PT0.004S + + + Default - - - 0 - - - - - - - - - - Item2 + Image Frame @@ -86,18 +74,15 @@ - - + + - + + - - + - - - \ No newline at end of file diff --git a/src/test_visualizer.bonsai b/src/test_visualizer.bonsai index 9341cd48..c4872e71 100644 --- a/src/test_visualizer.bonsai +++ b/src/test_visualizer.bonsai @@ -1,4 +1,4 @@ - + 5 0.5 5 - + 0 @@ -2854,7 +2854,6 @@ Metadata StartExperimentShortcut - EndExperiment UiHabituationTimeUpdate @@ -2885,10 +2884,10 @@ UiGiveRight UiMoveLeft UiMoveRight - SessionMetadata StartExperiment UiCueGiveLeft UiCueGiveRight + SessionMetadata From aa83829fd704e9154cff281610f6de279720010a Mon Sep 17 00:00:00 2001 From: svc_aind_behavior Date: Fri, 28 Aug 2026 13:17:46 -0700 Subject: [PATCH 101/116] guards retracted stage movement --- .bonsai/Settings/src/main.editor | 23 +- src/Extensions/OperationControl.bonsai | 373 +++++++++++++++++--- src/Extensions/PreSessionVisualizer.bonsai | 383 ++++++++++++++------- src/Extensions/TaskEngine.bonsai | 19 +- src/main.bonsai | 82 +++-- 5 files changed, 675 insertions(+), 205 deletions(-) diff --git a/.bonsai/Settings/src/main.editor b/.bonsai/Settings/src/main.editor index bbd6dca8..3c4419f3 100644 --- a/.bonsai/Settings/src/main.editor +++ b/.bonsai/Settings/src/main.editor @@ -1,17 +1,22 @@  - + - + - + + + + + + @@ -19,17 +24,19 @@ - + - + - + - - + + + + diff --git a/src/Extensions/OperationControl.bonsai b/src/Extensions/OperationControl.bonsai index 2f914b1d..9ccfee7b 100644 --- a/src/Extensions/OperationControl.bonsai +++ b/src/Extensions/OperationControl.bonsai @@ -7,8 +7,8 @@ xmlns:beh="clr-namespace:Harp.Behavior;assembly=Harp.Behavior" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns:sys="clr-namespace:System;assembly=mscorlib" - xmlns:p2="clr-namespace:Harp.StepperDriver;assembly=Harp.StepperDriver" - xmlns:p3="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" + xmlns:p2="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" + xmlns:p3="clr-namespace:Harp.StepperDriver;assembly=Harp.StepperDriver" xmlns:p4="clr-namespace:;assembly=Extensions" xmlns:p5="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" xmlns:p6="clr-namespace:Harp.SoundCard;assembly=Harp.SoundCard" @@ -660,23 +660,6 @@ ManipulatorTask - - IsRightTriggerQuickRetract - - - - it ? 2 : 4 - - - Write - - - - StepperDriverCommands - - - SpoutAvailableState - StartExperiment @@ -698,22 +681,249 @@ InitialManipulatorPosition - - InitialManipulatorPosition + + InitialManipulatorPosition + + + + SoftwareEvent + + + EndExperiment + + + ExtendedManipulatorPosition + + + + + + + 1 + + + + Item2 + + + + FinalManipulatorPosition SoftwareEvent + + ManipulatorPosition + + + + 1 + + + + ExtendedManipulatorPosition + + + IsRightTriggerQuickRetract + + + UpdateExtendedPosition + + + + IsRetracted + + + + 1 + + + + + + + + Source1 + + + + + + + + + + ManipulatorPosition + + + + + + Item2 + + + ExtendedManipulatorPosition + + + + false + + + + + + + Source1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SetRetractedState + + + + + true + + + + IsRetracted + + + + + + + + + + + + it ? 2 : 4 + + + Write + + + + StepperDriverCommands + + + SpoutAvailableState + SpoutAvailableState + + UpdateExtendedPosition + + + + IsRetracted + + + + 1 + + + + + + + + Source1 + + + + + + + + + + ManipulatorPosition + + + + + + Item2 + + + ExtendedManipulatorPosition + + + + false + + + + + + + Source1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CalculatePositions - InitialManipulatorPosition + ExtendedManipulatorPosition ManipulatorPosition @@ -756,6 +966,73 @@ MoveTo + + SetRetractedState + + + + SpoutAvailableState + + + + 1 + + + + + IsRetracted + + + ManipulatorPosition + + + + + + Source1 + + + + + + (Math.Round(Item1.X, 2) == Math.Round(Item2.X, 2)) && +(Math.Round(Item1.Y1, 2) == Math.Round(Item2.Y1, 2)) && +(Math.Round(Item1.Y2, 2) == Math.Round(Item2.Y2, 2)) && +(Math.Round(Item1.Z, 2) == Math.Round(Item2.Z, 2)) + + + + + + Source1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + ManualSpoutDelta @@ -829,7 +1106,7 @@ ManipulatorBiasTracker - InitialManipulatorPosition + ManipulatorPosition X @@ -858,8 +1135,8 @@ ManipulatorBiasTracker - - ManipulatorBiasTracker + + ManipulatorBiasTracker @@ -867,37 +1144,49 @@ - - + + - - - - - + + + + + + + - - - - + + - - - + + - - - + + + + + + + + + + + + + + + + diff --git a/src/Extensions/PreSessionVisualizer.bonsai b/src/Extensions/PreSessionVisualizer.bonsai index 1735d8da..0dd925cc 100644 --- a/src/Extensions/PreSessionVisualizer.bonsai +++ b/src/Extensions/PreSessionVisualizer.bonsai @@ -288,10 +288,24 @@ true - - MoveLeft - true - Move Left + + IsRetracted + + + + + + + + + MoveLeft + true + Move Left + true + + 100 + 20 + @@ -300,10 +314,20 @@ UiManipulatorLeft - - ForwardLeft - true - Forward Left + + + + + + + ForwardLeft + true + Forward Left + true + + 100 + 20 + @@ -312,10 +336,20 @@ UiManipulatorForwardLeft - - ForwardRight - true - Forward Right + + + + + + + ForwardRight + true + Forward Right + true + + 100 + 20 + @@ -324,10 +358,20 @@ UiManipulatorForwardRight - - Up - true - Up + + + + + + + Up + true + Up + true + + 100 + 20 + @@ -342,10 +386,24 @@ true - - MoveRight - true - Move Right + + IsRetracted + + + + + + + + + MoveRight + true + Move Right + true + + 100 + 20 + @@ -354,10 +412,20 @@ UiManipulatorRight - - BackLeft - true - Back Left + + + + + + + BackLeft + true + Back Left + true + + 100 + 20 + @@ -366,10 +434,20 @@ UiManipulatorBackLeft - - BackRight - true - Back Right + + + + + + + BackRight + true + Back Right + true + + 100 + 20 + @@ -378,10 +456,20 @@ UiManipulatorBackRight - - Down - true - Down + + + + + + + Down + true + Down + true + + 100 + 20 + @@ -411,10 +499,24 @@ UiManipulatorStop - - Home - true - Home + + IsRetracted + + + + + + + + + Home + true + Home + true + + 100 + 20 + @@ -423,10 +525,20 @@ UiManipulatorHome - - Initialize - true - Initialize + + + + + + + Initialize + true + Initialize + true + + 100 + 20 + @@ -484,7 +596,7 @@ true - 0.00 + 14.05 @@ -513,7 +625,7 @@ true - 0.00 + 11.80 @@ -542,7 +654,7 @@ true - 0.00 + 11.90 @@ -571,7 +683,7 @@ true - 0.00 + 17.80 @@ -660,105 +772,114 @@ - + - + - - - + + - + + - + + + + - - - - - + + + + + - - - - - - - - - - + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - + + + - - - - - - + + + - - - - - + + + + + - - - - - + + + + + + + + + + + + + + + + + + @@ -771,10 +892,24 @@ - - + + - + + + + + + + + + + + + + + + diff --git a/src/Extensions/TaskEngine.bonsai b/src/Extensions/TaskEngine.bonsai index 1a31ebd5..0ec04a8f 100644 --- a/src/Extensions/TaskEngine.bonsai +++ b/src/Extensions/TaskEngine.bonsai @@ -391,7 +391,7 @@ TimeToResetDuringQuiescence - RngSeedValue + RngObject @@ -399,7 +399,13 @@ - + + + + + + it < 0 ? 0 : it + it < 0 ? 0 : it @@ -411,7 +417,7 @@ - PT0S + PT2S @@ -423,7 +429,7 @@ - + @@ -431,10 +437,11 @@ - - + + + diff --git a/src/main.bonsai b/src/main.bonsai index aff9f4df..df46f347 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -7,6 +7,7 @@ xmlns:p2="clr-namespace:;assembly=Extensions" xmlns:p3="clr-namespace:System.Reactive;assembly=System.Reactive.Core" xmlns:p4="clr-namespace:AllenNeuralDynamics.AindBehaviorServices.DataTypes;assembly=AllenNeuralDynamics.AindBehaviorServices" + xmlns:num="clr-namespace:Bonsai.Numerics;assembly=Bonsai.Numerics" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -113,6 +114,19 @@ IsWaveformUploadDone + + + false + + + + + 1 + + + + IsRetracted + @@ -151,15 +165,6 @@ GlobalTrial - - SetIsRightRewardAmount - - - GlobalTrialMetrics - - - TrialIndex - TaskLogicParameters @@ -169,6 +174,28 @@ RngSeedValue + + + + + + + + + + + + RngObject + + + SetIsRightRewardAmount + + + GlobalTrialMetrics + + + TrialIndex + false @@ -290,31 +317,36 @@ + + + - - - - - + - + - + + - + + - - - + + - - - - + + + + - + + + + + + From 89e623c5126a4d26408e13d236ac89d7511b0fb5 Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Thu, 3 Sep 2026 09:18:22 -0700 Subject: [PATCH 102/116] fixes quiescent typo and adds annotation --- .bonsai/Settings/src/main.editor | 44 ----------------- .gitignore | 2 +- src/Extensions/OperationControl.bonsai | 65 ++++++++++++++++++++------ src/Extensions/TaskEngine.bonsai | 24 ++++++++-- 4 files changed, 72 insertions(+), 63 deletions(-) delete mode 100644 .bonsai/Settings/src/main.editor diff --git a/.bonsai/Settings/src/main.editor b/.bonsai/Settings/src/main.editor deleted file mode 100644 index 1a8cd625..00000000 --- a/.bonsai/Settings/src/main.editor +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.gitignore b/.gitignore index 414a43fb..7ab208c1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ bin obj Packages Bonsai.exe.WebView2 -.bonsai/Settings/ +.bonsai/Settings/** *.bin *.avi *.dll diff --git a/src/Extensions/OperationControl.bonsai b/src/Extensions/OperationControl.bonsai index 9ccfee7b..67ae506f 100644 --- a/src/Extensions/OperationControl.bonsai +++ b/src/Extensions/OperationControl.bonsai @@ -966,6 +966,10 @@ MoveTo + + Retraction State Logic + + SetRetractedState @@ -1013,6 +1017,31 @@ + + SpoutAvailableState + + + + 1 + + + + + + + + Source1 + + + + + + + + + + + @@ -1022,14 +1051,19 @@ - + - + + + + + + @@ -1170,23 +1204,24 @@ - - - - - - - - - - - - + + + + + + + + + + + + - + + diff --git a/src/Extensions/TaskEngine.bonsai b/src/Extensions/TaskEngine.bonsai index 745264a4..0a70dd97 100644 --- a/src/Extensions/TaskEngine.bonsai +++ b/src/Extensions/TaskEngine.bonsai @@ -441,7 +441,7 @@ - QuiscentPeriod + QuiescentPeriod @@ -539,6 +539,22 @@ QuickRetractSettings + + EnableDuringQuiescence + + + + + + Source1 + + + + + + + + @@ -580,10 +596,12 @@ - + - + + + From 1d2cdef4b5872b97f92df0299c09908d628dff17 Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Thu, 3 Sep 2026 10:11:42 -0700 Subject: [PATCH 103/116] evaluates is_rewarded to false if animal does not choose auto rewarded side --- src/Extensions/DetermineReward.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Extensions/DetermineReward.cs b/src/Extensions/DetermineReward.cs index 41e365c0..9be3bdfa 100644 --- a/src/Extensions/DetermineReward.cs +++ b/src/Extensions/DetermineReward.cs @@ -23,7 +23,7 @@ public IObservable Process(IObservable> source) { var response = value.Item1; var trial = value.Item2; - if (!response.HasValue) + if (!response.HasValue || trial.IsAutoRewardRight != response.Value) { return false; } From 49a54dc32f2d0e0562e2da2e930e38fc0daed088 Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Thu, 3 Sep 2026 10:16:22 -0700 Subject: [PATCH 104/116] evaluates choice only on auto reward trials --- src/Extensions/DetermineReward.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Extensions/DetermineReward.cs b/src/Extensions/DetermineReward.cs index 9be3bdfa..93f2de05 100644 --- a/src/Extensions/DetermineReward.cs +++ b/src/Extensions/DetermineReward.cs @@ -23,7 +23,7 @@ public IObservable Process(IObservable> source) { var response = value.Item1; var trial = value.Item2; - if (!response.HasValue || trial.IsAutoRewardRight != response.Value) + if (!response.HasValue || (trial.IsAutoRewardRight.HasValue && trial.IsAutoRewardRight.Value != response.Value)) { return false; } From be292aac11c231060c3ca07591bda9f0d6c1ddca Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Thu, 3 Sep 2026 16:04:39 -0700 Subject: [PATCH 105/116] adds autowater and bias movements to visualizers --- src/Extensions/BehaviorVisualizer.bonsai | 214 ++++++++++++++++++----- src/Extensions/BiasVisualizer.bonsai | 119 ++++++++++++- src/Extensions/Visualizers.bonsai | 175 ++++++++++++++++-- 3 files changed, 451 insertions(+), 57 deletions(-) diff --git a/src/Extensions/BehaviorVisualizer.bonsai b/src/Extensions/BehaviorVisualizer.bonsai index 320c9a30..0503b60b 100644 --- a/src/Extensions/BehaviorVisualizer.bonsai +++ b/src/Extensions/BehaviorVisualizer.bonsai @@ -2,11 +2,11 @@ @@ -17,11 +17,113 @@ + + BehaviorPlot + + + + + AutoRewardLeft + + + Value + + + + 0.9 + + + + Seconds + + + + + + new(it.Item1 as LickLeft, it.Item2) + + + 1000 + Item2 + LickLeft + + + EventPlot + + + + Diamond + 3 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + + + + AutoRewardRight + + + Value + + + + 0.1 + + + + Seconds + + + + + + new(it.Item1 as LickRight, it.Item2) + + + 1000 + Item2 + LickRight + + + EventPlot + + + + Diamond + 3 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + @@ -485,86 +587,108 @@ - - - - - + + + + + + - + + + - + + - - - - + + - - + + + + - - - - + - - - + - - - - - - + + + - + - - - - + + + - - + + + - - - + + + + + + - + - + - - - + + + + + - + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Extensions/BiasVisualizer.bonsai b/src/Extensions/BiasVisualizer.bonsai index 76b1cd5a..bb44d7b5 100644 --- a/src/Extensions/BiasVisualizer.bonsai +++ b/src/Extensions/BiasVisualizer.bonsai @@ -12,6 +12,8 @@ + + BiasVisualizer @@ -158,7 +160,7 @@ - 1 + 0.5 @@ -190,7 +192,7 @@ - -1 + -0.5 @@ -220,6 +222,100 @@ true None + + + + + RightBiasCorrection + + + + -0.5 + + + + + + + new (it.Item1 as RightBias, it.Item2 as TrialIndex) + + + 1000 + TrialIndex + RightBias + + + BiasPlot + + + + Down + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + + + + true + None + + + + + + LeftBiasCorrection + + + + 0.5 + + + + + + + new (it.Item1 as RightBias, it.Item2 as TrialIndex) + + + 1000 + TrialIndex + RightBias + + + BiasPlot + + + + Up + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + + + + true + None + + + TaskLogicParameters + + + TrialGenerator + @@ -251,6 +347,8 @@ + + @@ -265,6 +363,23 @@ + + + + + + + + + + + + + + + + + diff --git a/src/Extensions/Visualizers.bonsai b/src/Extensions/Visualizers.bonsai index 95aec580..d8f12b22 100644 --- a/src/Extensions/Visualizers.bonsai +++ b/src/Extensions/Visualizers.bonsai @@ -126,6 +126,141 @@ LickLeft + + GlobalTrial + + + IsAutoRewardRight + + + + + + + Source1 + + + Value + + + + + + + + + + + + + HarpTimestampSource + + + AutoRewardLeft + + + + + + Source1 + + + Value + + + + + + + + + + + HarpTimestampSource + + + AutoRewardRight + + + GlobalTrial + + + LickspoutOffsetDelta + + + NotZero + + + + Source1 + + + + 0 + + + + + + + + + + + + + + MoveRight + + + + Source1 + + + + 0 + + + + + + + + + + + + HarpTimestampSource + + + LeftBiasCorrection + + + MoveLeft + + + + Source1 + + + + false + + + + + + + + + + + + HarpTimestampSource + + + RightBiasCorrection + SoftwareEvent @@ -257,25 +392,41 @@ - + - + + - - + - - + + - - + - - + + + + + + + + + + + + + + + + + + + @@ -1747,10 +1898,14 @@ LickRight TimedTrial Behavior + AutoRewardRight + AutoRewardLeft Bias TrialIndexedBias + LeftBiasCorrection + RightBiasCorrection PLACEHOLDER From 3e2bc99d558ee65cdd9e71559a6d211e223997fc Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Fri, 4 Sep 2026 15:24:54 +0100 Subject: [PATCH 106/116] Refactor test visualizer workflow with new trial data structure --- .bonsai/Settings/src/test_visualizer.layout | 104 +- src/Extensions/AsObject.cs | 18 + src/test_visualizer.bonsai | 1069 +++++-------------- 3 files changed, 386 insertions(+), 805 deletions(-) create mode 100644 src/Extensions/AsObject.cs diff --git a/.bonsai/Settings/src/test_visualizer.layout b/.bonsai/Settings/src/test_visualizer.layout index 0829d87c..38b19797 100644 --- a/.bonsai/Settings/src/test_visualizer.layout +++ b/.bonsai/Settings/src/test_visualizer.layout @@ -1,2 +1,104 @@  - \ No newline at end of file + + + + + + 508 + 74 + + + 702 + 714 + + Bonsai.ImGui.Visualizers.ImPlotVisualizer + + + + + + false + + 120 + 130 + + + 334 + 64 + + Bonsai.Design.ObjectTextVisualizer + + + + + + + + + + false + + 24 + 26 + + + 334 + 64 + + Bonsai.Design.ObjectTextVisualizer + + + + + + false + + 48 + 52 + + + 334 + 369 + + Bonsai.Design.ObjectTextVisualizer + + + + + + false + + 72 + 78 + + + 334 + 338 + + Bonsai.Design.ObjectTextVisualizer + + + + + + false + + 96 + 104 + + + 334 + 361 + + Bonsai.Design.ObjectTextVisualizer + + + + + + + + + + + \ No newline at end of file diff --git a/src/Extensions/AsObject.cs b/src/Extensions/AsObject.cs new file mode 100644 index 00000000..5bf8b43d --- /dev/null +++ b/src/Extensions/AsObject.cs @@ -0,0 +1,18 @@ +using Bonsai; +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Reactive.Linq; +using Newtonsoft.Json.Linq; + +[Combinator] +[Description("")] +[WorkflowElementCategory(ElementCategory.Transform)] +public class AsObject +{ + public IObservable Process(IObservable> source) + { + return source.Select(value => JObject.FromObject(value)); + } +} diff --git a/src/test_visualizer.bonsai b/src/test_visualizer.bonsai index c4872e71..9c27090d 100644 --- a/src/test_visualizer.bonsai +++ b/src/test_visualizer.bonsai @@ -12,15 +12,14 @@ xmlns:p5="clr-namespace:AllenNeuralDynamics.AindBehaviorServices.DataTypes;assembly=AllenNeuralDynamics.AindBehaviorServices" xmlns:p6="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" + xmlns:p7="clr-namespace:;assembly=Extensions" xmlns:num="clr-namespace:Bonsai.Numerics;assembly=Bonsai.Numerics" xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp" - xmlns:p7="clr-namespace:;assembly=Extensions" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" - xmlns:implot="clr-namespace:Bonsai.ImPlot;assembly=Bonsai.ImPlot" - xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:p8="clr-namespace:System.Reactive;assembly=System.Reactive.Core" + xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -203,7 +202,7 @@ - PT2.277S + PT2.855S @@ -255,7 +254,7 @@ - PT0.609S + PT0.809S @@ -326,7 +325,7 @@ - PT2.764S + PT2.887S @@ -568,6 +567,9 @@ + + + SessionMetadata @@ -593,20 +595,17 @@ it < -1 ? -1 : it - - new (it as Bias) - - - Seconds - - + - - + + new ( +it.Value as Bias, +it.Index as TrialIndex +) - TimedBias + TrialIndexedBias @@ -732,7 +731,7 @@ - true + false @@ -815,67 +814,14 @@ - - 0 - 1 - - - - - 500 - - - - - 0.5 - - - - - - - - - - true - - - - - + + 0.5 + 0.5 - - - 0 - 1 - - - - - 500 - - - - - 0.05 - - - - - - - Item3 ? Item1 : Item2 - - - - - - Item2 - - + @@ -898,8 +844,8 @@ - true - false + false + true @@ -925,7 +871,7 @@ - PT0.637S + PT0.552S @@ -961,6 +907,65 @@ TimedTrial + + + 0 + 1 + + + + + 500 + + + + + 0.5 + + + + + + + + + + false + + + + + + + + + + 0 + 1 + + + + + 500 + + + + + 0.05 + + + + + + + Item3 ? Item1 : Item2 + + + + + + Item2 + @@ -1015,84 +1020,82 @@ - - - - + + + - - + + - + - + - + - + - + - - + + - - + + - - + + - - - - - + + + + + - - + + - - - - - - - - + + + + + + + + - + - - - + + - - - + + - + - + + - - - + + + @@ -1272,592 +1275,16 @@ - - BehaviorVisualizer - - - - - - - - - - - - - BehaviorPlot - - - - - - - Behavior - - - - - - Behavior1 - true - 1 - None - - 0 - 0 - - 0 - - - true - - - EventPlot - true - - -1 - 150 - - NoTitle - AutoFit - RangeFit - - - EventPlot - - - true - - - ContinuousPlot - true - - -1 - 150 - - NoTitle - AutoFit - None - - - ContinuousPlot - - - - EventPlot - - - - - 0 - 1 - - - R - L - - West - None - - - - - - - ContinuousPlot - - - - - 0 - 1 - - - West - None - - - - - - - - - LickLeft - - - Value - - - - 0.9 - - - - new(it as LickLeft) - - - Seconds - - - - - - 1000 - Item2 - Item1.LickLeft - - - EventPlot - - - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - - - - LickRight - - - Value - - - - 0.1 - - - - new(it as LickRight) - - - Seconds - - - - - - 1000 - Item2 - Item1.LickRight - - - EventPlot - - - - Square - 3 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - - - - TimedTrial - - - - - - Value.ChoiceCategory - - - NoChoice - - - - Source1 - - - - NoChoice - - - - - - - - - - - - - 0.5 - - - - LeftChoice - - - - Source1 - - - - LeftChoice - - - - - - - - - - - - - 0.85 - - - - RightChoice - - - - Source1 - - - - RightChoice - - - - - - - - - - - - - 0.15 - - - - - - - new ( - it as Choice -) - - - Seconds - - - - - - - - - 1000 - Seconds - Value.Choice - - - EventPlot - - - - Circle - 3 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - 1 - 1 - - - - true - None - - - Value.TrialCategory - - - LeftRewarded - - - - Source1 - - - - LeftRewarded - - - - - - - - - - - - - 0.8 - - - - RightRewarded - - - - Source1 - - - - RightRewarded - - - - - - - - - - - - - 0.2 - - - - - - - new ( - it as Choice -) - - - - - - - - - 1000 - Seconds - Value.Choice - - - EventPlot - - - - Circle - 3 - 0 - 1 - 0 - 1 - 0 - 1 - 0 - 1 - 1 - - - - true - None - - - TimedTrial - - - 1000 - Seconds - Value.Trial.Metadata.PRewardLeft - - - - ContinuousPlot - - - - - - 1 - 0 - 0 - 1 - 2 - - - - - - true - None - - - - 1000 - Seconds - Value.Trial.Metadata.PRewardRight - - - - ContinuousPlot - - - - - - 0 - 0 - 1 - 1 - 2 - - - - - - true - None - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Behavior1 + LickLeft + LickRight + TimedTrial + Behavior Bias - TimedBias + TrialIndexedBias OutputControl @@ -1970,7 +1397,18 @@ true - + + + + + + + + + + + + Break 200 @@ -2106,29 +1544,14 @@ CameraStream - - Value - - OverlayAlpha - - - - - - - - - - - + EndExperiment - - 53 - 215 - 0.5 - + + + + Value @@ -2285,6 +1708,25 @@ Linear + + OverlayAlpha + + + + + + + + + + + + + 0.476 + 0.1 + 0.3 + + @@ -2372,52 +1814,53 @@ - - - + + + - - - - - + + + + + + - + + - - - + - + - - - - + + + + - - + + - + - - - - - + + + + + - - - + + + - + + @@ -2522,29 +1965,14 @@ CameraStream - - Value - - OverlayAlpha - - - - - - - - - - - + EndExperiment - - 53 - 215 - 0.5 - + + + + Value @@ -2701,6 +2129,25 @@ Linear + + OverlayAlpha + + + + + + + + + + + + + 0.371 + 0.1 + 0.3 + + @@ -2788,52 +2235,53 @@ - - - + + + - - - - - + + + + + + - + + - - - + - + - - - - + + + + - - + + - + - - - - - + + + + + - - - + + + - + + @@ -2851,6 +2299,17 @@ SessionInfo + + + AindDynamicForaging + + 0.0.2-rc37 + Task6 + + + + + Metadata StartExperimentShortcut @@ -2898,7 +2357,9 @@ - + + + From 5f7aa03d85a5afca52d79d71c8b5dc06e45866c4 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Fri, 4 Sep 2026 15:57:38 +0100 Subject: [PATCH 107/116] Replace unnecessary CombineLatest with Zip in visualizers --- .bonsai/Settings/src/main.editor | 37 - .bonsai/Settings/src/main.layout | 2 - .../src/test_behavior_visualizer.editor | 37 - .../src/test_behavior_visualizer.layout | 2 - .bonsai/Settings/src/test_visualizer.editor | 37 - .bonsai/Settings/src/test_visualizer.layout | 104 - .gitignore | 5 +- src/Extensions/CameraPreviewVisualizer.bonsai | 14 +- src/Extensions/IntraSessionVisualizer.bonsai | 6 +- src/Extensions/MetadataVisualizer.bonsai | 10 +- src/Extensions/PreSessionVisualizer.bonsai | 26 +- src/Extensions/Visualizers.bonsai | 6 +- src/main.bonsai | 1939 ++++++++++++++++- src/test_visualizer.bonsai | 35 +- 14 files changed, 1991 insertions(+), 269 deletions(-) delete mode 100644 .bonsai/Settings/src/main.editor delete mode 100644 .bonsai/Settings/src/main.layout delete mode 100644 .bonsai/Settings/src/test_behavior_visualizer.editor delete mode 100644 .bonsai/Settings/src/test_behavior_visualizer.layout delete mode 100644 .bonsai/Settings/src/test_visualizer.editor delete mode 100644 .bonsai/Settings/src/test_visualizer.layout diff --git a/.bonsai/Settings/src/main.editor b/.bonsai/Settings/src/main.editor deleted file mode 100644 index bbd6dca8..00000000 --- a/.bonsai/Settings/src/main.editor +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.bonsai/Settings/src/main.layout b/.bonsai/Settings/src/main.layout deleted file mode 100644 index 0829d87c..00000000 --- a/.bonsai/Settings/src/main.layout +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/.bonsai/Settings/src/test_behavior_visualizer.editor b/.bonsai/Settings/src/test_behavior_visualizer.editor deleted file mode 100644 index a16eb316..00000000 --- a/.bonsai/Settings/src/test_behavior_visualizer.editor +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.bonsai/Settings/src/test_behavior_visualizer.layout b/.bonsai/Settings/src/test_behavior_visualizer.layout deleted file mode 100644 index 0829d87c..00000000 --- a/.bonsai/Settings/src/test_behavior_visualizer.layout +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/.bonsai/Settings/src/test_visualizer.editor b/.bonsai/Settings/src/test_visualizer.editor deleted file mode 100644 index a16eb316..00000000 --- a/.bonsai/Settings/src/test_visualizer.editor +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.bonsai/Settings/src/test_visualizer.layout b/.bonsai/Settings/src/test_visualizer.layout deleted file mode 100644 index 38b19797..00000000 --- a/.bonsai/Settings/src/test_visualizer.layout +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - 508 - 74 - - - 702 - 714 - - Bonsai.ImGui.Visualizers.ImPlotVisualizer - - - - - - false - - 120 - 130 - - - 334 - 64 - - Bonsai.Design.ObjectTextVisualizer - - - - - - - - - - false - - 24 - 26 - - - 334 - 64 - - Bonsai.Design.ObjectTextVisualizer - - - - - - false - - 48 - 52 - - - 334 - 369 - - Bonsai.Design.ObjectTextVisualizer - - - - - - false - - 72 - 78 - - - 334 - 338 - - Bonsai.Design.ObjectTextVisualizer - - - - - - false - - 96 - 104 - - - 334 - 361 - - Bonsai.Design.ObjectTextVisualizer - - - - - - - - - - - \ No newline at end of file diff --git a/.gitignore b/.gitignore index 414a43fb..6fa17086 100644 --- a/.gitignore +++ b/.gitignore @@ -87,4 +87,7 @@ ipython_config.py # IDEs and editors .vscode/ .idea -.sln \ No newline at end of file +.sln +*.editor + +*.layout diff --git a/src/Extensions/CameraPreviewVisualizer.bonsai b/src/Extensions/CameraPreviewVisualizer.bonsai index 074c598e..5d855a73 100644 --- a/src/Extensions/CameraPreviewVisualizer.bonsai +++ b/src/Extensions/CameraPreviewVisualizer.bonsai @@ -30,7 +30,7 @@ - Frame + Camera true @@ -202,8 +202,8 @@ - 720 - 540 + 320 + 240 @@ -217,8 +217,8 @@ - 720 - 540 + 320 + 240 0 @@ -350,10 +350,10 @@ OverlayAlpha - + - + diff --git a/src/Extensions/IntraSessionVisualizer.bonsai b/src/Extensions/IntraSessionVisualizer.bonsai index c1b444fa..f21e3c75 100644 --- a/src/Extensions/IntraSessionVisualizer.bonsai +++ b/src/Extensions/IntraSessionVisualizer.bonsai @@ -210,7 +210,7 @@ UiCueGiveRight - + true @@ -279,10 +279,10 @@ UiMoveRight - + - + true diff --git a/src/Extensions/MetadataVisualizer.bonsai b/src/Extensions/MetadataVisualizer.bonsai index 92b8123c..64d8e52a 100644 --- a/src/Extensions/MetadataVisualizer.bonsai +++ b/src/Extensions/MetadataVisualizer.bonsai @@ -93,7 +93,7 @@ true - + Task6 true @@ -139,7 +139,7 @@ true - + Expo true @@ -157,7 +157,7 @@ true - + Plimbo true @@ -176,7 +176,7 @@ true - + Task6 true @@ -216,7 +216,7 @@ UiHabituationTimeUpdate - + true diff --git a/src/Extensions/PreSessionVisualizer.bonsai b/src/Extensions/PreSessionVisualizer.bonsai index 1735d8da..bfdf3dac 100644 --- a/src/Extensions/PreSessionVisualizer.bonsai +++ b/src/Extensions/PreSessionVisualizer.bonsai @@ -160,7 +160,7 @@ UiKeepBothOpen - + true @@ -241,10 +241,10 @@ UiDrainBoth - + - + true @@ -337,7 +337,7 @@ UiManipulatorUp - + true @@ -391,10 +391,10 @@ UiManipulatorDown - + - + true @@ -436,10 +436,10 @@ UiManipulatorInitialize - + - + true @@ -487,7 +487,7 @@ 0.00 - + true @@ -516,7 +516,7 @@ 0.00 - + true @@ -545,7 +545,7 @@ 0.00 - + true @@ -574,7 +574,7 @@ 0.00 - + true @@ -597,7 +597,7 @@ OffsetGain - + diff --git a/src/Extensions/Visualizers.bonsai b/src/Extensions/Visualizers.bonsai index 95aec580..7006ab22 100644 --- a/src/Extensions/Visualizers.bonsai +++ b/src/Extensions/Visualizers.bonsai @@ -1651,7 +1651,7 @@ Ethogram - + true @@ -1660,7 +1660,7 @@ Camera - + true @@ -1704,7 +1704,7 @@ IntraSession - + diff --git a/src/main.bonsai b/src/main.bonsai index 3be493d9..80e59eb7 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -10,6 +10,11 @@ xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:num="clr-namespace:Bonsai.Numerics;assembly=Bonsai.Numerics" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" + xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" + xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" + xmlns:p5="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" + xmlns:p6="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" + xmlns:p7="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -477,7 +482,1939 @@ - + + Visualizers + + + + ImGuiContext + + + + + true + 1 + None + + 0 + 0 + + 0 + + + Frame + + + + + + + + + + + + DataTransformations + + + + GlobalTrialOutcome + + + HarpTimestampSource + + + TimedTrial + + + GlobalTrialMetrics + + + Bias + + + TrialIndex + + + + + + new (it.Item1 as Bias, it.Item2 as TrialIndex) + + + TrialIndexedBias + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + HarpTimestampSource + + + LickRight + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + + HarpTimestampSource + + + LickLeft + + + SoftwareEvent + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + LickRight + + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + + + LickLeft + + + + GiveRewardRight + + + + + + Source1 + + + + + + + + + + + WaterRight + + + + GiveRewardRight + + + + + + + Source1 + + + + + + + + + + + WaterLeft + + + + + + + HarpTimestampSource + + + + + + + + + + + + EthogramEvents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OutputControl + + + + Manipulator + + + + UiManipulatorLeft + + + MoveRelative + + + + Source1 + + + + -1 + 0 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorRight + + + MoveRelative + + + + Source1 + + + + 1 + 0 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorForwardLeft + + + MoveRelative + + + + Source1 + + + + 0 + 1 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorForwardRight + + + MoveRelative + + + + Source1 + + + + 0 + 0 + 1 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorBackLeft + + + MoveRelative + + + + Source1 + + + + 0 + -1 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorBackRight + + + MoveRelative + + + + Source1 + + + + 0 + 0 + -1 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorUp + + + MoveRelative + + + + Source1 + + + + 0 + 0 + 0 + 1 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorDown + + + MoveRelative + + + + Source1 + + + + 0 + 0 + 0 + -1 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorHome + + + Home + + + + Source1 + + + + HomeMotors + + + + + + + + + + + + UiManipulatorStop + + + StopMotors + + + + Source1 + + + + StopMotors + + + + + + + + + + + + UiManipulatorInitialize + + + GoToInitialPosition + + + + Source1 + + + + GoToInitialPosition + + + + + + + + + + + + OffsetGain + + + + + + + + + + + + + + + + + + + UiHabituationTimeUpdate + + + + 0.05 + + + + + 1 + + + + BumpSize + + + UiMoveLeft + + + BumpLeft + + + + Source1 + + + BumpSize + + + + + + Item2 + + + + -1 + + + + ManualSpoutDelta + + + + + + + + + + + + + + + UiMoveRight + + + BumpRight + + + + Source1 + + + BumpSize + + + + + + Item2 + + + ManualSpoutDelta + + + + + + + + + + + + + + UiGiveRight + + + TriggerRight + + + + Source1 + + + + true + + + + GiveManualWaterRight + + + + + + + + + + + + UiGiveLeft + + + TriggerLeft + + + + Source1 + + + + false + + + + GiveManualWaterRight + + + + + + + + + + + + UiCueGiveLeft + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetLeft() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + UiCueGiveRight + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetRight() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + + true + + + + IsFlushingValveLeft + + + GiveManualWaterRight + + + GiveManualWaterRight + + + GiveRewardRight + + + IsFlushingValveLeft + + + IsFlushingValveRight + + + UiKeepLeftOpen + + + UiKeepBothOpen + + + + + + KeepLeftOpen + + + + + 50 + + + + + 1 + + + + DefaultRewardAmount + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + false + + + + DefaultRewardAmount + + + + + + SetIsRightRewardAmount + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + + PT0.5S + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UiKeepRightOpen + + + + + + KeepRightOpen + + + + + 50 + + + + + 1 + + + + DefaultRewardAmount + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + true + + + + DefaultRewardAmount + + + + + + SetIsRightRewardAmount + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + + PT0.5S + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UiDrainLeft + + + UiDrainBoth + + + + + + FlushLeft + + + + + 50 + + + + + 1 + + + + DefaultVolume + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + false + + + + DefaultVolume + + + + + + SetIsRightRewardAmount + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + DefaultVolume + + + RigSchema + + + Calibration.WaterValveLeft + + + + + + RewardToTime + ((Item1 * 0.001) - Item2.Offset) / Item2.Slope + + + + + + + + + + + + PT1.288S + + + + DefaultVolume + + + DivideByEachOpen + Math.Ceiling(5000 / it) + + + + + + + + + 100 + + + + + + + + false + + + + IsFlushingValveLeft + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DrainLeftComplete + + + UiDrainRight + + + + + + FlushRight + + + + + 50 + + + + + 1 + + + + DefaultVolume + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + true + + + + DefaultVolume + + + + + + SetIsRightRewardAmount + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + DefaultVolume + + + RigSchema + + + Calibration.WaterValveRight + + + + + + RewardToTime + ((Item1 * 0.001) - Item2.Offset) / Item2.Slope + + + + + + + + + + + + PT0.888S + + + + DefaultVolume + + + DivideByEachOpen + Math.Ceiling(5000 / it) + + + + + + + + + 100 + + + + + + + + false + + + + IsFlushingValveRight + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DrainRightComplete + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VisualizerStructure + + + + + + + Frame + + + true + + + true + + + Ethograph + WidthStretch + 0 + + + Camera + WidthFixed + 320 + + + BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit + + 0 + 0 + + 0 + true + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + Behavior + + + true + + + Bias + + + true + + + Ethogram + + + + + + true + + + Camera + + + + + + true + + + true + 1 + Borders + + 0 + 0 + + 0 + + + Metadata + + + true + + + true + None + + + PreSession + true + pre-session + None + + + PreSession + + + IntraSession + true + intra-session + None + + + IntraSession + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Behavior1 + LickLeft + LickRight + TimedTrial + Behavior + + + Bias + TrialIndexedBias + + + PLACEHOLDER + + + + SessionInfo + + + + TimedTrial + + + Value.Trial.Metadata.Extra + + + SessionMetadata + + + + + + + + + + + + Ethogram + + + EthogramEvents + + + + + + + + + true + + Break + 200 + + + QuiescentPeriod + Gold + 0.3 + + + ResponsePeriod + SandyBrown + 0.3 + + + RewardConsumptionPeriod + RosyBrown + 0.3 + + + ItiPeriod + Green + 0.3 + + + + + LickLeft + Red + 0.9 + 6 + Down + + + LickRight + Blue + 0.1 + 6 + Up + + + IsRightTriggerQuickRetract + DarkCyan + 0.5 + 6 + Plus + + + DeliverSecondaryReinforcer + Sienna + 0.5 + 6 + Plus + + + WaterRight + Red + 0.2 + 6 + Circle + + + WaterLeft + Blue + 0.8 + 6 + Circle + + + + + + + Camera + SideCamera + 53 + 215 + 2 + 0 + TriggeredCamerasStream + + + Camera + BodyCamera + 53 + 215 + 2 + 0 + TriggeredCamerasStream + + + SessionSchema + + + TaskLogicSchema + + + + + + Metadata + StartExperimentShortcut + UiHabituationTimeUpdate + + + PreSession + UiKeepLeftOpen + UiKeepRightOpen + UiKeepBothOpen + UiDrainLeft + UiDrainRight + UiDrainBoth + UiManipulatorLeft + UiManipulatorForwardLeft + UiManipulatorForwardRight + UiManipulatorUp + UiManipulatorRight + UiManipulatorBackLeft + UiManipulatorBackRight + UiManipulatorDown + UiManipulatorStop + UiManipulatorHome + UiManipulatorInitialize + DrainLeftComplete + DrainRightComplete + + + IntraSession + UiGiveLeft + UiGiveRight + UiMoveLeft + UiMoveRight + StartExperiment + UiCueGiveLeft + UiCueGiveRight + SessionMetadata + + + + + + + + + + + + + + + diff --git a/src/test_visualizer.bonsai b/src/test_visualizer.bonsai index 9c27090d..9ab32d72 100644 --- a/src/test_visualizer.bonsai +++ b/src/test_visualizer.bonsai @@ -202,7 +202,7 @@ - PT2.855S + PT0.102S @@ -254,7 +254,7 @@ - PT0.809S + PT1.88S @@ -325,7 +325,7 @@ - PT2.887S + PT0.798S @@ -731,7 +731,7 @@ it.Index as TrialIndex - false + true @@ -844,8 +844,8 @@ it.Index as TrialIndex - false - true + + false @@ -871,7 +871,7 @@ it.Index as TrialIndex - PT0.552S + PT0.517S @@ -930,7 +930,7 @@ it.Index as TrialIndex - false + true @@ -1185,7 +1185,7 @@ it.Index as TrialIndex Ethogram - + true @@ -1194,7 +1194,7 @@ it.Index as TrialIndex Camera - + true @@ -1238,7 +1238,7 @@ it.Index as TrialIndex IntraSession - + @@ -1408,6 +1408,7 @@ it.Index as TrialIndex + Break 200 @@ -1722,7 +1723,7 @@ it.Index as TrialIndex - 0.476 + 0.5 0.1 0.3 @@ -1798,10 +1799,10 @@ it.Index as TrialIndex OverlayAlpha - + - + @@ -2143,7 +2144,7 @@ it.Index as TrialIndex - 0.371 + 0.5 0.1 0.3 @@ -2219,10 +2220,10 @@ it.Index as TrialIndex OverlayAlpha - + - + From 36af9015ef3cd80de303d5f0207b47a4f5c6d13e Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Fri, 4 Sep 2026 16:08:31 +0100 Subject: [PATCH 108/116] Package visualizers in main as IncludeWorkflow --- src/main.bonsai | 1939 +---------------------------------------------- 1 file changed, 1 insertion(+), 1938 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index 80e59eb7..3be493d9 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -10,11 +10,6 @@ xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:num="clr-namespace:Bonsai.Numerics;assembly=Bonsai.Numerics" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" - xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" - xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" - xmlns:p5="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" - xmlns:p6="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" - xmlns:p7="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -482,1939 +477,7 @@ - - Visualizers - - - - ImGuiContext - - - - - true - 1 - None - - 0 - 0 - - 0 - - - Frame - - - - - - - - - - - - DataTransformations - - - - GlobalTrialOutcome - - - HarpTimestampSource - - - TimedTrial - - - GlobalTrialMetrics - - - Bias - - - TrialIndex - - - - - - new (it.Item1 as Bias, it.Item2 as TrialIndex) - - - TrialIndexedBias - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - HarpTimestampSource - - - LickRight - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - - HarpTimestampSource - - - LickLeft - - - SoftwareEvent - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - LickRight - - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - - - LickLeft - - - - GiveRewardRight - - - - - - Source1 - - - - - - - - - - - WaterRight - - - - GiveRewardRight - - - - - - - Source1 - - - - - - - - - - - WaterLeft - - - - - - - HarpTimestampSource - - - - - - - - - - - - EthogramEvents - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OutputControl - - - - Manipulator - - - - UiManipulatorLeft - - - MoveRelative - - - - Source1 - - - - -1 - 0 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorRight - - - MoveRelative - - - - Source1 - - - - 1 - 0 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorForwardLeft - - - MoveRelative - - - - Source1 - - - - 0 - 1 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorForwardRight - - - MoveRelative - - - - Source1 - - - - 0 - 0 - 1 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorBackLeft - - - MoveRelative - - - - Source1 - - - - 0 - -1 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorBackRight - - - MoveRelative - - - - Source1 - - - - 0 - 0 - -1 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorUp - - - MoveRelative - - - - Source1 - - - - 0 - 0 - 0 - 1 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorDown - - - MoveRelative - - - - Source1 - - - - 0 - 0 - 0 - -1 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorHome - - - Home - - - - Source1 - - - - HomeMotors - - - - - - - - - - - - UiManipulatorStop - - - StopMotors - - - - Source1 - - - - StopMotors - - - - - - - - - - - - UiManipulatorInitialize - - - GoToInitialPosition - - - - Source1 - - - - GoToInitialPosition - - - - - - - - - - - - OffsetGain - - - - - - - - - - - - - - - - - - - UiHabituationTimeUpdate - - - - 0.05 - - - - - 1 - - - - BumpSize - - - UiMoveLeft - - - BumpLeft - - - - Source1 - - - BumpSize - - - - - - Item2 - - - - -1 - - - - ManualSpoutDelta - - - - - - - - - - - - - - - UiMoveRight - - - BumpRight - - - - Source1 - - - BumpSize - - - - - - Item2 - - - ManualSpoutDelta - - - - - - - - - - - - - - UiGiveRight - - - TriggerRight - - - - Source1 - - - - true - - - - GiveManualWaterRight - - - - - - - - - - - - UiGiveLeft - - - TriggerLeft - - - - Source1 - - - - false - - - - GiveManualWaterRight - - - - - - - - - - - - UiCueGiveLeft - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetLeft() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - UiCueGiveRight - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetRight() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - - true - - - - IsFlushingValveLeft - - - GiveManualWaterRight - - - GiveManualWaterRight - - - GiveRewardRight - - - IsFlushingValveLeft - - - IsFlushingValveRight - - - UiKeepLeftOpen - - - UiKeepBothOpen - - - - - - KeepLeftOpen - - - - - 50 - - - - - 1 - - - - DefaultRewardAmount - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - false - - - - DefaultRewardAmount - - - - - - SetIsRightRewardAmount - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - - PT0.5S - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UiKeepRightOpen - - - - - - KeepRightOpen - - - - - 50 - - - - - 1 - - - - DefaultRewardAmount - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - true - - - - DefaultRewardAmount - - - - - - SetIsRightRewardAmount - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - - PT0.5S - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UiDrainLeft - - - UiDrainBoth - - - - - - FlushLeft - - - - - 50 - - - - - 1 - - - - DefaultVolume - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - false - - - - DefaultVolume - - - - - - SetIsRightRewardAmount - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - DefaultVolume - - - RigSchema - - - Calibration.WaterValveLeft - - - - - - RewardToTime - ((Item1 * 0.001) - Item2.Offset) / Item2.Slope - - - - - - - - - - - - PT1.288S - - - - DefaultVolume - - - DivideByEachOpen - Math.Ceiling(5000 / it) - - - - - - - - - 100 - - - - - - - - false - - - - IsFlushingValveLeft - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DrainLeftComplete - - - UiDrainRight - - - - - - FlushRight - - - - - 50 - - - - - 1 - - - - DefaultVolume - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - true - - - - DefaultVolume - - - - - - SetIsRightRewardAmount - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - DefaultVolume - - - RigSchema - - - Calibration.WaterValveRight - - - - - - RewardToTime - ((Item1 * 0.001) - Item2.Offset) / Item2.Slope - - - - - - - - - - - - PT0.888S - - - - DefaultVolume - - - DivideByEachOpen - Math.Ceiling(5000 / it) - - - - - - - - - 100 - - - - - - - - false - - - - IsFlushingValveRight - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DrainRightComplete - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - VisualizerStructure - - - - - - - Frame - - - true - - - true - - - Ethograph - WidthStretch - 0 - - - Camera - WidthFixed - 320 - - - BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit - - 0 - 0 - - 0 - true - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - Behavior - - - true - - - Bias - - - true - - - Ethogram - - - - - - true - - - Camera - - - - - - true - - - true - 1 - Borders - - 0 - 0 - - 0 - - - Metadata - - - true - - - true - None - - - PreSession - true - pre-session - None - - - PreSession - - - IntraSession - true - intra-session - None - - - IntraSession - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Behavior1 - LickLeft - LickRight - TimedTrial - Behavior - - - Bias - TrialIndexedBias - - - PLACEHOLDER - - - - SessionInfo - - - - TimedTrial - - - Value.Trial.Metadata.Extra - - - SessionMetadata - - - - - - - - - - - - Ethogram - - - EthogramEvents - - - - - - - - - true - - Break - 200 - - - QuiescentPeriod - Gold - 0.3 - - - ResponsePeriod - SandyBrown - 0.3 - - - RewardConsumptionPeriod - RosyBrown - 0.3 - - - ItiPeriod - Green - 0.3 - - - - - LickLeft - Red - 0.9 - 6 - Down - - - LickRight - Blue - 0.1 - 6 - Up - - - IsRightTriggerQuickRetract - DarkCyan - 0.5 - 6 - Plus - - - DeliverSecondaryReinforcer - Sienna - 0.5 - 6 - Plus - - - WaterRight - Red - 0.2 - 6 - Circle - - - WaterLeft - Blue - 0.8 - 6 - Circle - - - - - - - Camera - SideCamera - 53 - 215 - 2 - 0 - TriggeredCamerasStream - - - Camera - BodyCamera - 53 - 215 - 2 - 0 - TriggeredCamerasStream - - - SessionSchema - - - TaskLogicSchema - - - - - - Metadata - StartExperimentShortcut - UiHabituationTimeUpdate - - - PreSession - UiKeepLeftOpen - UiKeepRightOpen - UiKeepBothOpen - UiDrainLeft - UiDrainRight - UiDrainBoth - UiManipulatorLeft - UiManipulatorForwardLeft - UiManipulatorForwardRight - UiManipulatorUp - UiManipulatorRight - UiManipulatorBackLeft - UiManipulatorBackRight - UiManipulatorDown - UiManipulatorStop - UiManipulatorHome - UiManipulatorInitialize - DrainLeftComplete - DrainRightComplete - - - IntraSession - UiGiveLeft - UiGiveRight - UiMoveLeft - UiMoveRight - StartExperiment - UiCueGiveLeft - UiCueGiveRight - SessionMetadata - - - - - - - - - - - - - - - + From 37a79af65d9a1e62169284f62f9207f7fb9fa8cc Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Fri, 4 Sep 2026 16:11:24 +0100 Subject: [PATCH 109/116] Remove unnecessary TakeUntil from CameraPreviewVisualizer --- src/Extensions/CameraPreviewVisualizer.bonsai | 80 +- src/main.bonsai | 2345 ++++++++++++++++- 2 files changed, 2380 insertions(+), 45 deletions(-) diff --git a/src/Extensions/CameraPreviewVisualizer.bonsai b/src/Extensions/CameraPreviewVisualizer.bonsai index 5d855a73..4cddafd1 100644 --- a/src/Extensions/CameraPreviewVisualizer.bonsai +++ b/src/Extensions/CameraPreviewVisualizer.bonsai @@ -68,7 +68,7 @@ - Camera1 + SideCamera @@ -96,12 +96,6 @@ CameraStream - - EndExperiment - - - - Value.Image @@ -275,8 +269,8 @@ 0.5 - 0.1 - 0.3 + 53 + 215 @@ -366,53 +360,51 @@ - - - + + + + - - + - - - + + + + - - - - - - - - + + + + + + + - - - + + + - - + + - - - - - - - + + + + + + + + - - + - - - - - + + + diff --git a/src/main.bonsai b/src/main.bonsai index 3be493d9..474f623d 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -10,6 +10,13 @@ xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:num="clr-namespace:Bonsai.Numerics;assembly=Bonsai.Numerics" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" + xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" + xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" + xmlns:p5="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" + xmlns:p6="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" + xmlns:p7="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" + xmlns:cv="clr-namespace:Bonsai.Vision;assembly=Bonsai.Vision" + xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -477,7 +484,2343 @@ - + + Visualizers + + + + ImGuiContext + + + + + true + 1 + None + + 0 + 0 + + 0 + + + Frame + + + + + + + + + + + + DataTransformations + + + + GlobalTrialOutcome + + + HarpTimestampSource + + + TimedTrial + + + GlobalTrialMetrics + + + Bias + + + TrialIndex + + + + + + new (it.Item1 as Bias, it.Item2 as TrialIndex) + + + TrialIndexedBias + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + HarpTimestampSource + + + LickRight + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + + HarpTimestampSource + + + LickLeft + + + SoftwareEvent + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + LickRight + + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + + + LickLeft + + + + GiveRewardRight + + + + + + Source1 + + + + + + + + + + + WaterRight + + + + GiveRewardRight + + + + + + + Source1 + + + + + + + + + + + WaterLeft + + + + + + + HarpTimestampSource + + + + + + + + + + + + EthogramEvents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OutputControl + + + + Manipulator + + + + UiManipulatorLeft + + + MoveRelative + + + + Source1 + + + + -1 + 0 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorRight + + + MoveRelative + + + + Source1 + + + + 1 + 0 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorForwardLeft + + + MoveRelative + + + + Source1 + + + + 0 + 1 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorForwardRight + + + MoveRelative + + + + Source1 + + + + 0 + 0 + 1 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorBackLeft + + + MoveRelative + + + + Source1 + + + + 0 + -1 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorBackRight + + + MoveRelative + + + + Source1 + + + + 0 + 0 + -1 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorUp + + + MoveRelative + + + + Source1 + + + + 0 + 0 + 0 + 1 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorDown + + + MoveRelative + + + + Source1 + + + + 0 + 0 + 0 + -1 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorHome + + + Home + + + + Source1 + + + + HomeMotors + + + + + + + + + + + + UiManipulatorStop + + + StopMotors + + + + Source1 + + + + StopMotors + + + + + + + + + + + + UiManipulatorInitialize + + + GoToInitialPosition + + + + Source1 + + + + GoToInitialPosition + + + + + + + + + + + + OffsetGain + + + + + + + + + + + + + + + + + + + UiHabituationTimeUpdate + + + + 0.05 + + + + + 1 + + + + BumpSize + + + UiMoveLeft + + + BumpLeft + + + + Source1 + + + BumpSize + + + + + + Item2 + + + + -1 + + + + ManualSpoutDelta + + + + + + + + + + + + + + + UiMoveRight + + + BumpRight + + + + Source1 + + + BumpSize + + + + + + Item2 + + + ManualSpoutDelta + + + + + + + + + + + + + + UiGiveRight + + + TriggerRight + + + + Source1 + + + + true + + + + GiveManualWaterRight + + + + + + + + + + + + UiGiveLeft + + + TriggerLeft + + + + Source1 + + + + false + + + + GiveManualWaterRight + + + + + + + + + + + + UiCueGiveLeft + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetLeft() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + UiCueGiveRight + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetRight() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + + true + + + + IsFlushingValveLeft + + + GiveManualWaterRight + + + GiveManualWaterRight + + + GiveRewardRight + + + IsFlushingValveLeft + + + IsFlushingValveRight + + + UiKeepLeftOpen + + + UiKeepBothOpen + + + + + + KeepLeftOpen + + + + + 50 + + + + + 1 + + + + DefaultRewardAmount + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + false + + + + DefaultRewardAmount + + + + + + SetIsRightRewardAmount + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + + PT0.5S + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UiKeepRightOpen + + + + + + KeepRightOpen + + + + + 50 + + + + + 1 + + + + DefaultRewardAmount + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + true + + + + DefaultRewardAmount + + + + + + SetIsRightRewardAmount + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + + PT0.5S + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UiDrainLeft + + + UiDrainBoth + + + + + + FlushLeft + + + + + 50 + + + + + 1 + + + + DefaultVolume + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + false + + + + DefaultVolume + + + + + + SetIsRightRewardAmount + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + DefaultVolume + + + RigSchema + + + Calibration.WaterValveLeft + + + + + + RewardToTime + ((Item1 * 0.001) - Item2.Offset) / Item2.Slope + + + + + + + + + + + + PT1.288S + + + + DefaultVolume + + + DivideByEachOpen + Math.Ceiling(5000 / it) + + + + + + + + + 100 + + + + + + + + false + + + + IsFlushingValveLeft + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DrainLeftComplete + + + UiDrainRight + + + + + + FlushRight + + + + + 50 + + + + + 1 + + + + DefaultVolume + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + true + + + + DefaultVolume + + + + + + SetIsRightRewardAmount + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + DefaultVolume + + + RigSchema + + + Calibration.WaterValveRight + + + + + + RewardToTime + ((Item1 * 0.001) - Item2.Offset) / Item2.Slope + + + + + + + + + + + + PT0.888S + + + + DefaultVolume + + + DivideByEachOpen + Math.Ceiling(5000 / it) + + + + + + + + + 100 + + + + + + + + false + + + + IsFlushingValveRight + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DrainRightComplete + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VisualizerStructure + + + + + + + Frame + + + true + + + true + + + Ethograph + WidthStretch + 0 + + + Camera + WidthFixed + 320 + + + BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit + + 0 + 0 + + 0 + true + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + Behavior + + + true + + + Bias + + + true + + + Ethogram + + + + + + true + + + Camera + + + + + + true + + + true + 1 + Borders + + 0 + 0 + + 0 + + + Metadata + + + true + + + true + None + + + PreSession + true + pre-session + None + + + PreSession + + + IntraSession + true + intra-session + None + + + IntraSession + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Behavior1 + LickLeft + LickRight + TimedTrial + Behavior + + + Bias + TrialIndexedBias + + + PLACEHOLDER + + + + SessionInfo + + + + TimedTrial + + + Value.Trial.Metadata.Extra + + + SessionMetadata + + + + + + + + + + + + Ethogram + + + EthogramEvents + + + + + + + + + true + + Break + 200 + + + QuiescentPeriod + Gold + 0.3 + + + ResponsePeriod + SandyBrown + 0.3 + + + RewardConsumptionPeriod + RosyBrown + 0.3 + + + ItiPeriod + Green + 0.3 + + + + + LickLeft + Red + 0.9 + 6 + Down + + + LickRight + Blue + 0.1 + 6 + Up + + + IsRightTriggerQuickRetract + DarkCyan + 0.5 + 6 + Plus + + + DeliverSecondaryReinforcer + Sienna + 0.5 + 6 + Plus + + + WaterRight + Red + 0.2 + 6 + Circle + + + WaterLeft + Blue + 0.8 + 6 + Circle + + + + + + + CameraPreviewVisualizer + + + + Source1 + + + + + + + + + + + + CameraPreview + + + + + + + Camera + + + true + 1 + None + + 0 + 0 + + 0 + + + Table + + + + + + TriggeredCamerasStream + + + + + + + + + Source1 + + + Key + + + + + + + SideCamera + + + + + + + + + + + + + + + + + CameraStream + + + Table + + + true + + + CameraStream + + + Value.Image + + + + + + + 2 + + + + + + + Flipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + Item1 + + + Item2 + + + + + + + + + Vertical + + + + NotFlipped + + + + Source1 + + + Item2 + + + + 2 + + + + + + + + + + + + + + + Item1 + + + + + + new ( + it.Size.Width / 2 as X, + it.Size.Height / 2 as Y +) + + + + + + + + + + 320 + 240 + + + + + + + + + + + + + + 320 + 240 + + + 0 + 0 + + 0 + + 1 + 1 + + + + + + + + + + + 1,0,0;0,1,0 + Linear + + 0 + 0 + 0 + 0 + + + + + Table + + + + Rgba + Repeat + Repeat + Linear + Linear + + + + OverlayAlpha + + + + + + + + + + + + + 0.5 + 53 + 215 + + + + + + + + + PreviewImage + true + + 320 + 320 + + + 0 + 0 + + + 1 + 1 + + + + Table + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + true + 2 + None + + 0 + 0 + + 0 + + + true + + + true + Alpha + + + true + + + true + 0 + 1 + None + 0.5 + + + OverlayAlpha + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Camera + BodyCamera + 53 + 215 + 2 + 0 + TriggeredCamerasStream + + + SessionSchema + + + TaskLogicSchema + + + + + + Metadata + StartExperimentShortcut + UiHabituationTimeUpdate + + + PreSession + UiKeepLeftOpen + UiKeepRightOpen + UiKeepBothOpen + UiDrainLeft + UiDrainRight + UiDrainBoth + UiManipulatorLeft + UiManipulatorForwardLeft + UiManipulatorForwardRight + UiManipulatorUp + UiManipulatorRight + UiManipulatorBackLeft + UiManipulatorBackRight + UiManipulatorDown + UiManipulatorStop + UiManipulatorHome + UiManipulatorInitialize + DrainLeftComplete + DrainRightComplete + + + IntraSession + UiGiveLeft + UiGiveRight + UiMoveLeft + UiMoveRight + StartExperiment + UiCueGiveLeft + UiCueGiveRight + SessionMetadata + + + + + + + + + + + + + + + From 6f9ae74f3b614c5052a1ef6e4a513769baf443f9 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Fri, 4 Sep 2026 16:41:25 +0100 Subject: [PATCH 110/116] Ensure all visualizers are using their IncludeWorkflow implementations --- src/Extensions/CameraPreviewVisualizer.bonsai | 6 +- src/Extensions/Visualizers.bonsai | 10 +- src/main.bonsai | 2345 +---------------- 3 files changed, 9 insertions(+), 2352 deletions(-) diff --git a/src/Extensions/CameraPreviewVisualizer.bonsai b/src/Extensions/CameraPreviewVisualizer.bonsai index 4cddafd1..fd79d52a 100644 --- a/src/Extensions/CameraPreviewVisualizer.bonsai +++ b/src/Extensions/CameraPreviewVisualizer.bonsai @@ -68,7 +68,7 @@ - SideCamera + BodyCamera @@ -269,8 +269,8 @@ 0.5 - 53 - 215 + 0.1 + 0.9 diff --git a/src/Extensions/Visualizers.bonsai b/src/Extensions/Visualizers.bonsai index 7006ab22..d414265a 100644 --- a/src/Extensions/Visualizers.bonsai +++ b/src/Extensions/Visualizers.bonsai @@ -1866,9 +1866,9 @@ Camera - SideCamera - 53 - 215 + BodyCamera + 0.1 + 0.9 2 0 TriggeredCamerasStream @@ -1876,8 +1876,8 @@ Camera BodyCamera - 53 - 215 + 0.1 + 0.9 2 0 TriggeredCamerasStream diff --git a/src/main.bonsai b/src/main.bonsai index 474f623d..3be493d9 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -10,13 +10,6 @@ xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:num="clr-namespace:Bonsai.Numerics;assembly=Bonsai.Numerics" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" - xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" - xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" - xmlns:p5="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" - xmlns:p6="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" - xmlns:p7="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" - xmlns:cv="clr-namespace:Bonsai.Vision;assembly=Bonsai.Vision" - xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -484,2343 +477,7 @@ - - Visualizers - - - - ImGuiContext - - - - - true - 1 - None - - 0 - 0 - - 0 - - - Frame - - - - - - - - - - - - DataTransformations - - - - GlobalTrialOutcome - - - HarpTimestampSource - - - TimedTrial - - - GlobalTrialMetrics - - - Bias - - - TrialIndex - - - - - - new (it.Item1 as Bias, it.Item2 as TrialIndex) - - - TrialIndexedBias - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - HarpTimestampSource - - - LickRight - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - - HarpTimestampSource - - - LickLeft - - - SoftwareEvent - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - LickRight - - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - - - LickLeft - - - - GiveRewardRight - - - - - - Source1 - - - - - - - - - - - WaterRight - - - - GiveRewardRight - - - - - - - Source1 - - - - - - - - - - - WaterLeft - - - - - - - HarpTimestampSource - - - - - - - - - - - - EthogramEvents - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OutputControl - - - - Manipulator - - - - UiManipulatorLeft - - - MoveRelative - - - - Source1 - - - - -1 - 0 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorRight - - - MoveRelative - - - - Source1 - - - - 1 - 0 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorForwardLeft - - - MoveRelative - - - - Source1 - - - - 0 - 1 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorForwardRight - - - MoveRelative - - - - Source1 - - - - 0 - 0 - 1 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorBackLeft - - - MoveRelative - - - - Source1 - - - - 0 - -1 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorBackRight - - - MoveRelative - - - - Source1 - - - - 0 - 0 - -1 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorUp - - - MoveRelative - - - - Source1 - - - - 0 - 0 - 0 - 1 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorDown - - - MoveRelative - - - - Source1 - - - - 0 - 0 - 0 - -1 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorHome - - - Home - - - - Source1 - - - - HomeMotors - - - - - - - - - - - - UiManipulatorStop - - - StopMotors - - - - Source1 - - - - StopMotors - - - - - - - - - - - - UiManipulatorInitialize - - - GoToInitialPosition - - - - Source1 - - - - GoToInitialPosition - - - - - - - - - - - - OffsetGain - - - - - - - - - - - - - - - - - - - UiHabituationTimeUpdate - - - - 0.05 - - - - - 1 - - - - BumpSize - - - UiMoveLeft - - - BumpLeft - - - - Source1 - - - BumpSize - - - - - - Item2 - - - - -1 - - - - ManualSpoutDelta - - - - - - - - - - - - - - - UiMoveRight - - - BumpRight - - - - Source1 - - - BumpSize - - - - - - Item2 - - - ManualSpoutDelta - - - - - - - - - - - - - - UiGiveRight - - - TriggerRight - - - - Source1 - - - - true - - - - GiveManualWaterRight - - - - - - - - - - - - UiGiveLeft - - - TriggerLeft - - - - Source1 - - - - false - - - - GiveManualWaterRight - - - - - - - - - - - - UiCueGiveLeft - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetLeft() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - UiCueGiveRight - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetRight() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - - true - - - - IsFlushingValveLeft - - - GiveManualWaterRight - - - GiveManualWaterRight - - - GiveRewardRight - - - IsFlushingValveLeft - - - IsFlushingValveRight - - - UiKeepLeftOpen - - - UiKeepBothOpen - - - - - - KeepLeftOpen - - - - - 50 - - - - - 1 - - - - DefaultRewardAmount - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - false - - - - DefaultRewardAmount - - - - - - SetIsRightRewardAmount - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - - PT0.5S - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UiKeepRightOpen - - - - - - KeepRightOpen - - - - - 50 - - - - - 1 - - - - DefaultRewardAmount - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - true - - - - DefaultRewardAmount - - - - - - SetIsRightRewardAmount - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - - PT0.5S - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UiDrainLeft - - - UiDrainBoth - - - - - - FlushLeft - - - - - 50 - - - - - 1 - - - - DefaultVolume - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - false - - - - DefaultVolume - - - - - - SetIsRightRewardAmount - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - DefaultVolume - - - RigSchema - - - Calibration.WaterValveLeft - - - - - - RewardToTime - ((Item1 * 0.001) - Item2.Offset) / Item2.Slope - - - - - - - - - - - - PT1.288S - - - - DefaultVolume - - - DivideByEachOpen - Math.Ceiling(5000 / it) - - - - - - - - - 100 - - - - - - - - false - - - - IsFlushingValveLeft - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DrainLeftComplete - - - UiDrainRight - - - - - - FlushRight - - - - - 50 - - - - - 1 - - - - DefaultVolume - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - true - - - - DefaultVolume - - - - - - SetIsRightRewardAmount - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - DefaultVolume - - - RigSchema - - - Calibration.WaterValveRight - - - - - - RewardToTime - ((Item1 * 0.001) - Item2.Offset) / Item2.Slope - - - - - - - - - - - - PT0.888S - - - - DefaultVolume - - - DivideByEachOpen - Math.Ceiling(5000 / it) - - - - - - - - - 100 - - - - - - - - false - - - - IsFlushingValveRight - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DrainRightComplete - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - VisualizerStructure - - - - - - - Frame - - - true - - - true - - - Ethograph - WidthStretch - 0 - - - Camera - WidthFixed - 320 - - - BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit - - 0 - 0 - - 0 - true - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - Behavior - - - true - - - Bias - - - true - - - Ethogram - - - - - - true - - - Camera - - - - - - true - - - true - 1 - Borders - - 0 - 0 - - 0 - - - Metadata - - - true - - - true - None - - - PreSession - true - pre-session - None - - - PreSession - - - IntraSession - true - intra-session - None - - - IntraSession - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Behavior1 - LickLeft - LickRight - TimedTrial - Behavior - - - Bias - TrialIndexedBias - - - PLACEHOLDER - - - - SessionInfo - - - - TimedTrial - - - Value.Trial.Metadata.Extra - - - SessionMetadata - - - - - - - - - - - - Ethogram - - - EthogramEvents - - - - - - - - - true - - Break - 200 - - - QuiescentPeriod - Gold - 0.3 - - - ResponsePeriod - SandyBrown - 0.3 - - - RewardConsumptionPeriod - RosyBrown - 0.3 - - - ItiPeriod - Green - 0.3 - - - - - LickLeft - Red - 0.9 - 6 - Down - - - LickRight - Blue - 0.1 - 6 - Up - - - IsRightTriggerQuickRetract - DarkCyan - 0.5 - 6 - Plus - - - DeliverSecondaryReinforcer - Sienna - 0.5 - 6 - Plus - - - WaterRight - Red - 0.2 - 6 - Circle - - - WaterLeft - Blue - 0.8 - 6 - Circle - - - - - - - CameraPreviewVisualizer - - - - Source1 - - - - - - - - - - - - CameraPreview - - - - - - - Camera - - - true - 1 - None - - 0 - 0 - - 0 - - - Table - - - - - - TriggeredCamerasStream - - - - - - - - - Source1 - - - Key - - - - - - - SideCamera - - - - - - - - - - - - - - - - - CameraStream - - - Table - - - true - - - CameraStream - - - Value.Image - - - - - - - 2 - - - - - - - Flipped - - - - Source1 - - - Item2 - - - - 2 - - - - - - - - - - - - - Item1 - - - Item2 - - - - - - - - - Vertical - - - - NotFlipped - - - - Source1 - - - Item2 - - - - 2 - - - - - - - - - - - - - - - Item1 - - - - - - new ( - it.Size.Width / 2 as X, - it.Size.Height / 2 as Y -) - - - - - - - - - - 320 - 240 - - - - - - - - - - - - - - 320 - 240 - - - 0 - 0 - - 0 - - 1 - 1 - - - - - - - - - - - 1,0,0;0,1,0 - Linear - - 0 - 0 - 0 - 0 - - - - - Table - - - - Rgba - Repeat - Repeat - Linear - Linear - - - - OverlayAlpha - - - - - - - - - - - - - 0.5 - 53 - 215 - - - - - - - - - PreviewImage - true - - 320 - 320 - - - 0 - 0 - - - 1 - 1 - - - - Table - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - true - 2 - None - - 0 - 0 - - 0 - - - true - - - true - Alpha - - - true - - - true - 0 - 1 - None - 0.5 - - - OverlayAlpha - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Camera - BodyCamera - 53 - 215 - 2 - 0 - TriggeredCamerasStream - - - SessionSchema - - - TaskLogicSchema - - - - - - Metadata - StartExperimentShortcut - UiHabituationTimeUpdate - - - PreSession - UiKeepLeftOpen - UiKeepRightOpen - UiKeepBothOpen - UiDrainLeft - UiDrainRight - UiDrainBoth - UiManipulatorLeft - UiManipulatorForwardLeft - UiManipulatorForwardRight - UiManipulatorUp - UiManipulatorRight - UiManipulatorBackLeft - UiManipulatorBackRight - UiManipulatorDown - UiManipulatorStop - UiManipulatorHome - UiManipulatorInitialize - DrainLeftComplete - DrainRightComplete - - - IntraSession - UiGiveLeft - UiGiveRight - UiMoveLeft - UiMoveRight - StartExperiment - UiCueGiveLeft - UiCueGiveRight - SessionMetadata - - - - - - - - - - - - - - - + From f3a26c0b8c98fc2da7eed5260fa8749b9b62a128 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Fri, 4 Sep 2026 16:42:31 +0100 Subject: [PATCH 111/116] Ensure visualizer is automatically visible on workflow start --- src/Extensions/Visualizers.bonsai | 8 + src/main.bonsai | 1947 ++++++++++++++++++++++++++++- 2 files changed, 1954 insertions(+), 1 deletion(-) diff --git a/src/Extensions/Visualizers.bonsai b/src/Extensions/Visualizers.bonsai index d414265a..36e084a7 100644 --- a/src/Extensions/Visualizers.bonsai +++ b/src/Extensions/Visualizers.bonsai @@ -4,6 +4,7 @@ xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" + xmlns:ui="clr-namespace:Bonsai.Design;assembly=Bonsai.Design" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns:p1="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" xmlns:p2="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" @@ -33,9 +34,16 @@ Frame + + true + + + + + diff --git a/src/main.bonsai b/src/main.bonsai index 3be493d9..7aad799e 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -10,6 +10,12 @@ xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:num="clr-namespace:Bonsai.Numerics;assembly=Bonsai.Numerics" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" + xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" + xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" + xmlns:ui="clr-namespace:Bonsai.Design;assembly=Bonsai.Design" + xmlns:p5="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" + xmlns:p6="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" + xmlns:p7="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -477,7 +483,1946 @@ - + + Visualizers + + + + ImGuiContext + + + + + true + 1 + None + + 0 + 0 + + 0 + + + Frame + + + + true + + + + + + + + + + + + + + + DataTransformations + + + + GlobalTrialOutcome + + + HarpTimestampSource + + + TimedTrial + + + GlobalTrialMetrics + + + Bias + + + TrialIndex + + + + + + new (it.Item1 as Bias, it.Item2 as TrialIndex) + + + TrialIndexedBias + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + HarpTimestampSource + + + LickRight + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + + HarpTimestampSource + + + LickLeft + + + SoftwareEvent + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + LickRight + + + + IsRightLickEvent + + + + + + Source1 + + + Value + + + + + + + + + + + + + + LickLeft + + + + GiveRewardRight + + + + + + Source1 + + + + + + + + + + + WaterRight + + + + GiveRewardRight + + + + + + + Source1 + + + + + + + + + + + WaterLeft + + + + + + + HarpTimestampSource + + + + + + + + + + + + EthogramEvents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OutputControl + + + + Manipulator + + + + UiManipulatorLeft + + + MoveRelative + + + + Source1 + + + + -1 + 0 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorRight + + + MoveRelative + + + + Source1 + + + + 1 + 0 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorForwardLeft + + + MoveRelative + + + + Source1 + + + + 0 + 1 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorForwardRight + + + MoveRelative + + + + Source1 + + + + 0 + 0 + 1 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorBackLeft + + + MoveRelative + + + + Source1 + + + + 0 + -1 + 0 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorBackRight + + + MoveRelative + + + + Source1 + + + + 0 + 0 + -1 + 0 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorUp + + + MoveRelative + + + + Source1 + + + + 0 + 0 + 0 + 1 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorDown + + + MoveRelative + + + + Source1 + + + + 0 + 0 + 0 + -1 + + + + OffsetGain + + + + + + + MoveBy + + + + + + + + + + + + + + + UiManipulatorHome + + + Home + + + + Source1 + + + + HomeMotors + + + + + + + + + + + + UiManipulatorStop + + + StopMotors + + + + Source1 + + + + StopMotors + + + + + + + + + + + + UiManipulatorInitialize + + + GoToInitialPosition + + + + Source1 + + + + GoToInitialPosition + + + + + + + + + + + + OffsetGain + + + + + + + + + + + + + + + + + + + UiHabituationTimeUpdate + + + + 0.05 + + + + + 1 + + + + BumpSize + + + UiMoveLeft + + + BumpLeft + + + + Source1 + + + BumpSize + + + + + + Item2 + + + + -1 + + + + ManualSpoutDelta + + + + + + + + + + + + + + + UiMoveRight + + + BumpRight + + + + Source1 + + + BumpSize + + + + + + Item2 + + + ManualSpoutDelta + + + + + + + + + + + + + + UiGiveRight + + + TriggerRight + + + + Source1 + + + + true + + + + GiveManualWaterRight + + + + + + + + + + + + UiGiveLeft + + + TriggerLeft + + + + Source1 + + + + false + + + + GiveManualWaterRight + + + + + + + + + + + + UiCueGiveLeft + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetLeft() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + UiCueGiveRight + + + UpdateGlobalState + + + + Source1 + + + GlobalAutoWaterState + + + + + + Item2 + + + + + + it.SetRight() + + + GlobalAutoWaterState + + + + + + + + + + + + + + + + + true + + + + IsFlushingValveLeft + + + GiveManualWaterRight + + + GiveManualWaterRight + + + GiveRewardRight + + + IsFlushingValveLeft + + + IsFlushingValveRight + + + UiKeepLeftOpen + + + UiKeepBothOpen + + + + + + KeepLeftOpen + + + + + 50 + + + + + 1 + + + + DefaultRewardAmount + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + false + + + + DefaultRewardAmount + + + + + + SetIsRightRewardAmount + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + + PT0.5S + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UiKeepRightOpen + + + + + + KeepRightOpen + + + + + 50 + + + + + 1 + + + + DefaultRewardAmount + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + true + + + + DefaultRewardAmount + + + + + + SetIsRightRewardAmount + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + + PT0.5S + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UiDrainLeft + + + UiDrainBoth + + + + + + FlushLeft + + + + + 50 + + + + + 1 + + + + DefaultVolume + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + false + + + + DefaultVolume + + + + + + SetIsRightRewardAmount + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + DefaultVolume + + + RigSchema + + + Calibration.WaterValveLeft + + + + + + RewardToTime + ((Item1 * 0.001) - Item2.Offset) / Item2.Slope + + + + + + + + + + + + PT1.288S + + + + DefaultVolume + + + DivideByEachOpen + Math.Ceiling(5000 / it) + + + + + + + + + 100 + + + + + + + + false + + + + IsFlushingValveLeft + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DrainLeftComplete + + + UiDrainRight + + + + + + FlushRight + + + + + 50 + + + + + 1 + + + + DefaultVolume + + + Source1 + + + + + + + Source1 + + + + + + + + + + + PT0.1S + + + + + + + + true + + + + DefaultVolume + + + + + + SetIsRightRewardAmount + + + + PT0.02S + + + + Item1 + + + GiveRewardRight + + + DefaultVolume + + + RigSchema + + + Calibration.WaterValveRight + + + + + + RewardToTime + ((Item1 * 0.001) - Item2.Offset) / Item2.Slope + + + + + + + + + + + + PT0.888S + + + + DefaultVolume + + + DivideByEachOpen + Math.Ceiling(5000 / it) + + + + + + + + + 100 + + + + + + + + false + + + + IsFlushingValveRight + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DrainRightComplete + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VisualizerStructure + + + + + + + Frame + + + true + + + true + + + Ethograph + WidthStretch + 0 + + + Camera + WidthFixed + 320 + + + BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit + + 0 + 0 + + 0 + true + + + true + + + true + 1 + None + + 0 + 0 + + 0 + + + true + + + Behavior + + + true + + + Bias + + + true + + + Ethogram + + + + + + true + + + Camera + + + + + + true + + + true + 1 + Borders + + 0 + 0 + + 0 + + + Metadata + + + true + + + true + None + + + PreSession + true + pre-session + None + + + PreSession + + + IntraSession + true + intra-session + None + + + IntraSession + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Behavior1 + LickLeft + LickRight + TimedTrial + Behavior + + + Bias + TrialIndexedBias + + + PLACEHOLDER + + + + SessionInfo + + + + TimedTrial + + + Value.Trial.Metadata.Extra + + + SessionMetadata + + + + + + + + + + + + Ethogram + + + EthogramEvents + + + + + + + + + true + + Break + 200 + + + QuiescentPeriod + Gold + 0.3 + + + ResponsePeriod + SandyBrown + 0.3 + + + RewardConsumptionPeriod + RosyBrown + 0.3 + + + ItiPeriod + Green + 0.3 + + + + + LickLeft + Red + 0.9 + 6 + Down + + + LickRight + Blue + 0.1 + 6 + Up + + + IsRightTriggerQuickRetract + DarkCyan + 0.5 + 6 + Plus + + + DeliverSecondaryReinforcer + Sienna + 0.5 + 6 + Plus + + + WaterRight + Red + 0.2 + 6 + Circle + + + WaterLeft + Blue + 0.8 + 6 + Circle + + + + + + + Camera + BodyCamera + 0.1 + 0.9 + 2 + 0 + TriggeredCamerasStream + + + Camera + BodyCamera + 0.1 + 0.9 + 2 + 0 + TriggeredCamerasStream + + + SessionSchema + + + TaskLogicSchema + + + + + + Metadata + StartExperimentShortcut + UiHabituationTimeUpdate + + + PreSession + UiKeepLeftOpen + UiKeepRightOpen + UiKeepBothOpen + UiDrainLeft + UiDrainRight + UiDrainBoth + UiManipulatorLeft + UiManipulatorForwardLeft + UiManipulatorForwardRight + UiManipulatorUp + UiManipulatorRight + UiManipulatorBackLeft + UiManipulatorBackRight + UiManipulatorDown + UiManipulatorStop + UiManipulatorHome + UiManipulatorInitialize + DrainLeftComplete + DrainRightComplete + + + IntraSession + UiGiveLeft + UiGiveRight + UiMoveLeft + UiMoveRight + StartExperiment + UiCueGiveLeft + UiCueGiveRight + SessionMetadata + + + + + + + + + + + + + + + From 984d832902370a44605721627928f3b568ccfbbd Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Fri, 4 Sep 2026 16:48:38 +0100 Subject: [PATCH 112/116] Group Visualizer as IncludeWorkflow --- src/main.bonsai | 1947 +---------------------------------------------- 1 file changed, 1 insertion(+), 1946 deletions(-) diff --git a/src/main.bonsai b/src/main.bonsai index 7aad799e..3be493d9 100644 --- a/src/main.bonsai +++ b/src/main.bonsai @@ -10,12 +10,6 @@ xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:num="clr-namespace:Bonsai.Numerics;assembly=Bonsai.Numerics" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" - xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" - xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" - xmlns:ui="clr-namespace:Bonsai.Design;assembly=Bonsai.Design" - xmlns:p5="clr-namespace:AllenNeuralDynamics.Core;assembly=AllenNeuralDynamics.Core" - xmlns:p6="clr-namespace:AllenNeuralDynamics.Core.Design;assembly=AllenNeuralDynamics.Core.Design" - xmlns:p7="clr-namespace:AllenNeuralDynamics.AindManipulator;assembly=AllenNeuralDynamics.AindManipulator" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -483,1946 +477,7 @@ - - Visualizers - - - - ImGuiContext - - - - - true - 1 - None - - 0 - 0 - - 0 - - - Frame - - - - true - - - - - - - - - - - - - - - DataTransformations - - - - GlobalTrialOutcome - - - HarpTimestampSource - - - TimedTrial - - - GlobalTrialMetrics - - - Bias - - - TrialIndex - - - - - - new (it.Item1 as Bias, it.Item2 as TrialIndex) - - - TrialIndexedBias - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - HarpTimestampSource - - - LickRight - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - - HarpTimestampSource - - - LickLeft - - - SoftwareEvent - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - LickRight - - - - IsRightLickEvent - - - - - - Source1 - - - Value - - - - - - - - - - - - - - LickLeft - - - - GiveRewardRight - - - - - - Source1 - - - - - - - - - - - WaterRight - - - - GiveRewardRight - - - - - - - Source1 - - - - - - - - - - - WaterLeft - - - - - - - HarpTimestampSource - - - - - - - - - - - - EthogramEvents - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OutputControl - - - - Manipulator - - - - UiManipulatorLeft - - - MoveRelative - - - - Source1 - - - - -1 - 0 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorRight - - - MoveRelative - - - - Source1 - - - - 1 - 0 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorForwardLeft - - - MoveRelative - - - - Source1 - - - - 0 - 1 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorForwardRight - - - MoveRelative - - - - Source1 - - - - 0 - 0 - 1 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorBackLeft - - - MoveRelative - - - - Source1 - - - - 0 - -1 - 0 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorBackRight - - - MoveRelative - - - - Source1 - - - - 0 - 0 - -1 - 0 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorUp - - - MoveRelative - - - - Source1 - - - - 0 - 0 - 0 - 1 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorDown - - - MoveRelative - - - - Source1 - - - - 0 - 0 - 0 - -1 - - - - OffsetGain - - - - - - - MoveBy - - - - - - - - - - - - - - - UiManipulatorHome - - - Home - - - - Source1 - - - - HomeMotors - - - - - - - - - - - - UiManipulatorStop - - - StopMotors - - - - Source1 - - - - StopMotors - - - - - - - - - - - - UiManipulatorInitialize - - - GoToInitialPosition - - - - Source1 - - - - GoToInitialPosition - - - - - - - - - - - - OffsetGain - - - - - - - - - - - - - - - - - - - UiHabituationTimeUpdate - - - - 0.05 - - - - - 1 - - - - BumpSize - - - UiMoveLeft - - - BumpLeft - - - - Source1 - - - BumpSize - - - - - - Item2 - - - - -1 - - - - ManualSpoutDelta - - - - - - - - - - - - - - - UiMoveRight - - - BumpRight - - - - Source1 - - - BumpSize - - - - - - Item2 - - - ManualSpoutDelta - - - - - - - - - - - - - - UiGiveRight - - - TriggerRight - - - - Source1 - - - - true - - - - GiveManualWaterRight - - - - - - - - - - - - UiGiveLeft - - - TriggerLeft - - - - Source1 - - - - false - - - - GiveManualWaterRight - - - - - - - - - - - - UiCueGiveLeft - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetLeft() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - UiCueGiveRight - - - UpdateGlobalState - - - - Source1 - - - GlobalAutoWaterState - - - - - - Item2 - - - - - - it.SetRight() - - - GlobalAutoWaterState - - - - - - - - - - - - - - - - - true - - - - IsFlushingValveLeft - - - GiveManualWaterRight - - - GiveManualWaterRight - - - GiveRewardRight - - - IsFlushingValveLeft - - - IsFlushingValveRight - - - UiKeepLeftOpen - - - UiKeepBothOpen - - - - - - KeepLeftOpen - - - - - 50 - - - - - 1 - - - - DefaultRewardAmount - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - false - - - - DefaultRewardAmount - - - - - - SetIsRightRewardAmount - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - - PT0.5S - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UiKeepRightOpen - - - - - - KeepRightOpen - - - - - 50 - - - - - 1 - - - - DefaultRewardAmount - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - true - - - - DefaultRewardAmount - - - - - - SetIsRightRewardAmount - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - - PT0.5S - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UiDrainLeft - - - UiDrainBoth - - - - - - FlushLeft - - - - - 50 - - - - - 1 - - - - DefaultVolume - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - false - - - - DefaultVolume - - - - - - SetIsRightRewardAmount - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - DefaultVolume - - - RigSchema - - - Calibration.WaterValveLeft - - - - - - RewardToTime - ((Item1 * 0.001) - Item2.Offset) / Item2.Slope - - - - - - - - - - - - PT1.288S - - - - DefaultVolume - - - DivideByEachOpen - Math.Ceiling(5000 / it) - - - - - - - - - 100 - - - - - - - - false - - - - IsFlushingValveLeft - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DrainLeftComplete - - - UiDrainRight - - - - - - FlushRight - - - - - 50 - - - - - 1 - - - - DefaultVolume - - - Source1 - - - - - - - Source1 - - - - - - - - - - - PT0.1S - - - - - - - - true - - - - DefaultVolume - - - - - - SetIsRightRewardAmount - - - - PT0.02S - - - - Item1 - - - GiveRewardRight - - - DefaultVolume - - - RigSchema - - - Calibration.WaterValveRight - - - - - - RewardToTime - ((Item1 * 0.001) - Item2.Offset) / Item2.Slope - - - - - - - - - - - - PT0.888S - - - - DefaultVolume - - - DivideByEachOpen - Math.Ceiling(5000 / it) - - - - - - - - - 100 - - - - - - - - false - - - - IsFlushingValveRight - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DrainRightComplete - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - VisualizerStructure - - - - - - - Frame - - - true - - - true - - - Ethograph - WidthStretch - 0 - - - Camera - WidthFixed - 320 - - - BordersInnerH BordersOuterH BordersInnerV BordersOuterV BordersH BordersV BordersInner BordersOuter Borders SizingFixedFit - - 0 - 0 - - 0 - true - - - true - - - true - 1 - None - - 0 - 0 - - 0 - - - true - - - Behavior - - - true - - - Bias - - - true - - - Ethogram - - - - - - true - - - Camera - - - - - - true - - - true - 1 - Borders - - 0 - 0 - - 0 - - - Metadata - - - true - - - true - None - - - PreSession - true - pre-session - None - - - PreSession - - - IntraSession - true - intra-session - None - - - IntraSession - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Behavior1 - LickLeft - LickRight - TimedTrial - Behavior - - - Bias - TrialIndexedBias - - - PLACEHOLDER - - - - SessionInfo - - - - TimedTrial - - - Value.Trial.Metadata.Extra - - - SessionMetadata - - - - - - - - - - - - Ethogram - - - EthogramEvents - - - - - - - - - true - - Break - 200 - - - QuiescentPeriod - Gold - 0.3 - - - ResponsePeriod - SandyBrown - 0.3 - - - RewardConsumptionPeriod - RosyBrown - 0.3 - - - ItiPeriod - Green - 0.3 - - - - - LickLeft - Red - 0.9 - 6 - Down - - - LickRight - Blue - 0.1 - 6 - Up - - - IsRightTriggerQuickRetract - DarkCyan - 0.5 - 6 - Plus - - - DeliverSecondaryReinforcer - Sienna - 0.5 - 6 - Plus - - - WaterRight - Red - 0.2 - 6 - Circle - - - WaterLeft - Blue - 0.8 - 6 - Circle - - - - - - - Camera - BodyCamera - 0.1 - 0.9 - 2 - 0 - TriggeredCamerasStream - - - Camera - BodyCamera - 0.1 - 0.9 - 2 - 0 - TriggeredCamerasStream - - - SessionSchema - - - TaskLogicSchema - - - - - - Metadata - StartExperimentShortcut - UiHabituationTimeUpdate - - - PreSession - UiKeepLeftOpen - UiKeepRightOpen - UiKeepBothOpen - UiDrainLeft - UiDrainRight - UiDrainBoth - UiManipulatorLeft - UiManipulatorForwardLeft - UiManipulatorForwardRight - UiManipulatorUp - UiManipulatorRight - UiManipulatorBackLeft - UiManipulatorBackRight - UiManipulatorDown - UiManipulatorStop - UiManipulatorHome - UiManipulatorInitialize - DrainLeftComplete - DrainRightComplete - - - IntraSession - UiGiveLeft - UiGiveRight - UiMoveLeft - UiMoveRight - StartExperiment - UiCueGiveLeft - UiCueGiveRight - SessionMetadata - - - - - - - - - - - - - - - + From d7cd301f3d2cfe4b82eb170c3c1612cbfedeb451 Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Fri, 4 Sep 2026 09:21:56 -0700 Subject: [PATCH 113/116] fixes graphing bugs --- src/Extensions/BehaviorVisualizer.bonsai | 246 ++++++++++----------- src/Extensions/BiasVisualizer.bonsai | 248 ++++++++++++---------- src/Extensions/SoftwareEventVisualizer.cs | 2 +- 3 files changed, 257 insertions(+), 239 deletions(-) diff --git a/src/Extensions/BehaviorVisualizer.bonsai b/src/Extensions/BehaviorVisualizer.bonsai index 0503b60b..0e983271 100644 --- a/src/Extensions/BehaviorVisualizer.bonsai +++ b/src/Extensions/BehaviorVisualizer.bonsai @@ -2,11 +2,11 @@ @@ -24,106 +24,6 @@ BehaviorPlot - - - - - AutoRewardLeft - - - Value - - - - 0.9 - - - - Seconds - - - - - - new(it.Item1 as LickLeft, it.Item2) - - - 1000 - Item2 - LickLeft - - - EventPlot - - - - Diamond - 3 - 0 - 0 - 1 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - - - - - - AutoRewardRight - - - Value - - - - 0.1 - - - - Seconds - - - - - - new(it.Item1 as LickRight, it.Item2) - - - 1000 - Item2 - LickRight - - - EventPlot - - - - Diamond - 3 - 0 - 0 - 1 - 1 - 0 - 0 - 0 - 1 - 1 - - - - true - None - @@ -215,6 +115,106 @@ + + + + + AutoRewardLeft + + + Value + + + + 0.9 + + + + Seconds + + + + + + new(it.Item1 as AutoReward, it.Item2) + + + 1000 + Item2 + AutoReward + + + EventPlot + + + + Diamond + 3 + 0 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + + + + true + None + + + + + + AutoRewardRight + + + Value + + + + 0.1 + + + + Seconds + + + + + + new(it.Item1 as AutoReward, it.Item2) + + + 1000 + Item2 + AutoReward + + + EventPlot + + + + Diamond + 3 + 0 + 0 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + + + + true + None + @@ -255,8 +255,8 @@ 0 1 0 - 0 - 0 + 1 + 1 1 1 @@ -587,38 +587,38 @@ - - - - - + + + + + - - + - - - - + + - - + + + - - + + - - + + - + + + diff --git a/src/Extensions/BiasVisualizer.bonsai b/src/Extensions/BiasVisualizer.bonsai index bb44d7b5..0425f86e 100644 --- a/src/Extensions/BiasVisualizer.bonsai +++ b/src/Extensions/BiasVisualizer.bonsai @@ -59,6 +59,108 @@ -1.1 + + + + + LeftBiasCorrection + + + + 0.5 + + + + TrialIndexedBias + + + TrialIndex + + + + + + + new (it.Item1 as StageCorrection, it.Item2 as TrialIndex) + + + 1000 + TrialIndex + StageCorrection + + + BiasPlot + + + + Up + 3 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + + + + RightBiasCorrection + + + + -0.5 + + + + TrialIndexedBias + + + TrialIndex + + + + + + + new (it.Item1 as StageCorrection, it.Item2 as TrialIndex) + + + 1000 + TrialIndex + StageCorrection + + + BiasPlot + + + + Down + 3 + 0 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + + + + true + None + @@ -148,9 +250,9 @@ true - 0.00 - 22 - 0 + 0.70 + 9 + 0.7 0 -10 @@ -222,94 +324,6 @@ true None - - - - - RightBiasCorrection - - - - -0.5 - - - - - - - new (it.Item1 as RightBias, it.Item2 as TrialIndex) - - - 1000 - TrialIndex - RightBias - - - BiasPlot - - - - Down - 0 - 0 - 0 - 1 - 1 - 0 - 0 - 0 - 0 - 0 - - - - true - None - - - - - - LeftBiasCorrection - - - - 0.5 - - - - - - - new (it.Item1 as RightBias, it.Item2 as TrialIndex) - - - 1000 - TrialIndex - RightBias - - - BiasPlot - - - - Up - 0 - 1 - 0 - 0 - 1 - 0 - 0 - 0 - 0 - 0 - - - - true - None - TaskLogicParameters @@ -325,61 +339,65 @@ - - - - - - + + + - - - - + - + - - - - - - + + + - + + + + + + - - + + + - + - - + + + + - + + + + + + diff --git a/src/Extensions/SoftwareEventVisualizer.cs b/src/Extensions/SoftwareEventVisualizer.cs index 6d141f2e..6788e743 100644 --- a/src/Extensions/SoftwareEventVisualizer.cs +++ b/src/Extensions/SoftwareEventVisualizer.cs @@ -26,7 +26,7 @@ public class SoftwareEventVisualizer private const double YAxisMax = 1.0; private const float InputWidth = 80.0f; - private float timeWindow = 120.0f; + private float timeWindow = 20.0f; public List ShadedAreaPlotters {get; set;} public List PointPlotters {get; set;} private int maxTrials = 0; From 43a96c4a745d4a4a1f20f9b6c930e75af0572a58 Mon Sep 17 00:00:00 2001 From: RoboDoig Date: Fri, 4 Sep 2026 20:00:22 +0100 Subject: [PATCH 114/116] Update test visualizer for new exposed subjects --- src/test_visualizer.bonsai | 809 +++++++++++++++++++++++++++++++++---- 1 file changed, 734 insertions(+), 75 deletions(-) diff --git a/src/test_visualizer.bonsai b/src/test_visualizer.bonsai index 9ab32d72..80d9447b 100644 --- a/src/test_visualizer.bonsai +++ b/src/test_visualizer.bonsai @@ -17,9 +17,11 @@ xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp" xmlns:imvizui="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers.Design" xmlns:imgui="clr-namespace:Bonsai.ImGui;assembly=Bonsai.ImGui" + xmlns:ui="clr-namespace:Bonsai.Design;assembly=Bonsai.Design" + xmlns:implot="clr-namespace:Bonsai.ImPlot;assembly=Bonsai.ImPlot" + xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:p8="clr-namespace:System.Reactive;assembly=System.Reactive.Core" - xmlns:imviz="clr-namespace:Bonsai.ImGui.Visualizers;assembly=Bonsai.ImGui.Visualizers" xmlns="https://bonsai-rx.org/2018/workflow"> @@ -156,6 +158,172 @@ LickLeft + + + false + + + + + 1 + + + + IsRetracted + + + TimedTrial + + + Value.Trial.IsAutoRewardRight + + + + + + + Source1 + + + Value + + + + + + + + + + + + + Seconds + + + + + + + + + AutoRewardLeft + + + + + + Source1 + + + Value + + + + + + + + + + + + + + + + + AutoRewardRight + + + TimedTrial + + + Value.Trial.LickspoutOffsetDelta + + + NotZero + + + + Source1 + + + + 0 + + + + + + + + + + + + + + MoveRight + + + + Source1 + + + + 0 + + + + + + + + + + + + Seconds + + + + + + + + + LeftBiasCorrection + + + MoveLeft + + + + Source1 + + + + false + + + + + + + + + + + + + + + + + + RightBiasCorrection + 0 @@ -202,7 +370,7 @@ - PT0.102S + PT1.756S @@ -254,7 +422,7 @@ - PT1.88S + PT1.826S @@ -325,7 +493,7 @@ - PT0.798S + PT0.735S @@ -844,7 +1012,7 @@ it.Index as TrialIndex - + true false @@ -871,7 +1039,7 @@ it.Index as TrialIndex - PT0.517S + PT0.377S @@ -972,131 +1140,159 @@ it.Index as TrialIndex - + + + - - + + + + - - - - - - + + + + + + + + - + - - - - + - + + - - + - - + + - - + - - + + + - + - + - - + + + + - - + + + + - - - + + - + - - + - - - + - - - + - - - - - + + - + - - + + - - + + + - + + - - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1118,6 +1314,12 @@ it.Index as TrialIndex Frame + + true + + + + VisualizerStructure @@ -1281,10 +1483,405 @@ it.Index as TrialIndex LickRight TimedTrial Behavior + AutoRewardRight + AutoRewardLeft - - Bias - TrialIndexedBias + + BiasVisualizer + + + + + + + + + + BiasVisualizer + + + + + + + Bias + + + BiasPlot + true + + -1 + 150 + + NoTitle + AutoFit + None + + + BiasPlot + + + + BiasPlot + + + + + -1 + 1 + + + R + L + + East + Outside + 1.1 + -1.1 + + + + + + + LeftBiasCorrection + + + + 0.5 + + + + TrialIndexedBias + + + TrialIndex + + + + + + + new (it.Item1 as StageCorrection, it.Item2 as TrialIndex) + + + 1000 + TrialIndex + StageCorrection + + + BiasPlot + + + + Up + 3 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + true + None + + + + + + RightBiasCorrection + + + + -0.5 + + + + TrialIndexedBias + + + TrialIndex + + + + + + + new (it.Item1 as StageCorrection, it.Item2 as TrialIndex) + + + 1000 + TrialIndex + StageCorrection + + + BiasPlot + + + + Down + 3 + 0 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + + + + true + None + + + + + + TrialIndexedBias + + + 1000 + TrialIndex + Bias + + + BiasPlot + + + + 0 + 0 + 0 + 1 + 2 + + + + true + None + + + 1 + TrialIndex + Bias + + + BiasPlot + + + + Circle + 5 + 0 + 1 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + + + + + true + None + + + + Bias + + + + BiasPlot + + + {0:N2} + it + + + + + + + + TrialIndex + + + + + + + + + + + + + + + true + 0.22 + 196 + 0.21708835946260363 + + 0 + -10 + + None + + + + + 0.5 + + + + + + + new (it.Item1 as LeftBias, it.Item2 as TrialIndex) + + + 1000 + TrialIndex + LeftBias + + + BiasPlot + + + + 1 + 0 + 0 + 0.7 + 1 + + + + true + None + + + + -0.5 + + + + + + + new (it.Item1 as RightBias, it.Item2 as TrialIndex) + + + 1000 + TrialIndex + RightBias + + + BiasPlot + + + + 0 + 0 + 1 + 0.7 + 1 + + + + true + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OutputControl @@ -1409,6 +2006,67 @@ it.Index as TrialIndex + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Break 200 @@ -1723,7 +2381,7 @@ it.Index as TrialIndex - 0.5 + 0.371 0.1 0.3 @@ -2352,15 +3010,16 @@ it.Index as TrialIndex + - - - - - - - - + + + + + + + + From 504797181b6b4d13077b08bc47cf84c127935c85 Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Fri, 4 Sep 2026 12:22:28 -0700 Subject: [PATCH 115/116] Adds back take until --- src/Extensions/CameraPreviewVisualizer.bonsai | 74 ++++++++++--------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/src/Extensions/CameraPreviewVisualizer.bonsai b/src/Extensions/CameraPreviewVisualizer.bonsai index fd79d52a..c8d3fc52 100644 --- a/src/Extensions/CameraPreviewVisualizer.bonsai +++ b/src/Extensions/CameraPreviewVisualizer.bonsai @@ -96,6 +96,12 @@ CameraStream + + EndExperiment + + + + Value.Image @@ -360,51 +366,53 @@ - - - - + + + - + + - - - - + + + - - - - - - - + + + + + + + + - - - + + + - - + + - - - - - - - + + + + + + + - - + + - - - + + + + + From 9baad24396e918297899d566882b8dcdcbac4201 Mon Sep 17 00:00:00 2001 From: Micah Woodard Date: Thu, 10 Sep 2026 07:27:13 -0700 Subject: [PATCH 116/116] bumps bonsai version --- .bonsai/Bonsai.config | 48 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/.bonsai/Bonsai.config b/.bonsai/Bonsai.config index 94a3a8ec..4dd0cf1a 100644 --- a/.bonsai/Bonsai.config +++ b/.bonsai/Bonsai.config @@ -14,12 +14,12 @@ - - - - - - + + + + + + @@ -36,19 +36,19 @@ - - - - + + + + - + - + @@ -147,12 +147,12 @@ - - - - - - + + + + + + @@ -169,17 +169,17 @@ - - - - + + + + - + - +