Skip to main content

pyPTE: Phase Transfer Entropy in Python

pyPTE is an open-source Python implementation of the Phase Transfer Entropy method, designed to analyze directed connectivity in networks influenced by oscillatory interactions. This tool is inspired by the following foundational works:

Installation

pip install pyPTE          # or: uv add pyPTE

The core requires only NumPy and SciPy. The 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.

Quickstart

PTE takes an (n_channels, n_samples) array and returns two matrices, where entry [i, j] describes information 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 direction is suppressed

raw_PTE holds the transfer entropy in bits. dPTE is the direction-normalised form, where dPTE[i, j] + dPTE[j, i] == 1: values above 0.5 mean net flow from i to j, and 0.5 means no preferred direction.

Introduction

Phase Transfer Entropy (PTE) is a measure for directed connectivity in networks coupled by oscillatory interactions. The pyPTE library provides a Python implementation of this method, allowing researchers and developers to apply PTE analysis to their data.

Mathematical Background

The mathematical formulation of PTE can be described as follows:

Given two time series $X$ and $Y$, the PTE is defined as:

$$PTE_{X \to Y} = H(Y_{t+1} | Y_t) - H(Y_{t+1} | Y_t, X_t)$$

The PTE value quantifies the amount of uncertainty reduced in predicting the future phase of $Y$ when considering the current phase of $X$.

Contributing

Contributions to pyPTE are welcome! If you have suggestions, bug reports, or want to contribute code via Pull Requests

License

pyPTE is released under the GPL-3.0 license. For more details, see the LICENSE file.

Release files for pyPTE 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyPTE 1.0.1
File Size Uploaded
pypte-1.0.1.tar.gz 27.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyPTE 1.0.1
File Interpreter ABI Platform
pypte-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 48.8 kB

Release files / pypte-1.0.1.tar.gz

Download URL pypte-1.0.1.tar.gz
Size 27.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f236c269b55366aacf25a868c57069f7711cce47e444ebd14d7f349bdeda88e8
BLAKE2b-256 checksum
How to use checksums
0751b783eb3c35cf570e69ce0527a832000c9322fd9aeaa61e0cf6a8823e3627
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 Aug 1, 2026.

Transparency log

Release files / pypte-1.0.1-py3-none-any.whl

Download URL pypte-1.0.1-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b79a4164ad3712dc0ce4e1d7b1e3f63d03af34fac2c96bbf4c757563d66702f6
BLAKE2b-256 checksum
How to use checksums
6f8ae2b2dbc0758ec373e6c1f4dc2e44300d7003933075ee3d6734962efa9a6e
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 Aug 1, 2026.

Transparency log

Release history Release notifications | RSS feed

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page