Skip to main content

Python bindings for DDA (Delay Differential Analysis)

Project description

dda-py

Python bindings for DDA (Delay Differential Analysis).

The DDA binary is required. Please download the most recent version from the file server.

Installation

pip install dda-py

Optional dependencies:

pip install dda-py[mne]     # MNE-Python integration
pip install dda-py[pandas]  # DataFrame export
pip install dda-py[all]     # All optional deps

Quick Start (High-Level API)

import numpy as np
from dda_py import run_st

# Analyze a numpy array (n_channels x n_samples)
data = np.random.randn(3, 10000)
result = run_st(data, sfreq=256.0, delays=(7, 10), wl=200, ws=100)

print(result.coefficients.shape)   # (3, n_windows, 3)
print(result.n_channels)           # 3
print(result.n_windows)            # depends on data length
print(result.to_dataframe().head())

MNE-Python Integration

import mne
from dda_py import run_st

raw = mne.io.read_raw_edf("data.edf", preload=True)
result = run_st(raw, delays=(7, 10), wl=200, ws=100)
# sfreq is extracted automatically from the MNE Raw object

Cross-Timeseries Analysis

from dda_py import run_ct

data = np.random.randn(4, 10000)  # 4 channels
result = run_ct(data, sfreq=256.0, delays=(7, 10), wl=200, ws=100)
print(result.n_pairs)              # 6 (all unique pairs)
print(result.pair_labels)          # ['ch0-ch1', 'ch0-ch2', ...]

Dynamical Ergodicity

from dda_py import run_de

data = np.random.randn(2, 10000)
result = run_de(data, sfreq=256.0, delays=(7, 10), wl=200, ws=100)
print(result.ergodicity.shape)     # (n_windows,)

Low-Level API

For full control over the DDA binary:

from dda_py import DDARequest, DDARunner

runner = DDARunner()  # auto-discovers binary
request = DDARequest(
    file_path="data.edf",
    channels=[0, 1, 2],
    variants=["ST"],
    window_length=200,
    window_step=100,
    delays=[7, 10],
)
results = runner.run(request)

Model Encoding

Visualize what DDA model indices mean:

from dda_py import visualize_model_space, decode_model_encoding

# Show all monomials for 2 delays, polynomial order 4
print(visualize_model_space(2, 4, highlight_encoding=[1, 2, 10]))

# Decode model [1, 2, 10] to equation
print(decode_model_encoding([1, 2, 10], num_delays=2, polynomial_order=4, format="text"))
# dx/dt = a_1 x_1 + a_2 x_2 + a_3 x_1^4

CLI

dda --file data.edf --channels 0 1 2 --variants ST --wl 200 --ws 100
dda --file data.edf --channels 0 1 2 --variants ST CT --delays 7 10 -o results.json

Variants

  • ST - Single Timeseries
  • CT - Cross Timeseries
  • CD - Cross Dynamical
  • DE - Dynamical Ergodicity
  • SY - Synchrony

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dda_py-0.3.0.tar.gz (36.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dda_py-0.3.0-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file dda_py-0.3.0.tar.gz.

File metadata

  • Download URL: dda_py-0.3.0.tar.gz
  • Upload date:
  • Size: 36.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for dda_py-0.3.0.tar.gz
Algorithm Hash digest
SHA256 102063fc8a5b39867b57ac8fd83ef39aab62d1b1bfb3ab91729fcd7bfa46283f
MD5 dfcd6bcd745dbd18080ac91f735ac2c1
BLAKE2b-256 06737609a92319e9ddd7aec77b7294012703c7bb3a56c7d1a7b813a7fac0b3a7

See more details on using hashes here.

File details

Details for the file dda_py-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: dda_py-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for dda_py-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b2b656bc82607fdba4e3d7533a200447113834cd541b40659c20d437e90d4f7b
MD5 205dc43aa4f327d248fdfb75c52bbb30
BLAKE2b-256 c9084d87048bbd756266dbb0118bc7f0665dcbc68756382ca02b2defacfa7195

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page