Skip to main content

High-performance signal processing for BCI research

Project description

zpybci -- Zerostone Python for BCI

High-performance, real-time signal processing for brain-computer interface research. Powered by Rust with zero-copy NumPy integration.

Installation

pip install zpybci

Wheels are available for Linux (x86_64, aarch64), macOS (Intel + Apple Silicon), and Windows (x86_64). Python 3.8+.

Quick Start

import numpy as np
import zpybci as zbci

# Bandpass filter for alpha band (8-12 Hz)
bpf = zbci.IirFilter.butterworth_bandpass(sample_rate=256.0, low_cutoff=8.0, high_cutoff=12.0)
signal = np.random.randn(1000).astype(np.float32)
filtered = bpf.process(signal)

# Chain multiple stages into a pipeline
pipe = zbci.Pipeline(sample_rate=256.0, stages=[
    ("highpass", {"cutoff": 1.0}),
    ("notch", {"freq": 50.0}),
    ("lowpass", {"cutoff": 40.0}),
])
cleaned = pipe.process(signal)

Features

Filters

  • IIR -- 4th-order Butterworth (lowpass, highpass, bandpass)
  • FIR -- arbitrary-length finite impulse response
  • AC coupling -- DC removal for streaming data
  • Median -- nonlinear smoothing
  • Adaptive -- LMS and NLMS for noise cancellation
  • Notch -- narrowband rejection (e.g., 50/60 Hz line noise)

Spatial Filters

  • CAR -- common average reference
  • Surface Laplacian -- current source density approximation
  • Channel Router -- flexible channel remapping

Spectral Analysis

  • FFT -- fast Fourier transform (magnitude/phase)
  • STFT -- short-time Fourier transform
  • Multi-band power -- concurrent power in multiple frequency bands
  • Welch PSD -- power spectral density estimation
  • CWT -- continuous wavelet transform (Morlet)

Detection

  • Threshold -- fixed-threshold event detection
  • Adaptive threshold -- self-adjusting threshold based on signal statistics
  • Zero-crossing -- rate estimation

Artifact Handling

  • Amplitude-based -- flag samples exceeding a threshold
  • Z-score -- flag statistically outlying segments

Analysis

  • Envelope follower -- instantaneous amplitude via rectification + smoothing
  • Windowed RMS -- streaming root-mean-square
  • Hilbert transform -- analytic signal, instantaneous phase/frequency

Statistics

  • Online mean/variance -- Welford's algorithm, no buffer required
  • Online covariance -- streaming covariance matrix

Advanced

  • CSP -- common spatial patterns with online adaptation
  • Riemannian tangent space -- SPD manifold projection for classification
  • OASIS deconvolution -- calcium transient inference from fluorescence traces

Utilities

  • Pipeline -- declarative stage chaining with a single process() call
  • Resampling -- integer decimation and interpolation
  • Streaming percentile -- approximate quantiles on unbounded streams
  • Clock sync -- offset estimation, linear drift correction, sample clock alignment
  • Cross-correlation -- full, valid, and circular modes
  • Window functions -- Hann, Hamming, Blackman, flat-top, Kaiser

Version

0.2.0

License

AGPL-3.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zpybci-0.2.0.tar.gz (295.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

zpybci-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (820.0 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

zpybci-0.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (822.9 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

zpybci-0.2.0-cp38-abi3-win_amd64.whl (635.4 kB view details)

Uploaded CPython 3.8+Windows x86-64

zpybci-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (798.4 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

zpybci-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (820.8 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

zpybci-0.2.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.5 MB view details)

Uploaded CPython 3.8+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file zpybci-0.2.0.tar.gz.

File metadata

  • Download URL: zpybci-0.2.0.tar.gz
  • Upload date:
  • Size: 295.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for zpybci-0.2.0.tar.gz
Algorithm Hash digest
SHA256 46934b05cf897362bfbb1f578ecc277188bf3a7ffa146939ef4b9b7fccaa4f2d
MD5 be26c7d3209f06f2b8d11a61cf85d127
BLAKE2b-256 3b1e85764873bb00e0ade1acfb870b8be3a68d3c0d3964c15f0547d13403d6ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for zpybci-0.2.0.tar.gz:

Publisher: release.yml on fredrikWHaug/zerostone

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zpybci-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for zpybci-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e376d21e3cec20d2c163c8c462e70dc1b94cba18f75cd6b4555a323941a9e75d
MD5 79bf618e13961a785aafe7474e966036
BLAKE2b-256 b8ae611b443dce17dad0012a2e5a7c180f7a689704549c37340ab02b731bdfde

See more details on using hashes here.

Provenance

The following attestation bundles were made for zpybci-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on fredrikWHaug/zerostone

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zpybci-0.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for zpybci-0.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 907be0cdbe5931bd61739e3cb22a07d20ff7ce84323579bceb283dad2a324e96
MD5 dbc10752aaa872dd8c17e4eecb7cb89c
BLAKE2b-256 0f6d1c6918a9f65a0388a97f108703a8857c231d42dab8daf7e6713cb5d8a597

See more details on using hashes here.

Provenance

The following attestation bundles were made for zpybci-0.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on fredrikWHaug/zerostone

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zpybci-0.2.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: zpybci-0.2.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 635.4 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for zpybci-0.2.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c75b198072f658ca16b1b6b8eace2e5ed6436ba60b41c827aea4c84530d7dcc5
MD5 48617d02ec893b4c729a1386740589a2
BLAKE2b-256 3024311a75d0dd554df4fced4ea395b80893aa82b6fbda09609711a4736ef50d

See more details on using hashes here.

Provenance

The following attestation bundles were made for zpybci-0.2.0-cp38-abi3-win_amd64.whl:

Publisher: release.yml on fredrikWHaug/zerostone

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zpybci-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for zpybci-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2433216799d85acbb81ebe53219b28c6f0f9705669438704650a088c531370f0
MD5 907daadf845281434acf39593009d6ae
BLAKE2b-256 6a52a84e2b5e62e43b404ac6e7796206d3cb979a4c3da065244050436904c936

See more details on using hashes here.

Provenance

The following attestation bundles were made for zpybci-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on fredrikWHaug/zerostone

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zpybci-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for zpybci-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 faecea1e3080e435d0071f0e1985893e66147cf7f3be43558b8e0b2f9b24f9bc
MD5 269266a5d08b9868b2f81fb011d21019
BLAKE2b-256 cfbe42c6314089cfea5f571e060bdac12c68cb1eec46f6569ad40822565953c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for zpybci-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on fredrikWHaug/zerostone

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zpybci-0.2.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for zpybci-0.2.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 eaba2440f8fb9b6511cf114432e057c1abd1ee5943eb3c7ea26b5debafc4f38f
MD5 991043dc9046b584fbf2775f50f519b8
BLAKE2b-256 bf88bff37b50e709feaa5b8b0548aa3fd8abc23fb6cc0b395905dc3773d046db

See more details on using hashes here.

Provenance

The following attestation bundles were made for zpybci-0.2.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: release.yml on fredrikWHaug/zerostone

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page