tvboptim 0.2.2__tar.gz → 0.2.4__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 (85) hide show
  1. {tvboptim-0.2.2/src/tvboptim.egg-info → tvboptim-0.2.4}/PKG-INFO +6 -21
  2. {tvboptim-0.2.2 → tvboptim-0.2.4}/README.md +4 -20
  3. {tvboptim-0.2.2 → tvboptim-0.2.4}/pyproject.toml +12 -3
  4. tvboptim-0.2.4/src/tvboptim/__init__.py +13 -0
  5. tvboptim-0.2.4/src/tvboptim/data/connectivity/dTOR/data.npz +0 -0
  6. tvboptim-0.2.4/src/tvboptim/data/connectivity/dk_average/data.npz +0 -0
  7. tvboptim-0.2.4/src/tvboptim/data/functional/dk_average/data.npz +0 -0
  8. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/data/loaders.py +8 -2
  9. tvboptim-0.2.4/src/tvboptim/data/plotting/dk_average/aparc+aseg-mni_09c.nii.gz +0 -0
  10. tvboptim-0.2.4/src/tvboptim/data/plotting/dk_average/fs_default.txt +104 -0
  11. tvboptim-0.2.4/src/tvboptim/data/plotting/dk_average/fs_default_freesurfer_idx.csv +88 -0
  12. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/__init__.py +1 -1
  13. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/__init__.py +1 -1
  14. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/core/network.py +13 -93
  15. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/coupling/__init__.py +6 -1
  16. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/coupling/base.py +400 -410
  17. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/coupling/subspace.py +239 -179
  18. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/solve.py +2 -2
  19. tvboptim-0.2.4/src/tvboptim/experimental/network_dynamics/utils/history.py +137 -0
  20. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/observations/observation.py +3 -1
  21. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/types/__init__.py +2 -1
  22. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/types/parameter.py +1 -1
  23. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/types/spaces.py +105 -3
  24. {tvboptim-0.2.2 → tvboptim-0.2.4/src/tvboptim.egg-info}/PKG-INFO +6 -21
  25. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim.egg-info/SOURCES.txt +7 -0
  26. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim.egg-info/requires.txt +1 -0
  27. tvboptim-0.2.2/src/tvboptim/__init__.py +0 -9
  28. {tvboptim-0.2.2 → tvboptim-0.2.4}/LICENSE +0 -0
  29. {tvboptim-0.2.2 → tvboptim-0.2.4}/setup.cfg +0 -0
  30. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/data/__init__.py +0 -0
  31. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/execution.py +0 -0
  32. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/core/__init__.py +0 -0
  33. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/core/bunch.py +0 -0
  34. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/coupling/linear.py +0 -0
  35. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/coupling/tvb.py +0 -0
  36. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/dynamics/__init__.py +0 -0
  37. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/dynamics/base.py +0 -0
  38. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/dynamics/lorenz.py +0 -0
  39. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/__init__.py +0 -0
  40. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/coombes_byrne.py +0 -0
  41. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/epileptor.py +0 -0
  42. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/generic_2d_oscillator.py +0 -0
  43. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/jansen_rit.py +0 -0
  44. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/kuramoto.py +0 -0
  45. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/larter_breakspear.py +0 -0
  46. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/linear.py +0 -0
  47. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/montbrio_pazo_roxin.py +0 -0
  48. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/sup_hopf.py +0 -0
  49. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/wilson_cowan.py +0 -0
  50. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/wong_wang.py +0 -0
  51. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/wong_wang_exc_inh.py +0 -0
  52. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/external_input/__init__.py +0 -0
  53. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/external_input/base.py +0 -0
  54. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/external_input/data.py +0 -0
  55. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/external_input/parametric.py +0 -0
  56. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/graph/__init__.py +0 -0
  57. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/graph/base.py +0 -0
  58. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/graph/sparse.py +0 -0
  59. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/graph/utils.py +0 -0
  60. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/noise/__init__.py +0 -0
  61. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/noise/base.py +0 -0
  62. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/noise/gaussian.py +0 -0
  63. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/result.py +0 -0
  64. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/solvers/__init__.py +0 -0
  65. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/solvers/base.py +0 -0
  66. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/solvers/diffrax.py +0 -0
  67. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/solvers/native.py +0 -0
  68. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/utils/__init__.py +0 -0
  69. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/experimental/network_dynamics/utils/printer.py +0 -0
  70. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/observations/__init__.py +0 -0
  71. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/observations/tvb_monitors/__init__.py +0 -0
  72. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/observations/tvb_monitors/bold.py +0 -0
  73. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/observations/tvb_monitors/downsampling.py +0 -0
  74. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/optim/__init__.py +0 -0
  75. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/optim/callbacks.py +0 -0
  76. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/optim/optax.py +0 -0
  77. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/tvbo/__init__.py +0 -0
  78. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/tvbo/prepare_experiment.py +0 -0
  79. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/types/stateutils.py +0 -0
  80. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/utils/__init__.py +0 -0
  81. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/utils/caching.py +0 -0
  82. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim/utils/utils.py +0 -0
  83. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim.egg-info/dependency_links.txt +0 -0
  84. {tvboptim-0.2.2 → tvboptim-0.2.4}/src/tvboptim.egg-info/top_level.txt +0 -0
  85. {tvboptim-0.2.2 → tvboptim-0.2.4}/tests/test_execution.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tvboptim
