emg_from_lfp
Derive a synthetic EMG from LFP (or any multichannel field-potential recording) by measuring the correlation of high-frequency activity across spatially separated channels in sliding windows. When channels share a common signal — e.g. EMG contamination during movement — their high-frequency activity co-varies, so this correlation tracks muscle tone without a dedicated EMG electrode. Useful as a movement/arousal proxy for sleep scoring.
This package originated as a self-contained port of the Buzsaki lab's
bz_EMGFromLFP.m, based on Erik Schomburg's method.
Further optimizations and extensions of the method have been added.
Citation
If you use this method, please cite:
Schomburg, E. W., et al. (2014). Theta phase segregation of input-specific gamma patterns in entorhinal-hippocampal networks. Neuron, 84(2), 470-485.
Install
pip install git+https://github.com/CSC-UW/emg_from_lfp.git
Usage
import numpy as np
from emg_from_lfp import compute, DEFAULTS
# lfp: (n_channels, n_samples), sf: sampling rate in Hz (must be > 2 * max(ws)).
both = compute(lfp, sf) # default method="both" -> dict
pw = compute(lfp, sf, method="per_window") # exact per-window correlation
gl = compute(lfp, sf, method="global") # fast amplitude-weighted approx.
print(DEFAULTS) # target_sf=20 Hz, window_size=25 s, band 300-600 Hz, ...
Methods
per_window— exact mean pairwise Pearson correlation, re-normalized within each window. Amplitude-independent, bounded to[-1, 1]. Numerically identical to the published method and reference implementation, but computed with an incremental sliding-window numba kernel (visits each sample O(1) times) for huge memory & compute gains.global— faster global-normalization approximation (a single boxcar moving average). Tracks the shape/ranking ofper_windowclosely but is amplitude-weighted and not bounded to[-1, 1]. Sometimes this is desirable, since the amplitude-weighting may carry information about the intensity of movement.both(default) — returns both as a dict; the band-pass filter (the dominant cost) is computed once and shared.
A (near-)constant channel within a window yields NaN for that window,
matching scipy.stats.pearsonr.
Metadata
Release files for emg_from_lfp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| emg_from_lfp-0.1.0.tar.gz | 7.9 kB | Without provenance | Details for emg_from_lfp-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| emg_from_lfp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for emg_from_lfp-0.1.0-py3-none-any.whl |
Total release size: 17.1 kB
Release files / emg_from_lfp-0.1.0.tar.gz
| Download URL | emg_from_lfp-0.1.0.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f337e2e3514964a379f24d304dea8a52458711392b3ab8f8bdc6cdd93a2e365
|
|
BLAKE2b-256 checksum How to use checksums |
0cc414d1019e03ce70a8555281a55ca6573be98eddb43d70b5cf483c690a556a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / emg_from_lfp-0.1.0-py3-none-any.whl
| Download URL | emg_from_lfp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9978c76b9952b851a178581e30c6940c8c6f17128abefec605299482e8779249
|
|
BLAKE2b-256 checksum How to use checksums |
ffe40a8faab9aad5e3a1842412f8c8e01eb2b01cd661af18349dc96f33de692a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for emg_from_lfp 0.1.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.