Skip to content

Commit

Permalink
Merge pull request #20 from fchampalimaud/JG_harp_examples_completion
Browse files Browse the repository at this point in the history
PlaySound and ToggleMultipleSteps schematics added + some more minor changes
  • Loading branch information
hgmarques authored Jan 6, 2025
2 parents a4d1c66 + 4ef5da6 commit 8ce5515
Show file tree
Hide file tree
Showing 15 changed files with 779 additions and 26 deletions.
10 changes: 8 additions & 2 deletions .bonsai/Bonsai.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<Package id="Bonsai.Dsp.Design" version="2.8.0" />
<Package id="Bonsai.Editor" version="2.8.1" />
<Package id="Bonsai.FFmpeg" version="0.1.0" />
<Package id="Bonsai.Gui" version="0.1.0" />
<Package id="Bonsai.Gui.ZedGraph" version="0.1.0" />
<Package id="Bonsai.Harp" version="3.5.2" />
<Package id="Bonsai.Harp.CF" version="1.7.0-preview3" />
<Package id="Bonsai.Harp.Design" version="3.5.0" />
Expand All @@ -31,7 +33,7 @@
<Package id="Bonsai.Video" version="2.4.0" />
<Package id="Bonsai.Video.Design" version="2.4.0" />
<Package id="Bonsai.Vision" version="2.8.1" />
<Package id="Bonsai.Vision.Design" version="2.5.1" />
<Package id="Bonsai.Vision.Design" version="2.8.1" />
<Package id="Bonsai.Windows.Input" version="2.7.0" />
<Package id="Bonsai.ZeroMQ" version="0.2.0" />
<Package id="BonZeb" version="1.0.0" />
Expand Down Expand Up @@ -85,6 +87,8 @@
<AssemblyReference assemblyName="Bonsai.Dsp.Design" />
<AssemblyReference assemblyName="Bonsai.Editor" />
<AssemblyReference assemblyName="Bonsai.FFmpeg" />
<AssemblyReference assemblyName="Bonsai.Gui" />
<AssemblyReference assemblyName="Bonsai.Gui.ZedGraph" />
<AssemblyReference assemblyName="Bonsai.Harp" />
<AssemblyReference assemblyName="Bonsai.Harp.CF" />
<AssemblyReference assemblyName="Bonsai.Harp.Design" />
Expand Down Expand Up @@ -136,6 +140,8 @@
<AssemblyLocation assemblyName="Bonsai.Dsp.Design" processorArchitecture="MSIL" location="Packages\Bonsai.Dsp.Design.2.8.0\lib\net462\Bonsai.Dsp.Design.dll" />
<AssemblyLocation assemblyName="Bonsai.Editor" processorArchitecture="MSIL" location="Packages\Bonsai.Editor.2.8.1\lib\net472\Bonsai.Editor.dll" />
<AssemblyLocation assemblyName="Bonsai.FFmpeg" processorArchitecture="MSIL" location="Packages\Bonsai.FFmpeg.0.1.0\lib\net462\Bonsai.FFmpeg.dll" />
<AssemblyLocation assemblyName="Bonsai.Gui" processorArchitecture="MSIL" location="Packages\Bonsai.Gui.0.1.0\lib\net472\Bonsai.Gui.dll" />
<AssemblyLocation assemblyName="Bonsai.Gui.ZedGraph" processorArchitecture="MSIL" location="Packages\Bonsai.Gui.ZedGraph.0.1.0\lib\net472\Bonsai.Gui.ZedGraph.dll" />
<AssemblyLocation assemblyName="Bonsai.Harp" processorArchitecture="MSIL" location="Packages\Bonsai.Harp.3.5.2\lib\net462\Bonsai.Harp.dll" />
<AssemblyLocation assemblyName="Bonsai.Harp.CF" processorArchitecture="MSIL" location="Packages\Bonsai.Harp.CF.1.7.0-preview3\lib\net472\Bonsai.Harp.CF.dll" />
<AssemblyLocation assemblyName="Bonsai.Harp.Design" processorArchitecture="MSIL" location="Packages\Bonsai.Harp.Design.3.5.0\lib\net462\Bonsai.Harp.Design.dll" />
Expand All @@ -152,7 +158,7 @@
<AssemblyLocation assemblyName="Bonsai.Video" processorArchitecture="MSIL" location="Packages\Bonsai.Video.2.4.0\lib\net462\Bonsai.Video.dll" />
<AssemblyLocation assemblyName="Bonsai.Video.Design" processorArchitecture="MSIL" location="Packages\Bonsai.Video.Design.2.4.0\lib\net462\Bonsai.Video.Design.dll" />
<AssemblyLocation assemblyName="Bonsai.Vision" processorArchitecture="MSIL" location="Packages\Bonsai.Vision.2.8.1\lib\net462\Bonsai.Vision.dll" />
<AssemblyLocation assemblyName="Bonsai.Vision.Design" processorArchitecture="MSIL" location="Packages\Bonsai.Vision.Design.2.5.1\lib\net462\Bonsai.Vision.Design.dll" />
<AssemblyLocation assemblyName="Bonsai.Vision.Design" processorArchitecture="MSIL" location="Packages\Bonsai.Vision.Design.2.8.1\lib\net462\Bonsai.Vision.Design.dll" />
<AssemblyLocation assemblyName="Bonsai.Windows.Input" processorArchitecture="MSIL" location="Packages\Bonsai.Windows.Input.2.7.0\lib\net462\Bonsai.Windows.Input.dll" />
<AssemblyLocation assemblyName="Bonsai.ZeroMQ" processorArchitecture="MSIL" location="Packages\Bonsai.ZeroMQ.0.2.0\lib\net472\Bonsai.ZeroMQ.dll" />
<AssemblyLocation assemblyName="BonZeb" processorArchitecture="MSIL" location="Packages\BonZeb.1.0.0\lib\net472\BonZeb.dll" />
Expand Down
29 changes: 17 additions & 12 deletions docs/articles/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
href: install_bonsai.md
- name: Install Harp
href: install_harp.md
- name: Bonsai/Harp Examples (16)
- name: Bonsai/Harp Examples (18)
items:
- name: Behavior Board (12)
items:
Expand Down Expand Up @@ -38,26 +38,30 @@
# href: ../workflows/HarpExamples/BehaviorBoard/NosePokeDetection/NosePokeDetection.md
# - name: Nose Poke LED Toggle
# href: ../workflows/HarpExamples/BehaviorBoard/NosePokeLEDToggle/NosePokeLEDToggle.md
# - name: Sound Card (2)
# items:
# - name: Play Sound
# href: ../workflows/HarpExamples/SoundCard/PlaySound/PlaySound.md
# - name: Sound Hardware Trigger
# href: ../workflows/HarpExamples/SoundCard/SoundHardwareTrigger/SoundHardwareTrigger.md
- name: Sound Card (1)
items:
- name: Play Sound
href: ../workflows/HarpExamples/SoundCard/PlaySound/PlaySound.md
# - name: Sound Hardware Trigger
# href: ../workflows/HarpExamples/SoundCard/SoundHardwareTrigger/SoundHardwareTrigger.md
- name: Olfactometer (2)
items:
- name: End Valve Toggle
href: ../workflows/HarpExamples/Olfactometer/EndValveToggle/EndValveToggle.md
- name: Odor Valve Toggle
href: ../workflows/HarpExamples/Olfactometer/OdorValveToggle/OdorValveToggle.md
- name: Syringe Pump (1)
- name: Syringe Pump (2)
items:
# - name: Toggle Single Steps
# href: ../workflows/HarpExamples/SyringePump/ToggleSingleSteps/ToggleSingleSteps.md
# - name: Toggle Multiple Steps
# - name: Toggle Micro Steps
# href: ../workflows/HarpExamples/SyringePump/ToggleMicroSteps/ToggleMicroSteps.md
- name: Toggle Multiple Steps
href: ../workflows/HarpExamples/SyringePump/ToggleMultipleSteps/ToggleMultipleSteps.md
- name: Create and Execute Protocol
href: ../workflows/HarpExamples/SyringePump/CreateAndExecuteProtocol/CreateAndExecuteProtocol.md
# - name: Calibration Protocol
# href: ../workflows/HarpExamples/SyringePump/CalibrationProtocol/CalibrationProtocol.md
- name: Feeder (1)
items:
- name: Reward Delivery
Expand Down Expand Up @@ -183,19 +187,20 @@
href: ../workflows\BonsaiExamples/DataTypes/ArrayManipulation/ArrayManipulation.md
- name: Streams to Mat
href: ../workflows\BonsaiExamples/DataTypes/StreamsToMat/StreamsToMat.md

