Skip to content
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

Add workflow containers to "Ephys Synchronization" tutorial #133

Open
wants to merge 1 commit 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
12 changes: 12 additions & 0 deletions tutorials/synching-ephys.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ The general approach when synchronizing two independent data acquisition clocks

### **Exercise 1:** Synchronizing behaviour events with ephys

:::workflow
![Syncing ephys with behavior](~/workflows/syncing-ephys-behavior.bonsai)
:::

- Insert a `KeyDown` source.
- Insert an `Equal` transform and set its `Value` to one of the keys. The output of this operator will toggle between `True` and `False` depending on whether the key press matches the specified key.
- Insert a `DigitalOutput` sink and connect it to Arduino pin 13.
Expand All @@ -22,6 +26,10 @@ The general approach when synchronizing two independent data acquisition clocks

### **Exercise 2:** Synchronizing video with ephys using an LED

:::workflow
![Syncing ephys with video](~/workflows/syncing-ephys-video.bonsai)
:::

- Using the workflow from the previous exercise, insert a `CameraCapture` source and point the camera such that you can see clearly both the LED and the computer keyboard.
- Insert a `VideoWriter` sink and configure the `FileName` with a path ending in `.avi`.
- Insert a `Crop` transform and set the `RegionOfInterest` property to a small area around the LED.
Expand Down Expand Up @@ -53,6 +61,10 @@ However, you can take advantage of the fact that all pixels in a frame are prese

In this exercise you will track the display of a very simple visual stimulus: a transition between black and white.

:::workflow
![Syncing ephys with visual stimulus](~/workflows/syncing-ephys-visual.bonsai)
:::

- Insert a `SolidColor` source and set its `Size` property to a positive value, e.g. 100,100.
- Insert a `Timer` source and set the `Period` to one second.
- Insert a `Mod` transform and set its `Value` property to 2.
Expand Down
79 changes: 79 additions & 0 deletions workflows/syncing-ephys-behavior.bonsai
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<WorkflowBuilder Version="2.8.5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ard="clr-namespace:Bonsai.Arduino;assembly=Bonsai.Arduino"
xmlns:wie="clr-namespace:Bonsai.Windows.Input;assembly=Bonsai.Windows.Input"
xmlns:p1="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
xmlns:eph="clr-namespace:Bonsai.Ephys;assembly=Bonsai.Ephys"
xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp"
xmlns="https://bonsai-rx.org/2018/workflow">
<Workflow>
<Nodes>
<Expression xsi:type="Combinator">
<Combinator xsi:type="ard:CreateArduino">
<ard:Name>Arduino</ard:Name>
<ard:PortName>COM1</ard:PortName>
<ard:BaudRate>57600</ard:BaudRate>
<ard:SamplingInterval>19</ard:SamplingInterval>
</Combinator>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="wie:KeyDown">
<wie:Filter>Space</wie:Filter>
<wie:SuppressRepetitions>false</wie:SuppressRepetitions>
</Combinator>
</Expression>
<Expression xsi:type="Equal">
<Operand xsi:type="WorkflowProperty" TypeArguments="p1:Keys">
<Value>Space</Value>
</Operand>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="ard:DigitalOutput">
<ard:PortName>Arduino</ard:PortName>
<ard:Pin>13</ard:Pin>
</Combinator>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="eph:Rhd2000EvalBoard">
<eph:BitFileName>main.bit</eph:BitFileName>
<eph:SampleRate>SampleRate20000Hz</eph:SampleRate>
<eph:ExternalFastSettleEnabled>false</eph:ExternalFastSettleEnabled>
<eph:LowerBandwidth>0.1</eph:LowerBandwidth>
<eph:UpperBandwidth>7500</eph:UpperBandwidth>
<eph:DspCutoffFrequency>1</eph:DspCutoffFrequency>
<eph:DspEnabled>true</eph:DspEnabled>
<eph:CableDelayA xsi:nil="true" />
<eph:CableDelayB xsi:nil="true" />
<eph:CableDelayC xsi:nil="true" />
<eph:CableDelayD xsi:nil="true" />
</Combinator>
</Expression>
<Expression xsi:type="MemberSelector">
<Selector>BoardAdcData</Selector>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="dsp:SelectChannels">
<dsp:Channels>
<dsp:int>0</dsp:int>
</dsp:Channels>
</Combinator>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="dsp:MatrixWriter">
<dsp:Path>test.bin</dsp:Path>
<dsp:Suffix>None</dsp:Suffix>
<dsp:Overwrite>false</dsp:Overwrite>
<dsp:Layout>ColumnMajor</dsp:Layout>
</Combinator>
</Expression>
</Nodes>
<Edges>
<Edge From="1" To="2" Label="Source1" />
<Edge From="2" To="3" Label="Source1" />
<Edge From="4" To="5" Label="Source1" />
<Edge From="5" To="6" Label="Source1" />
<Edge From="6" To="7" Label="Source1" />
</Edges>
</Workflow>
</WorkflowBuilder>
Loading