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.2.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.2.0
File Size Uploaded
pypte-1.2.0.tar.gz 36.1 kB Details

Built distribution (wheel)

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

Total release size: 62.1 kB

Release files / pypte-1.2.0.tar.gz

Download URL pypte-1.2.0.tar.gz
Size 36.1 kB
Tags Source
SHA-256 checksum
How to use checksums
834f0b81e9cc2ce56b477cce743e5cb1847959b2f468b106e1ac33c25c89ddac
BLAKE2b-256 checksum
How to use checksums
d4f6bdc6234bf6a2638b483e654cb2aaf703ec6f37043d1dece03dc67b5a0baf
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.2.0-py3-none-any.whl

Download URL pypte-1.2.0-py3-none-any.whl
Size 26.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c113a5ca83e16b0f8ccfdfb31430e3df6f75cc07fb36e14cc2678432fefcc2a3
BLAKE2b-256 checksum
How to use checksums
ebc2d59e611f35b8801b7b6e2a393848b79323e1eb0fbbaa2f0d8c43944ec55e
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

This release

1.2.0 This release

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