Skip to main content

cogpy

Atomic, composable primitives for ECoG / iEEG signal processing.

Python 3.10+ License: MIT

Documentation · Repository

What it is

cogpy provides small, pure, domain-agnostic operators for electrophysiology signal processing. It is not a pipeline framework — high-level orchestration belongs in Snakemake pipelines, notebooks, or project repos.

Capability areas

Area Key functions
Event detection ThresholdDetector, BurstDetector, score_to_bouts
Event matching match_nearest, estimate_lag, estimate_drift
Triggered analysis perievent_epochs, triggered_average, estimate_template, subtract_template
Regression lagged_design_matrix, ols_fit, ols_residual
Spectral psd_multitaper, spectrogramx, band_power, ftest_line_scan
Spatial measures moran_i, gradient_anisotropy, csd_power
Filtering bandpassx, cmrx, gaussian_spatialx, zscorex
Validation snr_improvement, bandpower_change, residual_energy_ratio

Install

pip install ecogpy               # core dependencies only
pip install ecogpy[viz]          # + matplotlib, holoviews, panel
pip install ecogpy[all]          # all optional dependencies
pip install -e .                # editable dev install

Note: The PyPI package is ecogpy (because cogpy was taken), but the import name is cogpy: import cogpy.

Quick start

from cogpy.detect import ThresholdDetector
from cogpy.brainstates.intervals import perievent_epochs
from cogpy.triggered import estimate_template, subtract_template
from cogpy.spectral.psd import psd_multitaper
from cogpy.measures.comparison import bandpower_change

# Detect events
detector = ThresholdDetector(threshold=3.0, direction="positive")
catalog = detector.detect(signal)

# Extract epochs and estimate template
epochs = perievent_epochs(signal, catalog.df["t"].values, fs, pre=0.01, post=0.01)
template = estimate_template(epochs, method="median")

# Subtract and validate
cleaned = subtract_template(signal, event_samples, template.values)
psd_before, freqs = psd_multitaper(signal.values, fs)
psd_after, _ = psd_multitaper(cleaned.values, fs)
delta = bandpower_change(psd_before, psd_after, freqs, band=(100, 140))

Package structure

All subpackages live directly under cogpy/ — no indirection layers.

cogpy/
├── detect/          Event detection (threshold, burst, ripple)
├── events/          EventCatalog, matching, lag estimation
├── triggered/       Epoch extraction, triggered stats, template subtraction
├── regression/      Design matrices, OLS fit/predict/residual
├── spectral/        PSD, spectrogram, coherence, multitaper, features
├── measures/        Spatial, temporal, and comparison metrics
├── preprocess/      Filtering, bad channel detection, interpolation
├── decomposition/   PCA, varimax rotation
├── brainstates/     Perievent epochs, interval operations
├── plot/            Static (matplotlib) and interactive (HoloViews) viz
├── io/              File I/O for ECoG/iEEG formats
├── datasets/        Sample data loaders
├── cli/             CLI entry points
└── workflows/       Snakemake preprocessing pipelines

Development

make check          # format + lint + typecheck + tests
make format         # black .
make lint           # ruff check . --fix
make tests          # pytest
make docs           # build Sphinx docs
make build          # build sdist + wheel

Documentation

License

MIT — see LICENSE.

Metadata

Release files for ecogpy 0.4.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 ecogpy 0.4.0
File Size Uploaded Provenance Actions
ecogpy-0.4.0.tar.gz 3.5 MB Without provenance Details for ecogpy-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ecogpy 0.4.0
File Interpreter ABI Platform Actions
ecogpy-0.4.0-py3-none-any.whl Python 3 none any Details for ecogpy-0.4.0-py3-none-any.whl

Total release size: 6.6 MB

Release files / ecogpy-0.4.0.tar.gz

Download URL ecogpy-0.4.0.tar.gz
Size 3.5 MB
Tags Source
SHA-256 checksum
How to use checksums
ee52d3e84d18a9707d77b5d4445f67f7f220aed5e1c829cfb92bef2812eaef8b
BLAKE2b-256 checksum
How to use checksums
bb2c7e20b225ba9f2fbfb3e61cb160434740f4d799462712f17da395a45a15e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / ecogpy-0.4.0-py3-none-any.whl

Download URL ecogpy-0.4.0-py3-none-any.whl
Size 3.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
f21c34af8d07449239e21e4233eff52842bd57caffbf8be4eeabf61648796f32
BLAKE2b-256 checksum
How to use checksums
2139bfe4e596732a55e62f5229f1948a56840779c9ee0c76299b781723639910
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Security for ecogpy 0.4.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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