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.

Download files

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

Source Distribution

ecogpy-0.4.0.tar.gz (3.5 MB view details)

Uploaded Source

Built Distribution

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

ecogpy-0.4.0-py3-none-any.whl (3.1 MB view details)

Uploaded Python 3

File details

Details for the file ecogpy-0.4.0.tar.gz.

File metadata

  • Download URL: ecogpy-0.4.0.tar.gz
  • Upload date:
  • Size: 3.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for ecogpy-0.4.0.tar.gz
Algorithm Hash digest
SHA256 ee52d3e84d18a9707d77b5d4445f67f7f220aed5e1c829cfb92bef2812eaef8b
MD5 6de341cea8a0d38854458e3912551f86
BLAKE2b-256 bb2c7e20b225ba9f2fbfb3e61cb160434740f4d799462712f17da395a45a15e0

See more details on using hashes here.

File details

Details for the file ecogpy-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: ecogpy-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 3.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for ecogpy-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f21c34af8d07449239e21e4233eff52842bd57caffbf8be4eeabf61648796f32
MD5 26e742b4b5a5c68bd47da1860408cd11
BLAKE2b-256 2139bfe4e596732a55e62f5229f1948a56840779c9ee0c76299b781723639910

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.2.0

2 files

0.1.1

2 files

Supported by

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