tvboptim 0.2.3__tar.gz → 0.2.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. {tvboptim-0.2.3/src/tvboptim.egg-info → tvboptim-0.2.5}/PKG-INFO +6 -21
  2. {tvboptim-0.2.3 → tvboptim-0.2.5}/README.md +4 -20
  3. {tvboptim-0.2.3 → tvboptim-0.2.5}/pyproject.toml +12 -1
  4. tvboptim-0.2.5/src/tvboptim/__init__.py +14 -0
  5. tvboptim-0.2.5/src/tvboptim/data/connectivity/dTOR/data.npz +0 -0
  6. tvboptim-0.2.5/src/tvboptim/data/connectivity/dk_average/data.npz +0 -0
  7. tvboptim-0.2.5/src/tvboptim/data/functional/dk_average/data.npz +0 -0
  8. tvboptim-0.2.5/src/tvboptim/data/plotting/dk_average/aparc+aseg-mni_09c.nii.gz +0 -0
  9. tvboptim-0.2.5/src/tvboptim/data/plotting/dk_average/fs_default.txt +104 -0
  10. tvboptim-0.2.5/src/tvboptim/data/plotting/dk_average/fs_default_freesurfer_idx.csv +88 -0
  11. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/__init__.py +1 -1
  12. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/__init__.py +1 -1
  13. tvboptim-0.2.5/src/tvboptim/experimental/network_dynamics/analysis/__init__.py +3 -0
  14. tvboptim-0.2.5/src/tvboptim/experimental/network_dynamics/analysis/lyapunov.py +173 -0
  15. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/core/network.py +16 -98
  16. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/coupling/__init__.py +9 -1
  17. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/coupling/base.py +33 -2
  18. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/coupling/subspace.py +235 -179
  19. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/result.py +49 -0
  20. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/solve.py +526 -103
  21. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/solvers/native.py +4 -2
  22. tvboptim-0.2.5/src/tvboptim/experimental/network_dynamics/utils/history.py +142 -0
  23. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/utils/printer.py +1 -1
  24. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/observations/observation.py +3 -1
  25. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/observations/tvb_monitors/bold.py +1 -1
  26. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/observations/tvb_monitors/downsampling.py +26 -3
  27. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/tvbo/prepare_experiment.py +3 -3
  28. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/types/__init__.py +1 -1
  29. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/types/parameter.py +1 -1
  30. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/types/spaces.py +1 -1
  31. {tvboptim-0.2.3 → tvboptim-0.2.5/src/tvboptim.egg-info}/PKG-INFO +6 -21
  32. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim.egg-info/SOURCES.txt +9 -0
  33. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim.egg-info/requires.txt +1 -0
  34. tvboptim-0.2.3/src/tvboptim/__init__.py +0 -9
  35. {tvboptim-0.2.3 → tvboptim-0.2.5}/LICENSE +0 -0
  36. {tvboptim-0.2.3 → tvboptim-0.2.5}/setup.cfg +0 -0
  37. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/data/__init__.py +0 -0
  38. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/data/loaders.py +0 -0
  39. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/execution.py +0 -0
  40. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/core/__init__.py +0 -0
  41. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/core/bunch.py +0 -0
  42. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/coupling/linear.py +0 -0
  43. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/coupling/tvb.py +0 -0
  44. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/dynamics/__init__.py +0 -0
  45. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/dynamics/base.py +0 -0
  46. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/dynamics/lorenz.py +0 -0
  47. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/__init__.py +0 -0
  48. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/coombes_byrne.py +0 -0
  49. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/epileptor.py +0 -0
  50. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/generic_2d_oscillator.py +0 -0
  51. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/jansen_rit.py +0 -0
  52. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/kuramoto.py +0 -0
  53. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/larter_breakspear.py +0 -0
  54. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/linear.py +0 -0
  55. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/montbrio_pazo_roxin.py +0 -0
  56. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/sup_hopf.py +0 -0
  57. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/wilson_cowan.py +0 -0
  58. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/wong_wang.py +0 -0
  59. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/wong_wang_exc_inh.py +0 -0
  60. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/external_input/__init__.py +0 -0
  61. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/external_input/base.py +0 -0
  62. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/external_input/data.py +0 -0
  63. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/external_input/parametric.py +0 -0
  64. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/graph/__init__.py +0 -0
  65. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/graph/base.py +0 -0
  66. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/graph/sparse.py +0 -0
  67. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/graph/utils.py +0 -0
  68. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/noise/__init__.py +0 -0
  69. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/noise/base.py +0 -0
  70. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/noise/gaussian.py +0 -0
  71. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/solvers/__init__.py +0 -0
  72. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/solvers/base.py +0 -0
  73. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/solvers/diffrax.py +0 -0
  74. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/experimental/network_dynamics/utils/__init__.py +0 -0
  75. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/observations/__init__.py +0 -0
  76. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/observations/tvb_monitors/__init__.py +0 -0
  77. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/optim/__init__.py +0 -0
  78. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/optim/callbacks.py +0 -0
  79. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/optim/optax.py +0 -0
  80. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/tvbo/__init__.py +0 -0
  81. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/types/stateutils.py +0 -0
  82. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/utils/__init__.py +0 -0
  83. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/utils/caching.py +0 -0
  84. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim/utils/utils.py +0 -0
  85. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim.egg-info/dependency_links.txt +0 -0
  86. {tvboptim-0.2.3 → tvboptim-0.2.5}/src/tvboptim.egg-info/top_level.txt +0 -0
  87. {tvboptim-0.2.3 → tvboptim-0.2.5}/tests/test_execution.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tvboptim
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: Optimization tools for The Virtual Brain
5
5
  Author-email: Marius Pille <marius.pille@bih-charite.de>
