Skip to content

Add missing data and trial logs #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/workflows/Extensions/CorridorTrial.bonsai
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,12 @@ Item2 as MaxActivations)</scr:Expression>
<Expression xsi:type="MulticastSubject">
<Name>PulseValve</Name>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>Position</Name>
</Expression>
<Expression xsi:type="MulticastSubject">
<Name>TrialPosition</Name>
</Expression>
</Nodes>
<Edges>
<Edge From="0" To="1" Label="Source1" />
Expand Down Expand Up @@ -1409,6 +1415,7 @@ Item2 as MaxActivations)</scr:Expression>
<Edge From="38" To="39" Label="Source1" />
<Edge From="39" To="40" Label="Source1" />
<Edge From="42" To="43" Label="Source1" />
<Edge From="44" To="45" Label="Source1" />
</Edges>
</Workflow>
</Expression>
Expand Down
154 changes: 154 additions & 0 deletions src/workflows/Extensions/FrameEventLogger.bonsai
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="utf-8"?>
<WorkflowBuilder Version="2.8.5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions"
xmlns:io="clr-namespace:Bonsai.IO;assembly=Bonsai.System"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns="https://bonsai-rx.org/2018/workflow">
<Description>Creates and initializes a CSV file, and matching behavior subject, used to log events with frame timing.</Description>
<Workflow>
<Nodes>
<Expression xsi:type="Combinator">
<Combinator xsi:type="StringProperty" />
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:IgnoreElements" />
</Expression>
<Expression xsi:type="ExternalizedMapping">
<Property Name="Name" Description="The name of the subject on which events will be logged." Category="Subject" />
</Expression>
<Expression xsi:type="rx:BehaviorSubject">
<Name>EncoderLog</Name>
</Expression>
<Expression xsi:type="WorkflowInput">
<Name>Source1</Name>
</Expression>
<Expression xsi:type="ExternalizedMapping">
<Property Name="Append" />
<Property Name="Overwrite" />
<Property Name="Suffix" />
<Property Name="FileName" />
</Expression>
<Expression xsi:type="rx:Sink">
<Name>CsvLogger</Name>
<Workflow>
<Nodes>
<Expression xsi:type="ExternalizedMapping">
<Property Name="Name" />
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>EncoderLog</Name>
</Expression>
<Expression xsi:type="WorkflowInput">
<Name>Source1</Name>
</Expression>
<Expression xsi:type="MemberSelector">
<Selector>TimeStep.ElapsedTime</Selector>
</Expression>
<Expression xsi:type="rx:Accumulate" />
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:WithLatestFrom" />
</Expression>
<Expression xsi:type="scr:ExpressionTransform">
<scr:Expression>new(
Item2 as ElapsedTime,
Item1 as Value)</scr:Expression>
</Expression>
<Expression xsi:type="ExternalizedMapping">
<Property Name="FileName" />
</Expression>
<Expression xsi:type="GroupWorkflow">
<Name>GenerateFileName</Name>
<Workflow>
<Nodes>
<Expression xsi:type="ExternalizedMapping">
<Property Name="Value" DisplayName="Name" />
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="StringProperty">
<Value>EncoderLog</Value>
</Combinator>
</Expression>
<Expression xsi:type="ExternalizedMapping">
<Property Name="Value" DisplayName="FileName" />
</Expression>
<Expression xsi:type="PropertySource" TypeArguments="io:CsvWriter,sys:String">
<MemberName>FileName</MemberName>
<Value />
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Zip" />
</Expression>
<Expression xsi:type="scr:ExpressionTransform">
<scr:Expression>!string.IsNullOrEmpty(Item2) ? Item2 : Item1 + ".csv"</scr:Expression>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Take">
<rx:Count>1</rx:Count>
</Combinator>
</Expression>
<Expression xsi:type="WorkflowOutput" />
</Nodes>
<Edges>
<Edge From="0" To="1" Label="Source1" />
<Edge From="1" To="4" Label="Source1" />
<Edge From="2" To="3" Label="Source1" />
<Edge From="3" To="4" Label="Source2" />
<Edge From="4" To="5" Label="Source1" />
<Edge From="5" To="6" Label="Source1" />
<Edge From="6" To="7" Label="Source1" />
</Edges>
</Workflow>
</Expression>
<Expression xsi:type="PropertyMapping">
<PropertyMappings>
<Property Name="FileName" />
</PropertyMappings>
</Expression>
<Expression xsi:type="ExternalizedMapping">
<Property Name="Append" />
<Property Name="Overwrite" />
<Property Name="Suffix" />
</Expression>
<Expression xsi:type="io:CsvWriter">
<io:FileName />
<io:Delimiter>,</io:Delimiter>
<io:Append>false</io:Append>
<io:Overwrite>false</io:Overwrite>
<io:Suffix>None</io:Suffix>
<io:IncludeHeader>true</io:IncludeHeader>
<io:Selector />
</Expression>
<Expression xsi:type="WorkflowOutput" />
</Nodes>
<Edges>
<Edge From="0" To="1" Label="Source1" />
<Edge From="0" To="8" Label="Source1" />
<Edge From="1" To="5" Label="Source1" />
<Edge From="2" To="3" Label="Source1" />
<Edge From="3" To="4" Label="Source1" />
<Edge From="4" To="5" Label="Source2" />
<Edge From="5" To="6" Label="Source1" />
<Edge From="6" To="11" Label="Source1" />
<Edge From="7" To="8" Label="Source2" />
<Edge From="8" To="9" Label="Source1" />
<Edge From="9" To="11" Label="Source2" />
<Edge From="10" To="11" Label="Source3" />
<Edge From="11" To="12" Label="Source1" />
</Edges>
</Workflow>
</Expression>
<Expression xsi:type="WorkflowOutput" />
</Nodes>
<Edges>
<Edge From="0" To="1" Label="Source1" />
<Edge From="1" To="3" Label="Source1" />
<Edge From="2" To="3" Label="Source2" />
<Edge From="2" To="6" Label="Source2" />
<Edge From="4" To="6" Label="Source1" />
<Edge From="5" To="6" Label="Source3" />
<Edge From="6" To="7" Label="Source1" />
</Edges>
</Workflow>
</WorkflowBuilder>
94 changes: 55 additions & 39 deletions src/workflows/Extensions/HarpRig.bonsai
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp"
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
xmlns:p1="clr-namespace:Bonsai.Harp.CF;assembly=Bonsai.Harp.CF"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:p1="clr-namespace:Bonsai.Harp.CF;assembly=Bonsai.Harp.CF"
xmlns="https://bonsai-rx.org/2018/workflow">
<Workflow>
<Nodes>
Expand Down Expand Up @@ -41,6 +41,9 @@
<Expression xsi:type="rx:BehaviorSubject">
<Name>Command</Name>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>Command</Name>
</Expression>
<Expression xsi:type="ExternalizedMapping">
<Property Name="PortName" />
</Expression>
Expand All @@ -58,30 +61,47 @@
<Expression xsi:type="rx:PublishSubject">
<Name>Behavior</Name>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>Behavior</Name>
</Expression>
<Expression xsi:type="p1:BehaviorEvent">
<p1:Type>QuadratureCounter</p1:Type>
<p1:Mask>Port2</p1:Mask>
</Expression>
<Expression xsi:type="ExternalizedMapping">
<Property Name="Value" DisplayName="EncoderScale" Description="The scale factor to convert encoder ticks to encoder distance." />
</Expression>
<Expression xsi:type="Multiply">
<Operand xsi:type="FloatProperty">
<Value>1</Value>
</Operand>
</Expression>
<Expression xsi:type="rx:Accumulate" />
<Expression xsi:type="rx:BehaviorSubject" TypeArguments="sys:Object">
<rx:Name>ResetEncoder</rx:Name>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:TakeUntil" />
<Expression xsi:type="ExternalizedMapping">
<Property Name="EncoderScale" />
</Expression>
<Expression xsi:type="rx:CreateObservable">
<Workflow>
<Nodes>
<Expression xsi:type="WorkflowInput">
<Name>Source1</Name>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>Behavior</Name>
</Expression>
<Expression xsi:type="p1:BehaviorEvent">
<p1:Type>QuadratureCounter</p1:Type>
<p1:Mask>Port2</p1:Mask>
</Expression>
<Expression xsi:type="ExternalizedMapping">
<Property Name="Value" DisplayName="EncoderScale" Description="The scale factor to convert encoder ticks to encoder distance." />
</Expression>
<Expression xsi:type="Multiply">
<Operand xsi:type="FloatProperty">
<Value>1</Value>
</Operand>
</Expression>
<Expression xsi:type="rx:Accumulate" />
<Expression xsi:type="WorkflowOutput" />
</Nodes>
<Edges>
<Edge From="1" To="2" Label="Source1" />
<Edge From="2" To="4" Label="Source1" />
<Edge From="3" To="4" Label="Source2" />
<Edge From="4" To="5" Label="Source1" />
<Edge From="5" To="6" Label="Source1" />
</Edges>
</Workflow>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Repeat" />
<Combinator xsi:type="rx:Switch" />
</Expression>
<Expression xsi:type="rx:PublishSubject">
<Name>RigEncoder</Name>
Expand Down Expand Up @@ -185,34 +205,30 @@
</Nodes>
<Edges>
<Edge From="0" To="1" Label="Source1" />
<Edge From="1" To="3" Label="Source1" />
<Edge From="2" To="3" Label="Source2" />
<Edge From="3" To="4" Label="Source1" />
<Edge From="5" To="6" Label="Source1" />
<Edge From="2" To="4" Label="Source1" />
<Edge From="3" To="4" Label="Source2" />
<Edge From="4" To="5" Label="Source1" />
<Edge From="6" To="8" Label="Source1" />
<Edge From="7" To="8" Label="Source2" />
<Edge From="8" To="9" Label="Source1" />
<Edge From="9" To="11" Label="Source1" />
<Edge From="10" To="11" Label="Source2" />
<Edge From="9" To="10" Label="Source1" />
<Edge From="11" To="12" Label="Source1" />
<Edge From="12" To="13" Label="Source1" />
<Edge From="14" To="15" Label="Source1" />
<Edge From="15" To="16" Label="Source1" />
<Edge From="17" To="18" Label="Source1" />
<Edge From="18" To="19" Label="Source1" />
<Edge From="20" To="22" Label="Source1" />
<Edge From="21" To="22" Label="Source2" />
<Edge From="17" To="19" Label="Source1" />
<Edge From="18" To="19" Label="Source2" />
<Edge From="19" To="20" Label="Source1" />
<Edge From="21" To="22" Label="Source1" />
<Edge From="22" To="23" Label="Source1" />
<Edge From="24" To="25" Label="Source1" />
<Edge From="25" To="26" Label="Source1" />
<Edge From="25" To="29" Label="Source1" />
<Edge From="26" To="28" Label="Source1" />
<Edge From="22" To="26" Label="Source1" />
<Edge From="23" To="25" Label="Source1" />
<Edge From="24" To="25" Label="Source2" />
<Edge From="24" To="27" Label="Source2" />
<Edge From="25" To="28" Label="Source1" />
<Edge From="26" To="27" Label="Source1" />
<Edge From="27" To="28" Label="Source2" />
<Edge From="27" To="30" Label="Source2" />
<Edge From="28" To="31" Label="Source1" />
<Edge From="29" To="30" Label="Source1" />
<Edge From="30" To="31" Label="Source2" />
<Edge From="31" To="32" Label="Source1" />
<Edge From="28" To="29" Label="Source1" />
</Edges>
</Workflow>
</WorkflowBuilder>
8 changes: 4 additions & 4 deletions src/workflows/Extensions/LogRegisters.bonsai
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<WorkflowBuilder Version="2.8.4"
<WorkflowBuilder Version="2.8.5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp"
Expand All @@ -10,7 +10,7 @@
<Name>Behavior</Name>
</Expression>
<Expression xsi:type="rx:GroupBy">
<rx:KeySelector>MessageType,Address</rx:KeySelector>
<rx:KeySelector>Address</rx:KeySelector>
</Expression>
<Expression xsi:type="rx:SelectMany">
<Name>LogRegisters</Name>
Expand Down Expand Up @@ -44,8 +44,8 @@
<Combinator xsi:type="rx:Zip" />
</Expression>
<Expression xsi:type="Format">
<Format>{0}_Behavior_{1}{2}.bin</Format>
<Selector>Item1,Item2.Item1,Item2.Item2</Selector>
<Format>{0}_Behavior_{1}.bin</Format>
<Selector>Item1,Item2</Selector>
</Expression>
<Expression xsi:type="PropertyMapping">
<PropertyMappings>
Expand Down
Loading