# - name: DAQmx (2)
# items:
# - name: Digital Inputs (Non-Buffered)
# href: ../workflows/BonsaiExamples/DAQmx/DigitalInputsNonBuffered/DigitalInputsNonBuffered.md
# - name: AI/AO Synchronization
# href: ../workflows/BonsaiExamples/DAQmx/AIAOSynchronization/AIAOSynchronization.md
- name: GUI (2)
- name: GUI (3)
items:
- name: ImageThresholdSlider
href: ../workflows/BonsaiExamples/GUI/ImageThresholdSlider/ImageThresholdSlider.md
- name: StartCameraSubPanel
href: ../workflows\BonsaiExamples/GUI/ImageThresholdSlider/ImageThresholdSlider.md
href: ../workflows\BonsaiExamples/GUI/StartCameraSubPanel/StartCameraSubPanel.md
- name: LineGraph
href: ../workflows\BonsaiExamples/GUI/LineGraph/LineGraph.md

# - name: Neuroscience Tasks (1)
# items:
Expand Down
114 changes: 114 additions & 0 deletions docs/workflows/BonsaiExamples/GUI/LineGraph/LineGraph.bonsai
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<WorkflowBuilder Version="2.8.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
xmlns:num="clr-namespace:Bonsai.Numerics;assembly=Bonsai.Numerics"
xmlns:cv="clr-namespace:Bonsai.Vision;assembly=Bonsai.Vision"
xmlns:zg="clr-namespace:Bonsai.Gui.ZedGraph;assembly=Bonsai.Gui.ZedGraph"
xmlns:viz="clr-namespace:Bonsai.Design.Visualizers;assembly=Bonsai.Design.Visualizers"
xmlns="https://bonsai-rx.org/2018/workflow">
<Workflow>
<Nodes>
<Expression xsi:type="Annotation">
<Name>1</Name>
<Text><![CDATA[]]></Text>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Timer">
<rx:DueTime>PT0S</rx:DueTime>
<rx:Period>PT1S</rx:Period>
</Combinator>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="num:Sin" />
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="num:Cos" />
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Zip" />
</Expression>
<Expression xsi:type="Annotation">
<Name>2</Name>
<Text><![CDATA[]]></Text>
</Expression>
<Expression xsi:type="InputMapping">
<PropertyMappings>
<Property Name="X" Selector="Item1" />
<Property Name="Y" Selector="Item2" />
</PropertyMappings>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="cv:CreatePoint2d">
<cv:X>0.79691841536989361</cv:X>
<cv:Y>0.12436683761159277</cv:Y>
</Combinator>
</Expression>
<Expression xsi:type="Annotation">
<Name>3</Name>
<Text><![CDATA[]]></Text>
</Expression>
<Expression xsi:type="zg:LineGraphBuilder">
<zg:SymbolType>None</zg:SymbolType>
<zg:LineWidth>3</zg:LineWidth>
<zg:CurveSettings>
<zg:CurveConfiguration>
<zg:Color>Turquoise</zg:Color>
</zg:CurveConfiguration>
</zg:CurveSettings>
<zg:Capacity xsi:nil="true" />
<zg:XMin xsi:nil="true" />
<zg:XMax xsi:nil="true" />
<zg:YMin xsi:nil="true" />
<zg:YMax xsi:nil="true" />
</Expression>
<Expression xsi:type="VisualizerMapping" />
<Expression xsi:type="Annotation">
<Name>4</Name>
<Text><![CDATA[]]></Text>
</Expression>
<Expression xsi:type="zg:GraphPanelBuilder">
<zg:ReverseX>false</zg:ReverseX>
<zg:ReverseY>false</zg:ReverseY>
<zg:Span xsi:nil="true" />
<zg:Capacity xsi:nil="true" />
<zg:XMin xsi:nil="true" />
<zg:XMax xsi:nil="true" />
<zg:YMin xsi:nil="true" />
<zg:YMax xsi:nil="true" />
</Expression>
<Expression xsi:type="VisualizerMapping" />
<Expression xsi:type="Annotation">
<Name>5</Name>
<Text><![CDATA[]]></Text>
</Expression>
<Expression xsi:type="viz:TableLayoutPanelBuilder">
<viz:ColumnCount>1</viz:ColumnCount>
<viz:RowCount>1</viz:RowCount>
<viz:ColumnStyles />
<viz:RowStyles />
<viz:CellSpans />
</Expression>
<Expression xsi:type="WorkflowOutput" />
</Nodes>
<Edges>
<Edge From="0" To="1" Label="Source1" />
<Edge From="1" To="2" Label="Source1" />
<Edge From="1" To="3" Label="Source1" />
<Edge From="2" To="4" Label="Source1" />
<Edge From="3" To="4" Label="Source2" />
<Edge From="4" To="6" Label="Source1" />
<Edge From="5" To="6" Label="Source2" />
<Edge From="6" To="7" Label="Source1" />
<Edge From="7" To="9" Label="Source1" />
<Edge From="8" To="9" Label="Source2" />
<Edge From="9" To="10" Label="Source1" />
<Edge From="10" To="12" Label="Source1" />
<Edge From="11" To="12" Label="Source2" />
<Edge From="12" To="13" Label="Source1" />
<Edge From="13" To="15" Label="Source1" />
<Edge From="14" To="15" Label="Source2" />
<Edge From="15" To="16" Label="Source1" />
</Edges>
</Workflow>
</WorkflowBuilder>
24 changes: 24 additions & 0 deletions docs/workflows/BonsaiExamples/GUI/LineGraph/LineGraph.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# LineGraph

