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
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
########################################################################################################################
|
|
2
|
+
# This configuration file can be used to set values in pynibs.Element() that influence the regression. #
|
|
3
|
+
# The values in this version are optimized for MEP data. #
|
|
4
|
+
########################################################################################################################
|
|
5
|
+
#
|
|
6
|
+
#
|
|
7
|
+
############################################## General regression concept ##############################################
|
|
8
|
+
# While trying to find the best fit, many possible regression functions are calculated and the best one is picked.
|
|
9
|
+
# Usually, that is the one that explains the most noise, meaning that the data points have a minimal distance to the
|
|
10
|
+
# regression function. With linear regression, this function always looks like the following term, with varying
|
|
11
|
+
# coefficients m and n:
|
|
12
|
+
## y = m*x + n
|
|
13
|
+
## (m is the slope)
|
|
14
|
+
## (n is the intercept with the y-axis)
|
|
15
|
+
|
|
16
|
+
# The usual approach is to start with a function described by some initial values (init_vals) for m and n and try out
|
|
17
|
+
# many other values within the value limits (limits), minimizing the distance between regression function and real data.
|
|
18
|
+
# During refitting, different initial vales (calculated within the random_vals_init_range) are used to see whether a
|
|
19
|
+
# better result can be achieved.
|
|
20
|
+
|
|
21
|
+
############################################### Picking suitable values ################################################
|
|
22
|
+
# Initial values for the regression coefficients:
|
|
23
|
+
init_vals:
|
|
24
|
+
m: 0.3
|
|
25
|
+
n: -1
|
|
26
|
+
# Strategy: Pick the values you may expect the result to have, or that are not far-fetched. Picking reasonable initial
|
|
27
|
+
# values can speed up the fitting procedure.
|
|
28
|
+
|
|
29
|
+
# Values that limit all possible regression coefficients:
|
|
30
|
+
limits:
|
|
31
|
+
m:
|
|
32
|
+
- -100
|
|
33
|
+
- 100
|
|
34
|
+
n:
|
|
35
|
+
- -100
|
|
36
|
+
- 100
|
|
37
|
+
# Strategy: Rather wide range recommended, since a few points could have very extreme values and therefore be
|
|
38
|
+
# approximated by a function very different from the expected values. E.g. a multiple of the presented data range.
|
|
39
|
+
# (Note: This should not be used to factor out outliers, since an approximation will still be calculated, but with too
|
|
40
|
+
# narrow limits it will just be a very bad one.)
|
|
41
|
+
|
|
42
|
+
# Value range for the calculation of new initial values for refits:
|
|
43
|
+
random_vals_init_range:
|
|
44
|
+
m:
|
|
45
|
+
- 0
|
|
46
|
+
- 100
|
|
47
|
+
n:
|
|
48
|
+
- 0
|
|
49
|
+
- 0.3
|
|
50
|
+
# Strategy: During refitting, new initial values are calculated by picking a random number between these lower and upper
|
|
51
|
+
# bounds, so the range should be a lot smaller than 'limits' and somewhat symmetrical around the 'init_vals'.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# Example usage:
|
|
55
|
+
##
|
|
56
|
+
## configfile = configuration_linear_MEP.yaml
|
|
57
|
+
## with open(configfile, "r") as yamlfile:
|
|
58
|
+
## config = yaml.load(yamlfile, Loader=yaml.FullLoader)
|
|
59
|
+
##
|
|
60
|
+
## pynibs.regress_data(...,
|
|
61
|
+
## **configfile)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
########################################################################################################################
|
|
2
|
+
# This configuration file can be used to set values in pynibs.Element() that influence the regression. #
|
|
3
|
+
# The values in this version are optimized for reaction time data. #
|
|
4
|
+
########################################################################################################################
|
|
5
|
+
#
|
|
6
|
+
#
|
|
7
|
+
############################################## General regression concept ##############################################
|
|
8
|
+
# While trying to find the best fit, many possible regression functions are calculated and the best one is picked.
|
|
9
|
+
# Usually, that is the one that explains the most noise, meaning that the data points have a minimal distance to the
|
|
10
|
+
# regression function. With linear regression, this function always looks like the following term, with varying
|
|
11
|
+
# coefficients m and n:
|
|
12
|
+
## y = m*x + n
|
|
13
|
+
## (m is the slope)
|
|
14
|
+
## (n is the intercept with the y-axis)
|
|
15
|
+
|
|
16
|
+
# The usual approach is to start with a function described by some initial values (init_vals) for m and n and try out
|
|
17
|
+
# many other values within the value limits (limits), minimizing the distance between regression function and real data.
|
|
18
|
+
# During refitting, different initial vales (calculated within the random_vals_init_range) are used to see whether a
|
|
19
|
+
# better result can be achieved.
|
|
20
|
+
|
|
21
|
+
############################################### Picking suitable values ################################################
|
|
22
|
+
# Initial values for the regression coefficients:
|
|
23
|
+
init_vals:
|
|
24
|
+
m: 0.1
|
|
25
|
+
n: 300
|
|
26
|
+
# Strategy: Pick the values you may expect the result to have, or that are not far-fetched. Picking reasonable initial
|
|
27
|
+
# values can speed up the fitting procedure.
|
|
28
|
+
|
|
29
|
+
# Values that limit all possible regression coefficients:
|
|
30
|
+
limits:
|
|
31
|
+
m:
|
|
32
|
+
- -10000
|
|
33
|
+
- 10000
|
|
34
|
+
n:
|
|
35
|
+
- -30000
|
|
36
|
+
- 30000
|
|
37
|
+
# Strategy: Rather wide range recommended, since a few points could have very extreme values and therefore be
|
|
38
|
+
# approximated by a function very different from the expected values. E.g. a multiple of the presented data range.
|
|
39
|
+
# (Note: This should not be used to factor out outliers, since an approximation will still be calculated, but with too
|
|
40
|
+
# narrow limits it will just be a very bad one.)
|
|
41
|
+
|
|
42
|
+
# Value range for the calculation of new initial values for refits:
|
|
43
|
+
random_vals_init_range:
|
|
44
|
+
m:
|
|
45
|
+
- -22
|
|
46
|
+
- 22
|
|
47
|
+
n:
|
|
48
|
+
- -50
|
|
49
|
+
- 500
|
|
50
|
+
# Strategy: During refitting, new initial values are calculated by picking a random number between these lower and upper
|
|
51
|
+
# bounds, so the range should be a lot smaller than 'limits' and somewhat symmetrical around the 'init_vals'.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# Example usage:
|
|
55
|
+
##
|
|
56
|
+
## configfile = configuration_linear_RT.yaml
|
|
57
|
+
## with open(configfile, "r") as yamlfile:
|
|
58
|
+
## config = yaml.load(yamlfile, Loader=yaml.FullLoader)
|
|
59
|
+
##
|
|
60
|
+
## pynibs.regress_data(...,
|
|
61
|
+
## **configfile)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
########################################################################################################################
|
|
2
|
+
# This configuration file can be used to set values in pynibs.Element() that influence the regression. #
|
|
3
|
+
# The values in this version are optimized for MEP data. #
|
|
4
|
+
########################################################################################################################
|
|
5
|
+
#
|
|
6
|
+
#
|
|
7
|
+
############################################## General regression concept ##############################################
|
|
8
|
+
# While trying to find the best fit, many possible regression functions are calculated and the best one is picked.
|
|
9
|
+
# Usually, that is the one that explains the most noise, meaning that the data points have a minimal distance to the
|
|
10
|
+
# regression function. The function sigmoid4 always looks like the following term, with varying coefficients:
|
|
11
|
+
## y = y_0 + \frac{amp - y_0}{1+e^{-r(x-x_0)}}
|
|
12
|
+
## (x0 : Horizontal shift along the abscissa)
|
|
13
|
+
## (r : Slope parameter (steepness))
|
|
14
|
+
## (amp : Maximum value the sigmoid converges to)
|
|
15
|
+
## (y0 : Offset value of the sigmoid)
|
|
16
|
+
# Note: The fourth parameter y0 is the only difference between sigmoid and sigmoid4. It presents the possibility to
|
|
17
|
+
# factor in an offset in y-direction.
|
|
18
|
+
|
|
19
|
+
# The usual regression approach is to start with a function described by some initial values (init_vals) and try out
|
|
20
|
+
# many other values within the value limits (limits), minimizing the distance between regression function and real data.
|
|
21
|
+
# During refitting, different initial vales (calculated within the random_vals_init_range) are used to see whether a
|
|
22
|
+
# better result can be achieved.
|
|
23
|
+
|
|
24
|
+
element_params:
|
|
25
|
+
############################################### Picking suitable values ################################################
|
|
26
|
+
# Values transforming the initial regression coefficients:
|
|
27
|
+
init_vals:
|
|
28
|
+
x0: # set initial x_0 to rate p of the x-data range
|
|
29
|
+
p: 0.75
|
|
30
|
+
r: # slope of tangent over middle of 1/p of the e-range (e.g. 25% = 0.25 = 1/4 -> set p=4)
|
|
31
|
+
p: 4
|
|
32
|
+
amp: # amp = y_max * m + t
|
|
33
|
+
m: 1
|
|
34
|
+
t: 0
|
|
35
|
+
y0: # y0 = y_min * m + t
|
|
36
|
+
m: 1
|
|
37
|
+
t: 0
|
|
38
|
+
# Strategy: Pick the values you may expect the result to have, or that are not far-fetched. Picking reasonable initial
|
|
39
|
+
# values can speed up the fitting procedure.
|
|
40
|
+
|
|
41
|
+
# Values that limit all possible regression coefficients:
|
|
42
|
+
limits:
|
|
43
|
+
limit_factor: # the initial values get multiplied with "limit_factor" to calculate the limits
|
|
44
|
+
100
|
|
45
|
+
y0: # y0 \in [c, y_max * m]
|
|
46
|
+
c: 1.0e-12
|
|
47
|
+
m: 1
|
|
48
|
+
# Strategy: Rather wide range recommended, since a few points could have very extreme values and therefore be
|
|
49
|
+
# approximated by a function very different from the expected values. E.g. a multiple of the presented data range.
|
|
50
|
+
# (Note: This should not be used to factor out outliers, since an approximation will still be calculated, but with too
|
|
51
|
+
# narrow limits it will just be a very bad one.)
|
|
52
|
+
|
|
53
|
+
# Value range for the calculation of new initial values for refits:
|
|
54
|
+
random_vals_init_range:
|
|
55
|
+
range_factor: # the initial values get multiplied with "range_factor" to calculate this range
|
|
56
|
+
3
|
|
57
|
+
# Strategy: During refitting, new initial values are calculated by picking a random number between these lower and upper
|
|
58
|
+
# bounds, so the range should be a lot smaller than 'limits' and somewhat symmetrical around the 'init_vals'.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# Example usage:
|
|
62
|
+
##
|
|
63
|
+
## configfile = configuration_sigmoid4.yaml
|
|
64
|
+
## with open(configfile, "r") as yamlfile:
|
|
65
|
+
## config = yaml.load(yamlfile, Loader=yaml.FullLoader)
|
|
66
|
+
##
|
|
67
|
+
## pynibs.regress_data(...,
|
|
68
|
+
## **configfile)
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# Network detection: Guide to using the configuration files
|
|
2
|
+
|
|
3
|
+
All settings and parameters relevant in the network detection process can be adjusted via the configuration files.
|
|
4
|
+
Here is a short explanation of the process and the configuration entries.
|
|
5
|
+
|
|
6
|
+
## Loading the config file
|
|
7
|
+
|
|
8
|
+
Using the following code you can add the desired configuration file to your script:
|
|
9
|
+
|
|
10
|
+
import yaml
|
|
11
|
+
# choose file name and path
|
|
12
|
+
configfile = 'configuration_TEMPLATE.yaml'
|
|
13
|
+
config_path = '/data/pt_01756/software/git/pynibs/data/network mapping configuration'
|
|
14
|
+
# read configfile
|
|
15
|
+
with open(f'{config_path}/{configfile}', "r") as yamlfile:
|
|
16
|
+
config = yaml.load(yamlfile, Loader=yaml.FullLoader)
|
|
17
|
+
print("-" * 64)
|
|
18
|
+
print("Using file '" + configfile + "' for current parameter setting.")
|
|
19
|
+
print("-" * 64)
|
|
20
|
+
|
|
21
|
+
Aside from that, the NDA application and testing functions only need the experimental data (e_matrix, response_values, roi_surf, fn_geo)
|
|
22
|
+
and the base_path (output folder).
|
|
23
|
+
|
|
24
|
+
## Configuration Parameters Guide
|
|
25
|
+
|
|
26
|
+
There are two different main functions: `network_detection_algorithm_testing()` and
|
|
27
|
+
`network_detection_algorithm_application()`. The configuration parameters are very similar, many entries apply to both.
|
|
28
|
+
They are presented separately in the following for simplicity.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Application (real data)
|
|
32
|
+
|
|
33
|
+
<u> Binarization </u>
|
|
34
|
+
|
|
35
|
+
Data binarization is a crucial preprocessing step since it determines what data the algorithm considers as affected.
|
|
36
|
+
Carefully adjust to the data at hand. Note that this is only relevant for the scoring_method 'clf'.
|
|
37
|
+
Default function is `binarize_response_data()`. For MEPs, you could also use `binarize_real_meps()`.
|
|
38
|
+
|
|
39
|
+
- ``bin_method``: Method used to calculate the binarization threshold.
|
|
40
|
+
- Options: `'mean'`, `'slope'`, `'median'`.
|
|
41
|
+
|
|
42
|
+
- ``bin_factor``: Multiplied with the value of `bin_method(response)` is used as binarization threshold.
|
|
43
|
+
(Above=1=affected, below=0=not affected).
|
|
44
|
+
|
|
45
|
+
<u> Scoring </u>
|
|
46
|
+
|
|
47
|
+
- ``scoring_method``: Select the method for the computation of hotspot scores per ROI element.
|
|
48
|
+
- Options: `'clf'`, `'regression'`, `'regress_data'` (single hotspot), `'mi'` (single hotspot).
|
|
49
|
+
- Remark:
|
|
50
|
+
Network detection:
|
|
51
|
+
- `'clf'`: Scores are based on the accuracies of Decision Tree Classifiers of pairwise element combinations. (recommended)
|
|
52
|
+
- `'regression'`: Scores are the R2-scores of multivariable regression.
|
|
53
|
+
- `'regress_data'`: Scores are the R2-score of a sigmoidal fit.
|
|
54
|
+
- `'mi'`: Scores are the mutual information scores of the e-fields and the response variables.
|
|
55
|
+
|
|
56
|
+
- ``scoring_emag_thr``: Threshold above which elements are scored.
|
|
57
|
+
More specifically: Per element, the `e_mag_max` as the
|
|
58
|
+
maximum e-field magnitude reached in all zaps indicates how accessible an element is to stimulation (gyral element have
|
|
59
|
+
the highest `e_mag_max`). This parameter is the lower bound for the `e_mag_max` of all scored elements.
|
|
60
|
+
- Remark: The higher the threshold, the higher the scored elements are on the cortical ROI.
|
|
61
|
+
|
|
62
|
+
- ``scoring_interval``: Interval at which elements are scored, determines subsampling resolution.
|
|
63
|
+
- Remark: `1/scoring_interval` elements are scored. Adjust to balance between computational efficiency and scoring detail.
|
|
64
|
+
|
|
65
|
+
<u>Detection</u>
|
|
66
|
+
|
|
67
|
+
- ``acc_thr``: Lower bound for the accuracy (clf) or scores (other scoring methods) of hotspot elements. Below that,
|
|
68
|
+
an element will not be categorized as hotspot.
|
|
69
|
+
- Remark: See recommendation sheet``data/network mapping configuration/recommendations_for_accuracy_threshold.md``.
|
|
70
|
+
For the clf-method, there is a table included recommending accuracy thresholds based on sample size.
|
|
71
|
+
|
|
72
|
+
- ``corr_thr``: Correlation threshold (upper bound) for hotspot pairs.
|
|
73
|
+
- Remark: When a second hotspot candidate too highly
|
|
74
|
+
correlates with the first one, it is ignored, to avoid double detection of a single hotspot. Preliminary analyses have
|
|
75
|
+
shown that this threshold does not have a lot of impact.
|
|
76
|
+
- 1: no limitation to how correlated they are, 0: only one hotspot allowed)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
<u>Additional Info</u>
|
|
80
|
+
|
|
81
|
+
- ``note``: Arbitrary string for additional comments or notes.
|
|
82
|
+
|
|
83
|
+
- ``fn_flag``: String to be mentioned in the output files. (to distinguish)
|
|
84
|
+
|
|
85
|
+
- ``subject_id``: ID of the subject.
|
|
86
|
+
- ``response_spec``: Specification (if any) to retrieve the response. (e.g. FDI, APB,...)
|
|
87
|
+
- ``e_field``: Specification (if any) to retrieve the e-field values. (E_tan, E_mag, E_norm)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
The remaining 8 entries are not saved in the results overview. Namely the following:
|
|
91
|
+
|
|
92
|
+
- ``save_files``: (boolean) Whether to save hotspot scores and scoremaps as HDF5 files.
|
|
93
|
+
|
|
94
|
+
- ``write_effect_map``: (boolean) Whether to create an effect map. See more under <u> Effect map </u>.
|
|
95
|
+
|
|
96
|
+
- ``fn_results``: Filename for the CSV the results/evaluation should be saved in.
|
|
97
|
+
To understand output, see ``output_documentation``.
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
<u> Effect map </u>
|
|
101
|
+
|
|
102
|
+
If the output should include an effect map (useful for validation), the following parameters should be included.
|
|
103
|
+
|
|
104
|
+
- ``effect_full``: The e-field magnitude that approximately needs to be reached to achieve the desired effect (in µV).
|
|
105
|
+
|
|
106
|
+
- ``effect_saturation``: The approx. e-field magnitude at which the effect is expected to saturate (in µV).
|
|
107
|
+
|
|
108
|
+
The effect map depicts the following: Assuming a network as detected was in effect, where can the effect
|
|
109
|
+
be expected highest/lowest? I.e., where is the response expected to be affected most/least?
|
|
110
|
+
This can be useful during experimental validation.
|
|
111
|
+
|
|
112
|
+
<u>Plotting</u>
|
|
113
|
+
|
|
114
|
+
- ``plot_std``: (boolean) Whether to plot the response data with color indicating response value, and the e-field values
|
|
115
|
+
of the chosen hotspots on x- and y-axis.
|
|
116
|
+
|
|
117
|
+
- ``plot_bin``: (boolean) Whether to plot the binarized response data with color indicating response category,
|
|
118
|
+
and the e-field values of the chosen hotspots on x- and y-axis.
|
|
119
|
+
|
|
120
|
+
- ``plot_curves``: (boolean) Whether to create two response data scatter plots, one for each chosen hotspot. (e-field
|
|
121
|
+
magnitudes on x-axis, response on y-axis).
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
### Testing (generated data)
|
|
125
|
+
|
|
126
|
+
<u> Artificial Data Generation </u>
|
|
127
|
+
|
|
128
|
+
The response will be generated as if `hotspot_elm0` and `hotspot_elm1`
|
|
129
|
+
form a network of type `network_type`. See function `create_response_data()` for the detailed process.
|
|
130
|
+
|
|
131
|
+
- ``hotspot_elm0``: `[0, n_elms-1]`
|
|
132
|
+
Specify the index of the first hotspot element.
|
|
133
|
+
|
|
134
|
+
- ``hotspot_elm1``: `[0, n_elms-1]`
|
|
135
|
+
Specify the index of the second hotspot element.
|
|
136
|
+
|
|
137
|
+
- ``sample_size``: The desired number of samples. Bounded by the number of available e-fields.
|
|
138
|
+
If `sample_size` is smaller, e-fields are randomly chosen.
|
|
139
|
+
(See `create_dummy_binary_data.py` for more elaborate e-field choosing functions.)
|
|
140
|
+
|
|
141
|
+
- ``rn_seed``: Seed for all processes that are in some way random, ensuring reproducibility.
|
|
142
|
+
|
|
143
|
+
- ``distribution_type``: Defines the statistical distribution type for data generation.
|
|
144
|
+
- Options: `'normal'`, `'logistic'`.
|
|
145
|
+
- Remark: `'ExGaussian'` is also an option but is not fully implemented.
|
|
146
|
+
|
|
147
|
+
- ``network_type``: Choose the network the two hotspots are forming.
|
|
148
|
+
- Options: `['NO', 'AND', '1_INH_0', 'SH_0', '0_INH_1', 'SH_1', 'XOR', 'OR']`.
|
|
149
|
+
- Remark:
|
|
150
|
+
- (1) NO: No network ("pseudonetwork").
|
|
151
|
+
- (2) AND: Dual node network: Effect if elm0 AND elm1 are stimulated.
|
|
152
|
+
- (3) 1_INH_0: Dual node network: elm1 inhibits elm0, elm0 has an effect.
|
|
153
|
+
- (4) SH_0: Single hotspot: Only elm0 has an effect.
|
|
154
|
+
- (5) 0_INH_1: Dual node network: elm0 inhibits elm1, elm1 has an effect.
|
|
155
|
+
- (6) SH_1: Single hotspot: Only elm1 has an effect.
|
|
156
|
+
- (7) XOR: Dual node network: elm0 inhibits elm1, elm1 inhibits elm0. Both have an effect.
|
|
157
|
+
- (8) OR: Dual node network: Effect if either elm0 or elm1 is stimulated.
|
|
158
|
+
|
|
159
|
+
- ``effect_full``: E-field magnitude at which the desired effect fully manifests.
|
|
160
|
+
- Remark: What value makes sense here strongly depends on the range of the e-field values.
|
|
161
|
+
For normalized e-field values (1% stimulator intensity) across the motor cortex, values tend to range up to 1.6 µV.
|
|
162
|
+
We chose to normalize the effect to 0.9 µV.
|
|
163
|
+
|
|
164
|
+
- ``effect_saturation``: E-field magnitude at which the desired effect saturates.
|
|
165
|
+
- Remark: See `effect_full`. We chose an effect saturation at 1.2 µV.
|
|
166
|
+
|
|
167
|
+
- ``jitter_ratio``: Percentage of data receiving random response values (uniformly distributed within the expected range).
|
|
168
|
+
|
|
169
|
+
- ``jitter_scale``: Multiplied with the mean value to calculate distribution deviation. Note that a heteroscedastic
|
|
170
|
+
distribution is implemented at the moment -> the higher the effect, the higher the deviation.
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
<u> Binarization </u>
|
|
174
|
+
|
|
175
|
+
Data binarization is a crucial preprocessing step since it determines what data the algorithm considers as affected.
|
|
176
|
+
Carefully adjust to the data at hand.
|
|
177
|
+
Default function is `binarize_response_data()`. For MEPs, you could also use `binarize_real_meps()`.
|
|
178
|
+
|
|
179
|
+
- ``bin_method``: Method used to calculate the binarization threshold.
|
|
180
|
+
- Options: `'mean'`, `'slope'`, `'median'`.
|
|
181
|
+
|
|
182
|
+
- ``bin_factor``: Multiplied with the value of `bin_method(response)` is used as binarization threshold.
|
|
183
|
+
(Above=1=affected, below=0=not affected).
|
|
184
|
+
|
|
185
|
+
<u> Scoring </u>
|
|
186
|
+
|
|
187
|
+
- ``scoring_method``: Select the method for the computation of hotspot scores per ROI element.
|
|
188
|
+
- Options: `'clf'`, `'regression'`, `'regress_data'` (single hotspot), `'mi'` (single hotspot).
|
|
189
|
+
- Remark:
|
|
190
|
+
Network detection:
|
|
191
|
+
- `'clf'`: Scores are based on the accuracies of Decision Tree Classifiers of pairwise element combinations. (recommended)
|
|
192
|
+
- `'regression'`: Scores are the R2-scores of multivariable regression.
|
|
193
|
+
- `'regress_data'`: Scores are the R2-score of a sigmoidal fit.
|
|
194
|
+
- `'mi'`: Scores are the mutual information scores of the e-fields and the response variables.
|
|
195
|
+
|
|
196
|
+
- ``scoring_emag_thr``: Threshold above which elements are scored.
|
|
197
|
+
More specifically: Per element, the `e_mag_max` as the
|
|
198
|
+
maximum e-field magnitude reached in all zaps indicates how accessible an element is to stimulation (gyral element have
|
|
199
|
+
the highest `e_mag_max`). This parameter is the lower bound for the `e_mag_max` of all scored elements.
|
|
200
|
+
- Remark: The higher the threshold, the higher the scored elements are on the cortical ROI.
|
|
201
|
+
|
|
202
|
+
- ``scoring_interval``: Interval at which elements are scored, determines subsampling resolution.
|
|
203
|
+
- Remark: `1/scoring_interval` elements are scored. Adjust to balance between computational efficiency and scoring detail.
|
|
204
|
+
|
|
205
|
+
<u>Detection</u>
|
|
206
|
+
|
|
207
|
+
- ``acc_thr``: Lower bound for the accuracy (clf) or scores (other scoring methods) of hotspot elements. Below that,
|
|
208
|
+
an element will not be categorized as hotspot.
|
|
209
|
+
- Remark: Remark: See recommendation sheet``data/network mapping configuration/recommendations_for_accuracy_threshold.md``.
|
|
210
|
+
For the clf-method, there is a table included recommending accuracy thresholds based on sample size.
|
|
211
|
+
|
|
212
|
+
- ``corr_thr``: Correlation threshold (upper bound) for hotspot pairs.
|
|
213
|
+
- Remark: When a second hotspot candidate too highly
|
|
214
|
+
correlates with the first one, it is ignored, to avoid double detection of a single hotspot. Preliminary analyses have
|
|
215
|
+
shown that this threshold does not have a lot of impact.
|
|
216
|
+
- 1: no limitation to how correlated they are, 0: only one hotspot allowed)
|
|
217
|
+
|
|
218
|
+
- ``note``: Arbitrary string for additional comments or notes.
|
|
219
|
+
|
|
220
|
+
The remaining 5 entries are not saved in the results overview. Namely the following:
|
|
221
|
+
|
|
222
|
+
<u>Evaluation</u>
|
|
223
|
+
|
|
224
|
+
- ``save_files``: (boolean) Whether to save hotspot scores and scoremaps as HDF5 files.
|
|
225
|
+
|
|
226
|
+
- ``fn_results``: Filename for the CSV the results/evaluation should be saved in.
|
|
227
|
+
To understand output, see ``output_documentation``.
|
|
228
|
+
|
|
229
|
+
<u>Plotting</u>
|
|
230
|
+
|
|
231
|
+
- ``plot_std``: (boolean) Whether to plot the response data with color indicating response value, and the e-field values
|
|
232
|
+
of the chosen hotspots on x- and y-axis.
|
|
233
|
+
|
|
234
|
+
- ``plot_bin``: (boolean) Whether to plot the binarized response data with color indicating response category,
|
|
235
|
+
and the e-field values of the chosen hotspots on x- and y-axis.
|
|
236
|
+
|
|
237
|
+
- ``plot_curves``: (boolean) Whether to create two response data scatter plots, one for each chosen hotspot. (e-field
|
|
238
|
+
magnitudes on x-axis, response on y-axis).
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# This configuration file contains settings and parameters for the application of the network detection algorithm.
|
|
2
|
+
|
|
3
|
+
# BINARIZATION
|
|
4
|
+
# binarization threshold is calculated as follows: method(response) * bin_factor
|
|
5
|
+
bin_method: 'mean' # mean, median or slope
|
|
6
|
+
bin_factor: 1.0
|
|
7
|
+
|
|
8
|
+
# SCORING
|
|
9
|
+
scoring_method: 'clf' # dual network expected: 'clf' or 'regression', single hotspot expected: 'regress_data' or 'mi'
|
|
10
|
+
scoring_emag_thr: 0 # elements with `max(e_mag) > scoring_emag_thr` are scored
|
|
11
|
+
scoring_interval: 22 # subsampling resolution: `1/scoring_interval' of all elements are scored
|
|
12
|
+
|
|
13
|
+
# DETECTION
|
|
14
|
+
acc_thr: 0.70 # accuracy threshold for hotspot elements (lower bound)
|
|
15
|
+
corr_thr: 0.5 # correlation(hot0, hot1) threshold for hotspot pairs (upper bound)
|
|
16
|
+
|
|
17
|
+
# ADDITIONAL INFO
|
|
18
|
+
note: 'MI_score mapping reasons' # arbitrary string # NO COMMAS
|
|
19
|
+
fn_flag: 'testrun_11' # mentioned in the file name
|
|
20
|
+
subject_id: '35357.53' #'09440.22' # '13061.30' 35334.2b
|
|
21
|
+
response_spec: 'FDI' # specification (if any) to retrieve the response
|
|
22
|
+
efield_spec: 'E_mag' # E_mag, E_tan, E_norm
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
####################################################
|
|
26
|
+
# The following is not saved in the evaluation sheet:
|
|
27
|
+
####################################################
|
|
28
|
+
|
|
29
|
+
save_files: True # whether to save experimental data & hotspot score data as hdf5
|
|
30
|
+
write_effect_map: True # whether to create effect map which can be used during validation
|
|
31
|
+
fn_results: 'evaluation_template' # file name of the .csv to save the results in
|
|
32
|
+
|
|
33
|
+
# EFFECT
|
|
34
|
+
# parameters used to create effect map - depends on e-field data and does not influence mapping result
|
|
35
|
+
effect_full: 42 # at what e-field magnitude the desired effect is expected to manifest fully
|
|
36
|
+
effect_saturation: 70 # at what e-mag the desired effect should saturate
|
|
37
|
+
|
|
38
|
+
# PLOTTING of the found data (not in evaluation sheet)
|
|
39
|
+
plot_std: True # plot e-mag hotspot0 x emag hotspot1 x response
|
|
40
|
+
plot_bin: True # plot e-mag hotspot0 x emag hotspot1 x binarized response
|
|
41
|
+
plot_curves: True # plot e-mag hotspot0 x response and e-mag hotspot1 x response
|
|
42
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# This configuration file contains settings and parameters for the testing of the network detection algorithm
|
|
2
|
+
# by generating response data and then test the algorithm on it.
|
|
3
|
+
|
|
4
|
+
# ARTIFICIAL DATA GENERATION
|
|
5
|
+
hotspot_elm0: 8797 # hotspot element 0
|
|
6
|
+
hotspot_elm1: 5334 # hotspot element 1
|
|
7
|
+
sample_size: 300 # number of data manifestations (i.e. trials / coil configurations / ...)
|
|
8
|
+
rn_seed: 44 # random seed used in multiple places
|
|
9
|
+
distribution_type: 'normal' # 'normal', 'logistic' are implemented
|
|
10
|
+
network_type: 'SH_0' # \in ['NO', 'AND', '1_INH_0', 'SH_0', '0_INH_1', 'SH_1', 'XOR', 'OR']
|
|
11
|
+
effect_full: 0.9 # at what e-field magnitude the desired effect is expected to manifest fully
|
|
12
|
+
effect_saturation: 1.2 # effect \in [0, effect_upper_bound) (at what e-mag the desired effect should saturate)
|
|
13
|
+
jitter_ratio: 0.05 # percentage of data that gets assigned random response values within observed range
|
|
14
|
+
jitter_scale: 0.2 # gets multiplied with the mean value to calculate distribution deviation:
|
|
15
|
+
## scale = loc * jitter_scale (smaller -> less noise)
|
|
16
|
+
|
|
17
|
+
# BINARIZATION
|
|
18
|
+
# binarization threshold is calculated as follows: method(response) * bin_factor
|
|
19
|
+
bin_method: 'mean'
|
|
20
|
+
bin_factor: 1.0
|
|
21
|
+
|
|
22
|
+
# SCORING
|
|
23
|
+
scoring_method: 'clf' # dual network expected: 'clf' or 'regression', single hotspot expected: 'regress_data' or 'mi'
|
|
24
|
+
scoring_emag_thr: 0 # elements with max(e_mag) > scoring_emag_thr are scored
|
|
25
|
+
scoring_interval: 22 # subsampling resolution: `1/scoring_interval' of all elements are scored
|
|
26
|
+
|
|
27
|
+
# DETECTION
|
|
28
|
+
acc_thr: 0.70 # accuracy threshold for hotspot elements (lower bound)
|
|
29
|
+
corr_thr: 0.75 # correlation(hot0, hot1) threshold for hotspot pairs (upper bound)
|
|
30
|
+
note: 'PLOTTING' # arbitrary string # NO COMMAS
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
####################################################
|
|
34
|
+
# The following is not saved in the evaluation sheet:
|
|
35
|
+
####################################################
|
|
36
|
+
|
|
37
|
+
save_files: True # whether to save hotspot scores and scoremaps as hdf5
|
|
38
|
+
fn_results: 'eval_final_tests' # file name of the .csv to save the results and evaluation in
|
|
39
|
+
|
|
40
|
+
# PLOTTING of the generated data (not in evaluation sheet)
|
|
41
|
+
plot_std: True # plot e-mag hotspot0 x emag hotspot1 x response
|
|
42
|
+
plot_bin: True # plot e-mag hotspot0 x emag hotspot1 x binarized response
|
|
43
|
+
plot_curves: True # plot e-mag hotspot0 x response and e-mag hotspot1 x response
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# This configuration file contains settings and parameters for the application of the network detection algorithm
|
|
2
|
+
# on reaction time data.
|
|
3
|
+
|
|
4
|
+
# BINARIZATION
|
|
5
|
+
# binarization threshold is calculated as follows: method(response) * bin_factor
|
|
6
|
+
bin_method: 'mean' # mean, median or slope
|
|
7
|
+
bin_factor: 1.3
|
|
8
|
+
|
|
9
|
+
# SCORING
|
|
10
|
+
scoring_method: 'clf' # dual network expected: 'clf' or 'regression', single hotspot expected: 'regress_data' or 'mi'
|
|
11
|
+
scoring_emag_thr: 0 # elements with `max(e_mag) > scoring_emag_thr` are scored
|
|
12
|
+
scoring_interval: 22 # subsampling resolution: `1/scoring_interval' of all elements are scored
|
|
13
|
+
|
|
14
|
+
# DETECTION
|
|
15
|
+
acc_thr: 0.8 # accuracy threshold for hotspot elements (lower bound)
|
|
16
|
+
corr_thr: 0.75 # correlation(hot0, hot1) threshold for hotspot pairs (upper bound)
|
|
17
|
+
|
|
18
|
+
# ADDITIONAL INFO
|
|
19
|
+
note: 'MI_score mapping reasons' # arbitrary string # NO COMMAS
|
|
20
|
+
fn_flag: 'testrun_11' # mentioned in the file name
|
|
21
|
+
subject_id: '35357.53' # '09440.22' # '13061.30' 35334.2b
|
|
22
|
+
response_spec: 'rt' # specification (if any) to retrieve the response
|
|
23
|
+
efield_spec: 'E_mag' # E_mag, E_tan, E_norm
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
####################################################
|
|
27
|
+
# The following is not saved in the evaluation sheet:
|
|
28
|
+
####################################################
|
|
29
|
+
|
|
30
|
+
save_files: True # whether to save experimental data & hotspot score data as hdf5
|
|
31
|
+
write_effect_map: True # whether to create effect map which can be used during validation
|
|
32
|
+
fn_results: 'eval_model_TMS' # file name of the .csv to save the results in
|
|
33
|
+
|
|
34
|
+
# EFFECT
|
|
35
|
+
# parameters used to create effect map - depends on e-field data and does not influence mapping result
|
|
36
|
+
effect_full: 42 # at what e-field magnitude the desired effect is expected to manifest fully
|
|
37
|
+
effect_saturation: 55 # at what e-mag the desired effect should saturate
|
|
38
|
+
|
|
39
|
+
# PLOTTING of the found data (not in evaluation sheet)
|
|
40
|
+
plot_std: True # plot e-mag hotspot0 x emag hotspot1 x response
|
|
41
|
+
plot_bin: True # plot e-mag hotspot0 x emag hotspot1 x binarized response
|
|
42
|
+
plot_curves: True # plot e-mag hotspot0 x response and e-mag hotspot1 x response
|
|
43
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# This configuration file contains settings and parameters for the application of the network detection algorithm
|
|
2
|
+
# on MEP data. More details below.
|
|
3
|
+
|
|
4
|
+
# BINARIZATION
|
|
5
|
+
# binarization threshold is calculated as follows: method(response) * bin_factor
|
|
6
|
+
bin_method: 'mean' # mean, median or slope
|
|
7
|
+
bin_factor: 1.0
|
|
8
|
+
|
|
9
|
+
# SCORING
|
|
10
|
+
scoring_method: 'clf' # dual network expected: 'clf' or 'regression', single hotspot expected: 'regress_data' or 'mi'
|
|
11
|
+
scoring_emag_thr: 0 # elements with `max(e_mag) > scoring_emag_thr` are scored
|
|
12
|
+
scoring_interval: 22 # subsampling resolution: `1/scoring_interval' of all elements are scored
|
|
13
|
+
|
|
14
|
+
# DETECTION
|
|
15
|
+
acc_thr: 0.70 # accuracy threshold for hotspot elements (lower bound)
|
|
16
|
+
corr_thr: 0.5 # correlation(hot0, hot1) threshold for hotspot pairs (upper bound)
|
|
17
|
+
|
|
18
|
+
# ADDITIONAL INFO
|
|
19
|
+
note: 'MI_score mapping reasons' # arbitrary string # NO COMMAS
|
|
20
|
+
fn_flag: 'testrun_11' # mentioned in the file name
|
|
21
|
+
subject_id: '35357.53' #'09440.22' # '13061.30' 35334.2b
|
|
22
|
+
response_spec: 'FDI' # FDI / ADM / APB
|
|
23
|
+
efield_spec: 'E_mag' # E_mag, E_tan, E_norm
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
####################################################
|
|
27
|
+
# The following is not saved in the evaluation sheet:
|
|
28
|
+
####################################################
|
|
29
|
+
|
|
30
|
+
save_files: True # whether to save experimental data & hotspot score data as hdf5
|
|
31
|
+
write_effect_map: True # whether to create effect map which can be used during validation
|
|
32
|
+
fn_results: 'evaluation_template' # file name of the .csv to save the results in
|
|
33
|
+
|
|
34
|
+
# EFFECT
|
|
35
|
+
# parameters used to create effect map - depends on e-field data and does not influence mapping result
|
|
36
|
+
effect_full: 42 # at what e-field magnitude the desired effect is expected to manifest fully
|
|
37
|
+
effect_saturation: 70 # at what e-mag the desired effect should saturate
|
|
38
|
+
|
|
39
|
+
# PLOTTING of the found data (not in evaluation sheet)
|
|
40
|
+
plot_std: True # plot e-mag hotspot0 x emag hotspot1 x response
|
|
41
|
+
plot_bin: True # plot e-mag hotspot0 x emag hotspot1 x binarized response
|
|
42
|
+
plot_curves: True # plot e-mag hotspot0 x response and e-mag hotspot1 x response
|
|
43
|
+
|