tvboptim 0.2.0__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 (76) hide show
  1. tvboptim-0.2.0/LICENSE +278 -0
  2. tvboptim-0.2.0/PKG-INFO +157 -0
  3. tvboptim-0.2.0/README.md +114 -0
  4. tvboptim-0.2.0/pyproject.toml +103 -0
  5. tvboptim-0.2.0/setup.cfg +4 -0
  6. tvboptim-0.2.0/src/tvboptim/__init__.py +9 -0
  7. tvboptim-0.2.0/src/tvboptim/data/__init__.py +12 -0
  8. tvboptim-0.2.0/src/tvboptim/data/loaders.py +99 -0
  9. tvboptim-0.2.0/src/tvboptim/execution.py +268 -0
  10. tvboptim-0.2.0/src/tvboptim/experimental/__init__.py +15 -0
  11. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/__init__.py +28 -0
  12. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/core/__init__.py +6 -0
  13. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/core/bunch.py +67 -0
  14. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/core/network.py +686 -0
  15. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/coupling/__init__.py +22 -0
  16. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/coupling/base.py +1005 -0
  17. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/coupling/linear.py +466 -0
  18. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/coupling/subspace.py +509 -0
  19. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/coupling/tvb.py +202 -0
  20. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/dynamics/__init__.py +7 -0
  21. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/dynamics/base.py +541 -0
  22. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/dynamics/lorenz.py +207 -0
  23. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/dynamics/tvb/__init__.py +29 -0
  24. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/dynamics/tvb/coombes_byrne.py +154 -0
  25. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/dynamics/tvb/epileptor.py +200 -0
  26. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/dynamics/tvb/generic_2d_oscillator.py +149 -0
  27. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/dynamics/tvb/jansen_rit.py +158 -0
  28. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/dynamics/tvb/kuramoto.py +120 -0
  29. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/dynamics/tvb/larter_breakspear.py +221 -0
  30. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/dynamics/tvb/linear.py +111 -0
  31. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/dynamics/tvb/montbrio_pazo_roxin.py +137 -0
  32. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/dynamics/tvb/sup_hopf.py +131 -0
  33. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/dynamics/tvb/wilson_cowan.py +210 -0
  34. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/dynamics/tvb/wong_wang.py +124 -0
  35. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/dynamics/tvb/wong_wang_exc_inh.py +177 -0
  36. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/external_input/__init__.py +20 -0
  37. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/external_input/base.py +152 -0
  38. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/external_input/data.py +203 -0
  39. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/external_input/parametric.py +270 -0
  40. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/graph/__init__.py +14 -0
  41. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/graph/base.py +706 -0
  42. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/graph/sparse.py +885 -0
  43. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/graph/utils.py +0 -0
  44. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/noise/__init__.py +6 -0
  45. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/noise/base.py +162 -0
  46. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/noise/gaussian.py +71 -0
  47. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/result.py +78 -0
  48. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/solve.py +721 -0
  49. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/solvers/__init__.py +15 -0
  50. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/solvers/base.py +46 -0
  51. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/solvers/diffrax.py +63 -0
  52. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/solvers/native.py +308 -0
  53. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/utils/__init__.py +3 -0
  54. tvboptim-0.2.0/src/tvboptim/experimental/network_dynamics/utils/printer.py +555 -0
  55. tvboptim-0.2.0/src/tvboptim/model.py +111 -0
  56. tvboptim-0.2.0/src/tvboptim/observations/__init__.py +3 -0
  57. tvboptim-0.2.0/src/tvboptim/observations/observation.py +32 -0
  58. tvboptim-0.2.0/src/tvboptim/observations/tvb_monitors/__init__.py +11 -0
  59. tvboptim-0.2.0/src/tvboptim/observations/tvb_monitors/bold.py +290 -0
  60. tvboptim-0.2.0/src/tvboptim/observations/tvb_monitors/downsampling.py +185 -0
  61. tvboptim-0.2.0/src/tvboptim/optim/__init__.py +4 -0
  62. tvboptim-0.2.0/src/tvboptim/optim/callbacks.py +333 -0
  63. tvboptim-0.2.0/src/tvboptim/optim/optax.py +379 -0
  64. tvboptim-0.2.0/src/tvboptim/types/__init__.py +35 -0
  65. tvboptim-0.2.0/src/tvboptim/types/parameter.py +769 -0
  66. tvboptim-0.2.0/src/tvboptim/types/spaces.py +943 -0
  67. tvboptim-0.2.0/src/tvboptim/types/stateutils.py +109 -0
  68. tvboptim-0.2.0/src/tvboptim/utils/__init__.py +16 -0
  69. tvboptim-0.2.0/src/tvboptim/utils/caching.py +82 -0
  70. tvboptim-0.2.0/src/tvboptim/utils/utils.py +265 -0
  71. tvboptim-0.2.0/src/tvboptim.egg-info/PKG-INFO +157 -0
  72. tvboptim-0.2.0/src/tvboptim.egg-info/SOURCES.txt +74 -0
  73. tvboptim-0.2.0/src/tvboptim.egg-info/dependency_links.txt +1 -0
  74. tvboptim-0.2.0/src/tvboptim.egg-info/requires.txt +23 -0
  75. tvboptim-0.2.0/src/tvboptim.egg-info/top_level.txt +1 -0
  76. tvboptim-0.2.0/tests/test_execution.py +189 -0
