Skip to content
Merged
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
68 changes: 36 additions & 32 deletions .bonsai/Bonsai.config
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Packages>
<Package id="Bonsai" version="2.8.5" />
<Package id="Bonsai.Core" version="2.8.5" />
<Package id="Bonsai.Design" version="2.8.5" />
<Package id="Bonsai.Editor" version="2.8.5" />
<Package id="Bonsai" version="2.9.0" />
<Package id="Bonsai.Core" version="2.9.0" />
<Package id="Bonsai.Design" version="2.9.0" />
<Package id="Bonsai.Editor" version="2.9.0" />
<Package id="DockPanelSuite" version="3.1.1" />
<Package id="DockPanelSuite.ThemeVS2015" version="3.1.1" />
<Package id="jacobslusser.ScintillaNET" version="3.6.3" />
<Package id="Markdig" version="0.18.1" />
<Package id="Microsoft.Web.WebView2" version="1.0.1823.32" />
<Package id="Markdig" version="0.41.1" />
<Package id="Microsoft.Web.WebView2" version="1.0.2792.45" />
<Package id="Rx-Core" version="2.2.5" />
<Package id="Rx-Interfaces" version="2.2.5" />
<Package id="Rx-Linq" version="2.2.5" />
<Package id="Rx-PlatformServices" version="2.2.5" />
<Package id="SvgNet" version="3.3.3" />
<Package id="System.Buffers" version="4.5.1" />
<Package id="System.Memory" version="4.5.5" />
<Package id="System.Numerics.Vectors" version="4.5.0" />
<Package id="SvgNet" version="3.5.0" />
<Package id="System.Buffers" version="4.6.0" />
<Package id="System.Memory" version="4.6.0" />
<Package id="System.Numerics.Vectors" version="4.6.0" />
<Package id="System.Resources.Extensions" version="8.0.0" />
<Package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" />
<Package id="YamlDotNet" version="13.1.1" />
<Package id="System.Runtime.CompilerServices.Unsafe" version="6.1.0" />
<Package id="YamlDotNet" version="16.3.0" />
</Packages>
<AssemblyReferences>
<AssemblyReference assemblyName="Bonsai" />
Expand All @@ -27,33 +29,35 @@
<AssemblyReference assemblyName="Bonsai.Editor" />
</AssemblyReferences>
<AssemblyLocations>
<AssemblyLocation assemblyName="Bonsai" processorArchitecture="MSIL" location="Packages/Bonsai.2.8.5/lib/net48/Bonsai.exe" />
<AssemblyLocation assemblyName="Bonsai.Core" processorArchitecture="MSIL" location="Packages/Bonsai.Core.2.8.5/lib/net462/Bonsai.Core.dll" />
<AssemblyLocation assemblyName="Bonsai.Design" processorArchitecture="MSIL" location="Packages/Bonsai.Design.2.8.5/lib/net462/Bonsai.Design.dll" />
<AssemblyLocation assemblyName="Bonsai.Editor" processorArchitecture="MSIL" location="Packages/Bonsai.Editor.2.8.5/lib/net472/Bonsai.Editor.dll" />
<AssemblyLocation assemblyName="Markdig" processorArchitecture="MSIL" location="Packages/Markdig.0.18.1/lib/net40/Markdig.dll" />
<AssemblyLocation assemblyName="Microsoft.Web.WebView2.Core" processorArchitecture="MSIL" location="Packages/Microsoft.Web.WebView2.1.0.1823.32/lib/net45/Microsoft.Web.WebView2.Core.dll" />
<AssemblyLocation assemblyName="Microsoft.Web.WebView2.WinForms" processorArchitecture="MSIL" location="Packages/Microsoft.Web.WebView2.1.0.1823.32/lib/net45/Microsoft.Web.WebView2.WinForms.dll" />
<AssemblyLocation assemblyName="Microsoft.Web.WebView2.Wpf" processorArchitecture="MSIL" location="Packages/Microsoft.Web.WebView2.1.0.1823.32/lib/net45/Microsoft.Web.WebView2.Wpf.dll" />
<AssemblyLocation assemblyName="Bonsai" processorArchitecture="MSIL" location="Packages/Bonsai.2.9.0/lib/net48/Bonsai.exe" />
<AssemblyLocation assemblyName="Bonsai.Core" processorArchitecture="MSIL" location="Packages/Bonsai.Core.2.9.0/lib/net472/Bonsai.Core.dll" />
<AssemblyLocation assemblyName="Bonsai.Design" processorArchitecture="MSIL" location="Packages/Bonsai.Design.2.9.0/lib/net472/Bonsai.Design.dll" />
<AssemblyLocation assemblyName="Bonsai.Editor" processorArchitecture="MSIL" location="Packages/Bonsai.Editor.2.9.0/lib/net472/Bonsai.Editor.dll" />
<AssemblyLocation assemblyName="Markdig" processorArchitecture="MSIL" location="Packages/Markdig.0.41.1/lib/net462/Markdig.dll" />
<AssemblyLocation assemblyName="Microsoft.Web.WebView2.Core" processorArchitecture="MSIL" location="Packages/Microsoft.Web.WebView2.1.0.2792.45/lib/net462/Microsoft.Web.WebView2.Core.dll" />
<AssemblyLocation assemblyName="Microsoft.Web.WebView2.WinForms" processorArchitecture="MSIL" location="Packages/Microsoft.Web.WebView2.1.0.2792.45/lib/net462/Microsoft.Web.WebView2.WinForms.dll" />
<AssemblyLocation assemblyName="Microsoft.Web.WebView2.Wpf" processorArchitecture="MSIL" location="Packages/Microsoft.Web.WebView2.1.0.2792.45/lib/net462/Microsoft.Web.WebView2.Wpf.dll" />
<AssemblyLocation assemblyName="ScintillaNET" processorArchitecture="MSIL" location="Packages/jacobslusser.ScintillaNET.3.6.3/lib/net40/ScintillaNET.dll" />
<AssemblyLocation assemblyName="SVG" processorArchitecture="MSIL" location="Packages/SvgNet.3.3.3/lib/net462/SVG.dll" />
<AssemblyLocation assemblyName="System.Buffers" processorArchitecture="MSIL" location="Packages/System.Buffers.4.5.1/lib/net461/System.Buffers.dll" />
<AssemblyLocation assemblyName="System.Memory" processorArchitecture="MSIL" location="Packages/System.Memory.4.5.5/lib/net461/System.Memory.dll" />
<AssemblyLocation assemblyName="System.Numerics.Vectors" processorArchitecture="MSIL" location="Packages/System.Numerics.Vectors.4.5.0/lib/net46/System.Numerics.Vectors.dll" />
<AssemblyLocation assemblyName="SVG" processorArchitecture="MSIL" location="Packages/SvgNet.3.5.0/lib/net462/SVG.dll" />
<AssemblyLocation assemblyName="System.Buffers" processorArchitecture="MSIL" location="Packages/System.Buffers.4.6.0/lib/net462/System.Buffers.dll" />
<AssemblyLocation assemblyName="System.Memory" processorArchitecture="MSIL" location="Packages/System.Memory.4.6.0/lib/net462/System.Memory.dll" />
<AssemblyLocation assemblyName="System.Numerics.Vectors" processorArchitecture="MSIL" location="Packages/System.Numerics.Vectors.4.6.0/lib/net462/System.Numerics.Vectors.dll" />
<AssemblyLocation assemblyName="System.Reactive.Core" processorArchitecture="MSIL" location="Packages/Rx-Core.2.2.5/lib/net45/System.Reactive.Core.dll" />
<AssemblyLocation assemblyName="System.Reactive.Interfaces" processorArchitecture="MSIL" location="Packages/Rx-Interfaces.2.2.5/lib/net45/System.Reactive.Interfaces.dll" />
<AssemblyLocation assemblyName="System.Reactive.Linq" processorArchitecture="MSIL" location="Packages/Rx-Linq.2.2.5/lib/net45/System.Reactive.Linq.dll" />
<AssemblyLocation assemblyName="System.Reactive.PlatformServices" processorArchitecture="MSIL" location="Packages/Rx-PlatformServices.2.2.5/lib/net45/System.Reactive.PlatformServices.dll" />
<AssemblyLocation assemblyName="System.Resources.Extensions" processorArchitecture="MSIL" location="Packages/System.Resources.Extensions.8.0.0/lib/net462/System.Resources.Extensions.dll" />
<AssemblyLocation assemblyName="System.Runtime.CompilerServices.Unsafe" processorArchitecture="MSIL" location="Packages/System.Runtime.CompilerServices.Unsafe.4.5.3/lib/net461/System.Runtime.CompilerServices.Unsafe.dll" />
<AssemblyLocation assemblyName="YamlDotNet" processorArchitecture="MSIL" location="Packages/YamlDotNet.13.1.1/lib/net47/YamlDotNet.dll" />
<AssemblyLocation assemblyName="System.Runtime.CompilerServices.Unsafe" processorArchitecture="MSIL" location="Packages/System.Runtime.CompilerServices.Unsafe.6.1.0/lib/net462/System.Runtime.CompilerServices.Unsafe.dll" />
<AssemblyLocation assemblyName="WeifenLuo.WinFormsUI.Docking" processorArchitecture="MSIL" location="Packages/DockPanelSuite.3.1.1/lib/net40/WeifenLuo.WinFormsUI.Docking.dll" />
<AssemblyLocation assemblyName="WeifenLuo.WinFormsUI.Docking.ThemeVS2015" processorArchitecture="MSIL" location="Packages/DockPanelSuite.ThemeVS2015.3.1.1/lib/net40/WeifenLuo.WinFormsUI.Docking.ThemeVS2015.dll" />
<AssemblyLocation assemblyName="YamlDotNet" processorArchitecture="MSIL" location="Packages/YamlDotNet.16.3.0/lib/net47/YamlDotNet.dll" />
</AssemblyLocations>
<LibraryFolders>
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.1823.32/runtimes/win-arm64/native" platform="arm64" />
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.1823.32/runtimes/win-arm64/native_uap" platform="arm64" />
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.1823.32/runtimes/win-x64/native" platform="x64" />
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.1823.32/runtimes/win-x64/native_uap" platform="x64" />
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.1823.32/runtimes/win-x86/native" platform="x86" />
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.1823.32/runtimes/win-x86/native_uap" platform="x86" />
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.2792.45/runtimes/win-arm64/native" platform="arm64" />
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.2792.45/runtimes/win-arm64/native_uap" platform="arm64" />
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.2792.45/runtimes/win-x64/native" platform="x64" />
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.2792.45/runtimes/win-x64/native_uap" platform="x64" />
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.2792.45/runtimes/win-x86/native" platform="x86" />
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.2792.45/runtimes/win-x86/native_uap" platform="x86" />
</LibraryFolders>
</PackageConfiguration>
47 changes: 8 additions & 39 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,17 @@
# Bonsai.SpikeGLX
[Bonsai](http://bonsai-rx.org/) package for interfacing with [SpikeGLX](https://billkarsh.github.io/SpikeGLX/).
# Bonsai - SpikeGLX
`Bonsai.SpikeGLX` is a [Bonsai](https://bonsai-rx.org/) package for interfacing with the [SpikeGLX](https://billkarsh.github.io/SpikeGLX/) recording software for [Neuropixels](https://www.neuropixels.org/) probes.

## Description
Bonsai.SpikeGLX is designed to allow integration of SpikeGLX recordings into Bonsai workflows. This package provides the ability to
- stream neural and non-neural data from SpikeGLX into Bonsai in real-time,
- set digital outputs on an NI device in use by SpikeGLX, and
- start and stop SpikeGLX recordings.

## Getting Started
### Starting the SpikeGLX Remote Command Server
Bonsai.SpikeGLX requires SpikeGLX's remote command server to be running. See the [SpikeGLX-CPP-SDK Getting Started](https://github.com/billkarsh/SpikeGLX-CPP-SDK/blob/main/GettingStarted.txt) page for how to do this. Each Bonsai.SpikeGLX marble requires the IP address and port of the SpikeGLX command server to work.

### Streaming SpikeGLX Data into Bonsai
Bonsai.SpikeGLX provides two ways to access data from SpikeGLX once an acquisition is running:
- **SpikeFetch** will fetch a fixed-size buffer of the latest data from SpikeGLX whenever it receives an input signal (or at a fixed interval if no input is provided).
- **SpikeStream** will continuously stream data in fixed-size buffers from SpikeGLX.

The key difference between the two is that unlike SpikeFetch, SpikeStream will never skip or repeat elements in the buffers it emits. This is demonstrated below, where both marbles have been used to stream a 1Hz sinewave in 1s buffers. The output of SpikeFetch 'jumps' around as it misses or repeats samples, whereas the output of SpikeStream does not.

![SpikeFetch-vs-SpikeStream-Timed](https://github.com/FeeLab/Bonsai.SpikeGLX/assets/120409412/24fda4b8-fa1c-4089-8dee-a33c9126eed7)

### Setting Digital Outputs
The **DigitalOutput** marble may be used to control digital outputs on an NI DAQ system in use by SpikeGLX.

### Controlling SpikeGLX Recordings
SpikeGLX recordings may be started and stopped using the **TriggerRecording** marble, which can increment/decrement the gate and trigger values in SpikeGLX. It takes a tuple of two integers, which modify the gate and trigger, respectively, in the following way:
- -1: No change
- 0: Set low
- 1: Increment and set high

As of SpikeGLX Release v20230815-phase30, adding a fixed period of saved data before and after triggering for context is not implemented for remote triggering. An alternative is to use TTL controlled start and stop, with a digital output (controlled using the **DigitalOutput** marble) as the TTL signal.
`Bonsai.SpikeGLX` is designed to allow integration of SpikeGLX recordings into Bonsai workflows. This package provides the ability to:
- stream neural and non-neural data from SpikeGLX into Bonsai in real-time;
- set digital outputs on an NI device in use by SpikeGLX; and
- start and stop SpikeGLX recordings.

## Authors
Bonsai.SpikeGLX is developed by Jacob White of the [Fee Lab](https://feelaboratory.org/) at MIT.

## Version History
-0.1
- Initial Release
`Bonsai.SpikeGLX` was initially developed by Jacob White of the [Fee Lab](https://feelaboratory.org/) at MIT.

## License
Use is subject to [MIT](https://opensource.org/license/mit/) license terms.
`Bonsai.SpikeGLX` is released as open source under the [MIT License](https://licenses.nuget.org/MIT).

SpikeGLX-CPP-SDK components are subject to [Janelia Research Campus Software Copyright 1.2 license](http://license.janelia.org/license) terms.

## Acknowledgments
The SpikeStream marble is inspired by the AudioCapture marble in [Bonsai.Audio](https://github.com/bonsai-rx/bonsai/tree/main/Bonsai.Audio).

5 changes: 5 additions & 0 deletions docs/apidoc/Bonsai_SpikeGLX_DigitalOutput.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
uid: Bonsai.SpikeGLX.DigitalOutput
---

[!include[DigitalOutput](~/articles/spikeglx-digitaloutput.md)]
5 changes: 5 additions & 0 deletions docs/apidoc/Bonsai_SpikeGLX_Fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
uid: Bonsai.SpikeGLX.Fetch
---

[!include[Fetch](~/articles/spikeglx-fetch.md)]
7 changes: 7 additions & 0 deletions docs/apidoc/Bonsai_SpikeGLX_Trigger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
uid: Bonsai.SpikeGLX.Trigger
---

> [!WARNING]
> [`Trigger`](xref:Bonsai.SpikeGLX.Trigger) works only with SpikeGLX runs configured to use **remote controlled start and stop** triggering.
[!include[Trigger](~/articles/spikeglx-trigger.md)]
37 changes: 37 additions & 0 deletions docs/articles/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Getting Started
`Bonsai.SpikeGLX` is a [Bonsai](https://bonsai-rx.org/) package for interfacing with the [SpikeGLX](https://billkarsh.github.io/SpikeGLX/) recording software for [Neuropixels](https://www.neuropixels.org/).

It is designed to supplement the core functionalities of SpikeGLX (*i.e.*, visualizing and saving data) and facilitate more complex experimental paradigms (*e.g.*, closed-loop neurofeedback, brain-computer interfaces, *etc.*).

`Bonsai.SpikeGLX` provides three ways of interacting with an ongoing SpikeGLX run:
- streaming data from SpikeGLX into Bonsai with [`Fetch`];
- controlling SpikeGLX digital output lines with [`DigitalOutput`]; and
- starting and stopping recordings with [`Trigger`].

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.

> [!NOTE]
> All `Bonsai.SpikeGLX` operators require SpikeGLX's remote command server to be running. A full description of how to do this can be found in the [SpikeGLX User Manual](https://billkarsh.github.io/SpikeGLX/Sgl_help/UserManual.html#remote-command-servers). Make sure to note the `Host` (IP Address) and `Port` the command server is listening on. These are properties that must be set for each `Bonsai.SpikeGLX` operator.

## Stream Data from SpikeGLX
[!include[Fetch](~/articles/spikeglx-fetch.md)]

## Control Digital Outputs
[!include[DigitalOutput](~/articles/spikeglx-digitaloutput.md)]

## Save Data
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.

[!include[Trigger](~/articles/spikeglx-trigger.md)]

> [!NOTE]
> SpikeGLX also provides the ability to trigger recordings using a TTL line. In some cases, this may be preferred over using [`Trigger`].

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.

<!--Reference Style Links -->
[`Fetch`]: xref:Bonsai.SpikeGLX.Fetch
[`DigitalOutput`]: xref:Bonsai.SpikeGLX.DigitalOutput
[`Trigger`]: xref:Bonsai.SpikeGLX.Trigger
[`Timer`]: xref:Bonsai.Reactive.Timer
[`MatrixWriter`]: xref:Bonsai.Dsp.MatrixWriter
17 changes: 17 additions & 0 deletions docs/articles/spikeglx-digitaloutput.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
uid: spikeglx-digitaloutput
title: DigitalOutput
---

[`DigitalOutput`] writes a logical value to one or more digital output lines on a NI-DAQ device in use by SpikeGLX. Digital lines are specified in the `Channels` property as a comma separated list, (*e.g.*, `Dev6/port0/line2,Dev6/port0/line5`).

For example, the below workflow toggles a digital line between high and low every second.
:::workflow
![DigitalOutput](../workflows/GettingStarted-DigitalOutput.bonsai)
:::

> [!WARNING]
> Unlike `Bonsai.DAQmx`'s [`DigitalOutput`](xref:Bonsai.DAQmx.DigitalOutput), `Bonsai.SpikeGLX`'s [`DigitalOutput`] writes **the same** logical value to all of its channels.

<!--Reference Style Links -->
[`DigitalOutput`]: xref:Bonsai.SpikeGLX.DigitalOutput
19 changes: 19 additions & 0 deletions docs/articles/spikeglx-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
uid: spikeglx-fetch
title: Fetch
---

[`Fetch`] samples data from an ongoing SpikeGLX run. Data are sampled from one or more channels of a single SpikeGLX data stream. Data are emitted in a sample buffer, where each row corresponds to a channel, and each column to a sample from each of the channels. The order of the channels follows the order in which you specify the channels in the `Channels` property.

If no input source is specified, data is emitted asynchronously every time a new buffer is filled.
:::workflow
![Unsubscribed Fetch](~/workflows/GettingStarted-UnsubscribedFetch.bonsai)
:::

Alternatively, if an input observable sequence is provided, a new data buffer is emitted every time a new notification is emitted by the input source.
:::workflow
![Subscribed Fetch](~/workflows/GettingStarted-SubscribedFetch.bonsai)
:::

<!--Reference Style Links -->
[`Fetch`]: xref:Bonsai.SpikeGLX.Fetch
17 changes: 17 additions & 0 deletions docs/articles/spikeglx-trigger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
uid: spikeglx-trigger
title: Trigger
---

[`Trigger`] takes as input a `Tuple` of two values, which modify the gate and trigger, respectively, in the following way:
- -1: No change
- 0: Set low
- 1: Increment and set high

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.
:::workflow
![Trigger](../workflows/GettingStarted-Trigger.bonsai)
:::

<!--Reference Style Links -->
[`Trigger`]: xref:Bonsai.SpikeGLX.Trigger
4 changes: 4 additions & 0 deletions docs/articles/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- name: Introduction
href: ../index.md
- name: Getting Started
href: getting-started.md
3 changes: 2 additions & 1 deletion docs/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
},
"xref": [
"https://bonsai-rx.org/docs/xrefmap.yml",
"https://horizongir.github.io/reactive/xrefmap.yml"
"https://horizongir.github.io/reactive/xrefmap.yml",
"https://bonsai-rx.org/daqmx/xrefmap.yml"
]
}
}
1 change: 1 addition & 0 deletions docs/filter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ apiRules:
- exclude:
hasAttribute:
uid: System.ObsoleteAttribute

4 changes: 0 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
---
_layout: landing
---

[!INCLUDE [](README.md)]
2 changes: 2 additions & 0 deletions docs/toc.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
- name: Manual
href: articles/
- name: API
href: ../artifacts/docs/api/
Loading