3
- Version: 0.2.2
3
+ Version: 0.2.4
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
@@ -38,6 +38,7 @@ Requires-Dist: quartodoc>=0.6.0; extra == "dev"
38
38
  Requires-Dist: jupyter>=1.0.0; extra == "dev"
39
39
  Requires-Dist: ipykernel; extra == "dev"
40
40
  Provides-Extra: docs
41
+ Requires-Dist: tvbo; extra == "docs"
41
42
  Requires-Dist: tvb-library; extra == "docs"
42
43
  Requires-Dist: jupyter-cache>=1.0.1; extra == "docs"
43
44
  Requires-Dist: nibabel; extra == "docs"
@@ -54,13 +55,12 @@ Dynamic: license-file
54
55
  [![Ruff](https://github.com/virtual-twin/tvboptim/actions/workflows/ruff.yml/badge.svg)](https://github.com/virtual-twin/tvboptim/actions/workflows/ruff.yml)
55
56
  [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
56
57
  [![PyPI version](https://img.shields.io/pypi/v/tvboptim.svg)](https://pypi.org/project/tvboptim/)
58
+ [![Documentation](https://img.shields.io/badge/docs-online-brightgreen.svg)](https://virtual-twin.github.io/tvboptim)
57
59
  <!-- [![Downloads](https://img.shields.io/pypi/dm/tvboptim.svg)](https://pypi.org/project/tvboptim/) -->
58
60
  <!-- [![codecov](https://codecov.io/gh/virtual-twin/tvboptim/branch/main/graph/badge.svg)](https://codecov.io/gh/virtual-twin/tvboptim) -->
59
61
 
60
62
  [JAX](https://jax.readthedocs.io/en/latest/)-based framework for brain network simulation and gradient-based optimization.
61
63
 
62
- **[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)**
63
-
64
64
  ## Key Features
65
65
 
66
66
  - **Gradient-based optimization:** Fit thousands of parameters using automatic differentiation through the entire simulation pipeline
@@ -115,23 +115,14 @@ opt = OptaxOptimizer(loss, optax.adam(learning_rate=0.03))
115
115
  final_params, history = opt.run(params, max_steps=50)
116
116
  ```
117
117
 
118
- See the [full example with visualization](https://virtual-twin.github.io/tvboptim/) in the documentation.
118
+ 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):
119
119
 
120
- ## Documentation
120
+ ## [Documentation](https://virtual-twin.github.io/tvboptim)
121
121
 
122
- - **[Get Started](https://virtual-twin.github.io/tvboptim/get_started.html)** - Introduction and basic workflows
123
- - **[Network Dynamics](https://virtual-twin.github.io/tvboptim/network_dynamics/network_dynamics.html)** - Build differentiable brain network models
122
+ - **[Network Dynamics](https://virtual-twin.github.io/tvboptim/network_dynamics/network_dynamics.html)** - Build differentiable brain network models in TVB-Optim
124
123
  - **[Parameters & Optimization](https://virtual-twin.github.io/tvboptim/parameters_and_optimization.html)** - Gradient-based parameter inference
125
124
  - **[API Reference](https://virtual-twin.github.io/tvboptim/reference/index.html)** - Complete API documentation
126
125
 
127
- ## How It Works
128
-
129
- **Functional Composition:** Models are composable functions that can be inspected, modified, and extended. Build complexity incrementally by wrapping functions.
130
-
131
- **End-to-End Differentiability:** Compute gradients through the full pipeline: neural dynamics → hemodynamic models → empirical observables.
132
-
133
- **Interoperability:** Convert existing TVB simulations to JAX-compatible functions via the TVB-O framework.
134
-
135
126
  ## Contributing
136
127
 
137
128
  We welcome contributions and questions from the community!
@@ -140,12 +131,6 @@ We welcome contributions and questions from the community!
140
131
  - **Ask Questions**: [Start a discussion](https://github.com/virtual-twin/tvboptim/discussions)
141
132
  - **Contribute Code**: [Open a pull request](https://github.com/virtual-twin/tvboptim/pulls)
142
133
 
143
- ## Contact
144
-
145
- Questions or want to collaborate? Reach out:
146
-
147
- * marius.pille[at]bih-charite.de
148
-
149
134
  ## Citation
150
135
 
151
136
  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.2"
7
+ version = "0.2.4"
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"
@@ -62,7 +71,7 @@ dev = [
62
71
  "ipykernel",
63
72
  ]
64
73
  docs = [
65
- # "tvbo",
74
+ "tvbo",
66
75
  "tvb-library",
67
76
  "jupyter-cache>=1.0.1",
68
77
  "nibabel",
@@ -80,7 +89,7 @@ dev = [
80
89
  "ipykernel",
81
90
  ]
82
91
  docs = [
83
- # "tvbo",
92
+ "tvbo",
84
93
  "tvb-library",
85
94
  "jupyter-cache>=1.0.1",
86
95
  "nibabel",
@@ -0,0 +1,13 @@
1
+ """TVB-Optim - Optimization tools for The Virtual Brain."""
2
+
3
+ try:
4
+ from importlib.metadata import version
5
+ __version__ = version("tvboptim")
6
+ except Exception:
7
+ __version__ = "unknown"
8
+
9
+ from . import data
10
+ from .tvbo.prepare_experiment import HAS_TVBO, prepare
11
+ from .types import parameter, spaces
12
+
13
+ __all__ = ["spaces", "prepare", "HAS_TVBO", "parameter", "data"]
@@ -6,8 +6,14 @@ from typing import List, Tuple
6
6
  import jax.numpy as jnp
7
7
  import numpy as np
8
8
 
9
- # Get the data directory
10
- _DATA_DIR = Path(__file__).parent
9
+ # Get the data directory - use importlib.resources for better compatibility
10
+ try:
11
+ from importlib.resources import files
12
+
13
+ _DATA_DIR = Path(str(files("tvboptim.data")))
14
+ except (TypeError, ModuleNotFoundError):
15
+ # Fallback for development without package installation
16
+ _DATA_DIR = Path(__file__).parent
11
17
 
12
18
 
13
19
  def load_structural_connectivity(
@@ -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
@@ -294,13 +294,15 @@ class Network:
294
294
 
295
295
  self._history = solution
296
296
 
297
- def prepare(self, dt: float) -> tuple[Bunch, Bunch]:
297
+ def prepare(self, dt: float, t0: float, t1: float) -> tuple[Bunch, Bunch]:
298
298
  """Prepare all couplings for simulation.
299
299
 
300
300
  Calls prepare() on each coupling to get coupling_data and coupling_state.
301
301
 
302
302
  Args:
303
303
  dt: Integration timestep
304
+ t0: Simulation start time
305
+ t1: Simulation end time
304
306
 
305
307
  Returns:
306
308
  coupling_data_dict: Bunch {name: coupling_data_bunch}
@@ -312,7 +314,7 @@ class Network:
312
314
  coupling_state_dict = Bunch()
313
315
 
314
316
  for name, coupling in self.couplings.items():
315
- data, state = coupling.prepare(self, dt)
317
+ data, state = coupling.prepare(self, dt, t0, t1)
316
318
  coupling_data_dict[name] = data
317
319
  coupling_state_dict[name] = state
318
320
 
@@ -550,97 +552,15 @@ class Network:
550
552
  History buffer [n_steps, n_states, n_nodes]
551
553
  where n_steps = ceil(max_delay / dt)
552
554
  """
553
- # Calculate required number of steps
554
- n_steps_needed = int(jnp.rint(self.max_delay / dt)) + 1
555
-
556
- # Get history data
557
- hist_ts = self._history.ts
558
- hist_ys = self._history.ys # [n_time, n_states, n_nodes]
559
-
560
- # Calculate history dt (assume uniform spacing)
561
- hist_dt = hist_ts[1] - hist_ts[0] if len(hist_ts) > 1 else dt
562
-
563
- # Check if we need interpolation (allow small numerical tolerance)
564
- needs_interpolation = jnp.abs(hist_dt - dt) > 1e-9
565
-
566
- # Calculate time coverage and check if we need padding
567
- time_coverage = hist_ts[-1] - hist_ts[0]
568
- needs_padding = time_coverage < self.max_delay
569
-
570
- if needs_padding:
571
- # Pad at the beginning with the first timestep
572
- n_steps_available = len(hist_ts)
573
- n_steps_to_pad = n_steps_needed - n_steps_available
574
-
575
- if n_steps_to_pad > 0:
576
- # Repeat first timestep
577
- first_state = hist_ys[0:1, :, :] # [1, n_states, n_nodes]
578
- padding = jnp.tile(first_state, (n_steps_to_pad, 1, 1))
579
-
580
- if needs_interpolation:
581
- # Interpolate available data, then pad
582
- interpolated = self._interpolate_history(
583
- hist_ts, hist_ys, n_steps_needed - n_steps_to_pad
584
- )
585
- return jnp.concatenate([padding, interpolated], axis=0)
586
- else:
587
- # Just pad and concatenate
588
- return jnp.concatenate([padding, hist_ys], axis=0)
589
- else:
590
- # We have enough data but warned in update_history
591
- # Extract what we need
592
- if needs_interpolation:
593
- return self._interpolate_history(hist_ts, hist_ys, n_steps_needed)
594
- else:
595
- return hist_ys[-n_steps_needed:]
596
- else:
597
- # Sufficient time coverage - extract last max_delay seconds
598
- if needs_interpolation:
599
- # Find the time window we need
600
- t_start = hist_ts[-1] - self.max_delay
601
- start_idx = jnp.searchsorted(hist_ts, t_start)
602
-
603
- # Extract and interpolate
604
- window_ts = hist_ts[start_idx:]
605
- window_ys = hist_ys[start_idx:]
606
-
607
- return self._interpolate_history(window_ts, window_ys, n_steps_needed)
608
- else:
609
- # No interpolation needed, just extract
610
- return hist_ys[-n_steps_needed:]
611
-
612
- def _interpolate_history(
613
- self, old_ts: jnp.ndarray, old_ys: jnp.ndarray, n_steps: int
614
- ) -> jnp.ndarray:
615
- """Interpolate history to match target dt.
616
-
617
- Args:
618
- old_ts: Original time points [n_time_old]
619
- old_ys: Original trajectory [n_time_old, n_states, n_nodes]
620
- n_steps: Number of steps needed in output
621
-
622
- Returns:
623
- Interpolated history [n_steps, n_states, n_nodes]
624
- """
625
- # Create new time grid
626
- new_ts = jnp.linspace(old_ts[0], old_ts[-1], n_steps)
627
-
628
- # Reshape for vectorized interpolation: [n_time, n_states * n_nodes]
629
- n_time_old, n_states, n_nodes = old_ys.shape
630
- old_ys_flat = old_ys.reshape(n_time_old, -1) # [n_time_old, n_states*n_nodes]
631
-
632
- # Interpolate each (state, node) combination
633
- # jnp.interp works on 1D, so we vmap over the second dimension
634
- def interp_1d(y_values):
635
- return jnp.interp(new_ts, old_ts, y_values)
636
-
637
- # Vectorize over all state-node combinations
638
- from jax import vmap
639
-
640
- new_ys_flat = vmap(interp_1d, in_axes=1, out_axes=1)(old_ys_flat)
641
-
642
- # Reshape back to [n_steps, n_states, n_nodes]
643
- return new_ys_flat.reshape(n_steps, n_states, n_nodes)
555
+ from ..utils.history import extract_history_window
556
+
557
+ return extract_history_window(
558
+ hist_ts=self._history.ts,
559
+ hist_ys=self._history.ys,
560
+ max_delay=self.max_delay,
561
+ dt=dt,
562
+ transform_fn=None, # No transformation for direct node history
563
+ )
644
564
 
645
565
  def get_history(self, dt: float) -> Optional[jnp.ndarray]:
646
566
  """Get history buffer for delayed coupling networks.
@@ -1,6 +1,6 @@
1
1
  """Coupling functions for network interactions."""
2
2
 
3
- from .base import AbstractCoupling
3
+ from .base import AbstractCoupling, BufferStrategy, DelayedCoupling, InstantaneousCoupling
4
4
  from .linear import (
5
5
  DelayedDifferenceCoupling,
6
6
  DelayedLinearCoupling,
@@ -9,9 +9,13 @@ from .linear import (
9
9
  LinearCoupling,
10
10
  )
11
11
  from .tvb import DelayedSigmoidalJansenRit, SigmoidalJansenRit
12
+ from .subspace import SubspaceCoupling
12
13
 
13
14
  __all__ = [
14
15
  "AbstractCoupling",
16
+ "InstantaneousCoupling",
17
+ "BufferStrategy",
18
+ "DelayedCoupling",
15
19
  "LinearCoupling",
16
20
  "DifferenceCoupling",
17
21
  "SigmoidalJansenRit",
@@ -19,4 +23,5 @@ __all__ = [
19
23
  "DelayedLinearCoupling",
20
24
  "DelayedDifferenceCoupling",
21
25
  "FastLinearCoupling",
26
+ "SubspaceCoupling",
22
27
  ]