tvboptim-0.2.0/LICENSE ADDED
@@ -0,0 +1,278 @@
1
+ Copyright © 2025 Charité Universitätsmedizin Berlin. This software is licensed under the terms of the European Union Public Licence (EUPL) version 1.2 or later.
2
+
3
+ ===============================================================================
4
+
5
+ European Union Public Licence
6
+ V. 1.2
7
+
8
+ EUPL © the European Union 2007, 2016
9
+
10
+ This European Union Public Licence (the ‘EUPL’) applies to the Work (as
11
+ defined below) which is provided under the terms of this Licence. Any use of
12
+ the Work, other than as authorised under this Licence is prohibited (to the
13
+ extent such use is covered by a right of the copyright holder of the Work).
14
+
15
+ The Work is provided under the terms of this Licence when the Licensor (as
16
+ defined below) has placed the following notice immediately following the
17
+ copyright notice for the Work: “Licensed under the EUPL”, or has expressed by
18
+ any other means his willingness to license under the EUPL.
19
+
20
+ 1. Definitions
21
+
22
+ In this Licence, the following terms have the following meaning:
23
+ — ‘The Licence’: this Licence.
24
+ — ‘The Original Work’: the work or software distributed or communicated by the
25
+ ‘Licensor under this Licence, available as Source Code and also as
26
+ ‘Executable Code as the case may be.
27
+ — ‘Derivative Works’: the works or software that could be created by the
28
+ ‘Licensee, based upon the Original Work or modifications thereof. This
29
+ ‘Licence does not define the extent of modification or dependence on the
30
+ ‘Original Work required in order to classify a work as a Derivative Work;
31
+ ‘this extent is determined by copyright law applicable in the country
32
+ ‘mentioned in Article 15.
33
+ — ‘The Work’: the Original Work or its Derivative Works.
34
+ — ‘The Source Code’: the human-readable form of the Work which is the most
35
+ convenient for people to study and modify.
36
+
37
+ — ‘The Executable Code’: any code which has generally been compiled and which
38
+ is meant to be interpreted by a computer as a program.
39
+ — ‘The Licensor’: the natural or legal person that distributes or communicates
40
+ the Work under the Licence.
41
+ — ‘Contributor(s)’: any natural or legal person who modifies the Work under
42
+ the Licence, or otherwise contributes to the creation of a Derivative Work.
43
+ — ‘The Licensee’ or ‘You’: any natural or legal person who makes any usage of
44
+ the Work under the terms of the Licence.
45
+ — ‘Distribution’ or ‘Communication’: any act of selling, giving, lending,
46
+ renting, distributing, communicating, transmitting, or otherwise making
47
+ available, online or offline, copies of the Work or providing access to its
48
+ essential functionalities at the disposal of any other natural or legal
49
+ person.
50
+
51
+ 2. Scope of the rights granted by the Licence
52
+
53
+ The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
54
+ sublicensable licence to do the following, for the duration of copyright
55
+ vested in the Original Work:
56
+
57
+ — use the Work in any circumstance and for all usage,
58
+ — reproduce the Work,
59
+ — modify the Work, and make Derivative Works based upon the Work,
60
+ — communicate to the public, including the right to make available or display
61
+ the Work or copies thereof to the public and perform publicly, as the case
62
+ may be, the Work,
63
+ — distribute the Work or copies thereof,
64
+ — lend and rent the Work or copies thereof,
65
+ — sublicense rights in the Work or copies thereof.
66
+
67
+ Those rights can be exercised on any media, supports and formats, whether now
68
+ known or later invented, as far as the applicable law permits so.
69
+
70
+ In the countries where moral rights apply, the Licensor waives his right to
71
+ exercise his moral right to the extent allowed by law in order to make
72
+ effective the licence of the economic rights here above listed.
73
+
74
+ The Licensor grants to the Licensee royalty-free, non-exclusive usage rights
75
+ to any patents held by the Licensor, to the extent necessary to make use of
76
+ the rights granted on the Work under this Licence.
77
+
78
+ 3. Communication of the Source Code
79
+
80
+ The Licensor may provide the Work either in its Source Code form, or as
81
+ Executable Code. If the Work is provided as Executable Code, the Licensor
82
+ provides in addition a machine-readable copy of the Source Code of the Work
83
+ along with each copy of the Work that the Licensor distributes or indicates,
84
+ in a notice following the copyright notice attached to the Work, a repository
85
+ where the Source Code is easily and freely accessible for as long as the
86
+ Licensor continues to distribute or communicate the Work.
87
+
88
+ 4. Limitations on copyright
89
+
90
+ Nothing in this Licence is intended to deprive the Licensee of the benefits
91
+ from any exception or limitation to the exclusive rights of the rights owners
92
+ in the Work, of the exhaustion of those rights or of other applicable
93
+ limitations thereto.
94
+
95
+ 5. Obligations of the Licensee
96
+
97
+ The grant of the rights mentioned above is subject to some restrictions and
98
+ obligations imposed on the Licensee. Those obligations are the following:
99
+
100
+ Attribution right: The Licensee shall keep intact all copyright, patent or
101
+ trademarks notices and all notices that refer to the Licence and to the
102
+ disclaimer of warranties. The Licensee must include a copy of such notices and
103
+ a copy of the Licence with every copy of the Work he/she distributes or
104
+ communicates. The Licensee must cause any Derivative Work to carry prominent
105
+ notices stating that the Work has been modified and the date of modification.
106
+
107
+ Copyleft clause: If the Licensee distributes or communicates copies of the
108
+ Original Works or Derivative Works, this Distribution or Communication will be
109
+ done under the terms of this Licence or of a later version of this Licence
110
+ unless the Original Work is expressly distributed only under this version of
111
+ the Licence — for example by communicating ‘EUPL v. 1.2 only’. The Licensee
112
+ (becoming Licensor) cannot offer or impose any additional terms or conditions
113
+ on the Work or Derivative Work that alter or restrict the terms of the
114
+ Licence.
115
+
116
+ Compatibility clause: If the Licensee Distributes or Communicates Derivative
117
+ Works or copies thereof based upon both the Work and another work licensed
118
+ under a Compatible Licence, this Distribution or Communication can be done
119
+ under the terms of this Compatible Licence. For the sake of this clause,
120
+ ‘Compatible Licence’ refers to the licences listed in the appendix attached to
121
+ this Licence. Should the Licensee's obligations under the Compatible Licence
122
+ conflict with his/her obligations under this Licence, the obligations of the
123
+ Compatible Licence shall prevail.
124
+
125
+ Provision of Source Code: When distributing or communicating copies of the
126
+ Work, the Licensee will provide a machine-readable copy of the Source Code or
127
+ indicate a repository where this Source will be easily and freely available
128
+ for as long as the Licensee continues to distribute or communicate the Work.
129
+
130
+ Legal Protection: This Licence does not grant permission to use the trade
131
+ names, trademarks, service marks, or names of the Licensor, except as required
132
+ for reasonable and customary use in describing the origin of the Work and
133
+ reproducing the content of the copyright notice.
134
+
135
+ 6. Chain of Authorship
136
+
137
+ The original Licensor warrants that the copyright in the Original Work granted
138
+ hereunder is owned by him/her or licensed to him/her and that he/she has the
139
+ power and authority to grant the Licence.
140
+
141
+ Each Contributor warrants that the copyright in the modifications he/she
142
+ brings to the Work are owned by him/her or licensed to him/her and that he/she
143
+ has the power and authority to grant the Licence.
144
+
145
+ Each time You accept the Licence, the original Licensor and subsequent
146
+ Contributors grant You a licence to their contributions to the Work, under the
147
+ terms of this Licence.
148
+
149
+ 7. Disclaimer of Warranty
150
+
151
+ The Work is a work in progress, which is continuously improved by numerous
152
+ Contributors. It is not a finished work and may therefore contain defects or
153
+ ‘bugs’ inherent to this type of development.
154
+
155
+ For the above reason, the Work is provided under the Licence on an ‘as is’
156
+ basis and without warranties of any kind concerning the Work, including
157
+ without limitation merchantability, fitness for a particular purpose, absence
158
+ of defects or errors, accuracy, non-infringement of intellectual property
159
+ rights other than copyright as stated in Article 6 of this Licence.
160
+
161
+ This disclaimer of warranty is an essential part of the Licence and a
162
+ condition for the grant of any rights to the Work.
163
+
164
+ 8. Disclaimer of Liability
165
+
166
+ Except in the cases of wilful misconduct or damages directly caused to natural
167
+ persons, the Licensor will in no event be liable for any direct or indirect,
168
+ material or moral, damages of any kind, arising out of the Licence or of the
169
+ use of the Work, including without limitation, damages for loss of goodwill,
170
+ work stoppage, computer failure or malfunction, loss of data or any commercial
171
+ damage, even if the Licensor has been advised of the possibility of such
172
+ damage. However, the Licensor will be liable under statutory product liability
173
+ laws as far such laws apply to the Work.
174
+
175
+ 9. Additional agreements
176
+
177
+ While distributing the Work, You may choose to conclude an additional
178
+ agreement, defining obligations or services consistent with this Licence.
179
+ However, if accepting obligations, You may act only on your own behalf and on
180
+ your sole responsibility, not on behalf of the original Licensor or any other
181
+ Contributor, and only if You agree to indemnify, defend, and hold each
182
+ Contributor harmless for any liability incurred by, or claims asserted against
183
+ such Contributor by the fact You have accepted any warranty or additional
184
+ liability.
185
+
186
+ 10. Acceptance of the Licence
187
+
188
+ The provisions of this Licence can be accepted by clicking on an icon ‘I
189
+ agree’ placed under the bottom of a window displaying the text of this Licence
190
+ or by affirming consent in any other similar way, in accordance with the rules
191
+ of applicable law. Clicking on that icon indicates your clear and irrevocable
192
+ acceptance of this Licence and all of its terms and conditions.
193
+
194
+ Similarly, you irrevocably accept this Licence and all of its terms and
195
+ conditions by exercising any rights granted to You by Article 2 of this
196
+ Licence, such as the use of the Work, the creation by You of a Derivative Work
197
+ or the Distribution or Communication by You of the Work or copies thereof.
198
+
199
+ 11. Information to the public
200
+
201
+ In case of any Distribution or Communication of the Work by means of
202
+ electronic communication by You (for example, by offering to download the Work
203
+ from a remote location) the distribution channel or media (for example, a
204
+ website) must at least provide to the public the information requested by the
205
+ applicable law regarding the Licensor, the Licence and the way it may be
206
+ accessible, concluded, stored and reproduced by the Licensee.
207
+
208
+ 12. Termination of the Licence
209
+
210
+ The Licence and the rights granted hereunder will terminate automatically upon
211
+ any breach by the Licensee of the terms of the Licence. Such a termination
212
+ will not terminate the licences of any person who has received the Work from
213
+ the Licensee under the Licence, provided such persons remain in full
214
+ compliance with the Licence.
215
+
216
+ 13. Miscellaneous
217
+
218
+ Without prejudice of Article 9 above, the Licence represents the complete
219
+ agreement between the Parties as to the Work.
220
+
221
+ If any provision of the Licence is invalid or unenforceable under applicable
222
+ law, this will not affect the validity or enforceability of the Licence as a
223
+ whole. Such provision will be construed or reformed so as necessary to make it
224
+ valid and enforceable.
225
+
226
+ The European Commission may publish other linguistic versions or new versions
227
+ of this Licence or updated versions of the Appendix, so far this is required
228
+ and reasonable, without reducing the scope of the rights granted by the
229
+ Licence. New versions of the Licence will be published with a unique version
230
+ number.
231
+
232
+ All linguistic versions of this Licence, approved by the European Commission,
233
+ have identical value. Parties can take advantage of the linguistic version of
234
+ their choice.
235
+
236
+ 14. Jurisdiction
237
+
238
+ Without prejudice to specific agreement between parties,
239
+ — any litigation resulting from the interpretation of this License, arising
240
+ between the European Union institutions, bodies, offices or agencies, as a
241
+ Licensor, and any Licensee, will be subject to the jurisdiction of the Court
242
+ of Justice of the European Union, as laid down in article 272 of the Treaty
243
+ on the Functioning of the European Union,
244
+ — any litigation arising between other parties and resulting from the
245
+ interpretation of this License, will be subject to the exclusive
246
+ jurisdiction of the competent court where the Licensor resides or conducts
247
+ its primary business.
248
+
249
+ 15. Applicable Law
250
+
251
+ Without prejudice to specific agreement between parties,
252
+ — this Licence shall be governed by the law of the European Union Member State
253
+ where the Licensor has his seat, resides or has his registered office,
254
+ — this licence shall be governed by Belgian law if the Licensor has no seat,
255
+ residence or registered office inside a European Union Member State.
256
+
257
+ Appendix
258
+
259
+ ‘Compatible Licences’ according to Article 5 EUPL are:
260
+ — GNU General Public License (GPL) v. 2, v. 3
261
+ — GNU Affero General Public License (AGPL) v. 3
262
+ — Open Software License (OSL) v. 2.1, v. 3.0
263
+ — Eclipse Public License (EPL) v. 1.0
264
+ — CeCILL v. 2.0, v. 2.1
265
+ — Mozilla Public Licence (MPL) v. 2
266
+ — GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
267
+ — Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
268
+ works other than software
269
+ — European Union Public Licence (EUPL) v. 1.1, v. 1.2
270
+ — Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or
271
+ Strong Reciprocity (LiLiQ-R+)
272
+
273
+ — The European Commission may update this Appendix to later versions of the
274
+ above licences without producing a new version of the EUPL, as long as they
275
+ provide the rights granted in Article 2 of this Licence and protect the
276
+ covered Source Code from exclusive appropriation.
277
+ — All other changes or additions to this Appendix require the production of a
278
+ new EUPL version.
@@ -0,0 +1,157 @@
1
+ Metadata-Version: 2.4
2
+ Name: tvboptim
3
+ Version: 0.2.0
4
+ Summary: Optimization tools for The Virtual Brain
5
+ Author-email: Marius Pille <marius.pille@bih-charite.de>
6
+ License-Expression: EUPL-1.2
7
+ Project-URL: Homepage, https://github.com/virtual-twin/tvboptim
8
+ Project-URL: Bug Tracker, https://github.com/virtual-twin/tvboptim/issues
9
+ Keywords: tvb,optimization,neuroscience,brain,virtual-brain,jax,neural-simulation
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
13
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Operating System :: OS Independent
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: optax
22
+ Requires-Dist: optimistix
23
+ Requires-Dist: matplotlib
24
+ Requires-Dist: numpy
25
+ Requires-Dist: pandas
26
+ Requires-Dist: jax<0.8
27
+ Requires-Dist: equinox
28
+ Requires-Dist: dill
29
+ Requires-Dist: tqdm
30
+ Requires-Dist: numpyro>=0.19.0
31
+ Requires-Dist: diffrax
32
+ Requires-Dist: plum-dispatch
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
35
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
36
+ Requires-Dist: ruff>=0.8.0; extra == "dev"
37
+ Requires-Dist: quartodoc>=0.6.0; extra == "dev"
38
+ Requires-Dist: jupyter>=1.0.0; extra == "dev"
39
+ Requires-Dist: ipykernel; extra == "dev"
40
+ Provides-Extra: docs
41
+ Requires-Dist: jupyter-cache>=1.0.1; extra == "docs"
42
+ Dynamic: license-file
43
+
44
+ <p align="center">
45
+ <img src="./docs/images/tvboptim.png" width="60%">
46
+ </p>
47
+
48
+ # TVB-Optim
49
+
50
+ [![Tests](https://github.com/virtual-twin/tvboptim/actions/workflows/python-package.yml/badge.svg)](https://github.com/virtual-twin/tvboptim/actions/workflows/python-package.yml)
51
+ [![codecov](https://codecov.io/gh/virtual-twin/tvboptim/branch/main/graph/badge.svg)](https://codecov.io/gh/virtual-twin/tvboptim)
52
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
53
+
54
+ [JAX](https://jax.readthedocs.io/en/latest/)-based framework for brain network simulation and gradient-based optimization.
55
+
56
+ **[Documentation](https://virtual-twin.github.io/tvboptim)** | **[Get Started](https://virtual-twin.github.io/tvboptim/get_started.html)** | **[Examples](https://virtual-twin.github.io/tvboptim/network_dynamics/network_dynamics.html)**
57
+
58
+ ## Key Features
59
+
60
+ - **Gradient-based optimization** - Fit thousands of parameters using automatic differentiation through the entire simulation pipeline
61
+ - **Performance** - JAX-powered with seamless GPU/TPU scaling
62
+ - **Flexible & extensible** - Build models with [Network Dynamics](https://virtual-twin.github.io/tvboptim/network_dynamics/network_dynamics.html), a composable framework for whole-brain modeling. Existing TVB workflows supported via [TVB-O](https://github.com/virtual-twin/tvbo).
63
+ - **Intuitive parameter control** - Mark values for optimization with [Parameter()](https://virtual-twin.github.io/tvboptim/parameters_and_optimization.html). Define exploration spaces with [Axes](https://virtual-twin.github.io/tvboptim/axes_and_spaces.html) for automatic parallel evaluation via JAX vmap/pmap.
64
+
65
+ ## Installation
66
+
67
+ **Requires Python 3.11 or above**
68
+
69
+ ```bash
70
+ # Using uv (recommended)
71
+ uv pip install tvboptim
72
+
73
+ # Using pip
74
+ pip install tvboptim
75
+ ```
76
+
77
+ ## Quick Example
78
+
79
+ ```python
80
+ import jax.numpy as jnp
81
+ from tvboptim.experimental.network_dynamics import Network, solve, prepare
82
+ from tvboptim.experimental.network_dynamics.dynamics.tvb import ReducedWongWang
83
+ from tvboptim.experimental.network_dynamics.coupling import LinearCoupling
84
+ from tvboptim.experimental.network_dynamics.graph import DenseDelayGraph
85
+ from tvboptim.observations.tvb_monitors import Bold
86
+ from tvboptim.observations import compute_fc, rmse
87
+ from tvboptim.optim import OptaxOptimizer
88
+ import optax
89
+
90
+ # Build brain network model
91
+ network = Network(
92
+ dynamics=ReducedWongWang(),
93
+ coupling={'delayed': LinearCoupling(incoming_states="S", G=0.5)},
94
+ graph=DenseDelayGraph(weights, delays)
95
+ )
96
+
97
+ # Run simulation
98
+ result = solve(network, Heun(), t0=0.0, t1=60_000.0, dt=1.0)
99
+
100
+ # Optimize coupling strength to match empirical functional connectivity
101
+ simulator, params = prepare(network, Heun(), t0=0.0, t1=60_000.0, dt=1.0)
102
+ bold_monitor = Bold(history=result, period=720.0)
103
+
104
+ def loss(params):
105
+ predicted_fc = compute_fc(bold_monitor(simulator(params)))
106
+ return rmse(predicted_fc, target_fc)
107
+
108
+ opt = OptaxOptimizer(loss, optax.adam(learning_rate=0.03))
109
+ final_params, history = opt.run(params, max_steps=50)
110
+ ```
111
+
112
+ See the [full example with visualization](https://virtual-twin.github.io/tvboptim/) in the documentation.
113
+
114
+ ## Documentation
115
+
116
+ - **[Get Started](https://virtual-twin.github.io/tvboptim/get_started.html)** - Introduction and basic workflows
117
+ - **[Network Dynamics](https://virtual-twin.github.io/tvboptim/network_dynamics/network_dynamics.html)** - Build differentiable brain network models
118
+ - **[Parameters & Optimization](https://virtual-twin.github.io/tvboptim/parameters_and_optimization.html)** - Gradient-based parameter inference
119
+ - **[API Reference](https://virtual-twin.github.io/tvboptim/reference/index.html)** - Complete API documentation
120
+
121
+ ## How It Works
122
+
123
+ **Functional Composition** - Models are composable functions that can be inspected, modified, and extended. Build complexity incrementally by wrapping functions.
124
+
125
+ **End-to-End Differentiability** - Compute gradients through the full pipeline: neural dynamics → hemodynamic models → empirical observables.
126
+
127
+ **Interoperability** - Convert existing TVB simulations to JAX-compatible functions via the TVB-O framework.
128
+
129
+ ## Contributing
130
+
131
+ We welcome contributions and questions from the community!
132
+
133
+ - **Report Issues**: [Open an issue](https://github.com/virtual-twin/tvboptim/issues)
134
+ - **Ask Questions**: [Start a discussion](https://github.com/virtual-twin/tvboptim/discussions)
135
+ - **Contribute Code**: [Open a pull request](https://github.com/virtual-twin/tvboptim/pulls)
136
+
137
+ ## Contact
138
+
139
+ Questions or want to collaborate? Reach out:
140
+
141
+ * marius.pille[at]bih-charite.de
142
+
143
+ ## Citation
144
+
145
+ If you use TVB-Optim in your research, please cite:
146
+
147
+ ```bibtex
148
+ @article{2025tvboptim,
149
+ title={Fast and Easy Whole-Brain Network Model Parameter Estimation with Automatic Differentiation},
150
+ author={Pille, Marius and Martin, Leon and Richter, Emilius and Perdikis, Dionysios and Schirner, Michael and Ritter, Petra},
151
+ journal={bioRxiv},
152
+ year={2025},
153
+ doi={10.1101/2025.11.18.689003}
154
+ }
155
+ ```
156
+
157
+ Copyright © 2025 Charité Universitätsmedizin Berlin
@@ -0,0 +1,114 @@
1
+ <p align="center">
2
+ <img src="./docs/images/tvboptim.png" width="60%">
3
+ </p>
4
+
5
+ # TVB-Optim
6
+
7
+ [![Tests](https://github.com/virtual-twin/tvboptim/actions/workflows/python-package.yml/badge.svg)](https://github.com/virtual-twin/tvboptim/actions/workflows/python-package.yml)
8
+ [![codecov](https://codecov.io/gh/virtual-twin/tvboptim/branch/main/graph/badge.svg)](https://codecov.io/gh/virtual-twin/tvboptim)
9
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
10
+
11
+ [JAX](https://jax.readthedocs.io/en/latest/)-based framework for brain network simulation and gradient-based optimization.
12
+
13
+ **[Documentation](https://virtual-twin.github.io/tvboptim)** | **[Get Started](https://virtual-twin.github.io/tvboptim/get_started.html)** | **[Examples](https://virtual-twin.github.io/tvboptim/network_dynamics/network_dynamics.html)**
14
+
15
+ ## Key Features
16
+
17
+ - **Gradient-based optimization** - Fit thousands of parameters using automatic differentiation through the entire simulation pipeline
18
+ - **Performance** - JAX-powered with seamless GPU/TPU scaling
19
+ - **Flexible & extensible** - Build models with [Network Dynamics](https://virtual-twin.github.io/tvboptim/network_dynamics/network_dynamics.html), a composable framework for whole-brain modeling. Existing TVB workflows supported via [TVB-O](https://github.com/virtual-twin/tvbo).
20
+ - **Intuitive parameter control** - Mark values for optimization with [Parameter()](https://virtual-twin.github.io/tvboptim/parameters_and_optimization.html). Define exploration spaces with [Axes](https://virtual-twin.github.io/tvboptim/axes_and_spaces.html) for automatic parallel evaluation via JAX vmap/pmap.
21
+
22
+ ## Installation
23
+
24
+ **Requires Python 3.11 or above**
25
+
26
+ ```bash
27
+ # Using uv (recommended)
28
+ uv pip install tvboptim
29
+
30
+ # Using pip
31
+ pip install tvboptim
32
+ ```
33
+
34
+ ## Quick Example
35
+
36
+ ```python
37
+ import jax.numpy as jnp
38
+ from tvboptim.experimental.network_dynamics import Network, solve, prepare
39
+ from tvboptim.experimental.network_dynamics.dynamics.tvb import ReducedWongWang
40
+ from tvboptim.experimental.network_dynamics.coupling import LinearCoupling
41
+ from tvboptim.experimental.network_dynamics.graph import DenseDelayGraph
42
+ from tvboptim.observations.tvb_monitors import Bold
43
+ from tvboptim.observations import compute_fc, rmse
44
+ from tvboptim.optim import OptaxOptimizer
45
+ import optax
46
+
47
+ # Build brain network model
48
+ network = Network(
49
+ dynamics=ReducedWongWang(),
50
+ coupling={'delayed': LinearCoupling(incoming_states="S", G=0.5)},
51
+ graph=DenseDelayGraph(weights, delays)
52
+ )
53
+
54
+ # Run simulation
55
+ result = solve(network, Heun(), t0=0.0, t1=60_000.0, dt=1.0)
56
+
57
+ # Optimize coupling strength to match empirical functional connectivity
58
+ simulator, params = prepare(network, Heun(), t0=0.0, t1=60_000.0, dt=1.0)
59
+ bold_monitor = Bold(history=result, period=720.0)
60
+
61
+ def loss(params):
62
+ predicted_fc = compute_fc(bold_monitor(simulator(params)))
63
+ return rmse(predicted_fc, target_fc)
64
+
65
+ opt = OptaxOptimizer(loss, optax.adam(learning_rate=0.03))
66
+ final_params, history = opt.run(params, max_steps=50)
67
+ ```
68
+
69
+ See the [full example with visualization](https://virtual-twin.github.io/tvboptim/) in the documentation.
70
+
71
+ ## Documentation
72
+
73
+ - **[Get Started](https://virtual-twin.github.io/tvboptim/get_started.html)** - Introduction and basic workflows
74
+ - **[Network Dynamics](https://virtual-twin.github.io/tvboptim/network_dynamics/network_dynamics.html)** - Build differentiable brain network models
75
+ - **[Parameters & Optimization](https://virtual-twin.github.io/tvboptim/parameters_and_optimization.html)** - Gradient-based parameter inference
76
+ - **[API Reference](https://virtual-twin.github.io/tvboptim/reference/index.html)** - Complete API documentation
77
+
78
+ ## How It Works
79
+
80
+ **Functional Composition** - Models are composable functions that can be inspected, modified, and extended. Build complexity incrementally by wrapping functions.
81
+
82
+ **End-to-End Differentiability** - Compute gradients through the full pipeline: neural dynamics → hemodynamic models → empirical observables.
83
+
84
+ **Interoperability** - Convert existing TVB simulations to JAX-compatible functions via the TVB-O framework.
85
+
86
+ ## Contributing
87
+
88
+ We welcome contributions and questions from the community!
89
+
90
+ - **Report Issues**: [Open an issue](https://github.com/virtual-twin/tvboptim/issues)
91
+ - **Ask Questions**: [Start a discussion](https://github.com/virtual-twin/tvboptim/discussions)
92
+ - **Contribute Code**: [Open a pull request](https://github.com/virtual-twin/tvboptim/pulls)
93
+
94
+ ## Contact
95
+
96
+ Questions or want to collaborate? Reach out:
97
+
98
+ * marius.pille[at]bih-charite.de
99
+
100
+ ## Citation
101
+
102
+ If you use TVB-Optim in your research, please cite:
103
+
104
+ ```bibtex
105
+ @article{2025tvboptim,
106
+ title={Fast and Easy Whole-Brain Network Model Parameter Estimation with Automatic Differentiation},
107
+ author={Pille, Marius and Martin, Leon and Richter, Emilius and Perdikis, Dionysios and Schirner, Michael and Ritter, Petra},
108
+ journal={bioRxiv},
109
+ year={2025},
110
+ doi={10.1101/2025.11.18.689003}
111
+ }
112
+ ```
113
+
114
+ Copyright © 2025 Charité Universitätsmedizin Berlin
@@ -0,0 +1,103 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "tvboptim"
7
+ version = "0.2.0"
8
+ description = "Optimization tools for The Virtual Brain"
9
+ readme = "README.md"
10
+ authors = [
11
+ {name = "Marius Pille", email = "marius.pille@bih-charite.de"},
12
+ ]
13
+ license = "EUPL-1.2"
14
+ license-files = ["LICENSE"]
15
+ keywords = ["tvb", "optimization", "neuroscience", "brain", "virtual-brain", "jax", "neural-simulation"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Science/Research",
19
+ "Topic :: Scientific/Engineering :: Medical Science Apps.",
20
+ "Topic :: Scientific/Engineering :: Bio-Informatics",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Operating System :: OS Independent",
25
+ ]
26
+ requires-python = ">=3.11"
27
+ dependencies = [
28
+ "optax",
29
+ "optimistix",
30
+ "matplotlib",
31
+ "numpy",
32
+ "pandas",
33
+ "jax<0.8",
34
+ "equinox",
35
+ "dill",
36
+ "tqdm",
37
+ "numpyro>=0.19.0",
38
+ "diffrax",
39
+ "plum-dispatch",
40
+ ]
41
+
42
+ [project.urls]
43
+ "Homepage" = "https://github.com/virtual-twin/tvboptim"
44
+ "Bug Tracker" = "https://github.com/virtual-twin/tvboptim/issues"
45
+
46
+ [tool.setuptools]
47
+ package-dir = {"" = "src"}
48
+
49
+ [tool.pytest.ini_options]
50
+ testpaths = ["tests"]
51
+ python_files = "test_*.py"
52
+ pythonpath = ["src"]
53
+
54
+ # uv-specific dependency groups for local development
55
+ [dependency-groups]
56
+ dev = [
57
+ "pytest>=7.0.0",
58
+ "pytest-cov>=4.0.0",
59
+ "ruff>=0.8.0",
60
+ "quartodoc>=0.6.0",
61
+ "jupyter>=1.0.0",
62
+ "ipykernel",
63
+ ]
64
+ docs = [
65
+ # "tvbo",
66
+ "jupyter-cache>=1.0.1",
67
+ ]
68
+
69
+ # Standard PEP 621 optional dependencies (used by PyPI)
70
+ [project.optional-dependencies]
71
+ dev = [
72
+ "pytest>=7.0.0",
73
+ "pytest-cov>=4.0.0",
74
+ "ruff>=0.8.0",
75
+ "quartodoc>=0.6.0",
76
+ "jupyter>=1.0.0",
77
+ "ipykernel",
78
+ ]
79
+ docs = [
80
+ # "tvbo", # Uncomment when published to PyPI
81
+ "jupyter-cache>=1.0.1",
82
+ ]
83
+
84
+ [tool.ruff]
85
+ line-length = 88
86
+ target-version = "py311"
87
+
88
+ [tool.ruff.format]
89
+ # Use Black-compatible formatting
90
+ quote-style = "double"
91
+ indent-style = "space"
92
+
93
+ [tool.ruff.lint]
94
+ # Enable pycodestyle (E), Pyflakes (F), and isort (I) rules
95
+ select = ["E", "F", "I"]
96
+ # Ignore line too long (E501) since formatter handles it
97
+ # F811: Ignore redefinition warnings (used by plum-dispatch for multiple dispatch)
98
+ # E741: Allow ambiguous variable names like 'I' (standard in neuroscience)
99
+ ignore = ["E501", "F811", "E741"]
100
+
101
+ [tool.ruff.lint.per-file-ignores]
102
+ # Allow imports after jax.config.update in tests
103
+ "tests/**/*.py" = ["E402"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,9 @@
1
+ """TVBOptim - Optimization tools for The Virtual Brain."""
2
+
3
+ __version__ = "0.1.0"
4
+
5
+ from . import data
6
+ from .model import jaxify
7
+ from .types import parameter, spaces
8
+
9
+ __all__ = ["spaces", "jaxify", "parameter", "data"]
@@ -0,0 +1,12 @@
1
+ """Data loading utilities for tvboptim.
2
+
3
+ This module provides convenient access to built-in connectivity and
4
+ functional connectivity datasets.
5
+ """
6
+
7
+ from .loaders import load_functional_connectivity, load_structural_connectivity
8
+
9
+ __all__ = [
10
+ "load_structural_connectivity",
11
+ "load_functional_connectivity",
12
+ ]