diff --git a/src/Extensions/MetadataVisualizer.bonsai b/src/Extensions/MetadataVisualizer.bonsai index 45d9842..192b563 100644 --- a/src/Extensions/MetadataVisualizer.bonsai +++ b/src/Extensions/MetadataVisualizer.bonsai @@ -82,10 +82,10 @@ CurrentMetadata - Item2.StageName + @@ -104,6 +104,7 @@ Item1.Experimenter + @@ -301,52 +302,53 @@ - - - - + + + + - + - - - + + + - - - + + + - - + + - - - - - + + + + + - + - - - + + + - - - - - + + + + + + diff --git a/src/Extensions/PreSessionVisualizer.bonsai b/src/Extensions/PreSessionVisualizer.bonsai index ae31e7e..bd67eda 100644 --- a/src/Extensions/PreSessionVisualizer.bonsai +++ b/src/Extensions/PreSessionVisualizer.bonsai @@ -1,5 +1,5 @@  - + + + + PreSessionVisualizer @@ -84,6 +88,17 @@ + + + + + KeepLeftOpenComplete + + + + + + KeepLeftOpen true @@ -107,6 +122,17 @@ + + + + + KeepRightOpenComplete + + + + + + KeepRightOpen true @@ -141,6 +167,14 @@ + + + + + + + + KeepBothOpen true @@ -176,6 +210,32 @@ + + + + + DrainLeftCountdown + + + Cancel Drain Left ({0:N0} s) + it + + + DrainLeftComplete + + + + Cancel Drain Left + + + + + + + + + + DrainLeft true @@ -202,6 +262,32 @@ + + + + + DrainRightCountdown + + + Cancel Drain Right ({0:N0} s) + it + + + DrainRightComplete + + + + Cancel Drain Right + + + + + + + + + + DrainRight true @@ -225,6 +311,26 @@ + + + + + Cancel Drain Both (L {0:N0} s, R {1:N0} s) + Item1,Item2 + + + + Cancel Drain Both + + + + + + + + + + DrainBoth true @@ -711,205 +817,251 @@ + + LeftOpenState + + + RightOpenState + + + BothOpenState + - + - - - - + + + + - - + + - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + - - - + + + - - - - - - - - + + + + + + + + + + + - - + + + - - - - - + + + + + + - - + + - - - - - - + + + - - - - - - - + + + + - - - + + + + - - - - - - - - - - - - - + + + + + + + + + + + - - - - + + + + + - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - + + + - - - - + + + + - - - - - - - - - - - - - + + + + + - - - - - - - - + + + + + - - - - - - + + + + + + + + + + - + - - - - - + + + + + + - + - - - + + + + + + + + + + + + - - - - - + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Extensions/Visualizers.bonsai b/src/Extensions/Visualizers.bonsai index e478827..36e66dc 100644 --- a/src/Extensions/Visualizers.bonsai +++ b/src/Extensions/Visualizers.bonsai @@ -38,7 +38,7 @@ true - + Maximized @@ -1121,16 +1121,16 @@ IsFlushingValveRight - UiKeepLeftOpen + UiDrainLeft - UiKeepBothOpen + UiDrainBoth - KeepLeftOpen + FlushLeft @@ -1144,7 +1144,7 @@ - DefaultRewardAmount + DefaultVolume Source1 @@ -1177,7 +1177,7 @@ - DefaultRewardAmount + DefaultVolume @@ -1196,17 +1196,63 @@ GiveRewardRight + + DefaultVolume + + + RigSchema + + + Calibration.WaterValveLeft + + + + + + RewardToTime + ((Item1 * 0.001) - Item2.Offset) / Item2.Slope + + + + + + + + + - PT0.5S + PT1.288S + + DefaultVolume + + + DivideByEachOpen + Math.Ceiling(5000 / it) + + + + + + - + + 100 + + + + false + + + + IsFlushingValveLeft + @@ -1216,13 +1262,29 @@ + + + + + + + + + + + RemainingSeconds + (Item2 - Item1.Item1.Index - 1) * (Item1.Item2 + 0.12) + + + DrainLeftCountdown + - + @@ -1231,26 +1293,48 @@ - - + + + + + + + + + + + + + + + + + + + + + + + DrainLeftComplete + - UiKeepRightOpen + UiDrainRight - KeepRightOpen + FlushRight @@ -1264,7 +1348,7 @@ - DefaultRewardAmount + DefaultVolume Source1 @@ -1297,7 +1381,7 @@ - DefaultRewardAmount + DefaultVolume @@ -1316,17 +1400,63 @@ GiveRewardRight + + DefaultVolume + + + RigSchema + + + Calibration.WaterValveRight + + + + + + RewardToTime + ((Item1 * 0.001) - Item2.Offset) / Item2.Slope + + + + + + + + + - PT0.5S + PT0.888S + + DefaultVolume + + + DivideByEachOpen + Math.Ceiling(5000 / it) + + + + + + - + + 100 + + + + false + + + + IsFlushingValveRight + @@ -1336,13 +1466,29 @@ + + + + + + + + + + + RemainingSeconds + (Item2 - Item1.Item1.Index - 1) * (Item1.Item2 + 0.12) + + + DrainRightCountdown + - + @@ -1351,29 +1497,51 @@ - - + + + + + + + + + + + + + + + + + + + + + + + DrainRightComplete + - UiDrainLeft + UiKeepLeftOpen - UiDrainBoth + UiKeepBothOpen - FlushLeft + KeepLeftOpen @@ -1387,7 +1555,7 @@ - DefaultVolume + DefaultRewardAmount Source1 @@ -1420,7 +1588,7 @@ - DefaultVolume + DefaultRewardAmount @@ -1439,62 +1607,24 @@ GiveRewardRight - - DefaultVolume - - - RigSchema - - - Calibration.WaterValveLeft - - - - - - RewardToTime - ((Item1 * 0.001) - Item2.Offset) / Item2.Slope - - - - - - - - - - PT1.288S + PT0.5S - - DefaultVolume - - - DivideByEachOpen - Math.Ceiling(5000 / it) - - - - - + + - - 100 + + PT3M - + - - false - - - - IsFlushingValveLeft + @@ -1511,7 +1641,7 @@ - + @@ -1520,24 +1650,14 @@ - - - + + + - + - - - - - - - - - - - + @@ -1545,16 +1665,16 @@ - DrainLeftComplete + KeepLeftOpenComplete - UiDrainRight + UiKeepRightOpen - FlushRight + KeepRightOpen @@ -1568,7 +1688,7 @@ - DefaultVolume + DefaultRewardAmount Source1 @@ -1601,7 +1721,7 @@ - DefaultVolume + DefaultRewardAmount @@ -1620,62 +1740,24 @@ GiveRewardRight - - DefaultVolume - - - RigSchema - - - Calibration.WaterValveRight - - - - - - RewardToTime - ((Item1 * 0.001) - Item2.Offset) / Item2.Slope - - - - - - - - - - PT0.888S + PT0.5S - - DefaultVolume - - - DivideByEachOpen - Math.Ceiling(5000 / it) - - - - - + + - - 100 + + PT3M - + - - false - - - - IsFlushingValveRight + @@ -1692,7 +1774,7 @@ - + @@ -1701,24 +1783,14 @@ - - - + + + - + - - - - - - - - - - - + @@ -1726,7 +1798,13 @@ - DrainRightComplete + KeepRightOpenComplete + + + DrainLeftCountdown + + + DrainRightCountdown @@ -1749,22 +1827,24 @@ - + - + - - - - - + + + + + + - + + @@ -2142,6 +2222,10 @@ UiManipulatorInitialize DrainLeftComplete DrainRightComplete + KeepLeftOpenComplete + KeepRightOpenComplete + DrainLeftCountdown + DrainRightCountdown diff --git a/src/aind_behavior_dynamic_foraging/task_logic/trial_generators/integration_test_trial_generator.py b/src/aind_behavior_dynamic_foraging/task_logic/trial_generators/integration_test_trial_generator.py index 7023604..56ba65d 100644 --- a/src/aind_behavior_dynamic_foraging/task_logic/trial_generators/integration_test_trial_generator.py +++ b/src/aind_behavior_dynamic_foraging/task_logic/trial_generators/integration_test_trial_generator.py @@ -2,7 +2,7 @@ from aind_behavior_services.task import distributions -from ..trial_models import QuickRetractSettings, Trial, TrialOutcome +from ..trial_models import QuickRetractSettings, Trial, TrialMetrics, TrialOutcome from ._base import BaseTrialGeneratorSpecModel, ITrialGenerator @@ -82,3 +82,13 @@ def next(self) -> Trial | None: def update(self, outcome: TrialOutcome | str) -> None: self._idx += 1 + + def get_metrics(self) -> TrialMetrics: + """Return metrics at current state of the trial generator. + + The integration test generator does not track bias, so the metrics are empty. + Without this override, the class inherits ITrialGenerator.get_metrics directly, + which is an empty stub for now. + Bonsai deserialised this into a null TrialMetrics and the visualizers throws. + """ + return TrialMetrics() diff --git a/src/test_visualizer.bonsai b/src/test_visualizer.bonsai index 80d9447..4f125a2 100644 --- a/src/test_visualizer.bonsai +++ b/src/test_visualizer.bonsai @@ -1,5 +1,5 @@  - DrainRightComplete + + KeepLeftOpenComplete + + + KeepRightOpenComplete + + + DrainLeftCountdown + + + DrainRightCountdown + @@ -1994,80 +2006,7 @@ it.Index as TrialIndex true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Break 200 @@ -2995,6 +2934,10 @@ it.Index as TrialIndex UiManipulatorInitialize DrainLeftComplete DrainRightComplete + KeepLeftOpenComplete + KeepRightOpenComplete + DrainLeftCountdown + DrainRightCountdown IntraSession diff --git a/tests/trial_generators/test_integration_test_trial_generator.py b/tests/trial_generators/test_integration_test_trial_generator.py index fab593e..dc27a7a 100644 --- a/tests/trial_generators/test_integration_test_trial_generator.py +++ b/tests/trial_generators/test_integration_test_trial_generator.py @@ -1,7 +1,7 @@ import unittest from aind_behavior_dynamic_foraging.task_logic.trial_generators import IntegrationTestTrialGeneratorSpec -from aind_behavior_dynamic_foraging.task_logic.trial_models import Trial, TrialOutcome +from aind_behavior_dynamic_foraging.task_logic.trial_models import Trial, TrialMetrics, TrialOutcome class TestIntegrationTestTrialGenerator(unittest.TestCase): @@ -54,6 +54,17 @@ def test_sequential_access(self): self.assertEqual(trials_count, expected_count) + def test_get_metrics_returns_empty_metrics(self): + spec = IntegrationTestTrialGeneratorSpec() + generator = spec.create_generator() + + metrics = generator.get_metrics() + self.assertIsInstance(metrics, TrialMetrics) + self.assertIsNone(metrics.bias) + + generator.update(TrialOutcome(trial=generator.next(), is_right_choice=True, is_rewarded=True)) + self.assertIsInstance(generator.get_metrics(), TrialMetrics) + if __name__ == "__main__": unittest.main()