pyNIBS 0.2024.8__py3-none-any.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.
- pyNIBS-0.2024.8.dist-info/LICENSE +623 -0
- pyNIBS-0.2024.8.dist-info/METADATA +723 -0
- pyNIBS-0.2024.8.dist-info/RECORD +107 -0
- pyNIBS-0.2024.8.dist-info/WHEEL +5 -0
- pyNIBS-0.2024.8.dist-info/top_level.txt +1 -0
- pynibs/__init__.py +34 -0
- pynibs/coil.py +1367 -0
- pynibs/congruence/__init__.py +15 -0
- pynibs/congruence/congruence.py +1108 -0
- pynibs/congruence/ext_metrics.py +257 -0
- pynibs/congruence/stimulation_threshold.py +318 -0
- pynibs/data/configuration_exp0.yaml +59 -0
- pynibs/data/configuration_linear_MEP.yaml +61 -0
- pynibs/data/configuration_linear_RT.yaml +61 -0
- pynibs/data/configuration_sigmoid4.yaml +68 -0
- pynibs/data/network mapping configuration/configuration guide.md +238 -0
- pynibs/data/network mapping configuration/configuration_TEMPLATE.yaml +42 -0
- pynibs/data/network mapping configuration/configuration_for_testing.yaml +43 -0
- pynibs/data/network mapping configuration/configuration_modelTMS.yaml +43 -0
- pynibs/data/network mapping configuration/configuration_reg_isi_05.yaml +43 -0
- pynibs/data/network mapping configuration/output_documentation.md +185 -0
- pynibs/data/network mapping configuration/recommendations_for_accuracy_threshold.md +77 -0
- pynibs/data/neuron/models/L23_PC_cADpyr_biphasic_v1.csv +1281 -0
- pynibs/data/neuron/models/L23_PC_cADpyr_monophasic_v1.csv +1281 -0
- pynibs/data/neuron/models/L4_LBC_biphasic_v1.csv +1281 -0
- pynibs/data/neuron/models/L4_LBC_monophasic_v1.csv +1281 -0
- pynibs/data/neuron/models/L4_NBC_biphasic_v1.csv +1281 -0
- pynibs/data/neuron/models/L4_NBC_monophasic_v1.csv +1281 -0
- pynibs/data/neuron/models/L4_SBC_biphasic_v1.csv +1281 -0
- pynibs/data/neuron/models/L4_SBC_monophasic_v1.csv +1281 -0
- pynibs/data/neuron/models/L5_TTPC2_cADpyr_biphasic_v1.csv +1281 -0
- pynibs/data/neuron/models/L5_TTPC2_cADpyr_monophasic_v1.csv +1281 -0
- pynibs/expio/Mep.py +1518 -0
- pynibs/expio/__init__.py +8 -0
- pynibs/expio/brainsight.py +979 -0
- pynibs/expio/brainvis.py +71 -0
- pynibs/expio/cobot.py +239 -0
- pynibs/expio/exp.py +1876 -0
- pynibs/expio/fit_funs.py +287 -0
- pynibs/expio/localite.py +1987 -0
- pynibs/expio/signal_ced.py +51 -0
- pynibs/expio/visor.py +624 -0
- pynibs/freesurfer.py +502 -0
- pynibs/hdf5_io/__init__.py +10 -0
- pynibs/hdf5_io/hdf5_io.py +1857 -0
- pynibs/hdf5_io/xdmf.py +1542 -0
- pynibs/mesh/__init__.py +3 -0
- pynibs/mesh/mesh_struct.py +1394 -0
- pynibs/mesh/transformations.py +866 -0
- pynibs/mesh/utils.py +1103 -0
- pynibs/models/_TMS.py +211 -0
- pynibs/models/__init__.py +0 -0
- pynibs/muap.py +392 -0
- pynibs/neuron/__init__.py +2 -0
- pynibs/neuron/neuron_regression.py +284 -0
- pynibs/neuron/util.py +58 -0
- pynibs/optimization/__init__.py +5 -0
- pynibs/optimization/multichannel.py +278 -0
- pynibs/optimization/opt_mep.py +152 -0
- pynibs/optimization/optimization.py +1445 -0
- pynibs/optimization/workhorses.py +698 -0
- pynibs/pckg/__init__.py +0 -0
- pynibs/pckg/biosig/biosig4c++-1.9.5.src_fixed.tar.gz +0 -0
- pynibs/pckg/libeep/__init__.py +0 -0
- pynibs/pckg/libeep/pyeep.so +0 -0
- pynibs/regression/__init__.py +11 -0
- pynibs/regression/dual_node_detection.py +2375 -0
- pynibs/regression/regression.py +2984 -0
- pynibs/regression/score_types.py +0 -0
- pynibs/roi/__init__.py +2 -0
- pynibs/roi/roi.py +895 -0
- pynibs/roi/roi_structs.py +1233 -0
- pynibs/subject.py +1009 -0
- pynibs/tensor_scaling.py +144 -0
- pynibs/tests/data/InstrumentMarker20200225163611937.xml +19 -0
- pynibs/tests/data/TriggerMarkers_Coil0_20200225163443682.xml +14 -0
- pynibs/tests/data/TriggerMarkers_Coil1_20200225170337572.xml +6373 -0
- pynibs/tests/data/Xdmf.dtd +89 -0
- pynibs/tests/data/brainsight_niiImage_nifticoord.txt +145 -0
- pynibs/tests/data/brainsight_niiImage_nifticoord_largefile.txt +1434 -0
- pynibs/tests/data/brainsight_niiImage_niifticoord_mixedtargets.txt +47 -0
- pynibs/tests/data/create_subject_testsub.py +332 -0
- pynibs/tests/data/data.hdf5 +0 -0
- pynibs/tests/data/geo.hdf5 +0 -0
- pynibs/tests/test_coil.py +474 -0
- pynibs/tests/test_elements2nodes.py +100 -0
- pynibs/tests/test_hdf5_io/test_xdmf.py +61 -0
- pynibs/tests/test_mesh_transformations.py +123 -0
- pynibs/tests/test_mesh_utils.py +143 -0
- pynibs/tests/test_nnav_imports.py +101 -0
- pynibs/tests/test_quality_measures.py +117 -0
- pynibs/tests/test_regressdata.py +289 -0
- pynibs/tests/test_roi.py +17 -0
- pynibs/tests/test_rotations.py +86 -0
- pynibs/tests/test_subject.py +71 -0
- pynibs/tests/test_util.py +24 -0
- pynibs/tms_pulse.py +34 -0
- pynibs/util/__init__.py +4 -0
- pynibs/util/dosing.py +233 -0
- pynibs/util/quality_measures.py +562 -0
- pynibs/util/rotations.py +340 -0
- pynibs/util/simnibs.py +763 -0
- pynibs/util/util.py +727 -0
- pynibs/visualization/__init__.py +2 -0
- pynibs/visualization/para.py +4372 -0
- pynibs/visualization/plot_2D.py +137 -0
- pynibs/visualization/render_3D.py +347 -0
pynibs/expio/fit_funs.py
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def dummy_fun(x, a):
|
|
5
|
+
"""
|
|
6
|
+
Dummy function for congruence factor calculation.
|
|
7
|
+
"""
|
|
8
|
+
return x
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def sigmoid(x, x0, r, amp):
|
|
12
|
+
"""
|
|
13
|
+
Parametrized sigmoid function.
|
|
14
|
+
|
|
15
|
+
.. math::
|
|
16
|
+
y = \\frac{amp}{1+e^{-r(x-x_0)}}
|
|
17
|
+
|
|
18
|
+
Parameters
|
|
19
|
+
----------
|
|
20
|
+
x : np.ndarray of float
|
|
21
|
+
(N_x) X-values the function is evaluated in.
|
|
22
|
+
x0 : float
|
|
23
|
+
Horizontal shift along the abscissa.
|
|
24
|
+
r : float
|
|
25
|
+
Slope parameter (steepness).
|
|
26
|
+
amp : float
|
|
27
|
+
Maximum value the sigmoid converges to.
|
|
28
|
+
|
|
29
|
+
Returns
|
|
30
|
+
-------
|
|
31
|
+
y : np.ndarray of float
|
|
32
|
+
(N_x) Function value at argument x.
|
|
33
|
+
"""
|
|
34
|
+
y = amp / (1 + np.exp(-r * (x - x0)))
|
|
35
|
+
return y
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def sigmoid4(x, x0, r, amp, y0):
|
|
39
|
+
"""
|
|
40
|
+
Parametrized sigmoid function with 4 parameters.
|
|
41
|
+
|
|
42
|
+
.. math::
|
|
43
|
+
y = y_0 + \\frac{amp - y_0}{1+e^{-r(x-x_0)}}
|
|
44
|
+
|
|
45
|
+
Parameters
|
|
46
|
+
----------
|
|
47
|
+
x : np.ndarray of float
|
|
48
|
+
(N_x) x-values the function is evaluated in.
|
|
49
|
+
x0 : float
|
|
50
|
+
Horizontal shift along the abscissa.
|
|
51
|
+
r : float
|
|
52
|
+
Slope parameter (steepness).
|
|
53
|
+
amp : float
|
|
54
|
+
Maximum value the sigmoid converges to.
|
|
55
|
+
y0 : float
|
|
56
|
+
Offset value of the sigmoid.
|
|
57
|
+
|
|
58
|
+
Returns
|
|
59
|
+
-------
|
|
60
|
+
y : np.ndarray of float
|
|
61
|
+
(N_x) Function value at argument x.
|
|
62
|
+
"""
|
|
63
|
+
exp = -r * (x - x0)
|
|
64
|
+
|
|
65
|
+
# avoid numpy RuntimeWarning: overflow encountered in exp
|
|
66
|
+
if np.all(exp < 500):
|
|
67
|
+
y = y0 + (amp - y0) / (1 + np.exp(exp))
|
|
68
|
+
else:
|
|
69
|
+
# return a flat line; high value to maximally impair fits
|
|
70
|
+
y = np.ones(x.shape)
|
|
71
|
+
y *= np.iinfo(np.int32).max
|
|
72
|
+
|
|
73
|
+
return y
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def sigmoid_log(x, x0, r, amp):
|
|
77
|
+
"""
|
|
78
|
+
Parametrized log transformed sigmoid function.
|
|
79
|
+
|
|
80
|
+
.. math::
|
|
81
|
+
y = \\log\\left(\\frac{amp}{1+e^{-r(x-x_0)}}\\right)
|
|
82
|
+
|
|
83
|
+
Parameters
|
|
84
|
+
----------
|
|
85
|
+
x : np.ndarray of float
|
|
86
|
+
(N_x) x-values the function is evaluated in.
|
|
87
|
+
x0 : float
|
|
88
|
+
Horizontal shift along the abscissa.
|
|
89
|
+
r : float
|
|
90
|
+
Slope parameter (steepness).
|
|
91
|
+
amp : float
|
|
92
|
+
Maximum value the sigmoid converges to.
|
|
93
|
+
|
|
94
|
+
Returns
|
|
95
|
+
-------
|
|
96
|
+
y : np.ndarray of float
|
|
97
|
+
(N_x) Function value at argument x.
|
|
98
|
+
"""
|
|
99
|
+
y = np.log10(1e-12 + (amp - 1e-12) / (1 + np.exp(-r * (x - x0))))
|
|
100
|
+
return y
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def sigmoid4_log(x, x0, r, amp, y0):
|
|
104
|
+
"""
|
|
105
|
+
Parametrized log transformed sigmoid function with 4 parameters.
|
|
106
|
+
|
|
107
|
+
.. math::
|
|
108
|
+
y = \\log\\left(y_0 + \\frac{amp - y_0}{1+e^{-r(x-x_0)}}\\right)
|
|
109
|
+
|
|
110
|
+
Parameters
|
|
111
|
+
----------
|
|
112
|
+
x : np.ndarray of float
|
|
113
|
+
(N_x) X-values the function is evaluated in.
|
|
114
|
+
x0 : float
|
|
115
|
+
Horizontal shift along the abscissa.
|
|
116
|
+
r : float
|
|
117
|
+
Slope parameter (steepness).
|
|
118
|
+
amp : float
|
|
119
|
+
Maximum value the sigmoid converges to (upper saturation).
|
|
120
|
+
y0 : float
|
|
121
|
+
Y-offset value of the sigmoid.
|
|
122
|
+
|
|
123
|
+
Returns
|
|
124
|
+
-------
|
|
125
|
+
y : np.ndarray of float
|
|
126
|
+
(N_x) Function value at argument x.
|
|
127
|
+
"""
|
|
128
|
+
return np.log10(sigmoid4(y0=y0, amp=amp, x=x, x0=x0, r=r))
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def linear(x, m, n):
|
|
132
|
+
"""
|
|
133
|
+
Parametrized linear function.
|
|
134
|
+
|
|
135
|
+
.. math::
|
|
136
|
+
y = mx+n
|
|
137
|
+
|
|
138
|
+
Parameters
|
|
139
|
+
----------
|
|
140
|
+
x : np.ndarray of float
|
|
141
|
+
(N_x) X-values the function is evaluated in.
|
|
142
|
+
m : float
|
|
143
|
+
Slope parameter.
|
|
144
|
+
n : float
|
|
145
|
+
Y-offset.
|
|
146
|
+
|
|
147
|
+
Returns
|
|
148
|
+
-------
|
|
149
|
+
y : np.ndarray of float
|
|
150
|
+
(N_x) Function value at argument x.
|
|
151
|
+
"""
|
|
152
|
+
y = m * x + n
|
|
153
|
+
return y
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def linear_log(x, m, n):
|
|
157
|
+
"""
|
|
158
|
+
Parametrized log linear function.
|
|
159
|
+
|
|
160
|
+
.. math::
|
|
161
|
+
y = mx+n
|
|
162
|
+
|
|
163
|
+
Parameters
|
|
164
|
+
----------
|
|
165
|
+
x : np.ndarray of float
|
|
166
|
+
(N_x) X-values the function is evaluated in.
|
|
167
|
+
m : float
|
|
168
|
+
Slope parameter (steepness).
|
|
169
|
+
n : float
|
|
170
|
+
Y-offset.
|
|
171
|
+
|
|
172
|
+
Returns
|
|
173
|
+
-------
|
|
174
|
+
y : np.ndarray of float
|
|
175
|
+
(N_x) Function value at x.
|
|
176
|
+
"""
|
|
177
|
+
y = m * x + n
|
|
178
|
+
y[y <= 0] = 1e-16
|
|
179
|
+
y = np.log10(y)
|
|
180
|
+
y[y == -np.inf] = -16
|
|
181
|
+
y[y == np.inf] = 16
|
|
182
|
+
|
|
183
|
+
return y
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def exp(x, x0, r, y0):
|
|
187
|
+
"""
|
|
188
|
+
Parametrized exponential function.
|
|
189
|
+
|
|
190
|
+
.. math::
|
|
191
|
+
y = y_0 + e^{r(x-x_0)}
|
|
192
|
+
|
|
193
|
+
Parameters
|
|
194
|
+
----------
|
|
195
|
+
x : np.ndarray of float
|
|
196
|
+
(N_x) X-values the function is evaluated in.
|
|
197
|
+
x0 : float
|
|
198
|
+
Horizontal shift along the abscissa.
|
|
199
|
+
r : float
|
|
200
|
+
Slope parameter (steepness).
|
|
201
|
+
y0: float
|
|
202
|
+
Offset parameter.
|
|
203
|
+
|
|
204
|
+
Returns
|
|
205
|
+
-------
|
|
206
|
+
y : np.ndarray of float
|
|
207
|
+
(N_x,) Function value at x.
|
|
208
|
+
"""
|
|
209
|
+
y = y0 + np.exp(r * (x - x0))
|
|
210
|
+
return y
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def exp_log(x, x0, r, y0):
|
|
214
|
+
"""
|
|
215
|
+
Parametrized exponential function (log).
|
|
216
|
+
|
|
217
|
+
.. math::
|
|
218
|
+
y = y_0 + e^{r(x-x_0)}
|
|
219
|
+
|
|
220
|
+
Parameters
|
|
221
|
+
----------
|
|
222
|
+
x : np.ndarray of float
|
|
223
|
+
(N_x) X-values the function is evaluated in.
|
|
224
|
+
x0 : float
|
|
225
|
+
Horizontal shift along the abscissa.
|
|
226
|
+
r : float
|
|
227
|
+
Slope parameter (steepness).
|
|
228
|
+
y0: float
|
|
229
|
+
y-offset parameter.
|
|
230
|
+
|
|
231
|
+
Returns
|
|
232
|
+
-------
|
|
233
|
+
y : np.ndarray of float
|
|
234
|
+
(N_x) Function value at x.
|
|
235
|
+
"""
|
|
236
|
+
y = np.log10(y0 + np.exp(r * (x - x0)))
|
|
237
|
+
return y
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def exp0(x, x0, r):
|
|
241
|
+
"""
|
|
242
|
+
Parametrized exponential function w/o offset.
|
|
243
|
+
|
|
244
|
+
.. math::
|
|
245
|
+
y = e^{r(x-x_0)}
|
|
246
|
+
|
|
247
|
+
Parameters
|
|
248
|
+
----------
|
|
249
|
+
x : np.ndarray of float
|
|
250
|
+
(N_x) X-values the function is evaluated in.
|
|
251
|
+
x0 : float
|
|
252
|
+
Horizontal shift along the abscissa.
|
|
253
|
+
r : float
|
|
254
|
+
Slope parameter (steepness).
|
|
255
|
+
|
|
256
|
+
Returns
|
|
257
|
+
-------
|
|
258
|
+
y : np.ndarray of float
|
|
259
|
+
(N_x) Function value at x.
|
|
260
|
+
"""
|
|
261
|
+
y = np.exp(r * (x - x0))
|
|
262
|
+
return y
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def exp0_log(x, x0, r):
|
|
266
|
+
"""
|
|
267
|
+
Parametrized exponential function w/o offset.
|
|
268
|
+
|
|
269
|
+
.. math::
|
|
270
|
+
y = e^{r(x-x_0)}
|
|
271
|
+
|
|
272
|
+
Parameters
|
|
273
|
+
----------
|
|
274
|
+
x : np.ndarray of float
|
|
275
|
+
(N_x) X-values the function is evaluated in.
|
|
276
|
+
x0 : float
|
|
277
|
+
Horizontal shift along the abscissa.
|
|
278
|
+
r : float
|
|
279
|
+
Slope parameter.
|
|
280
|
+
|
|
281
|
+
Returns
|
|
282
|
+
-------
|
|
283
|
+
y : np.ndarray of float
|
|
284
|
+
(N_x) Function value at x.
|
|
285
|
+
"""
|
|
286
|
+
y = np.log10(np.exp(r * (x - x0)))
|
|
287
|
+
return y
|