Skip to main content

pycbsdk

PyPI version

Python bindings for the CereLink SDK, providing real-time access to Blackrock Neurotech Cerebus neural signal processors.

Built on cffi (ABI mode) — no compiler needed at install time.

Installation

pip install pycbsdk

# With numpy support (zero-copy array access for continuous data)
pip install pycbsdk[numpy]

Windows prerequisite: The bundled shared library requires the Microsoft Visual C++ Redistributable. Most Windows systems already have it installed. If you get a DLL load error, download it from Microsoft.

Quick Start

from pycbsdk import Session
import time

with Session("HUB1") as session:
    # Register a callback for spike events
    @session.on_event("FRONTEND")
    def on_spike(header, data):
        print(f"Spike on channel {header.chid} at t={header.time}")

    # Register a callback for 30kHz continuous data
    @session.on_group(5, as_array=True)
    def on_continuous(header, samples):
        # samples is a numpy int16 array of shape (n_channels,)
        print(f"Group packet: {len(samples)} channels")

    time.sleep(10)
    print(session.stats)

Features

  • Callback-driven: decorator-based registration for event, group, config, and catch-all packet callbacks
  • Context manager: automatic cleanup on exit
  • numpy integration (optional): zero-copy arrays for continuous data, ring buffer accumulator, blocking read_continuous() collector
  • Device support: LEGACY_NSP, NSP, HUB1, HUB2, HUB3, NPLAY

API Overview

Session

session = Session(device_type="HUB1", callback_queue_depth=16384)

Callbacks (decorator style):

Decorator Description
@session.on_event("FRONTEND") Spike / event packets for a channel type
@session.on_group(5) Continuous sample group (1-6)
@session.on_group(5, as_array=True) Same, but data as numpy array
@session.on_config(pkt_type) Config / system packets
@session.on_packet() All packets (catch-all)
session.on_error(fn) Error messages

Configuration access:

  • session.get_channel_label(chan_id) — channel label string
  • session.get_channel_smpgroup(chan_id) — channel's sample group (0-6)
  • session.get_group_channels(group_id) — list of channel IDs in a group
  • session.runlevel — current device run level
  • Session.max_chans(), Session.num_fe_chans(), Session.num_analog_chans()

Commands:

  • session.send_comment("marker text", rgba=0xFF0000) — inject a comment
  • session.set_digital_output(chan_id, value) — set digital output
  • session.set_runlevel(level) — change system run level
  • session.set_sample_group(n, "FRONTEND", group_id) — configure sampling
  • session.set_spike_sorting(n, "FRONTEND", sort_options) — configure spike sorting

CCF Configuration Files:

  • session.save_ccf("config.ccf") — save current device config to XML file
  • session.load_ccf("config.ccf") — load config from file and apply to device

Recording Control (requires Central):

  • session.start_central_recording("filename", comment="session 1") — start recording
  • session.stop_central_recording() — stop recording

Clock Synchronization:

# Convert device timestamp to Python's time.monotonic()
@session.on_event("FRONTEND")
def on_spike(header, data):
    t = session.device_to_monotonic(header.time)
    latency_ms = (time.monotonic() - t) * 1000
    print(f"Spike latency: {latency_ms:.1f} ms")
  • session.device_to_monotonic(device_time_ns) — convert device timestamp to time.monotonic() seconds
  • session.clock_offset_ns — raw clock offset (device_ns - steady_clock_ns), or None
  • session.clock_uncertainty_ns — uncertainty (half-RTT), or None
  • session.send_clock_probe() — send a sync probe

Statistics:

stats = session.stats  # Stats dataclass
print(stats.packets_received, stats.packets_dropped)
session.reset_stats()

numpy Integration

Requires pip install pycbsdk[numpy].

# Blocking data collection
data = session.read_continuous(group_id=5, duration=2.0)
# data.shape == (n_channels, ~60000), dtype int16

# Ring buffer for ongoing collection
reader = session.continuous_reader(group_id=5, buffer_seconds=10)
import time; time.sleep(5)
data = reader.read()        # most recent samples
data = reader.read(1000)    # last 1000 samples
print(reader.total_samples, reader.dropped)
reader.close()

