Derive a synthetic EMG from LFP via correlation of high-frequency activity (Schomburg et al. 2014).
Project description
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.
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 emg_from_lfp-0.1.0.tar.gz.
File metadata
- Download URL: emg_from_lfp-0.1.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f337e2e3514964a379f24d304dea8a52458711392b3ab8f8bdc6cdd93a2e365
|
|
| MD5 |
d1be0ad4b2c31fa3558414c9a87cc154
|
|
| BLAKE2b-256 |
0cc414d1019e03ce70a8555281a55ca6573be98eddb43d70b5cf483c690a556a
|
File details
Details for the file emg_from_lfp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: emg_from_lfp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9978c76b9952b851a178581e30c6940c8c6f17128abefec605299482e8779249
|
|
| MD5 |
6ecaab4a77973ebd90f510bbdec132bb
|
|
| BLAKE2b-256 |
ffe40a8faab9aad5e3a1842412f8c8e01eb2b01cd661af18349dc96f33de692a
|