pyPTE: Phase Transfer Entropy in Python
pyPTE estimates directed connectivity between oscillatory signals: given
two channels of EEG, MEG or any rhythmic time series, it answers which one is
leading the other.
It is worth being precise about the claim, because it is narrower than it first appears:
pyPTE recovers the direction of information flow between a pair of signals. It does not recover the wiring diagram of a network.
Direction is reliable. Which connections are direct is not recoverable from a
bivariate measure, and what can fool it
shows exactly how that fails, with numbers. Every claim below is produced by a
script in examples/ that asserts its own result, so if something
here stops being true, the test suite says so.
Based on:
- Lobier et al., 2014: Phase transfer entropy: A novel phase-based measure for directed connectivity in networks coupled by oscillatory interactions
- Hillebrand et al., 2016: Direction of information flow in large-scale resting-state networks is frequency-dependent
Installation
pip install pyPTE # or: uv add pyPTE
The core needs only NumPy and SciPy. Adapters are optional:
pip install "pyPTE[mne]" # MNE-Python adapter (also installs pandas)
pip install "pyPTE[pandas]" # pandas adapter
Requires Python 3.11 or newer. Dependencies are deliberately unpinned at the top
end so pyPTE resolves alongside whatever NumPy and SciPy the rest of your
environment needs.
Quickstart
PTE takes an (n_channels, n_samples) array and returns two matrices, where
entry [i, j] describes flow from channel i to channel j.
import numpy as np
from pyPTE import PTE
rng = np.random.default_rng(0)
t = np.arange(8000) / 250.0
driver = np.sin(2 * np.pi * 10 * t) + 0.2 * rng.standard_normal(t.size)
target = 0.9 * np.roll(driver, 12) + 0.4 * rng.standard_normal(t.size)
dPTE, raw_PTE = PTE(np.vstack([driver, target]))
print(dPTE[0, 1]) # ~0.80 -> driver leads target
print(dPTE[1, 0]) # ~0.20 -> the reverse is suppressed
raw_PTE is transfer entropy in bits. dPTE is the direction-normalised form,
where dPTE[i, j] + dPTE[j, i] == 1: above 0.5 means net flow from i to
j, and exactly 0.5 means no preferred direction.
A raw dPTE value on its own is not a finding. See
running a real analysis.
Documentation
- Tutorial: the measure built up from phase histograms, figure by figure
- Running a real analysis: surrogate tests, epoched group tests, multiple comparisons
- What can fool it: unequal noise, indirect paths, symmetric coupling
- Examples and API reference
Contributing
Contributions are welcome — issues, suggestions and pull requests alike.
git clone https://github.com/patrk/pyPTE && cd pyPTE
uv sync --all-extras
uv run pytest
Before opening a PR: uv run ruff check ., uv run ruff format .,
uv run mypy pyPTE tests.
Citing
If pyPTE helps your research, please cite it. GitHub's "Cite this repository" button gives the details from CITATION.cff. Please also cite the papers that introduced the method:
- Lobier, Siebenhühner, Palva & Palva (2014). Phase transfer entropy: a novel phase-based measure for directed connectivity in networks coupled by oscillatory interactions. NeuroImage 85, 853–872. doi:10.1016/j.neuroimage.2013.08.056
- Hillebrand et al. (2016). Direction of information flow in large-scale resting-state networks is frequency-dependent. PNAS 113(14), 3867–3872. doi:10.1073/pnas.1515657113
License
pyPTE is released under GPL-3.0-or-later. See LICENSE.
Metadata
Release files for pyPTE 1.11.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 | |
|---|---|---|---|---|
| pypte-1.11.0.tar.gz | 62.3 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pypte-1.11.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 102.6 kB
Release files / pypte-1.11.0.tar.gz
| Download URL | pypte-1.11.0.tar.gz |
|---|---|
| Size | 62.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ecc650d5df09b0a4163e2f6b3fadf275d1ede156c30bc6252d32446ad0a46c8d
|
|
BLAKE2b-256 checksum How to use checksums |
74168912210aff3603026a2ddbe329c8deffdd7be38c365fd352e33d5fb48196
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logRelease files / pypte-1.11.0-py3-none-any.whl
| Download URL | pypte-1.11.0-py3-none-any.whl |
|---|---|
| Size | 40.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba51593fcf87e1d7120db40c8c3f5462738a4a0c763edbaf6df7d976c4182e6c
|
|
BLAKE2b-256 checksum How to use checksums |
0bd7e70cca70510e3299b0e252b38193c4f2983b963f327574e74720774c9c95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logSecurity for pyPTE 1.11.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pypte-1.11.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logA 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.