Supported Devices

Device Type Description
LEGACY_NSP Legacy NSP (default)
NSP NSP
HUB1 Gemini Hub 1
HUB2 Gemini Hub 2
HUB3 Gemini Hub 3
NPLAY nPlay

Development

# Build the shared library
cmake -S . -B build -DCBSDK_BUILD_SHARED=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --target cbsdk_shared --config Release

# Install pycbsdk in development mode
cd pycbsdk
pip install -e ".[dev,numpy]"

# Point to the shared library
export CBSDK_LIB_PATH=/path/to/libcbsdk.dll  # or .so / .dylib

License

BSD 2-Clause. See LICENSE.txt.

Metadata

Release files for pycbsdk 10.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycbsdk 10.2.0
File Size Uploaded
pycbsdk-10.2.0.tar.gz 102.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pycbsdk 10.2.0
File Interpreter ABI Platform
pycbsdk-10.2.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
pycbsdk-10.2.0-py3-none-manylinux_2_39_x86_64.whl Python 3 none Linux glibc 2.39+ x86-64 Details
pycbsdk-10.2.0-py3-none-macosx_26_0_universal2.whl Python 3 none macOS 26.0+ universal2 (ARM64, x86-64) Details

Total release size: 1.8 MB

Release files / pycbsdk-10.2.0.tar.gz

Download URL pycbsdk-10.2.0.tar.gz
Size 102.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2d04b96ee8f62d6bcc1284ce49931254f18f73da3f7695287b574f6af15fbe78
BLAKE2b-256 checksum
How to use checksums
4004c8d425edbd4d92484b6228d470c618251bc47b6e2878058a77a8da09fa87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.

Transparency log

Release files / pycbsdk-10.2.0-py3-none-win_amd64.whl

Download URL pycbsdk-10.2.0-py3-none-win_amd64.whl
Size 351.8 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
2886fcc2cf6753495a760457c5626722e0b1aeb9f6089e35153608169b77eb9b
BLAKE2b-256 checksum
How to use checksums
d5e93fdcc87a57d6da437b1ab4c6d5d4c7bd790b883ec3b687fefc3925915220
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.

Transparency log

Release files / pycbsdk-10.2.0-py3-none-manylinux_2_39_x86_64.whl

Download URL pycbsdk-10.2.0-py3-none-manylinux_2_39_x86_64.whl
Size 551.9 kB
Tags Linux glibc 2.39+ x86-64 Python 3
SHA-256 checksum
How to use checksums
01999e1da39e82ce5349b63c7bc78941e26e32f9573b11f8c8cb3328ff18ec06
BLAKE2b-256 checksum
How to use checksums
d4ddf1d672a339e20aa25e347be49a67bb0eab72d7cfc274f88c6827d4595884
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.

Transparency log

Release files / pycbsdk-10.2.0-py3-none-macosx_26_0_universal2.whl

Download URL pycbsdk-10.2.0-py3-none-macosx_26_0_universal2.whl
Size 812.8 kB
Tags Python 3 macOS 26.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
75af8c307c913904ea62834d472e716b1dd469cbd8e2c50e495d9aeb7398a405
BLAKE2b-256 checksum
How to use checksums
87d9df690d97d277f9e9eb90bb788718ee25e1f385187b78131d533ed832eed3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.

Transparency log

Release history Release notifications | RSS feed

10.3.0

4 release files

This release

10.2.0 This release

4 release files

10.1.0

4 release files

9.12.0

4 release files

9.11.1

4 release files

9.11.0

4 release files

9.9.1

4 release files

9.9.0

4 release files

9.8.0

4 release files

9.7.3

4 release files

9.7.2

4 release files

9.7.1

4 release files

9.7.0

4 release files

9.6.1

4 release files

9.6.0

4 release files

9.5.1

4 release files

9.5.0

4 release files

9.4.1

4 release files

9.4.0

4 release files

9.3.0

4 release files

9.2.0

4 release files

9.1.0

4 release files

9.0.1

4 release files

9.0.0

4 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page