Skip to content

Commit 4056f09

Browse files
authored
WIP Tutorials for np1e & np2e headstages (#50)
- Preliminary tutorials for np1e & np2e - it's a WIP but needs to go up so people have access to workflows - tutorials organized into partial templates rather than an extended markdown file so that bits and pieces can be reused for - enums templating fixed (issue #48) - Also, add references to the GUI in the template
1 parent 9912690 commit 4056f09

24 files changed

+3248
-293
lines changed

src/onix-bonsai-onix1

template/ManagedReference.extension.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function extractEnumData(model) {
1212
.filter(child => child.type === 'field')
1313
.map(child => ({
1414
'field&value': child.syntax.content[0].value,
15-
'enumDescription': [child.summary, child.remarks].join(''),
15+
'description': [child.summary, child.remarks].join(''),
1616
}));
1717
}
1818

template/ManagedReference.html.primary.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
{{!master(layout/_master.tmpl)}}
44

5+
{{#isClass}}
56
{{>partials/class}}
7+
{{/isClass}}
68

7-
{{>partials/enum}}
9+
{{#isEnum}}
10+
{{>partials/enum}}
11+
{{/isEnum}}

template/conceptual.html.primary.tmpl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{{!master(layout/_master.tmpl)}}
22

3+
{{^tut}}
34
<h1>{{title}}</h1>
5+
{{/tut}}
6+
47
{{#isGuide}}
5-
<br>
68

79
{{#workflow}}
810
{{#isDevice}}
@@ -36,4 +38,8 @@
3638
{{/visualize}}
3739
{{/isGuide}}
3840

39-
{{{conceptual}}}
41+
{{#tut}}
42+
{{>partials/tutorials/main}}
43+
{{/tut}}
44+
45+
{{{conceptual}}}

template/partials/class.tmpl.partial

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
{{#isClass}}
2-
31
{{#oe.operator.configureDevice}}
42

53
<div class="CAUTION alert alert-danger">
@@ -57,8 +55,8 @@
5755
<table>
5856

5957
<tr>
60-
<th style = "white-space: nowrap;">Property</th>
61-
<th style = "white-space: nowrap;">Type</th>
58+
<th style="white-space: nowrap;">Property</th>
59+
<th style="white-space: nowrap;">Type</th>
6260
<th>Description</th>
6361
</tr>
6462

@@ -82,8 +80,8 @@
8280
<table>
8381

8482
<tr>
85-
<th style = "white-space: nowrap;">Property</th>
86-
<th style = "white-space: nowrap;">Type</th>
83+
<th style="white-space: nowrap;">Property</th>
84+
<th style="white-space: nowrap;">Type</th>
8785
<th>Description</th>
8886
</tr>
8987

@@ -93,6 +91,4 @@
9391

9492
</table>
9593

96-
{{/oe.operator.hub}}
97-
98-
{{/isClass}}
94+
{{/oe.operator.hub}}

template/partials/enum.tmpl.partial

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
{{#isEnum}}
2-
31
<h1 class="text-break">
42
{{oe.name}}
53
{{#sourceurl}}<a class="header-action link-secondary" title="View source" href="{{sourceurl}}"><i class="bi bi-code-slash"></i></a>{{/sourceurl}}
@@ -12,13 +10,13 @@
1210
<table>
1311

1412
<tr>
15-
<th style = "white-space: no-wrap">Field & Value</th>
13+
<th style="white-space: no-wrap">Field & Value</th>
1614
<th>Description</th>
1715
</tr>
1816

1917
{{#oe.enum}}
2018
<tr>
21-
<td style = "white-space: no-wrap">
19+
<td style="white-space: no-wrap">
2220
<code>
2321
{{{field&value}}}
2422
</code>
@@ -29,6 +27,4 @@
2927
</tr>
3028
{{/oe.enum}}
3129

32-
</table>
33-
34-
{{/isEnum}}
30+
</table>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<h3> {{data}} </h3>
2+
3+
<div class="workflow">
4+
<p><img src="../workflows/examples/{{{operator}}}.bonsai" alt="{{{operator}}} Workflow"></p>
5+
</div>
6+
7+
<p>{{{graphDescription}}}</p>
8+
9+
<p>{{{operator}}} is configured as follows:</p>
10+
11+
<ul>
12+
<li><code>DeviceName</code> is set to "{{{configureOperator}}}/{{{operator}}}". This is the only selection available in the drop down menu because the configuration chain contains a single {{{hub}}}.</li>
13+
{{#bufferSize}}<li><code>BufferSize</code> is set to {{{bufferSize}}}. {{{bufferSize}}} samples will be collected from each of the probe channels into a <a class="xref" ref="api/OpenEphys.Onix1.{{{operator}}}Frame.html">{{{operator}}}Frame</a> that is propagated downstream (each frame will contain a {{{bufferSize}}}-element Clock vector and a {{{bufferSize}}}-sample {{{data}}} data vector).<!---To learn how to decide the ideal <code>BufferSize</code> value, refer to <a class="xref" href="breakoutboard-tut.html#analog-inputs">the corresponding section in the Breakout Board Tutorial</a>.---></li>{{/bufferSize}}
14+
{{#multiple}}<li><code>ProbeIndex</code> is set to "PortA". {{{operator}}} generates data from a {{{data}}} connected to the headstage's Port A.</li>{{/multiple}}
15+
{{#additionalConfiguration}}<li>{{{.}}}</li>{{/additionalConfiguration}}
16+
</ul>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<h1> {{title}} </h1>
2+
3+
{{#overview}}
4+
5+
<p>In this example, we will explore the {{{hub}}}'s functionality by demoing its capabilities. The workflow below can by copy/pasted into the Bonsai editor using the clipboard icon in the top right. This workflow:</p>
6+
7+
<ul>
8+
{{#workflowFunctions}}
9+
<li>{{{.}}}</li>
10+
{{/workflowFunctions}}
11+
</ul>
12+
13+
<div class="workflow">
14+
<p><img src="../workflows/examples/{{{hubSnakeCase}}}.bonsai" alt="{{{hub}}} Workflow"></p>
15+
</div>
16+
17+
<div class="TIP alert alert-info">
18+
<h5>TIP</h5>
19+
<p>If you want a less busy starting point for using the {{{hub}}} then have a look at the <a class="xref" href="../articles/hubs/{{{hubSnakeCase}}}.html">{{{operator}}}</a> in the user guide.</p>
20+
</div>
21+
22+
{{/overview}}
23+
24+
{{#configure}}
25+
26+
<h2> Configuring the {{{hub}}} </h2>
27+
28+
<p>We start by configuring the hardware using a configuration chain. This chain creates a hardware context using <a class="xref" href="../api/OpenEphys.Onix1.CreateContext.html">CreateContext</a>, adds a {{{hub}}} configuration using <a class="xref" href="../api/OpenEphys.Onix1.Configure{{{configureOperator}}}.html">{{{configureOperator}}}</a>, and then starts acquisition using <a class="xref" href="../api/OpenEphys.Onix1.StartAcquisition.html">StartAcquisition</a>. Here we break down each of these operators.</p>
29+
30+
<div class="workflow">
31+
<p><img src="../workflows/examples/{{{configureOperator}}}.bonsai" alt="{{{configureOperator}}} Workflow"></p>
32+
</div>
33+
34+
<h3> CreateContext </h3>
35+
36+
<p>The <a class="xref" href="../api/OpenEphys.Onix1.CreateContext.html">CreateContext</a> operator determines the device driver and host-computer index that the system communicates through. The <code>Driver</code> property is set to "riffa", which is the name of the the PCIe device used by ONIX. In our case, because we are using a single ONIX system, the the <code>Index</code> property is set to 0. If second system was used on the same computer, a second <a class="xref" href="../api/OpenEphys.Onix1.CreateContext.html">CreateContext</a> operator would be required and its <code>Index</code> property set to 1.</p>
37+
38+
<h3> {{{configureOperator}}} </h3>
39+
40+
<p>The <a class="xref" href="../api/OpenEphys.Onix1.Configure{{{configureOperator}}}.html">{{{configureOperator}}}</a> operator is used to configure the {{hub}}. Configuration settings for the {{hub}} can be examined and edited by clicking on the operator to open its property pane to the right of the editor. Expanding the members of the property pane allows you to configure each of the devices contained by the {{hub}}.
41+
{{#gui}}This {{hub}} has a configuration GUI that can be accessed by following the <a class="xref" href="./{{hubSnakeCase}}-gui-tut.html">{{hub}} GUI Tutorial</a>.{{/gui}}
42+
{{^nonDefaultProperties}}In this demo, the {{hub}} properties are set to their default values.{{/nonDefaultProperties}}
43+
{{#nonDefaultProperties}}In this demo, the {{hub}} properties are set to their default values, except:{{/nonDefaultProperties}}</p>
44+
45+
<ul>
46+
{{#nonDefaultProperties}}<li>{{{.}}}</li>{{/nonDefaultProperties}}
47+
</ul>
48+
49+
<p>Aside from the configuration operations, the output of the <a class="xref" href="../api/OpenEphys.Onix1.Configure{{{configureOperator}}}.html">{{{configureOperator}}}</a> operator is timestamped and then saved to a CSV file. This file will contain the wall-clock time that data collection start along with metadata concerning important system configuration settings.</p>
50+
51+
<h3> StartAcquisition </h3>
52+
53+
<p>The <a class="xref" href="../api/OpenEphys.Onix1.StartAcquisition.html">StartAcquisition</a> operator begins acquisition after the hardware has been configured. In this example, we are going to be capturing data from the {{{hub}}}. <!---To learn how to decide the ideal <code>ReadBlockSize</code> value, refer to <a class="xref" href="breakoutboard-tut.html#startacquisition">the corresponding section in the Breakout Board Tutorial</a>---><!---<a class="xref">Setting ReadBlockSize Tutorial</a>--->.</p>
54+
55+
{{/configure}}
56+
57+
<h2> Streaming data </h2>
58+
59+
<p>The rest of the workflow concerns capturing data to and from the {{{hub}}}, using a set of discrete "processing graphs" that either produce data from hardware (inputs/sources) or accept data produced by software (outputs/sinks). We describe these graphs in the following sections.</p>
60+
61+
<div class="TIP alert alert-info">
62+
<h5>TIP</h5>
63+
<p>When trying to understand a workflow's operation, its very useful to visualize the data that being generated by each operator. You can open an operator's visualizer by double clicking the node while the workflow is running. The type of visualizer that opens will depend on the type of data handled by the operator and whether or not the appropriate Design library has been installed.</p>
64+
</div>
65+
66+
{{#dataIOOperators}}{{>partials/tutorials/device}}{{/dataIOOperators}}
67+
68+
<!---
69+
<h2>Loading data</h2>
70+
<p>The following python script can be used to load and plot the data produced by the workflow described in this tutorial.</p>
71+
72+
[!code-python[](../workflows/examples/load-breakoutboard.py)]
73+
74+
<div class="NOTE alert alert-info">
75+
<h5>NOTE</h5>
76+
<p>This script will attempt to load entire files into arrays. For long recordings, data will need to be split into more manageable chunks by:</p>
77+
<ul>
78+
<li>Modifying this script to partially load files</li>
79+
<li>Modifying the workflow to cyclically creating new files after a certain duration</li>
80+
</ul>
81+
</div>
82+
--->
83+
84+

tutorials/headstage64-tut.md

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
1-
# Headstage 64 Tutorial
1+
---
2+
uid: hs64-tut
3+
title: Headstage64 Tutorial
4+
tut: true
5+
hub: Headstage64
6+
hubSnakeCase: headstage64
7+
configureOperator: Headstage64
8+
overview:
9+
workflowFunctions:
10+
- Configures the Headstage64.
11+
- Streams RHD2164, BNO055, and TS4231 data.
12+
- Triggers electrical and optical stimulation.
13+
---
214

3-
:::workflow
4-
![Headstage64](../workflows/examples/Headstage64.bonsai)
5-
:::
15+
> [!NOTE]
16+
> This page is a WIP
17+
18+
<!-- configure:
19+
nonDefaultProperties:
20+
dataIOOperators:
21+
- operator: PortStatus
22+
data: Port Status
23+
graphDescription: This processing graph generates data about the communication status between the headstage/miniscope and the ONIX data acquisition system, timestamps it, and writes it to a .csv file.
24+
- operator: Rhd2164Data
25+
data: RHD2164
26+
graphDescription: This processing graph generates data from the headstage's Rhd2164Data,
27+
bufferSize: 36
28+
- operator: Bno055Data
29+
data: BNO055
30+
graphDescription: This processing graph generates data from the headstage's BNO055, writes it to a .csv file, and selects <code>Quaternion</code> data to send to an operator that automatically commutates the tether if there is a proper commutator connection.
31+
- operator: Ts4231PositionData
32+
data: TS4231 Position
33+
graphDescription: This processing graph generates position data from the headstage's TS4231 data.
34+
additionalConfiguration:
35+
- <code>P</code> is set to (0, 0, 0)
36+
- <code>Q</code> is set to (1, 0, 0)
37+
- operator: Ts4231Data
38+
data: TS4231
39+
graphDescription: This processing graph data from the headstage's TS4231 data. -->

tutorials/neuropixelsv1e-tut.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
1-
# NeuropixelsV1e Tutorial
1+
---
2+
uid: np1e-tut
3+
title: NeuropixelsV1e Headstage Tutorial
4+
tut: true
5+
hub: NeuropixelsV1e Headstage
6+
hubSnakeCase: neuropixelsv1e
7+
configureOperator: NeuropixelsV1eHeadstage
8+
overview:
9+
workflowFunctions:
10+
- Configures the NeuropixelsV1e Headstage.
11+
- Streams Neuropixels 1.0 and BNO055 data.
12+
- Commutates the tether automatically if there is a proper commutator connection.
13+
configure:
14+
gui: false
15+
nonDefaultProperties:
16+
dataIOOperators:
17+
- operator: PortStatus
18+
data: Port Status
19+
graphDescription: This processing graph generates data about the communication status between the headstage and the ONIX data acquisition system, timestamps it, and writes it to a .csv file.
20+
- operator: NeuropixelsV1eData
21+
data: Neuropixels 1.0
22+
graphDescription: This processing graph generates data from one of the headstage's Neuropixels 2.0 probes, and selects the <code>Clock</code> and <code>AmplifierData</code> data to write to .bin files.
23+
multiple: false
24+
bufferSize: 36
25+
- operator: NeuropixelsV1eBno055Data
26+
data: BNO055
27+
graphDescription: This processing graph generates data from the headstage's BNO055, writes it to a .csv file, and selects <code>Quaternion</code> data to send to a node that commutates the tether automatically if there is a proper commutator connection. Because <code>CsvWriter</code> is a <code>Sink</code> operator, it emits the same item downstream as it receives from upstream. Therefore, Bno55DataFrame members can by selected by hovering over <code>Output</code> in the context menu that appears by right-clicking the <code>CsvWriter</code> node.
28+
---
29+
<!---
30+
[!code-python[](../workflows/examples/load-np1.py)]
231
3-
:::workflow
4-
![NeuropixelsV1e](../workflows/examples/NeuropixelsV1e.bonsai)
5-
:::
32+
> [!NOTE]
33+
> This script will attempt to load entire files into arrays. For long recordings, data will need to be split into more manageable chunks by:
34+
> - Modifying this script to partially load files
35+
> - Modifying the workflow to cyclically creating new files after a certain duration
36+
--->

0 commit comments

Comments
 (0)