Skip to content

Make DigitalOutput work in newer versions of SpikeGLX#12

Merged
glopesdev merged 7 commits intobonsai-rx:mainfrom
FeeLab:10-digitaloutput-does-not-work-in-newer-versions-of-spikeglx
Nov 28, 2025
Merged

Make DigitalOutput work in newer versions of SpikeGLX#12
glopesdev merged 7 commits intobonsai-rx:mainfrom
FeeLab:10-digitaloutput-does-not-work-in-newer-versions-of-spikeglx

Conversation

@J-M-White
Copy link
Collaborator

@J-M-White J-M-White commented Nov 21, 2025

As mentioned in #10, DigitalOutput currently doesn't work with the most recent version of SpikeGLX.

Here, we move to the newest version of the SpikeGLX-CPP-SDK. To be consistent with the new API functions, SetDigitalOut is replaced with SetNIDigitalOut in the SpikeGLX class. DigitalOutput is updated to use SetNIDigitalOut while maintaining the same functionality.

Fixes #10

Update submodules to most recent commit of SpikeGLX-CPP-SDK.
Alter paths in Bonsai.SpikeGLX.csproj to point to correct subdirectory in new SpikeGLX-CPP-SDK commit.
Replace SetDigitalOut with SetNIDigitalOut in SpikeGLX.cs.
Update DigitalOutput to use SetNIDigitalOut.
@J-M-White
Copy link
Collaborator Author

@glopesdev, this should make DigitalOutput work with the newest SpikeGLX version without changing anything else about it. The new API function takes a bitmask now, which means we could do something more similar to DAQmx's DigitalOutput and allow for simulataneous setting of different lines with a bitmask input if we wanted.

There's also the question of whether DigitalOutput is still the correct name. This operator is only for NI digital outputs and in the future we may want to separately implement the functionality of c_sglx_obx_AO_set for Onebox digital/analog outputs.

@J-M-White J-M-White requested a review from glopesdev November 21, 2025 22:05
return Process(source.Select(input => input ? 1 : 0));
return Observable.Using(() => new SpikeGLX(Host, Port),
connection => source.Do(input => connection.SetNIDigitalOut(Channels,
input != 0 ? uint.MaxValue : uint.MinValue)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@J-M-White I was wondering whether here we might want to simply pass on the unmodified int value itself, so we afford the possibility of setting the state of individual channels according to the bitmask?

In fact, it might be easier to simply make the overload take a uint directly so that it aligns exactly with the SpikeGLX API.

In order to reduce the git diff from the current version, you might also want to swap the order of the overloads (uint first, then the bool) so that it becomes easier to spot the relevant differences.

@J-M-White
Copy link
Collaborator Author

Hi @glopesdev, DigitalOutput has now been updated to take a bitmask, in the same way as the API function. The documentation has also been updated to describe the two different input cases (bool vs. uint).

Sorry this took a little while - I wanted to test this on one of our rigs to make sure the new API function worked how I thought it did (especially when using a bitmask input).

@J-M-White J-M-White requested a review from glopesdev November 27, 2025 19:10
Copy link
Member

@glopesdev glopesdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just left a few final comments, but I'm happy to merge anytime.

Also make formatting of NI ports in comments consistent (no space between port and number).

Co-authored-by: glopesdev <g.lopes@neurogears.org>
@J-M-White
Copy link
Collaborator Author

@glopesdev, great - thanks! Your suggested changes to when Channels are fixed in DigitalOutput were a great idea and I've committed them.

I think you need to approve before I can merge.

Correct DigitalOutput so that the same Channel freezing on subscription happens for boolean inputs as for uint inputs.

Co-authored-by: glopesdev <g.lopes@neurogears.org>
@J-M-White J-M-White requested a review from glopesdev November 28, 2025 15:46
@glopesdev glopesdev merged commit 25a1d13 into bonsai-rx:main Nov 28, 2025
9 checks passed
@J-M-White J-M-White deleted the 10-digitaloutput-does-not-work-in-newer-versions-of-spikeglx branch November 28, 2025 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DigitalOutput does not work in newer versions of SpikeGLX

2 participants