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.3.0

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.3.0
File Size Uploaded
pypte-1.3.0.tar.gz 38.6 kB Details

Built distribution (wheel)

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

Total release size: 66.6 kB

Release files / pypte-1.3.0.tar.gz

Download URL pypte-1.3.0.tar.gz
Size 38.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8b64a7e516e532aaec51760c231a6341b9bd1bbd4888052eeac24b67538ebbb2
BLAKE2b-256 checksum
How to use checksums
1b1a1a257a0fa04269a60e0bc169bd709d9ed0e3818b69268bb4beb34b111e9a
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.3.0-py3-none-any.whl

Download URL pypte-1.3.0-py3-none-any.whl
Size 27.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a9979295abb26d7d6958540917263b5b7b86b575b156e0551218cdfb69bc90d
BLAKE2b-256 checksum
How to use checksums
422a4a5753c55cb9039f3352873694409c81ded92b89c4408b5d8439500232d0
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

This release

1.3.0 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

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