Skip to main content

TVB-Optim

Tests Python 3.11+ PyPI version Documentation

JAX-based framework for brain network simulation and gradient-based optimization.

Key Features

  • Gradient-based optimization: Fit thousands of parameters using automatic differentiation through the entire simulation pipeline
  • Performance: JAX-powered with seamless GPU/TPU scaling
  • Flexible & extensible: Build models with Network Dynamics, a composable framework for whole-brain modeling. Existing TVB workflows supported via TVB-O.
  • Intuitive parameter control: Mark values for optimization with Parameter(). Define exploration spaces with Axes for automatic parallel evaluation via JAX vmap/pmap.

Installation

Requires Python 3.11 or above

# Using uv (recommended)
uv pip install tvboptim

# Using pip
pip install tvboptim

Quick Example

import jax.numpy as jnp
from tvboptim.experimental.network_dynamics import Network, solve, prepare
from tvboptim.experimental.network_dynamics.dynamics.tvb import ReducedWongWang
from tvboptim.experimental.network_dynamics.coupling import LinearCoupling
from tvboptim.experimental.network_dynamics.graph import DenseDelayGraph
from tvboptim.observations.tvb_monitors import Bold
from tvboptim.observations import compute_fc, rmse
from tvboptim.optim import OptaxOptimizer
from tvboptim.types import Parameter
import optax

# Build brain network model
network = Network(
    dynamics=ReducedWongWang(),
    coupling={'delayed': LinearCoupling(incoming_states="S", G=Parameter(0.5))},
    graph=DenseDelayGraph(weights, delays)
)

# Run simulation
result = solve(network, Heun(), t0=0.0, t1=60_000.0, dt=1.0)

# Optimize coupling strength to match empirical functional connectivity
simulator, params = prepare(network, Heun(), t0=0.0, t1=60_000.0, dt=1.0)
bold_monitor = Bold(history=result, period=720.0)

def loss(params):
    predicted_fc = compute_fc(bold_monitor(simulator(params)))
    return rmse(predicted_fc, target_fc)

opt = OptaxOptimizer(loss, optax.adam(learning_rate=0.03))
final_params, history = opt.run(params, max_steps=50)

See the full example with visualization in the documentation or run it directly in Google Colab:

Documentation

Contributing

We welcome contributions and questions from the community!

Citation

If you use TVB-Optim in your research, please cite:

@article{2025tvboptim,
  title={Fast and Easy Whole-Brain Network Model Parameter Estimation with Automatic Differentiation},
  author={Pille, Marius and Martin, Leon and Richter, Emilius and Perdikis, Dionysios and Schirner, Michael and Ritter, Petra},
  journal={bioRxiv},
  year={2025},
  doi={10.1101/2025.11.18.689003}
}

Copyright © 2026 Charité Universitätsmedizin Berlin

Metadata

Release files for tvboptim 0.4.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 tvboptim 0.4.0
File Size Uploaded Provenance Actions
tvboptim-0.4.0.tar.gz 1.1 MB Without provenance Details for tvboptim-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tvboptim 0.4.0
File Interpreter ABI Platform Actions
tvboptim-0.4.0-py3-none-any.whl Python 3 none any Details for tvboptim-0.4.0-py3-none-any.whl

Total release size: 2.3 MB

Release files / tvboptim-0.4.0.tar.gz

Download URL tvboptim-0.4.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
94aed572bd3ad9a0566cc2ab44ab8f58bf3d7023daa5977e303f702d5c5fa5e7
BLAKE2b-256 checksum
How to use checksums
3a546be218e7cd178347ce79e6316ece73288b8b786653f3eea5f5f1e3072dec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / tvboptim-0.4.0-py3-none-any.whl

Download URL tvboptim-0.4.0-py3-none-any.whl
Size 1.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
18223f4a69a9fcef0b70f2d7d2ab534be07887326bbd136cac59d637a24d87e7
BLAKE2b-256 checksum
How to use checksums
8b9ca5b11baf86d42c07c956266ed402afe2afdd15b3a7549ff822bdda0b8c7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Security for tvboptim 0.4.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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