Skip to content

Commit eeb6631

Browse files
authored
Refactor Trigger operator to more clearly reflect SpikeGLX API (#9)
* Rename and refactor trigger operator Using the same function name makes identification easier. The arguments are also exposed as properties for improved readability. * Rename operator in documentation * Group command server properties * Allow TriggerGT to operate with no input sequences * Reorder attribute declarations
1 parent de96b33 commit eeb6631

File tree

11 files changed

+195
-247
lines changed

11 files changed

+195
-247
lines changed

docs/apidoc/Bonsai_SpikeGLX_Trigger.md

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
uid: Bonsai.SpikeGLX.TriggerGT
3+
---
4+
5+
> [!WARNING]
6+
> [`TriggerGT`](xref:Bonsai.SpikeGLX.TriggerGT) works only with SpikeGLX runs configured to use **remote controlled start and stop** triggering.
7+
[!include[TriggerGT](~/articles/spikeglx-triggerGT.md)]

docs/articles/getting-started.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ It is designed to supplement the core functionalities of SpikeGLX (*i.e.*, visua
66
`Bonsai.SpikeGLX` provides three ways of interacting with an ongoing SpikeGLX run:
77
- streaming data from SpikeGLX into Bonsai with [`Fetch`];
88
- controlling SpikeGLX digital output lines with [`DigitalOutput`]; and
9-
- starting and stopping recordings with [`Trigger`].
9+
- starting and stopping recordings with [`TriggerGT`].
1010

1111
A brief summary of the functionality of each of these operators is provided here. A more detailed description of each may be found on the associated Reference page.
1212

@@ -20,18 +20,18 @@ A brief summary of the functionality of each of these operators is provided here
2020
[!include[DigitalOutput](~/articles/spikeglx-digitaloutput.md)]
2121

2222
## Save Data
23-
SpikeGLX is expressly designed for saving Neuropixels data. As a result, it is recommended to use SpikeGLX's built-in capabilities to save your data; however, `Bonsai.SpikeGLX` provides ways to control which parts of a run SpikeGLX should save. If a SpikeGLX run is configured to use "remote controlled start and stop" triggering, [`Trigger`] may be used to set gate and trigger values.
23+
SpikeGLX is expressly designed for saving Neuropixels data. As a result, it is recommended to use SpikeGLX's built-in capabilities to save your data; however, `Bonsai.SpikeGLX` provides ways to control which parts of a run SpikeGLX should save. If a SpikeGLX run is configured to use "remote controlled start and stop" triggering, [`TriggerGT`] may be used to set gate and trigger values.
2424

25-
[!include[Trigger](~/articles/spikeglx-trigger.md)]
25+
[!include[TriggerGT](~/articles/spikeglx-triggerGT.md)]
2626

2727
> [!NOTE]
28-
> SpikeGLX also provides the ability to trigger recordings using a TTL line. In some cases, this may be preferred over using [`Trigger`].
28+
> SpikeGLX also provides the ability to trigger recordings using a TTL line. In some cases, this may be preferred over using [`TriggerGT`].
2929
3030
If you do wish to save data you have streamed into Bonsai using [`Fetch`], you can use the [`MatrixWriter`] operator from the `Bonsai.Dsp` package.
3131

3232
<!--Reference Style Links -->
3333
[`Fetch`]: xref:Bonsai.SpikeGLX.Fetch
3434
[`DigitalOutput`]: xref:Bonsai.SpikeGLX.DigitalOutput
35-
[`Trigger`]: xref:Bonsai.SpikeGLX.Trigger
35+
[`TriggerGT`]: xref:Bonsai.SpikeGLX.TriggerGT
3636
[`Timer`]: xref:Bonsai.Reactive.Timer
3737
[`MatrixWriter`]: xref:Bonsai.Dsp.MatrixWriter

docs/articles/spikeglx-trigger.md

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
uid: spikeglx-trigger
3+
title: TriggerGT
4+
---
5+
6+
For example, the below workflow starts a new gate immediately, and then toggles the trigger every five seconds. This results in SpikeGLX saving five-second periods of the run every ten seconds.
7+
8+
:::workflow
9+
![TriggerGT](../workflows/GettingStarted-TriggerGT.bonsai)
10+
:::
11+
12+
<!--Reference Style Links -->
13+
[`TriggerGT`]: xref:Bonsai.SpikeGLX.TriggerGT

docs/workflows/GettingStarted-Trigger.bonsai

Lines changed: 0 additions & 158 deletions
This file was deleted.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<WorkflowBuilder Version="2.9.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:glx="clr-namespace:Bonsai.SpikeGLX;assembly=Bonsai.SpikeGLX"
5+
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
6+
xmlns="https://bonsai-rx.org/2018/workflow">
7+
<Workflow>
8+
<Nodes>
9+
<Expression xsi:type="Annotation">
10+
<Name>Set Gate</Name>
11+
<Text><![CDATA[]]></Text>
12+
</Expression>
13+
<Expression xsi:type="Combinator">
14+
<Combinator xsi:type="glx:TriggerGT">
15+
<glx:Host>localhost</glx:Host>
16+
<glx:Port>4142</glx:Port>
17+
<glx:Gate>SetHigh</glx:Gate>
18+
<glx:Trigger>SetLow</glx:Trigger>
19+
</Combinator>
20+
</Expression>
21+
<Expression xsi:type="Annotation">
22+
<Name>Toggle Trigger</Name>
23+
<Text><![CDATA[]]></Text>
24+
</Expression>
25+
<Expression xsi:type="Combinator">
26+
<Combinator xsi:type="rx:Timer">
27+
<rx:DueTime>PT5S</rx:DueTime>
28+
<rx:Period>PT10S</rx:Period>
29+
</Combinator>
30+
</Expression>
31+
<Expression xsi:type="Combinator">
32+
<Combinator xsi:type="glx:TriggerGT">
33+
<glx:Host>localhost</glx:Host>
34+
<glx:Port>4142</glx:Port>
35+
<glx:Gate>NoChange</glx:Gate>
36+
<glx:Trigger>SetHigh</glx:Trigger>
37+
</Combinator>
38+
</Expression>
39+
<Expression xsi:type="Combinator">
40+
<Combinator xsi:type="rx:Delay">
41+
<rx:DueTime>PT5S</rx:DueTime>
42+
</Combinator>
43+
</Expression>
44+
<Expression xsi:type="Combinator">
45+
<Combinator xsi:type="glx:TriggerGT">
46+
<glx:Host>localhost</glx:Host>
47+
<glx:Port>4142</glx:Port>
48+
<glx:Gate>NoChange</glx:Gate>
49+
<glx:Trigger>SetLow</glx:Trigger>
50+
</Combinator>
51+
</Expression>
52+
</Nodes>
53+
<Edges>
54+
<Edge From="0" To="1" Label="Source1" />
55+
<Edge From="2" To="3" Label="Source1" />
56+
<Edge From="3" To="4" Label="Source1" />
57+
<Edge From="4" To="5" Label="Source1" />
58+
<Edge From="5" To="6" Label="Source1" />
59+
</Edges>
60+
</Workflow>
61+
</WorkflowBuilder>

src/Bonsai.SpikeGLX/DigitalOutput.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,21 @@ namespace Bonsai.SpikeGLX
99
/// a sequence of values representing the state of the line.
1010
/// </summary>
1111
[Combinator]
12-
[Description("Sets one or more digital output lines through SpikeGLX from a sequence of values representing the state of the line.")]
1312
[WorkflowElementCategory(ElementCategory.Sink)]
13+
[Description("Sets one or more digital output lines through SpikeGLX from a sequence of values representing the state of the line.")]
1414
public class DigitalOutput
1515
{
1616
/// <summary>
1717
/// Gets or sets the IP address of the SpikeGLX command server.
1818
/// </summary>
19+
[Category("Command Server")]
1920
[Description("The IP address of the SpikeGLX command server.")]
2021
public string Host { get; set; } = "localhost";
2122

2223
/// <summary>
2324
/// Gets or sets the port of the SpikeGLX command server.
2425
/// </summary>
26+
[Category("Command Server")]
2527
[Description("The port of the SpikeGLX command server.")]
2628
public int Port { get; set; } = 4142;
2729

src/Bonsai.SpikeGLX/Fetch.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,32 @@ namespace Bonsai.SpikeGLX
1111
/// <summary>
1212
/// Represents an operator that generates a sequence of data buffers from a SpikeGLX data stream.
1313
/// </summary>
14-
[Description("Streams buffers of data from a SpikeGLX data stream.")]
1514
[Combinator(MethodName = nameof(Generate))]
1615
[WorkflowElementCategory(ElementCategory.Source)]
16+
[Description("Streams buffers of data from a SpikeGLX data stream.")]
1717
public class Fetch : Source<Mat>
1818
{
19-
/// <summary>
20-
/// Gets or sets the duration of fetched data buffers, in ms.
21-
/// </summary>
22-
[Description("Duration of streamed data buffers, in ms.")]
23-
public int BufferLength { get; set; } = 1000;
24-
2519
/// <summary>
2620
/// Gets or sets the IP address of the SpikeGLX command server
2721
/// </summary>
22+
[Category("Command Server")]
2823
[Description("IP address of the SpikeGLX command server." +
2924
"\"localhost\" evaluates to 127.0.0.1.")]
3025
public string Host { get; set; } = "localhost";
3126

3227
/// <summary>
3328
/// Gets or sets the port of the SpikeGLX command server.
3429
/// </summary>
30+
[Category("Command Server")]
3531
[Description("Port of the SpikeGLX command server.")]
3632
public int Port { get; set; } = 4142;
3733

34+
/// <summary>
35+
/// Gets or sets the duration of fetched data buffers, in ms.
36+
/// </summary>
37+
[Description("Duration of streamed data buffers, in ms.")]
38+
public int BufferLength { get; set; } = 1000;
39+
3840
/// <summary>
3941
/// Gets or sets the stream type (0: NIDAQ, 1: Onebox, 2: IMEC Probe).
4042
/// </summary>
@@ -173,4 +175,4 @@ public IObservable<Mat> Generate<TSource>(IObservable<TSource> source)
173175
.RefCount();
174176
}
175177
}
176-
}
178+
}

0 commit comments

Comments
 (0)