Skip to main content

Interactive phase plane widget for neural mass models

Project description

Phase Plane Widget

Interactive phase plane widget for neural mass models, usable in Jupyter notebooks, VS Code, and static HTML exports.

📖 Full Documentation & Live Demos

🧪 Try the Custom Model Editor → — pre-loaded with the MPR (QIF) model; tweak equations and watch the phase plane update in real time.

Features

  • Interactive phase plane visualization with nullclines, vector field, fixed points, and trajectories
  • N-dimensional state space — project any 2 variables, clamp the rest with live sliders
  • Click-to-set initial conditions directly on the phase plane
  • Real-time time series display of all state variables
  • Stochastic integration — Stratonovich Heun with per-variable noise strength sliders
  • Parameter sweeps with bifurcation diagram visualization
  • Regime detection — automatically classifies dynamics as fixed point, limit cycle, or other
  • Custom models — define arbitrary ODEs in Python (SymPy), compile to JavaScript via inlined Nerdamer CAS
  • Standalone HTML — fully self-contained exports (no server, no kernel)

Installation

# Using uv
uv venv
uv pip install -e .

# Or using pip
pip install -e .

For development with Jupyter:

uv pip install -e ".[dev]"

Quick Start

Jupyter / VS Code — Built-in Models

from tvb_phaseplane import PhasePlaneWidget

widget = PhasePlaneWidget()
widget  # display interactive widget

Custom Model

from tvb_phaseplane import phase_plane

# Define any ODE system
pp = phase_plane(
    equations=["a*x - x**3 - y", "x - b*y"],
    state_vars={"x": (-3, 3), "y": (-3, 3)},
    params={"a": (0.7, 0, 2), "b": (0.8, 0, 2)},
)
pp  # Nerdamer-compiled, runs entirely in the browser

3-D Projection

pp = phase_plane(
    equations=["a*x - x**3 - y", "x - b*y", "c*(x - z)"],
    state_vars={"x": (-3, 3), "y": (-3, 3), "z": (0, 5)},
    params={"a": (0.7, 0, 2), "b": (0.8, 0, 2), "c": (10, 0, 20)},
    display=["x", "y"],  # project onto x-y plane
)

Stochastic Dynamics

pp = phase_plane(
    equations=["a*x - x**3 - y", "x - b*y"],
    state_vars={"x": (-3, 3), "y": (-3, 3)},
    params={"a": (0.7, 0, 2), "b": (0.8, 0, 2)},
    integrator="heun",
    noise_per_var=[0.1, 0.05],
)

Standalone HTML Export

from tvb_phaseplane import PhasePlaneWidget

widget = PhasePlaneWidget()
widget.to_standalone_html("widget.html", title="My Model")

The resulting .html file is fully self-contained — it bundles the Nerdamer CAS, all built-in models, the computation engine, CSS, and current widget state. Works in any modern browser with no Python runtime and no Jupyter kernel.

Built-in Models

Model State Vars Parameters Key Dynamics
Wilson-Cowan E, I aee, aei, aie, aii, Pe, Pi, ke, ki, thetae, thetai E-I population oscillations, bistability
FitzHugh-Nagumo v, w a, b, epsilon, I Excitable spiking, limit cycles
MPR (QIF) r, v delta, eta_bar, J, I Mean-field firing rate, macroscopic chaos

Architecture

  • Client-side computation — All ODE solving, fixed-point finding, and rendering runs in JavaScript (no server round-trips)
  • Nerdamer CAS inlined — ~100 KB minified core bundled into widget.js; custom SymPy models compile directly to JS
  • Dual-mode — Jupyter widget (anywidget) + fully self-contained HTML (to_standalone_html())
  • Safety guards — NaN/Inf short-circuit, 50K step budget, exp clamping ([-709, 709]), computation budgets on nullclines and fixed-point search

Documentation

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

tvb_phaseplane-0.1.0.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

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

tvb_phaseplane-0.1.0-py3-none-any.whl (225.1 kB view details)

Uploaded Python 3

File details

Details for the file tvb_phaseplane-0.1.0.tar.gz.

File metadata

  • Download URL: tvb_phaseplane-0.1.0.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tvb_phaseplane-0.1.0.tar.gz
Algorithm Hash digest
SHA256 672ffe2d89fa41004a96c91d767a66e3e5b468255fbf2bbbe052dbe4cf37e3bc
MD5 43a3aa5b77d86a11cba6b91fed9da058
BLAKE2b-256 7c216d056ebd20e41439f928838ca0051c4c2b132cb69e9a0dea4d6c32ab83af

See more details on using hashes here.

Provenance

The following attestation bundles were made for tvb_phaseplane-0.1.0.tar.gz:

Publisher: publish.yml on maedoc/trajecturtle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tvb_phaseplane-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tvb_phaseplane-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 225.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tvb_phaseplane-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 195064edc146a497aeac9fdf4d9023108fd120885e5d12a41a8e5eb86458233d
MD5 6e884a17d56a0015243036c3d744dcb7
BLAKE2b-256 5c66d39302fa21ea535a7734337faddb432fd8aad795c43d408ffb9f43384e0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for tvb_phaseplane-0.1.0-py3-none-any.whl:

Publisher: publish.yml on maedoc/trajecturtle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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