vbi 0.1.3__cp310-cp310-manylinux2014_x86_64.whl
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.
- vbi/__init__.py +37 -0
- vbi/_version.py +17 -0
- vbi/dataset/__init__.py +0 -0
- vbi/dataset/connectivity_84/centers.txt +84 -0
- vbi/dataset/connectivity_84/centres.txt +84 -0
- vbi/dataset/connectivity_84/cortical.txt +84 -0
- vbi/dataset/connectivity_84/tract_lengths.txt +84 -0
- vbi/dataset/connectivity_84/weights.txt +84 -0
- vbi/dataset/connectivity_88/Aud_88.txt +88 -0
- vbi/dataset/connectivity_88/Bold.npz +0 -0
- vbi/dataset/connectivity_88/Labels.txt +17 -0
- vbi/dataset/connectivity_88/Region_labels.txt +88 -0
- vbi/dataset/connectivity_88/tract_lengths.txt +88 -0
- vbi/dataset/connectivity_88/weights.txt +88 -0
- vbi/feature_extraction/__init__.py +1 -0
- vbi/feature_extraction/calc_features.py +293 -0
- vbi/feature_extraction/features.json +535 -0
- vbi/feature_extraction/features.py +2124 -0
- vbi/feature_extraction/features_settings.py +374 -0
- vbi/feature_extraction/features_utils.py +1357 -0
- vbi/feature_extraction/infodynamics.jar +0 -0
- vbi/feature_extraction/utility.py +507 -0
- vbi/inference.py +98 -0
- vbi/models/__init__.py +0 -0
- vbi/models/cpp/__init__.py +0 -0
- vbi/models/cpp/_src/__init__.py +0 -0
- vbi/models/cpp/_src/__pycache__/mpr_sde.cpython-310.pyc +0 -0
- vbi/models/cpp/_src/_do.cpython-310-x86_64-linux-gnu.so +0 -0
- vbi/models/cpp/_src/_jr_sdde.cpython-310-x86_64-linux-gnu.so +0 -0
- vbi/models/cpp/_src/_jr_sde.cpython-310-x86_64-linux-gnu.so +0 -0
- vbi/models/cpp/_src/_km_sde.cpython-310-x86_64-linux-gnu.so +0 -0
- vbi/models/cpp/_src/_mpr_sde.cpython-310-x86_64-linux-gnu.so +0 -0
- vbi/models/cpp/_src/_vep.cpython-310-x86_64-linux-gnu.so +0 -0
- vbi/models/cpp/_src/_wc_ode.cpython-310-x86_64-linux-gnu.so +0 -0
- vbi/models/cpp/_src/bold.hpp +303 -0
- vbi/models/cpp/_src/do.hpp +167 -0
- vbi/models/cpp/_src/do.i +17 -0
- vbi/models/cpp/_src/do.py +467 -0
- vbi/models/cpp/_src/do_wrap.cxx +12811 -0
- vbi/models/cpp/_src/jr_sdde.hpp +352 -0
- vbi/models/cpp/_src/jr_sdde.i +19 -0
- vbi/models/cpp/_src/jr_sdde.py +688 -0
- vbi/models/cpp/_src/jr_sdde_wrap.cxx +18718 -0
- vbi/models/cpp/_src/jr_sde.hpp +264 -0
- vbi/models/cpp/_src/jr_sde.i +17 -0
- vbi/models/cpp/_src/jr_sde.py +470 -0
- vbi/models/cpp/_src/jr_sde_wrap.cxx +13406 -0
- vbi/models/cpp/_src/km_sde.hpp +158 -0
- vbi/models/cpp/_src/km_sde.i +19 -0
- vbi/models/cpp/_src/km_sde.py +671 -0
- vbi/models/cpp/_src/km_sde_wrap.cxx +17367 -0
- vbi/models/cpp/_src/makefile +52 -0
- vbi/models/cpp/_src/mpr_sde.hpp +327 -0
- vbi/models/cpp/_src/mpr_sde.i +19 -0
- vbi/models/cpp/_src/mpr_sde.py +711 -0
- vbi/models/cpp/_src/mpr_sde_wrap.cxx +18618 -0
- vbi/models/cpp/_src/utility.hpp +307 -0
- vbi/models/cpp/_src/vep.hpp +171 -0
- vbi/models/cpp/_src/vep.i +16 -0
- vbi/models/cpp/_src/vep.py +464 -0
- vbi/models/cpp/_src/vep_wrap.cxx +12968 -0
- vbi/models/cpp/_src/wc_ode.hpp +294 -0
- vbi/models/cpp/_src/wc_ode.i +19 -0
- vbi/models/cpp/_src/wc_ode.py +686 -0
- vbi/models/cpp/_src/wc_ode_wrap.cxx +24263 -0
- vbi/models/cpp/damp_oscillator.py +143 -0
- vbi/models/cpp/jansen_rit.py +543 -0
- vbi/models/cpp/km.py +187 -0
- vbi/models/cpp/mpr.py +289 -0
- vbi/models/cpp/vep.py +150 -0
- vbi/models/cpp/wc.py +216 -0
- vbi/models/cupy/__init__.py +0 -0
- vbi/models/cupy/bold.py +111 -0
- vbi/models/cupy/ghb.py +284 -0
- vbi/models/cupy/jansen_rit.py +473 -0
- vbi/models/cupy/km.py +224 -0
- vbi/models/cupy/mpr.py +475 -0
- vbi/models/cupy/mpr_modified_bold.py +12 -0
- vbi/models/cupy/utils.py +184 -0
- vbi/models/numba/__init__.py +0 -0
- vbi/models/numba/_ww_EI.py +444 -0
- vbi/models/numba/damp_oscillator.py +162 -0
- vbi/models/numba/ghb.py +208 -0
- vbi/models/numba/mpr.py +383 -0
- vbi/models/pytorch/__init__.py +0 -0
- vbi/models/pytorch/data/default_parameters.npz +0 -0
- vbi/models/pytorch/data/input/ROI_sim.mat +0 -0
- vbi/models/pytorch/data/input/fc_test.csv +68 -0
- vbi/models/pytorch/data/input/fc_train.csv +68 -0
- vbi/models/pytorch/data/input/fc_vali.csv +68 -0
- vbi/models/pytorch/data/input/fcd_test.mat +0 -0
- vbi/models/pytorch/data/input/fcd_test_high_window.mat +0 -0
- vbi/models/pytorch/data/input/fcd_test_low_window.mat +0 -0
- vbi/models/pytorch/data/input/fcd_train.mat +0 -0
- vbi/models/pytorch/data/input/fcd_vali.mat +0 -0
- vbi/models/pytorch/data/input/myelin.csv +68 -0
- vbi/models/pytorch/data/input/rsfc_gradient.csv +68 -0
- vbi/models/pytorch/data/input/run_label_testset.mat +0 -0
- vbi/models/pytorch/data/input/sc_test.csv +68 -0
- vbi/models/pytorch/data/input/sc_train.csv +68 -0
- vbi/models/pytorch/data/input/sc_vali.csv +68 -0
- vbi/models/pytorch/data/obs_kong0.npz +0 -0
- vbi/models/pytorch/ww_sde_kong.py +570 -0
- vbi/models/tvbk/__init__.py +9 -0
- vbi/models/tvbk/tvbk_wrapper.py +166 -0
- vbi/models/tvbk/utils.py +72 -0
- vbi/papers/__init__.py +0 -0
- vbi/papers/pavlides_pcb_2015/pavlides.py +211 -0
- vbi/tests/__init__.py +0 -0
- vbi/tests/_test_mpr_nb.py +36 -0
- vbi/tests/test_features.py +355 -0
- vbi/tests/test_ghb_cupy.py +90 -0
- vbi/tests/test_mpr_cupy.py +49 -0
- vbi/tests/test_mpr_numba.py +84 -0
- vbi/tests/test_suite.py +19 -0
- vbi/utils.py +402 -0
- vbi-0.1.3.dist-info/METADATA +166 -0
- vbi-0.1.3.dist-info/RECORD +121 -0
- vbi-0.1.3.dist-info/WHEEL +5 -0
- vbi-0.1.3.dist-info/licenses/LICENSE +201 -0
- vbi-0.1.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,294 @@
|
|
1
|
+
#ifndef WC_ODE_HPP_
|
2
|
+
#define WC_ODE_HPP_
|
3
|
+
|
4
|
+
#include <cmath>
|
5
|
+
#include <fenv.h>
|
6
|
+
#include <vector>
|
7
|
+
#include <random>
|
8
|
+
#include <string>
|
9
|
+
#include <assert.h>
|
10
|
+
#include <iostream>
|
11
|
+
#include <fstream>
|
12
|
+
#include "utility.hpp"
|
13
|
+
|
14
|
+
using std::string;
|
15
|
+
using std::vector;
|
16
|
+
|
17
|
+
typedef std::vector<double> dim1;
|
18
|
+
typedef std::vector<dim1> dim2;
|
19
|
+
typedef std::vector<unsigned int> dim1I;
|
20
|
+
typedef std::vector<dim1I> dim2I;
|
21
|
+
|
22
|
+
|
23
|
+
class WC_ode
|
24
|
+
{
|
25
|
+
private:
|
26
|
+
int N;
|
27
|
+
double dt;
|
28
|
+
double c_ee;
|
29
|
+
double c_ei;
|
30
|
+
double c_ie;
|
31
|
+
double c_ii;
|
32
|
+
double tau_e;
|
33
|
+
double tau_i;
|
34
|
+
double a_e;
|
35
|
+
double a_i;
|
36
|
+
double b_e;
|
37
|
+
double b_i;
|
38
|
+
double c_e;
|
39
|
+
double c_i;
|
40
|
+
double theta_i;
|
41
|
+
double theta_e;
|
42
|
+
double r_e;
|
43
|
+
double r_i;
|
44
|
+
double k_e;
|
45
|
+
double k_i;
|
46
|
+
double alpha_e;
|
47
|
+
double alpha_i;
|
48
|
+
double g_e;
|
49
|
+
double g_i;
|
50
|
+
double inv_tau_e;
|
51
|
+
double inv_tau_i;
|
52
|
+
size_t num_steps;
|
53
|
+
size_t index_cut;
|
54
|
+
dim1 P;
|
55
|
+
dim1 Q;
|
56
|
+
dim1 x0;
|
57
|
+
dim2 weights;
|
58
|
+
dim2I adjlist;
|
59
|
+
|
60
|
+
int fix_seed;
|
61
|
+
double t_end;
|
62
|
+
double t_cut;
|
63
|
+
|
64
|
+
vector<float> times;
|
65
|
+
vector<double> initial_state;
|
66
|
+
vector<vector<float>> states;
|
67
|
+
|
68
|
+
public:
|
69
|
+
WC_ode(
|
70
|
+
int N,
|
71
|
+
double dt,
|
72
|
+
dim1 P,
|
73
|
+
dim1 Q,
|
74
|
+
dim1 x0,
|
75
|
+
dim2 weights,
|
76
|
+
double t_end = 300.0,
|
77
|
+
double t_cut = 0.0,
|
78
|
+
double c_ee = 16.0,
|
79
|
+
double c_ei = 12.0,
|
80
|
+
double c_ie = 15.0,
|
81
|
+
double c_ii = 3.0,
|
82
|
+
double tau_e = 8.0,
|
83
|
+
double tau_i = 8.0,
|
84
|
+
double a_e = 1.3,
|
85
|
+
double a_i = 2.0,
|
86
|
+
double b_e = 4.0,
|
87
|
+
double b_i = 3.7,
|
88
|
+
double c_e = 1.0,
|
89
|
+
double c_i = 1.0,
|
90
|
+
double theta_i = 0.0,
|
91
|
+
double theta_e = 0.0,
|
92
|
+
double r_e = 1.0,
|
93
|
+
double r_i = 1.0,
|
94
|
+
double k_e = 0.994,
|
95
|
+
double k_i = 0.999,
|
96
|
+
double alpha_e = 1.0,
|
97
|
+
double alpha_i = 1.0,
|
98
|
+
double g_e = 0.0,
|
99
|
+
double g_i = 0.0,
|
100
|
+
int fix_seed = 0)
|
101
|
+
{
|
102
|
+
this->N = N;
|
103
|
+
this->dt = dt;
|
104
|
+
this->c_ee = c_ee;
|
105
|
+
this->c_ei = c_ei;
|
106
|
+
this->c_ie = c_ie;
|
107
|
+
this->c_ii = c_ii;
|
108
|
+
this->tau_e = tau_e;
|
109
|
+
this->tau_i = tau_i;
|
110
|
+
this->a_e = a_e;
|
111
|
+
this->a_i = a_i;
|
112
|
+
this->b_e = b_e;
|
113
|
+
this->b_i = b_i;
|
114
|
+
this->c_e = c_e;
|
115
|
+
this->c_i = c_i;
|
116
|
+
this->theta_i = theta_i;
|
117
|
+
this->theta_e = theta_e;
|
118
|
+
this->r_e = r_e;
|
119
|
+
this->r_i = r_i;
|
120
|
+
this->k_e = k_e;
|
121
|
+
this->k_i = k_i;
|
122
|
+
this->alpha_e = alpha_e;
|
123
|
+
this->alpha_i = alpha_i;
|
124
|
+
this->g_e = g_e;
|
125
|
+
this->g_i = g_i;
|
126
|
+
this->weights = weights;
|
127
|
+
this->P = P;
|
128
|
+
this->Q = Q;
|
129
|
+
this->x0 = x0;
|
130
|
+
|
131
|
+
inv_tau_e = 1.0 / tau_e;
|
132
|
+
inv_tau_i = 1.0 / tau_i;
|
133
|
+
|
134
|
+
adjlist = adjmat_to_adjlist(weights);
|
135
|
+
num_steps = int(t_end / dt);
|
136
|
+
index_cut = int(t_cut / dt);
|
137
|
+
size_t buffer_size = num_steps - index_cut;
|
138
|
+
times.resize(buffer_size);
|
139
|
+
states.resize(buffer_size);
|
140
|
+
for (size_t i = 0; i < buffer_size; ++i)
|
141
|
+
states[i].resize(2 * N);
|
142
|
+
}
|
143
|
+
|
144
|
+
double sigmoid(const double x,
|
145
|
+
const double a,
|
146
|
+
const double b,
|
147
|
+
const double c)
|
148
|
+
{
|
149
|
+
return c / (1.0 + exp(-a * (x - b)));
|
150
|
+
}
|
151
|
+
|
152
|
+
void rhs(const dim1 &y,
|
153
|
+
dim1 &dydt,
|
154
|
+
const double dt)
|
155
|
+
{
|
156
|
+
dim1 lc_e(N);
|
157
|
+
dim1 lc_i(N);
|
158
|
+
double thr = 1e-6;
|
159
|
+
if (std::abs(g_e) > thr)
|
160
|
+
lc_e = matvec(weights, y, 0);
|
161
|
+
if (std::abs(g_i) > thr)
|
162
|
+
lc_i = matvec(weights, y, N);
|
163
|
+
|
164
|
+
for (int i = 0; i < N; ++i)
|
165
|
+
{
|
166
|
+
double x_e = alpha_e * (c_ee * y[i] - c_ei * y[i + N] + P[i] - theta_e + g_e * lc_e[i]);
|
167
|
+
double x_i = alpha_i * (c_ie * y[i] - c_ii * y[i + N] + Q[i] - theta_i + g_i * lc_i[i]);
|
168
|
+
double s_e = sigmoid(x_e, a_e, b_e, c_e);
|
169
|
+
double s_i = sigmoid(x_i, a_i, b_i, c_i);
|
170
|
+
dydt[i] = inv_tau_e * (-y[i] + (k_e - r_e * y[i]) * s_e);
|
171
|
+
dydt[i + N] = inv_tau_i * (-y[i + N] + (k_i - r_i * y[i + N]) * s_i);
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
void euler_step(dim1 &y, const double dt)
|
176
|
+
{
|
177
|
+
|
178
|
+
dim1 dydt(2 * N);
|
179
|
+
rhs(y, dydt, dt);
|
180
|
+
for (int i = 0; i < 2 * N; ++i)
|
181
|
+
y[i] += dt * dydt[i];
|
182
|
+
}
|
183
|
+
|
184
|
+
void eulerIntegrate()
|
185
|
+
{
|
186
|
+
size_t nc = 2 * N;
|
187
|
+
dim1 dy(nc);
|
188
|
+
dim1 y(nc);
|
189
|
+
|
190
|
+
y = x0;
|
191
|
+
for (size_t i = 0; i < index_cut; ++i)
|
192
|
+
euler_step(y, dt);
|
193
|
+
|
194
|
+
size_t ind = 0;
|
195
|
+
for (size_t i = index_cut; i < num_steps; ++i)
|
196
|
+
{
|
197
|
+
euler_step(y, dt);
|
198
|
+
times[ind] = i * dt;
|
199
|
+
for (size_t j = 0; j < 2 * N; ++j)
|
200
|
+
states[ind][j] = y[j];
|
201
|
+
ind++;
|
202
|
+
}
|
203
|
+
}
|
204
|
+
|
205
|
+
void heun_step(dim1 &y, const double dt)
|
206
|
+
{
|
207
|
+
dim1 dydt(2 * N);
|
208
|
+
dim1 tmp(2 * N);
|
209
|
+
rhs(y, dydt, dt);
|
210
|
+
for (size_t i = 0; i < 2 * N; ++i)
|
211
|
+
tmp[i] = y[i] + dt * dydt[i];
|
212
|
+
rhs(tmp, dydt, dt);
|
213
|
+
for (size_t i = 0; i < 2 * N; ++i)
|
214
|
+
y[i] += 0.5 * dt * (dydt[i] + dydt[i]);
|
215
|
+
}
|
216
|
+
|
217
|
+
void heunIntegrate()
|
218
|
+
{
|
219
|
+
size_t nc = 2 * N;
|
220
|
+
dim1 dy(nc);
|
221
|
+
dim1 y(nc);
|
222
|
+
|
223
|
+
y = x0;
|
224
|
+
for (size_t i = 0; i < index_cut; ++i)
|
225
|
+
heun_step(y, dt);
|
226
|
+
|
227
|
+
size_t ind = 0;
|
228
|
+
for (size_t i = index_cut; i < num_steps; ++i)
|
229
|
+
{
|
230
|
+
heun_step(y, dt);
|
231
|
+
times[ind] = i * dt;
|
232
|
+
for (size_t j = 0; j < 2 * N; ++j)
|
233
|
+
states[ind][j] = y[j];
|
234
|
+
ind++;
|
235
|
+
}
|
236
|
+
}
|
237
|
+
|
238
|
+
void rk4_step(dim1 &y, const double dt)
|
239
|
+
{
|
240
|
+
dim1 dydt(2 * N);
|
241
|
+
dim1 tmp(2 * N);
|
242
|
+
dim1 k1(2 * N);
|
243
|
+
dim1 k2(2 * N);
|
244
|
+
dim1 k3(2 * N);
|
245
|
+
dim1 k4(2 * N);
|
246
|
+
double dt_over_6 = dt / 6.0;
|
247
|
+
|
248
|
+
rhs(y, k1, dt);
|
249
|
+
for (size_t i = 0; i < 2 * N; ++i)
|
250
|
+
tmp[i] = y[i] + 0.5 * dt * k1[i];
|
251
|
+
rhs(tmp, k2, dt);
|
252
|
+
for (size_t i = 0; i < 2 * N; ++i)
|
253
|
+
tmp[i] = y[i] + 0.5 * dt * k2[i];
|
254
|
+
rhs(tmp, k3, dt);
|
255
|
+
for (size_t i = 0; i < 2 * N; ++i)
|
256
|
+
tmp[i] = y[i] + dt * k3[i];
|
257
|
+
rhs(tmp, k4, dt);
|
258
|
+
for (size_t i = 0; i < 2 * N; ++i)
|
259
|
+
y[i] += dt_over_6 * (k1[i] + 2.0 * k2[i] + 2.0 * k3[i] + k4[i]);
|
260
|
+
}
|
261
|
+
|
262
|
+
void rk4Integrate()
|
263
|
+
{
|
264
|
+
size_t nc = 2 * N;
|
265
|
+
dim1 dy(nc);
|
266
|
+
dim1 y(nc);
|
267
|
+
|
268
|
+
y = x0;
|
269
|
+
for (size_t i = 0; i < index_cut; ++i)
|
270
|
+
rk4_step(y, dt);
|
271
|
+
|
272
|
+
size_t ind = 0;
|
273
|
+
for (size_t i = index_cut; i < num_steps; ++i)
|
274
|
+
{
|
275
|
+
rk4_step(y, dt);
|
276
|
+
times[ind] = i * dt;
|
277
|
+
for (size_t j = 0; j < 2 * N; ++j)
|
278
|
+
states[ind][j] = y[j];
|
279
|
+
ind++;
|
280
|
+
}
|
281
|
+
}
|
282
|
+
|
283
|
+
vector<vector<float>> get_states()
|
284
|
+
{
|
285
|
+
return states;
|
286
|
+
}
|
287
|
+
|
288
|
+
vector<float> get_times()
|
289
|
+
{
|
290
|
+
return times;
|
291
|
+
}
|
292
|
+
};
|
293
|
+
|
294
|
+
#endif // WC_ODE_HPP_
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
%module wc_ode
|
3
|
+
|
4
|
+
%{
|
5
|
+
#include "wc_ode.hpp"
|
6
|
+
%}
|
7
|
+
|
8
|
+
%include stl.i
|
9
|
+
%include "std_string.i"
|
10
|
+
/* instantiate the required template specializations */
|
11
|
+
namespace std {
|
12
|
+
%template(IntVector) vector<int>;
|
13
|
+
%template(DoubleVector) vector<double>;
|
14
|
+
%template(DoubleVector2) vector<vector<double> >;
|
15
|
+
%template(SingleVector) vector<float>;
|
16
|
+
%template(SingleVector2) vector<vector<float> >;
|
17
|
+
}
|
18
|
+
|
19
|
+
%include "wc_ode.hpp"
|