## Summary
This example demonstrates how to use the LineGraph GUI element to display real-time random data.

## Workflow
:::workflow
![Example](~/workflows//BonsaiExamples/GUI/LineGraph/LineGraph.bonsai)
:::

## Details
1. Each second both the sine and cosine are calculated and zipped.
2. The sine and cosine are mapped into the X and Y coordinates of a Point2d object. This is the object that must be input in the LineGraph.
3. The LineGraph node responsible for the real-time visualizations.
4. The LineGraph is mapped into a GraphPanel so that the settings from the LineGraph node are applied.
5. Finally, the GraphPanel is mapped into a TableLayoutPanel.

## Requirements
You need to install the Bonsai.Gui package available in the nuget.org package source.
You need to install the following packages:
- Bonsai - GUI (from nuget.org)
- Bonsai - GUI ZedGraph (from nuget.org)
- Bonsai - Vision Library (from Bonsai Packages)
- Bonsai - Numerics Library (from Bonsai Packages)
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ This example requires the following Bonsai packages:
All the messages to and from the [Harp Behavior](https://harp-tech.org/api/Harp.Behavior.html) can be logged. In this example, only data relative setting and clearing of digital output ports is logged.

![Schematics](./LogSelectedSch.svg){ width=65% }

## CSV Conversion
It's often desirable to convert the binary files that come out of the MessageWriter node into a human readable file. One way to do this is to convert them into CSV files through the [Harp Convert To CSV](https://github.com/harp-tech/csv_converter) GUI.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Nose Poke Detection

## Summary
This example demonstrates how to control the brightness of a LED using the current driven ports in the [Harp Behavior](https://harp-tech.org/api/Harp.Behavior.html) board (see hardware schematics below).
This example demonstrates how to detect a rodent nose poke using the [Mice Poke](https://github.com/harp-tech/peripheral.micepoke) peripheral for the [Harp Behavior](https://harp-tech.org/api/Harp.Behavior.html) board (see hardware schematics below).

## Workflow
:::workflow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Nose Poke LED Toggle

## Summary
This example demonstrates how to control the brightness of a LED using the current driven ports in the [Harp Behavior](https://harp-tech.org/api/Harp.Behavior.html) board (see hardware schematics below).
This example demonstrates how to toggle the built-in LED from the [Mice Poke](https://github.com/harp-tech/peripheral.micepoke) peripheral for the [Harp Behavior](https://harp-tech.org/api/Harp.Behavior.html) board (see hardware schematics below).

## Workflow
:::workflow
Expand Down
20 changes: 16 additions & 4 deletions docs/workflows/HarpExamples/SoundCard/PlaySound/PlaySound.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,30 @@ This example demonstrates how to play a .wav file using the [Harp SoundCard](htt
:::

## Details
The Harp SoundCard board allows the user to upload wav files using its graphical user interface (see details here????). Each file is linked to an index (0-31), which can be played by the sound card.
The Harp SoundCard board allows the user to upload wav files using its graphical user interface (see details [here](#uploading-sounds-to-the-harp-soundcard)). Each file is linked to an index (2-31), which can be played by the sound card.
1. Establishes the commands to be sent to the SoundCard board. The PortName property in the Behavior node needs to be set to the COM device on the computer. To create the subject node, right-click on the SoundCard node -> Create Source -> Behavior Subject, and name it accordingly.
2. Plays the sound stored at index 4, when 'A' is pressed. \*
3. Plays the sound stored at index 5, when 'S' is pressed. \*\*
4. Ensures that command messages are sent only when the device is ready.

\* The example file loaded in index 4 can be found here
\* The example file loaded in index 4 can be found here \
\*\* The example file loaded in index 5 can be found here

## Requirements
Install Harp SoundCard (https://harp-tech.org/api/Harp.SoundCard.html)

This example requires the following Bonsai packages:
- Harp - SoundCard (from nuget.org)

Additionally, install the [Harp SoundCard](https://github.com/harp-tech/device.soundcard) GUI in order to upload sounds to the SoundCard.

## Schematics
The [Harp SoundCard](https://harp-tech.org/api/Harp.SoundCard.html) board has 2 RCA ports (one for the left channel and the other for the right one) which allow the device to connect to a [Harp Audio Amplifier](https://github.com/harp-tech/peripheral.audioamp) on each side which, in turn, connect to a speaker.

![Schematics](./PlaySoundSch.svg){ width=65% }

## Uploading sounds to the Harp SoundCard
1. Install the [Harp SoundCard](https://github.com/harp-tech/device.soundcard) GUI.
2. Open the GUI. Then click on `Launch`.
3. It is possible to generate pure tones and white noises or to load sounds from .wav or binary files. Either way, after tweaking with the configurations according to one's needs, click on the correct `Generate` button (for a sound loaded from a .wav - or binary - file, the button is names `Load and Generate`). The sound will be plotted in the figure at the bottom of the GUI.
4. In the `Interface with the Sound Card` frame of the GUI, select the index (between 2 and 31) where the sound will be uploaded to in the device's memory. Then click on `Create files and send to device`.
5. _Optional:_ To play the sound, select the device's COM port and sound index in the bottom right corner of the GUI (above the plot) and hit the `Play` button.
6. _Mandatory:_ Party as hell to your recently uploaded sound! :D
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Play Sound

## Summary
This example demonstrates how to play a .wav file using the [Harp SoundCard](https://harp-tech.org/api/Harp.SoundCard.html) board (see hardware schematics below).
This example demonstrates how to play a .wav file using the [Harp SoundCard](https://harp-tech.org/api/Harp.SoundCard.html) board from an external trigger given by the [Harp Behavior](https://harp-tech.org/api/Harp.Behavior.html) (see hardware schematics below).

## Workflow
:::workflow
Expand All @@ -18,14 +18,12 @@ The Harp SoundCard board allows the user to upload wav files using its graphical
\* The example file loaded in index 4 can be found here
\*\* The example file loaded in index 5 can be found here



## Requirements
Install Harp SoundCard (https://harp-tech.org/api/Harp.SoundCard.html)

This example requires the following Bonsai packages:
- Harp - SoundCard (from nuget.org)

Additionally, install the [Harp SoundCard](https://github.com/harp-tech/device.soundcard) GUI in order to upload sounds to the SoundCard.

## Schematics
The [Harp Sound Card](https://harp-tech.org/api/Harp.SoundCard.html)

Expand Down
Loading

0 comments on commit 8ce5515

Please sign in to comment.