Atomic, composable primitives for ECoG / iEEG signal processing
Project description
cogpy
Atomic, composable primitives for ECoG / iEEG signal processing.
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(becausecogpywas taken), but the import name iscogpy: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
- Primitive catalog — all operators with imports and signatures
- Package map — module tree overview
- Composition patterns — how to assemble primitives
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ecogpy-0.2.0.tar.gz.
File metadata
- Download URL: ecogpy-0.2.0.tar.gz
- Upload date:
- Size: 3.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f2e37fa4d12947a7ef824338b4c31c2332dbe89590bc0f8b288e5e7079e7001
|
|
| MD5 |
4935b9860d0e29943c4203df1765dc09
|
|
| BLAKE2b-256 |
a9e3c21eeae254e25d5216d789ad886b1bd97e17c94bf439cf6bb25a87c1037b
|
File details
Details for the file ecogpy-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ecogpy-0.2.0-py3-none-any.whl
- Upload date:
- Size: 3.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bc452de61a793d91ccf6a40fb71d869ee80e997f10e0954116b79087ff32696
|
|
| MD5 |
cff67acbb1b6b83324c9d0f3f7cbe49c
|
|
| BLAKE2b-256 |
9c212b94715a3be86e88ae500d412475fd16bdf2020e34264312edae5e3cdf03
|