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,264 @@
|
|
1
|
+
#ifndef jr_sde_HPP
|
2
|
+
#define jr_sde_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
|
+
|
20
|
+
class JR_sde
|
21
|
+
{
|
22
|
+
private:
|
23
|
+
size_t N;
|
24
|
+
double dt;
|
25
|
+
double t_initial;
|
26
|
+
double t_final;
|
27
|
+
double t_transition;
|
28
|
+
size_t dimension;
|
29
|
+
size_t num_steps;
|
30
|
+
size_t index_transition;
|
31
|
+
vector<vector<unsigned>> adjlist;
|
32
|
+
|
33
|
+
double par_A;
|
34
|
+
double par_a;
|
35
|
+
double par_B;
|
36
|
+
double par_b;
|
37
|
+
double par_r;
|
38
|
+
double par_v0;
|
39
|
+
double par_vmax;
|
40
|
+
double coupling;
|
41
|
+
double noise_mu;
|
42
|
+
double noise_sigma;
|
43
|
+
|
44
|
+
dim2 adj;
|
45
|
+
dim1 C0;
|
46
|
+
dim1 C1;
|
47
|
+
dim1 C2;
|
48
|
+
dim1 C3;
|
49
|
+
|
50
|
+
int fix_seed;
|
51
|
+
|
52
|
+
dim1 times;
|
53
|
+
dim2 states;
|
54
|
+
dim1 initial_state;
|
55
|
+
|
56
|
+
// bool ADJ_SET = false; //check if adjacency matrix is set.
|
57
|
+
// bool COUPLING_SET = false; //check if coupling is set
|
58
|
+
|
59
|
+
public:
|
60
|
+
JR_sde(size_t N,
|
61
|
+
double dt,
|
62
|
+
double t_transition,
|
63
|
+
double t_final,
|
64
|
+
double coupling,
|
65
|
+
dim2 adj,
|
66
|
+
dim1 y,
|
67
|
+
double A,
|
68
|
+
double B,
|
69
|
+
double a,
|
70
|
+
double b,
|
71
|
+
double r,
|
72
|
+
double v0,
|
73
|
+
double vmax,
|
74
|
+
dim1 C0,
|
75
|
+
dim1 C1,
|
76
|
+
dim1 C2,
|
77
|
+
dim1 C3,
|
78
|
+
double noise_mu,
|
79
|
+
double noise_sigma,
|
80
|
+
int fix_seed=0)
|
81
|
+
{
|
82
|
+
assert(t_final > t_transition);
|
83
|
+
|
84
|
+
par_A = A;
|
85
|
+
par_B = B;
|
86
|
+
par_a = a;
|
87
|
+
par_b = b;
|
88
|
+
par_r = r;
|
89
|
+
par_v0 = v0;
|
90
|
+
par_vmax = vmax;
|
91
|
+
|
92
|
+
this-> noise_mu = noise_mu;
|
93
|
+
this-> noise_sigma = noise_sigma;
|
94
|
+
|
95
|
+
initial_state = y;
|
96
|
+
this->N = N;
|
97
|
+
this->dt = dt;
|
98
|
+
this->t_final = t_final;
|
99
|
+
this->t_transition = t_transition;
|
100
|
+
this->coupling = coupling;
|
101
|
+
this->adj = adj;
|
102
|
+
this->fix_seed = fix_seed;
|
103
|
+
this->C0 = C0;
|
104
|
+
this->C1 = C1;
|
105
|
+
this->C2 = C2;
|
106
|
+
this->C3 = C3;
|
107
|
+
|
108
|
+
adjlist = adjmat_to_adjlist(adj);
|
109
|
+
|
110
|
+
dimension = y.size();
|
111
|
+
num_steps = int(t_final / dt);
|
112
|
+
|
113
|
+
index_transition = int(t_transition / dt);
|
114
|
+
size_t buffer_size = num_steps - index_transition; // int((t_final - t_transition) / dt);
|
115
|
+
|
116
|
+
states.resize(buffer_size);
|
117
|
+
for (size_t i = 0; i < buffer_size; ++i)
|
118
|
+
states[i].resize(N);
|
119
|
+
times.resize(buffer_size);
|
120
|
+
}
|
121
|
+
// ------------------------------------------------------------------------
|
122
|
+
double sigma(const double v)
|
123
|
+
{
|
124
|
+
return par_vmax / (1 + exp(par_r * (par_v0 - v)));
|
125
|
+
}
|
126
|
+
// ------------------------------------------------------------------------
|
127
|
+
void rhs(const vector<double> &y,
|
128
|
+
vector<double> &dxdt,
|
129
|
+
const double t)
|
130
|
+
{
|
131
|
+
|
132
|
+
double a2 = par_a * par_a;
|
133
|
+
double b2 = par_b * par_b;
|
134
|
+
double Aa = par_A * par_a;
|
135
|
+
double Bb = par_B * par_b;
|
136
|
+
|
137
|
+
size_t N2 = 2 * N;
|
138
|
+
size_t N3 = 3 * N;
|
139
|
+
size_t N4 = 4 * N;
|
140
|
+
size_t N5 = 5 * N;
|
141
|
+
|
142
|
+
for (size_t i = 0; i < N; ++i)
|
143
|
+
{
|
144
|
+
double coupling_term = 0.0;
|
145
|
+
|
146
|
+
for (size_t j = 0; j < adjlist[i].size(); ++j)
|
147
|
+
{
|
148
|
+
int k = adjlist[i][j];
|
149
|
+
coupling_term += adj[i][k] * sigma(y[k + N] - y[k + N2]);
|
150
|
+
}
|
151
|
+
|
152
|
+
dxdt[i] = y[i + N3];
|
153
|
+
dxdt[i + N] = y[i + N4];
|
154
|
+
dxdt[i + N2] = y[i + N5];
|
155
|
+
dxdt[i + N3] = par_A * par_a * sigma(y[i + N] - y[i + N2]) - 2 * par_a * y[i + N3] - a2 * y[i];
|
156
|
+
dxdt[i + N4] = Aa * (noise_mu + C1[i] * sigma(C0[i] * y[i]) + coupling * coupling_term) - 2 * par_a * y[i + N4] - a2 * y[i + N];
|
157
|
+
dxdt[i + N5] = Bb * C3[i] * sigma(C2[i] * y[i]) - 2 * par_b * y[i + N5] -
|
158
|
+
b2 * y[i + N2];
|
159
|
+
}
|
160
|
+
}
|
161
|
+
// ------------------------------------------------------------------------
|
162
|
+
void euler(dim1 &y, const double t)
|
163
|
+
{
|
164
|
+
std::normal_distribution<> normal(0, 1);
|
165
|
+
|
166
|
+
size_t n = y.size();
|
167
|
+
dim1 dydt(n);
|
168
|
+
rhs(y, dydt, t);
|
169
|
+
for (size_t i = 0; i < n; ++i)
|
170
|
+
{
|
171
|
+
if ((i>= (4*N)) && (i<(5*N)))
|
172
|
+
y[i] += dydt[i] * dt + sqrt(dt) * noise_sigma * normal(rng(fix_seed));
|
173
|
+
else
|
174
|
+
y[i] += dydt[i] * dt;
|
175
|
+
}
|
176
|
+
}
|
177
|
+
// ------------------------------------------------------------------------
|
178
|
+
void eulerIntegrate()
|
179
|
+
{
|
180
|
+
size_t n = dimension;
|
181
|
+
size_t N2 = 2 * N;
|
182
|
+
|
183
|
+
dim1 y = initial_state;
|
184
|
+
size_t counter = 0;
|
185
|
+
|
186
|
+
for (int step = 0; step < num_steps; ++step)
|
187
|
+
{
|
188
|
+
double t = step * dt;
|
189
|
+
|
190
|
+
if (step >= index_transition)
|
191
|
+
{
|
192
|
+
times[counter] = t;
|
193
|
+
|
194
|
+
for (size_t i = 0; i < N; ++i)
|
195
|
+
states[counter][i] = y[i + N] - y[i + N2];
|
196
|
+
counter++;
|
197
|
+
}
|
198
|
+
euler(y, t);
|
199
|
+
}
|
200
|
+
}
|
201
|
+
|
202
|
+
void heun(dim1 &y, const double t)
|
203
|
+
{
|
204
|
+
std::normal_distribution<> normal(0, 1);
|
205
|
+
|
206
|
+
size_t n = y.size();
|
207
|
+
dim1 k1(n);
|
208
|
+
dim1 k2(n);
|
209
|
+
dim1 tmp(n);
|
210
|
+
rhs(y, k1, t);
|
211
|
+
for (size_t i = 0; i < n; ++i)
|
212
|
+
{
|
213
|
+
if ((i>= (4*N)) && (i<(5*N)))
|
214
|
+
tmp[i] = y[i] + k1[i] * dt + sqrt(dt) * noise_sigma * normal(rng(fix_seed));
|
215
|
+
else
|
216
|
+
tmp[i] = y[i] + k1[i] * dt;
|
217
|
+
}
|
218
|
+
|
219
|
+
rhs(tmp, k2, t + dt);
|
220
|
+
for (size_t i = 0; i < n; ++i)
|
221
|
+
{
|
222
|
+
if ((i>= (4*N)) && (i<(5*N)))
|
223
|
+
y[i] += 0.5 * dt * (k1[i] + k2[i]) + sqrt(dt) * noise_sigma * normal(rng(fix_seed));
|
224
|
+
else
|
225
|
+
y[i] += 0.5 * dt * (k1[i] + k2[i]);
|
226
|
+
}
|
227
|
+
|
228
|
+
}
|
229
|
+
|
230
|
+
void heunIntegrate()
|
231
|
+
{
|
232
|
+
size_t n = dimension;
|
233
|
+
size_t N2 = 2 * N;
|
234
|
+
|
235
|
+
dim1 y = initial_state;
|
236
|
+
size_t counter = 0;
|
237
|
+
|
238
|
+
for (int step = 0; step < num_steps; ++step)
|
239
|
+
{
|
240
|
+
double t = step * dt;
|
241
|
+
if (step >= index_transition)
|
242
|
+
{
|
243
|
+
times[counter] = t;
|
244
|
+
for (size_t i = 0; i < N; ++i)
|
245
|
+
states[counter][i] = y[i + N] - y[i + N2];
|
246
|
+
counter++;
|
247
|
+
}
|
248
|
+
heun(y, t);
|
249
|
+
}
|
250
|
+
}
|
251
|
+
|
252
|
+
// ------------------------------------------------------------------------
|
253
|
+
dim2 get_coordinates()
|
254
|
+
{
|
255
|
+
return states;
|
256
|
+
}
|
257
|
+
// ------------------------------------------------------------------------
|
258
|
+
dim1 get_times()
|
259
|
+
{
|
260
|
+
return times;
|
261
|
+
}
|
262
|
+
};
|
263
|
+
|
264
|
+
#endif
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
%module jr_sde
|
3
|
+
|
4
|
+
%{
|
5
|
+
#include "jr_sde.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
|
+
}
|
16
|
+
|
17
|
+
%include "jr_sde.hpp"
|