6
6
  License-Expression: EUPL-1.2
@@ -43,6 +43,7 @@ Requires-Dist: tvb-library; extra == "docs"
43
43
  Requires-Dist: jupyter-cache>=1.0.1; extra == "docs"
44
44
  Requires-Dist: nibabel; extra == "docs"
45
45
  Requires-Dist: nilearn; extra == "docs"
46
+ Requires-Dist: griffe<2.0.0; extra == "docs"
46
47
  Dynamic: license-file
47
48
 
48
49
  <p align="center">
@@ -55,13 +56,12 @@ Dynamic: license-file
55
56
  [![Ruff](https://github.com/virtual-twin/tvboptim/actions/workflows/ruff.yml/badge.svg)](https://github.com/virtual-twin/tvboptim/actions/workflows/ruff.yml)
56
57
  [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
57
58
  [![PyPI version](https://img.shields.io/pypi/v/tvboptim.svg)](https://pypi.org/project/tvboptim/)
59
+ [![Documentation](https://img.shields.io/badge/docs-online-brightgreen.svg)](https://virtual-twin.github.io/tvboptim)
58
60
  <!-- [![Downloads](https://img.shields.io/pypi/dm/tvboptim.svg)](https://pypi.org/project/tvboptim/) -->
59
61
  <!-- [![codecov](https://codecov.io/gh/virtual-twin/tvboptim/branch/main/graph/badge.svg)](https://codecov.io/gh/virtual-twin/tvboptim) -->
60
62
 
61
63
  [JAX](https://jax.readthedocs.io/en/latest/)-based framework for brain network simulation and gradient-based optimization.
62
64
 
63
- **[Documentation](https://virtual-twin.github.io/tvboptim)** | **[Get Started](https://virtual-twin.github.io/tvboptim/get_started.html)** | **[Network Dynamics](https://virtual-twin.github.io/tvboptim/network_dynamics/network_dynamics.html)**
64
-
65
65
  ## Key Features
66
66
 
67
67
  - **Gradient-based optimization:** Fit thousands of parameters using automatic differentiation through the entire simulation pipeline
@@ -116,23 +116,14 @@ opt = OptaxOptimizer(loss, optax.adam(learning_rate=0.03))
116
116
  final_params, history = opt.run(params, max_steps=50)
117
117
  ```
118
118
 
119
- See the [full example with visualization](https://virtual-twin.github.io/tvboptim/) in the documentation.
119
+ See the [full example with visualization](https://virtual-twin.github.io/tvboptim/) in the documentation or [run it directly in Google Colab](https://colab.research.google.com/github/virtual-twin/tvboptim/blob/main/docs/workflows/RWW.ipynb):
120
120
 
121
- ## Documentation
121
+ ## [Documentation](https://virtual-twin.github.io/tvboptim)
122
122
 
123
- - **[Get Started](https://virtual-twin.github.io/tvboptim/get_started.html)** - Introduction and basic workflows
124
- - **[Network Dynamics](https://virtual-twin.github.io/tvboptim/network_dynamics/network_dynamics.html)** - Build differentiable brain network models
123
+ - **[Network Dynamics](https://virtual-twin.github.io/tvboptim/network_dynamics/network_dynamics.html)** - Build differentiable brain network models in TVB-Optim
125
124
  - **[Parameters & Optimization](https://virtual-twin.github.io/tvboptim/parameters_and_optimization.html)** - Gradient-based parameter inference
126
125
  - **[API Reference](https://virtual-twin.github.io/tvboptim/reference/index.html)** - Complete API documentation
127
126
 
128
- ## How It Works
129
-
130
- **Functional Composition:** Models are composable functions that can be inspected, modified, and extended. Build complexity incrementally by wrapping functions.
131
-
132
- **End-to-End Differentiability:** Compute gradients through the full pipeline: neural dynamics → hemodynamic models → empirical observables.
133
-
134
- **Interoperability:** Convert existing TVB simulations to JAX-compatible functions via the TVB-O framework.
135
-
136
127
  ## Contributing
137
128
 
138
129
  We welcome contributions and questions from the community!
@@ -141,12 +132,6 @@ We welcome contributions and questions from the community!
141
132
  - **Ask Questions**: [Start a discussion](https://github.com/virtual-twin/tvboptim/discussions)
142
133
  - **Contribute Code**: [Open a pull request](https://github.com/virtual-twin/tvboptim/pulls)
143
134
 
144
- ## Contact
145
-
146
- Questions or want to collaborate? Reach out:
147
-
148
- * marius.pille[at]bih-charite.de
149
-
150
135
  ## Citation
151
136
 
152
137
  If you use TVB-Optim in your research, please cite:
@@ -8,13 +8,12 @@
8
8
  [![Ruff](https://github.com/virtual-twin/tvboptim/actions/workflows/ruff.yml/badge.svg)](https://github.com/virtual-twin/tvboptim/actions/workflows/ruff.yml)
9
9
  [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
10
10
  [![PyPI version](https://img.shields.io/pypi/v/tvboptim.svg)](https://pypi.org/project/tvboptim/)
11
+ [![Documentation](https://img.shields.io/badge/docs-online-brightgreen.svg)](https://virtual-twin.github.io/tvboptim)
11
12
  <!-- [![Downloads](https://img.shields.io/pypi/dm/tvboptim.svg)](https://pypi.org/project/tvboptim/) -->
12
13
  <!-- [![codecov](https://codecov.io/gh/virtual-twin/tvboptim/branch/main/graph/badge.svg)](https://codecov.io/gh/virtual-twin/tvboptim) -->
13
14
 
14
15
  [JAX](https://jax.readthedocs.io/en/latest/)-based framework for brain network simulation and gradient-based optimization.
15
16
 
16
- **[Documentation](https://virtual-twin.github.io/tvboptim)** | **[Get Started](https://virtual-twin.github.io/tvboptim/get_started.html)** | **[Network Dynamics](https://virtual-twin.github.io/tvboptim/network_dynamics/network_dynamics.html)**
17
-
18
17
  ## Key Features
19
18
 
20
19
  - **Gradient-based optimization:** Fit thousands of parameters using automatic differentiation through the entire simulation pipeline
@@ -69,23 +68,14 @@ opt = OptaxOptimizer(loss, optax.adam(learning_rate=0.03))
69
68
  final_params, history = opt.run(params, max_steps=50)
70
69
  ```
71
70
 
72
- See the [full example with visualization](https://virtual-twin.github.io/tvboptim/) in the documentation.
71
+ See the [full example with visualization](https://virtual-twin.github.io/tvboptim/) in the documentation or [run it directly in Google Colab](https://colab.research.google.com/github/virtual-twin/tvboptim/blob/main/docs/workflows/RWW.ipynb):
73
72
 
74
- ## Documentation
73
+ ## [Documentation](https://virtual-twin.github.io/tvboptim)
75
74
 
76
- - **[Get Started](https://virtual-twin.github.io/tvboptim/get_started.html)** - Introduction and basic workflows
77
- - **[Network Dynamics](https://virtual-twin.github.io/tvboptim/network_dynamics/network_dynamics.html)** - Build differentiable brain network models
75
+ - **[Network Dynamics](https://virtual-twin.github.io/tvboptim/network_dynamics/network_dynamics.html)** - Build differentiable brain network models in TVB-Optim
78
76
  - **[Parameters & Optimization](https://virtual-twin.github.io/tvboptim/parameters_and_optimization.html)** - Gradient-based parameter inference
79
77
  - **[API Reference](https://virtual-twin.github.io/tvboptim/reference/index.html)** - Complete API documentation
80
78
 
81
- ## How It Works
82
-
83
- **Functional Composition:** Models are composable functions that can be inspected, modified, and extended. Build complexity incrementally by wrapping functions.
84
-
85
- **End-to-End Differentiability:** Compute gradients through the full pipeline: neural dynamics → hemodynamic models → empirical observables.
86
-
87
- **Interoperability:** Convert existing TVB simulations to JAX-compatible functions via the TVB-O framework.
88
-
89
79
  ## Contributing
90
80
 
91
81
  We welcome contributions and questions from the community!
@@ -94,12 +84,6 @@ We welcome contributions and questions from the community!
94
84
  - **Ask Questions**: [Start a discussion](https://github.com/virtual-twin/tvboptim/discussions)
95
85
  - **Contribute Code**: [Open a pull request](https://github.com/virtual-twin/tvboptim/pulls)
96
86
 
97
- ## Contact
98
-
99
- Questions or want to collaborate? Reach out:
100
-
101
- * marius.pille[at]bih-charite.de
102
-
103
87
  ## Citation
104
88
 
105
89
  If you use TVB-Optim in your research, please cite:
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tvboptim"
7
- version = "0.2.3"
7
+ version = "0.2.5"
8
8
  description = "Optimization tools for The Virtual Brain"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -46,6 +46,15 @@ dependencies = [
46
46
  [tool.setuptools]
47
47
  package-dir = {"" = "src"}
48
48
 
49
+ [tool.setuptools.package-data]
50
+ tvboptim = [
51
+ "data/connectivity/*/data.npz",
52
+ "data/functional/*/data.npz",
53
+ "data/plotting/*/*.nii.gz",
54
+ "data/plotting/*/*.csv",
55
+ "data/plotting/*/*.txt",
56
+ ]
57
+
49
58
  [tool.pytest.ini_options]
50
59
  testpaths = ["tests"]
51
60
  python_files = "test_*.py"
@@ -67,6 +76,7 @@ docs = [
67
76
  "jupyter-cache>=1.0.1",
68
77
  "nibabel",
69
78
  "nilearn",
79
+ "griffe<2.0.0"
70
80
  ]
71
81
 
72
82
  # Standard PEP 621 optional dependencies (used by PyPI)
@@ -85,6 +95,7 @@ docs = [
85
95
  "jupyter-cache>=1.0.1",
86
96
  "nibabel",
87
97
  "nilearn",
98
+ "griffe<2.0.0"
88
99
  ]
89
100
 
90
101
  [tool.ruff]
@@ -0,0 +1,14 @@
1
+ """TVB-Optim - Optimization tools for The Virtual Brain."""
2
+
3
+ try:
4
+ from importlib.metadata import version
5
+
6
+ __version__ = version("tvboptim")
7
+ except Exception:
8
+ __version__ = "unknown"
9
+
10
+ from . import data
11
+ from .tvbo.prepare_experiment import HAS_TVBO, prepare
12
+ from .types import parameter, spaces
13
+
14
+ __all__ = ["spaces", "prepare", "HAS_TVBO", "parameter", "data"]
@@ -0,0 +1,104 @@
1
+ # Copyright (c) 2008-2024 the MRtrix3 contributors.
2
+ #
3
+ # This Source Code Form is subject to the terms of the Mozilla Public
4
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
+ #
7
+ # Covered Software is provided under this License on an "as is"
8
+ # basis, without warranty of any kind, either expressed, implied, or
9
+ # statutory, including, without limitation, warranties that the
10
+ # Covered Software is free of defects, merchantable, fit for a
11
+ # particular purpose or non-infringing.
12
+ # See the Mozilla Public License v. 2.0 for more details.
13
+ #
14
+ # For more details, see http://www.mrtrix.org/.
15
+
16
+ # Lookup table for extracting the relevant grey matter parcellations from the default FreeSurfer segmentation (desikan_killiany)
17
+
18
+ 0 ??? Unknown 0 0 0 0
19
+ 1 L.BSTS ctx-lh-bankssts 25 100 40 255
20
+ 2 L.CACG ctx-lh-caudalanteriorcingulate 125 100 160 255
21
+ 3 L.CMFG ctx-lh-caudalmiddlefrontal 100 25 0 255
22
+ 4 L.CU ctx-lh-cuneus 220 20 100 255
23
+ 5 L.EC ctx-lh-entorhinal 220 20 10 255
24
+ 6 L.FG ctx-lh-fusiform 180 220 140 255
25
+ 7 L.IPG ctx-lh-inferiorparietal 220 60 220 255
26
+ 8 L.ITG ctx-lh-inferiortemporal 180 40 120 255
27
+ 9 L.ICG ctx-lh-isthmuscingulate 140 20 140 255
28
+ 10 L.LOG ctx-lh-lateraloccipital 20 30 140 255
29
+ 11 L.LOFG ctx-lh-lateralorbitofrontal 35 75 50 255
30
+ 12 L.LG ctx-lh-lingual 225 140 140 255
31
+ 13 L.MOFG ctx-lh-medialorbitofrontal 200 35 75 255
32
+ 14 L.MTG ctx-lh-middletemporal 160 100 50 255
33
+ 15 L.PHIG ctx-lh-parahippocampal 20 220 60 255
34
+ 16 L.PaCG ctx-lh-paracentral 60 220 60 255
35
+ 17 L.POP ctx-lh-parsopercularis 220 180 140 255
36
+ 18 L.POR ctx-lh-parsorbitalis 20 100 50 255
37
+ 19 L.PTR ctx-lh-parstriangularis 220 60 20 255
38
+ 20 L.PCAL ctx-lh-pericalcarine 120 100 60 255
39
+ 21 L.PoCG ctx-lh-postcentral 220 20 20 255
40
+ 22 L.PCG ctx-lh-posteriorcingulate 220 180 220 255
41
+ 23 L.PrCG ctx-lh-precentral 60 20 220 255
42
+ 24 L.PCU ctx-lh-precuneus 160 140 180 255
43
+ 25 L.RACG ctx-lh-rostralanteriorcingulate 80 20 140 255
44
+ 26 L.RMFG ctx-lh-rostralmiddlefrontal 75 50 125 255
45
+ 27 L.SFG ctx-lh-superiorfrontal 20 220 160 255
46
+ 28 L.SPG ctx-lh-superiorparietal 20 180 140 255
47
+ 29 L.STG ctx-lh-superiortemporal 140 220 220 255
48
+ 30 L.SMG ctx-lh-supramarginal 80 160 20 255
49
+ 31 L.FP ctx-lh-frontalpole 100 0 100 255
50
+ 32 L.TP ctx-lh-temporalpole 70 70 70 255
51
+ 33 L.TTG ctx-lh-transversetemporal 150 150 200 255
52
+ 34 L.IN ctx-lh-insula 255 192 32 255
53
+ 35 L.CER Left-Cerebellum-Cortex 230 148 34 255
54
+ 36 L.TH Left-Thalamus 0 118 14 255
55
+ 36 L.TH Left-Thalamus-Proper 0 118 14 255
56
+ 37 L.CA Left-Caudate 122 186 220 255
57
+ 38 L.PU Left-Putamen 236 13 176 255
58
+ 39 L.PA Left-Pallidum 12 48 255 255
59
+ 40 L.HI Left-Hippocampus 220 216 20 255
60
+ 41 L.AM Left-Amygdala 103 255 255 255
61
+ 42 L.AC Left-Accumbens-area 255 165 0 255
62
+ 43 R.TH Right-Thalamus 0 118 14 255
63
+ 43 R.TH Right-Thalamus-Proper 0 118 14 255
64
+ 44 R.CA Right-Caudate 122 186 220 255
65
+ 45 R.PU Right-Putamen 236 13 176 255
66
+ 46 R.PA Right-Pallidum 13 48 255 255
67
+ 47 R.HI Right-Hippocampus 220 216 20 255
68
+ 48 R.AM Right-Amygdala 103 255 255 255
69
+ 49 R.AC Right-Accumbens-area 255 165 0 255
70
+ 50 R.BSTS ctx-rh-bankssts 25 100 40 255
71
+ 51 R.CACG ctx-rh-caudalanteriorcingulate 125 100 160 255
72
+ 52 R.CMFG ctx-rh-caudalmiddlefrontal 100 25 0 255
73
+ 53 R.CU ctx-rh-cuneus 220 20 100 255
74
+ 54 R.EC ctx-rh-entorhinal 220 20 10 255
75
+ 55 R.FG ctx-rh-fusiform 180 220 140 255
76
+ 56 R.IPG ctx-rh-inferiorparietal 220 60 220 255
77
+ 57 R.ITG ctx-rh-inferiortemporal 180 40 120 255
78
+ 58 R.ICG ctx-rh-isthmuscingulate 140 20 140 255
79
+ 59 R.LOG ctx-rh-lateraloccipital 20 30 140 255
80
+ 60 R.LOFG ctx-rh-lateralorbitofrontal 35 75 50 255
81
+ 61 R.LG ctx-rh-lingual 225 140 140 255
82
+ 62 R.MOFG ctx-rh-medialorbitofrontal 200 35 75 255
83
+ 63 R.MTG ctx-rh-middletemporal 160 100 50 255
84
+ 64 R.PHIG ctx-rh-parahippocampal 20 220 60 255
85
+ 65 R.PaCG ctx-rh-paracentral 60 220 60 255
86
+ 66 R.POP ctx-rh-parsopercularis 220 180 140 255
87
+ 67 R.POR ctx-rh-parsorbitalis 20 100 50 255
88
+ 68 R.PTR ctx-rh-parstriangularis 220 60 20 255
89
+ 69 R.PCAL ctx-rh-pericalcarine 120 100 60 255
90
+ 70 R.PoCG ctx-rh-postcentral 220 20 20 255
91
+ 71 R.PCG ctx-rh-posteriorcingulate 220 180 220 255
92
+ 72 R.PrCG ctx-rh-precentral 60 20 220 255
93
+ 73 R.PCU ctx-rh-precuneus 160 140 180 255
94
+ 74 R.RACG ctx-rh-rostralanteriorcingulate 80 20 140 255
95
+ 75 R.RMFG ctx-rh-rostralmiddlefrontal 75 50 125 255
96
+ 76 R.SFG ctx-rh-superiorfrontal 20 220 160 255
97
+ 77 R.SPG ctx-rh-superiorparietal 20 180 140 255
98
+ 78 R.STG ctx-rh-superiortemporal 140 220 220 255
99
+ 79 R.SMG ctx-rh-supramarginal 80 160 20 255
100
+ 80 R.FP ctx-rh-frontalpole 100 0 100 255
101
+ 81 R.TP ctx-rh-temporalpole 70 70 70 255
102
+ 82 R.TTG ctx-rh-transversetemporal 150 150 200 255
103
+ 83 R.IN ctx-rh-insula 255 192 32 255
104
+ 84 R.CER Right-Cerebellum-Cortex 230 148 34 255
@@ -0,0 +1,88 @@
1
+ acronym,label,r,g,b,a,freesurfer_idx
2
+ ???,Unknown,0,0,0,0,0
3
+ L.BSTS,ctx-lh-bankssts,25,100,40,255,1001
4
+ L.CACG,ctx-lh-caudalanteriorcingulate,125,100,160,255,1002
5
+ L.CMFG,ctx-lh-caudalmiddlefrontal,100,25,0,255,1003
6
+ L.CU,ctx-lh-cuneus,220,20,100,255,1005
7
+ L.EC,ctx-lh-entorhinal,220,20,10,255,1006
8
+ L.FG,ctx-lh-fusiform,180,220,140,255,1007
9
+ L.IPG,ctx-lh-inferiorparietal,220,60,220,255,1008
10
+ L.ITG,ctx-lh-inferiortemporal,180,40,120,255,1009
11
+ L.ICG,ctx-lh-isthmuscingulate,140,20,140,255,1010
12
+ L.LOG,ctx-lh-lateraloccipital,20,30,140,255,1011
13
+ L.LOFG,ctx-lh-lateralorbitofrontal,35,75,50,255,1012
14
+ L.LG,ctx-lh-lingual,225,140,140,255,1013
15
+ L.MOFG,ctx-lh-medialorbitofrontal,200,35,75,255,1014
16
+ L.MTG,ctx-lh-middletemporal,160,100,50,255,1015
17
+ L.PHIG,ctx-lh-parahippocampal,20,220,60,255,1016
18
+ L.PaCG,ctx-lh-paracentral,60,220,60,255,1017
19
+ L.POP,ctx-lh-parsopercularis,220,180,140,255,1018
20
+ L.POR,ctx-lh-parsorbitalis,20,100,50,255,1019
21
+ L.PTR,ctx-lh-parstriangularis,220,60,20,255,1020
22
+ L.PCAL,ctx-lh-pericalcarine,120,100,60,255,1021
23
+ L.PoCG,ctx-lh-postcentral,220,20,20,255,1022
24
+ L.PCG,ctx-lh-posteriorcingulate,220,180,220,255,1023
25
+ L.PrCG,ctx-lh-precentral,60,20,220,255,1024
26
+ L.PCU,ctx-lh-precuneus,160,140,180,255,1025
27
+ L.RACG,ctx-lh-rostralanteriorcingulate,80,20,140,255,1026
28
+ L.RMFG,ctx-lh-rostralmiddlefrontal,75,50,125,255,1027
29
+ L.SFG,ctx-lh-superiorfrontal,20,220,160,255,1028
30
+ L.SPG,ctx-lh-superiorparietal,20,180,140,255,1029
31
+ L.STG,ctx-lh-superiortemporal,140,220,220,255,1030
32
+ L.SMG,ctx-lh-supramarginal,80,160,20,255,1031
33
+ L.FP,ctx-lh-frontalpole,100,0,100,255,1032
34
+ L.TP,ctx-lh-temporalpole,70,70,70,255,1033
35
+ L.TTG,ctx-lh-transversetemporal,150,150,200,255,1034
36
+ L.IN,ctx-lh-insula,255,192,32,255,1035
37
+ L.CER,Left-Cerebellum-Cortex,230,148,34,255,8
38
+ L.TH,Left-Thalamus,0,118,14,255,10
39
+ L.TH,Left-Thalamus-Proper,0,118,14,255,10
40
+ L.CA,Left-Caudate,122,186,220,255,11
41
+ L.PU,Left-Putamen,236,13,176,255,12
42
+ L.PA,Left-Pallidum,12,48,255,255,13
43
+ L.HI,Left-Hippocampus,220,216,20,255,17
44
+ L.AM,Left-Amygdala,103,255,255,255,18
45
+ L.AC,Left-Accumbens-area,255,165,0,255,26
46
+ R.TH,Right-Thalamus,0,118,14,255,49
47
+ R.TH,Right-Thalamus-Proper,0,118,14,255,49
48
+ R.CA,Right-Caudate,122,186,220,255,50
49
+ R.PU,Right-Putamen,236,13,176,255,51
50
+ R.PA,Right-Pallidum,13,48,255,255,52
51
+ R.HI,Right-Hippocampus,220,216,20,255,53
52
+ R.AM,Right-Amygdala,103,255,255,255,54
53
+ R.AC,Right-Accumbens-area,255,165,0,255,58
54
+ R.BSTS,ctx-rh-bankssts,25,100,40,255,2001
55
+ R.CACG,ctx-rh-caudalanteriorcingulate,125,100,160,255,2002
56
+ R.CMFG,ctx-rh-caudalmiddlefrontal,100,25,0,255,2003
57
+ R.CU,ctx-rh-cuneus,220,20,100,255,2005
58
+ R.EC,ctx-rh-entorhinal,220,20,10,255,2006
59
+ R.FG,ctx-rh-fusiform,180,220,140,255,2007
60
+ R.IPG,ctx-rh-inferiorparietal,220,60,220,255,2008
61
+ R.ITG,ctx-rh-inferiortemporal,180,40,120,255,2009
62
+ R.ICG,ctx-rh-isthmuscingulate,140,20,140,255,2010
63
+ R.LOG,ctx-rh-lateraloccipital,20,30,140,255,2011
64
+ R.LOFG,ctx-rh-lateralorbitofrontal,35,75,50,255,2012
65
+ R.LG,ctx-rh-lingual,225,140,140,255,2013
66
+ R.MOFG,ctx-rh-medialorbitofrontal,200,35,75,255,2014
67
+ R.MTG,ctx-rh-middletemporal,160,100,50,255,2015
68
+ R.PHIG,ctx-rh-parahippocampal,20,220,60,255,2016
69
+ R.PaCG,ctx-rh-paracentral,60,220,60,255,2017
70
+ R.POP,ctx-rh-parsopercularis,220,180,140,255,2018
71
+ R.POR,ctx-rh-parsorbitalis,20,100,50,255,2019
72
+ R.PTR,ctx-rh-parstriangularis,220,60,20,255,2020
73
+ R.PCAL,ctx-rh-pericalcarine,120,100,60,255,2021
74
+ R.PoCG,ctx-rh-postcentral,220,20,20,255,2022
75
+ R.PCG,ctx-rh-posteriorcingulate,220,180,220,255,2023
76
+ R.PrCG,ctx-rh-precentral,60,20,220,255,2024
77
+ R.PCU,ctx-rh-precuneus,160,140,180,255,2025
78
+ R.RACG,ctx-rh-rostralanteriorcingulate,80,20,140,255,2026
79
+ R.RMFG,ctx-rh-rostralmiddlefrontal,75,50,125,255,2027
80
+ R.SFG,ctx-rh-superiorfrontal,20,220,160,255,2028
81
+ R.SPG,ctx-rh-superiorparietal,20,180,140,255,2029
82
+ R.STG,ctx-rh-superiortemporal,140,220,220,255,2030
83
+ R.SMG,ctx-rh-supramarginal,80,160,20,255,2031
84
+ R.FP,ctx-rh-frontalpole,100,0,100,255,2032
85
+ R.TP,ctx-rh-temporalpole,70,70,70,255,2033
86
+ R.TTG,ctx-rh-transversetemporal,150,150,200,255,2034
87
+ R.IN,ctx-rh-insula,255,192,32,255,2035
88
+ R.CER,Right-Cerebellum-Cortex,230,148,34,255,47
@@ -1,4 +1,4 @@
1
- """Experimental modules for TVBOptim.
1
+ """Experimental modules for TVB-Optim.
2
2
 
3
3
  This package contains experimental features and integrations that are under
4
4
  active development. APIs may change without notice.
@@ -1,6 +1,6 @@
1
1
  """Network Dynamics: JAX-based brain network modeling interface.
2
2
 
3
- Part of TVBOptim experimental modules.
3
+ Part of TVB-Optim experimental modules.
4
4
  """
5
5
 
6
6
  from .core import Bunch, Network
@@ -0,0 +1,3 @@
1
+ from .lyapunov import lyapunov, lyapunov_spectrum
2
+
3
+ __all__ = ["lyapunov", "lyapunov_spectrum"]
@@ -0,0 +1,173 @@
1
+ import jax
2
+ import jax.numpy as jnp
3
+ from ..solvers import Heun
4
+ from ..core.bunch import Bunch
5
+ from .. import prepare
6
+
7
+
8
+ def lyapunov(network, solver=None, t=1000.0, n=10, d0=1e-9, dt=0.1, t0=0.0):
9
+ """
10
+ Estimate the maximum Lyapunov exponent for a network.
11
+
12
+ Uses Benettin's rescaling algorithm: two nearby trajectories are
13
+ simulated for n segments of length t ms; their divergence rate is
14
+ averaged to estimate the MLE.
15
+
16
+ Parameters
17
+ ----------
18
+ network : Network
19
+ solver : solver instance, optional (default: Heun())
20
+ t : float — segment duration in ms
21
+ n : int — number of rescaling steps
22
+ d0 : float — initial perturbation magnitude
23
+ dt : float — integration timestep in ms
24
+ t0 : float — simulation start time
25
+
26
+ Returns
27
+ -------
28
+ float — estimated maximum Lyapunov exponent (1/ms)
29
+
30
+ Notes
31
+ -----
32
+ For networks with delayed coupling the delay history is held fixed
33
+ across segments (good approximation when t >> max_delay). Run a
34
+ warmup via network.update_history(result) before calling this
35
+ function to initialise the delay buffer from a settled trajectory.
36
+ """
37
+ if solver is None:
38
+ solver = Heun()
39
+ solve_fn, config = prepare(network, solver, t0=t0, t1=t0 + t, dt=dt)
40
+ return _lyapunov(solve_fn, config, t=t, n=n, d0=d0)
41
+
42
+
43
+ def _lyapunov(solve_fn, config, t, n=10, d0=1e-9):
44
+ """Low-level MLE estimation using a pre-built solve_fn / config."""
45
+ u_init = config.initial_state.dynamics # [n_states, n_nodes]
46
+ D = u_init.size
47
+ u2_init = u_init + d0 / jnp.sqrt(D)
48
+
49
+ def _solve_from(u):
50
+ new_is = Bunch({**config.initial_state, 'dynamics': u})
51
+ new_cfg = Bunch({**config, 'initial_state': new_is})
52
+ return solve_fn(new_cfg).ys[-1]
53
+
54
+ @jax.jit
55
+ def _scan(u1, u2):
56
+ def _step(carry, _):
57
+ u1, u2, log_sum = carry
58
+ new_u1 = _solve_from(u1)
59
+ new_u2 = _solve_from(u2)
60
+ d = jnp.sqrt(jnp.sum((new_u1 - new_u2) ** 2))
61
+ log_sum = log_sum + jnp.log(d / d0)
62
+ u2 = new_u1 + (new_u2 - new_u1) / (d / d0)
63
+ return (new_u1, u2, log_sum), None
64
+
65
+ init = (u1, u2, jnp.zeros(()))
66
+ (_, _, log_sum), _ = jax.lax.scan(_step, init, None, length=n)
67
+ return log_sum
68
+
69
+ log_sum = _scan(u_init, u2_init)
70
+ return float(log_sum / (n * t))
71
+
72
+
73
+ def lyapunov_spectrum(network, solver=None, t=1000.0, n=10, k=None,
74
+ dt=0.1, t0=0.0, mode="jvp", d0=1e-9):
75
+ """
76
+ Estimate the Lyapunov spectrum of a network.
77
+
78
+ Parameters
79
+ ----------
80
+ network : Network
81
+ solver : solver instance, optional (default: Heun())
82
+ t : float — segment duration in ms
83
+ n : int — number of rescaling steps
84
+ k : int — number of exponents to compute (default: all D)
85
+ dt : float — integration timestep in ms
86
+ t0 : float — simulation start time
87
+ mode : str — "jvp" (default) uses tangent-space propagation via
88
+ jax.linearize; exact and efficient for differentiable
89
+ systems. "sim" uses finite-difference with d0-scaled
90
+ perturbations; works for non-differentiable systems.
91
+ d0 : float — perturbation magnitude (only used when mode="sim")
92
+
93
+ Returns
94
+ -------
95
+ jnp.ndarray — top k Lyapunov exponents sorted descending (1/ms)
96
+ """
97
+ if solver is None:
98
+ solver = Heun()
99
+ solve_fn, config = prepare(network, solver, t0=t0, t1=t0 + t, dt=dt)
100
+ if mode == "jvp":
101
+ return _lyapunov_spectrum_jvp(solve_fn, config, t=t, n=n, k=k)
102
+ elif mode == "sim":
103
+ return _lyapunov_spectrum_sim(solve_fn, config, t=t, n=n, k=k, d0=d0)
104
+ else:
105
+ raise ValueError(f"Unknown mode {mode!r}, expected 'jvp' or 'sim'")
106
+
107
+
108
+ def _lyapunov_spectrum_sim(solve_fn, config, t, n=10, k=None, d0=1e-9):
109
+ """Spectrum via finite-difference (k+1 trajectories per step)."""
110
+ u_init = config.initial_state.dynamics
111
+ shape = u_init.shape
112
+ D = u_init.size
113
+ if k is None:
114
+ k = D
115
+ Q_init = jnp.eye(D, k) # [D, k] — first k columns of identity
116
+
117
+ def _solve_flat(u_flat):
118
+ u = u_flat.reshape(shape)
119
+ new_is = Bunch({**config.initial_state, 'dynamics': u})
120
+ new_cfg = Bunch({**config, 'initial_state': new_is})
121
+ return solve_fn(new_cfg).ys[-1].flatten()
122
+
123
+ @jax.jit
124
+ def _scan(u_flat, Q):
125
+ def _step(carry, _):
126
+ u_flat, Q, log_sum = carry
127
+ new_u = _solve_flat(u_flat)
128
+ perturbed = u_flat + d0 * Q.T # [k, D]
129
+ new_perturbed = jax.vmap(_solve_flat)(perturbed) # [k, D]
130
+ delta = (new_perturbed - new_u) / d0 # [k, D]
131
+ Q_new, R = jnp.linalg.qr(delta.T) # [D, k], [k, k]
132
+ log_sum = log_sum + jnp.log(jnp.abs(jnp.diag(R)))
133
+ return (new_u, Q_new, log_sum), None
134
+
135
+ init = (u_flat, Q, jnp.zeros(k))
136
+ (_, _, log_sum), _ = jax.lax.scan(_step, init, None, length=n)
137
+ return log_sum
138
+
139
+ log_sum = _scan(u_init.flatten(), Q_init)
140
+ return jnp.sort(log_sum / (n * t))[::-1]
141
+
142
+
143
+ def _lyapunov_spectrum_jvp(solve_fn, config, t, n=10, k=None):
144
+ """Spectrum via tangent-space propagation (linearize + vmap)."""
145
+ u_init = config.initial_state.dynamics
146
+ shape = u_init.shape
147
+ D = u_init.size
148
+ if k is None:
149
+ k = D
150
+ Q_init = jnp.eye(D, k) # [D, k]
151
+
152
+ def _solve_flat(u_flat):
153
+ u = u_flat.reshape(shape)
154
+ new_is = Bunch({**config.initial_state, 'dynamics': u})
155
+ new_cfg = Bunch({**config, 'initial_state': new_is})
156
+ return solve_fn(new_cfg).ys[-1].flatten()
157
+
158
+ @jax.jit
159
+ def _scan(u_flat, Q):
160
+ def _step(carry, _):
161
+ u_flat, Q, log_sum = carry
162
+ new_u, jvp_fn = jax.linearize(_solve_flat, u_flat)
163
+ tangents = jax.vmap(jvp_fn)(Q.T) # [k, D]
164
+ Q_new, R = jnp.linalg.qr(tangents.T) # [D, k], [k, k]
165
+ log_sum = log_sum + jnp.log(jnp.abs(jnp.diag(R)))
166
+ return (new_u, Q_new, log_sum), None
167
+
168
+ init = (u_flat, Q, jnp.zeros(k))
169
+ (_, _, log_sum), _ = jax.lax.scan(_step, init, None, length=n)
170
+ return log_sum
171
+
172
+ log_sum = _scan(u_init.flatten(), Q_init)
173
+ return jnp.sort(log_sum / (n * t))[::-1]