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
4 changes: 2 additions & 2 deletions docs/workflows/GettingStarted-SubscribedFetch.bonsai
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="glx:Fetch">
<glx:BufferLength>1000</glx:BufferLength>
<glx:Host>localhost</glx:Host>
<glx:Port>4142</glx:Port>
<glx:StreamType>0</glx:StreamType>
<glx:BufferLength>1000</glx:BufferLength>
<glx:StreamType>Daq</glx:StreamType>
<glx:Substream>0</glx:Substream>
<glx:Channels>
<glx:int>0</glx:int>
Expand Down
4 changes: 2 additions & 2 deletions docs/workflows/GettingStarted-UnsubscribedFetch.bonsai
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<Nodes>
<Expression xsi:type="Combinator">
<Combinator xsi:type="glx:Fetch">
<glx:BufferLength>1000</glx:BufferLength>
<glx:Host>localhost</glx:Host>
<glx:Port>4142</glx:Port>
<glx:StreamType>0</glx:StreamType>
<glx:BufferLength>1000</glx:BufferLength>
<glx:StreamType>Daq</glx:StreamType>
<glx:Substream>0</glx:Substream>
<glx:Channels>
<glx:int>0</glx:int>
Expand Down
31 changes: 26 additions & 5 deletions src/Bonsai.SpikeGLX/Fetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public class Fetch : Source<Mat>
public int BufferLength { get; set; } = 1000;

/// <summary>
/// Gets or sets the stream type (0: NIDAQ, 1: Onebox, 2: IMEC Probe).
/// Gets or sets a value specifying the type of stream to fetch from.
/// </summary>
[Description("Stream type (0: NIDAQ, 1: Onebox, 2: IMEC Probe).")]
public int StreamType { get; set; } = 0;
[Description("The type of stream to fetch from.")]
public StreamType StreamType { get; set; } = StreamType.Daq;

/// <summary>
/// Gets or sets the substream (0 for NIDAQ, probe number for IMEC Probe).
Expand Down Expand Up @@ -98,7 +98,7 @@ public override IObservable<Mat> Generate()
return Task.Factory.StartNew(() =>
{
// Establish connection to SpikeGLX command server.
using SpikeGLXDataStream connection = new(Host, Port, StreamType, Substream, Channels);
using SpikeGLXDataStream connection = new(Host, Port, (int)StreamType, Substream, Channels);

// Get the sample rate of the stream and use it to convert the buffer length,
// in ms, to a buffer size, in number of elements.
Expand Down Expand Up @@ -158,7 +158,7 @@ public IObservable<Mat> Generate<TSource>(IObservable<TSource> source)
{
// Create a disposable data stream connection using the provided host, port, stream type, substream, and channels.
return Observable
.Using<Mat, SpikeGLXDataStream>(() => new SpikeGLXDataStream(Host, Port, StreamType, Substream, Channels),
.Using<Mat, SpikeGLXDataStream>(() => new SpikeGLXDataStream(Host, Port, (int)StreamType, Substream, Channels),
// Use the data stream connection to fetch the latest data for each input notification.
connection => source
.Select(input =>
Expand All @@ -175,4 +175,25 @@ public IObservable<Mat> Generate<TSource>(IObservable<TSource> source)
.RefCount();
}
}

/// <summary>
/// Specifies possible values for the SpikeGLX stream.
/// </summary>
public enum StreamType
{
/// <summary>
/// NIDAQ
/// </summary>
Daq = 0,

/// <summary>
/// Onebox
/// </summary>
OneBox = 1,

/// <summary>
/// IMEC probe
/// </summary>
Probe = 2
}
}