junifer 0.0.3.dev186__py3-none-any.whl → 0.0.4__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.
- junifer/_version.py +14 -2
- junifer/api/cli.py +162 -17
- junifer/api/functions.py +87 -419
- junifer/api/parser.py +24 -0
- junifer/api/queue_context/__init__.py +8 -0
- junifer/api/queue_context/gnu_parallel_local_adapter.py +258 -0
- junifer/api/queue_context/htcondor_adapter.py +365 -0
- junifer/api/queue_context/queue_context_adapter.py +60 -0
- junifer/api/queue_context/tests/test_gnu_parallel_local_adapter.py +192 -0
- junifer/api/queue_context/tests/test_htcondor_adapter.py +257 -0
- junifer/api/res/afni/run_afni_docker.sh +6 -6
- junifer/api/res/ants/ResampleImage +3 -0
- junifer/api/res/ants/antsApplyTransforms +3 -0
- junifer/api/res/ants/antsApplyTransformsToPoints +3 -0
- junifer/api/res/ants/run_ants_docker.sh +39 -0
- junifer/api/res/fsl/applywarp +3 -0
- junifer/api/res/fsl/flirt +3 -0
- junifer/api/res/fsl/img2imgcoord +3 -0
- junifer/api/res/fsl/run_fsl_docker.sh +39 -0
- junifer/api/res/fsl/std2imgcoord +3 -0
- junifer/api/res/run_conda.sh +4 -4
- junifer/api/res/run_venv.sh +22 -0
- junifer/api/tests/data/partly_cloudy_agg_mean_tian.yml +16 -0
- junifer/api/tests/test_api_utils.py +21 -3
- junifer/api/tests/test_cli.py +232 -9
- junifer/api/tests/test_functions.py +211 -439
- junifer/api/tests/test_parser.py +1 -1
- junifer/configs/juseless/datagrabbers/aomic_id1000_vbm.py +6 -1
- junifer/configs/juseless/datagrabbers/camcan_vbm.py +6 -1
- junifer/configs/juseless/datagrabbers/ixi_vbm.py +6 -1
- junifer/configs/juseless/datagrabbers/tests/test_ucla.py +8 -8
- junifer/configs/juseless/datagrabbers/ucla.py +44 -26
- junifer/configs/juseless/datagrabbers/ukb_vbm.py +6 -1
- junifer/data/VOIs/meta/AutobiographicalMemory_VOIs.txt +23 -0
- junifer/data/VOIs/meta/Power2013_MNI_VOIs.tsv +264 -0
- junifer/data/__init__.py +4 -0
- junifer/data/coordinates.py +298 -31
- junifer/data/masks.py +360 -28
- junifer/data/parcellations.py +621 -188
- junifer/data/template_spaces.py +190 -0
- junifer/data/tests/test_coordinates.py +34 -3
- junifer/data/tests/test_data_utils.py +1 -0
- junifer/data/tests/test_masks.py +202 -86
- junifer/data/tests/test_parcellations.py +266 -55
- junifer/data/tests/test_template_spaces.py +104 -0
- junifer/data/utils.py +4 -2
- junifer/datagrabber/__init__.py +1 -0
- junifer/datagrabber/aomic/id1000.py +111 -70
- junifer/datagrabber/aomic/piop1.py +116 -53
- junifer/datagrabber/aomic/piop2.py +116 -53
- junifer/datagrabber/aomic/tests/test_id1000.py +27 -27
- junifer/datagrabber/aomic/tests/test_piop1.py +27 -27
- junifer/datagrabber/aomic/tests/test_piop2.py +27 -27
- junifer/datagrabber/base.py +62 -10
- junifer/datagrabber/datalad_base.py +0 -2
- junifer/datagrabber/dmcc13_benchmark.py +372 -0
- junifer/datagrabber/hcp1200/datalad_hcp1200.py +5 -0
- junifer/datagrabber/hcp1200/hcp1200.py +30 -13
- junifer/datagrabber/pattern.py +133 -27
- junifer/datagrabber/pattern_datalad.py +111 -13
- junifer/datagrabber/tests/test_base.py +57 -6
- junifer/datagrabber/tests/test_datagrabber_utils.py +204 -76
- junifer/datagrabber/tests/test_datalad_base.py +0 -6
- junifer/datagrabber/tests/test_dmcc13_benchmark.py +256 -0
- junifer/datagrabber/tests/test_multiple.py +43 -10
- junifer/datagrabber/tests/test_pattern.py +125 -178
- junifer/datagrabber/tests/test_pattern_datalad.py +44 -25
- junifer/datagrabber/utils.py +151 -16
- junifer/datareader/default.py +36 -10
- junifer/external/nilearn/junifer_nifti_spheres_masker.py +6 -0
- junifer/markers/base.py +25 -16
- junifer/markers/collection.py +35 -16
- junifer/markers/complexity/__init__.py +27 -0
- junifer/markers/complexity/complexity_base.py +149 -0
- junifer/markers/complexity/hurst_exponent.py +136 -0
- junifer/markers/complexity/multiscale_entropy_auc.py +140 -0
- junifer/markers/complexity/perm_entropy.py +132 -0
- junifer/markers/complexity/range_entropy.py +136 -0
- junifer/markers/complexity/range_entropy_auc.py +145 -0
- junifer/markers/complexity/sample_entropy.py +134 -0
- junifer/markers/complexity/tests/test_complexity_base.py +19 -0
- junifer/markers/complexity/tests/test_hurst_exponent.py +69 -0
- junifer/markers/complexity/tests/test_multiscale_entropy_auc.py +68 -0
- junifer/markers/complexity/tests/test_perm_entropy.py +68 -0
- junifer/markers/complexity/tests/test_range_entropy.py +69 -0
- junifer/markers/complexity/tests/test_range_entropy_auc.py +69 -0
- junifer/markers/complexity/tests/test_sample_entropy.py +68 -0
- junifer/markers/complexity/tests/test_weighted_perm_entropy.py +68 -0
- junifer/markers/complexity/weighted_perm_entropy.py +133 -0
- junifer/markers/falff/_afni_falff.py +153 -0
- junifer/markers/falff/_junifer_falff.py +142 -0
- junifer/markers/falff/falff_base.py +91 -84
- junifer/markers/falff/falff_parcels.py +61 -45
- junifer/markers/falff/falff_spheres.py +64 -48
- junifer/markers/falff/tests/test_falff_parcels.py +89 -121
- junifer/markers/falff/tests/test_falff_spheres.py +92 -127
- junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +1 -0
- junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +1 -0
- junifer/markers/functional_connectivity/functional_connectivity_base.py +1 -0
- junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py +46 -44
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +34 -39
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +40 -52
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +62 -70
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +99 -85
- junifer/markers/parcel_aggregation.py +60 -38
- junifer/markers/reho/_afni_reho.py +192 -0
- junifer/markers/reho/_junifer_reho.py +281 -0
- junifer/markers/reho/reho_base.py +69 -34
- junifer/markers/reho/reho_parcels.py +26 -16
- junifer/markers/reho/reho_spheres.py +23 -9
- junifer/markers/reho/tests/test_reho_parcels.py +93 -92
- junifer/markers/reho/tests/test_reho_spheres.py +88 -86
- junifer/markers/sphere_aggregation.py +54 -9
- junifer/markers/temporal_snr/temporal_snr_base.py +1 -0
- junifer/markers/temporal_snr/tests/test_temporal_snr_parcels.py +38 -37
- junifer/markers/temporal_snr/tests/test_temporal_snr_spheres.py +34 -38
- junifer/markers/tests/test_collection.py +43 -42
- junifer/markers/tests/test_ets_rss.py +29 -37
- junifer/markers/tests/test_parcel_aggregation.py +587 -468
- junifer/markers/tests/test_sphere_aggregation.py +209 -157
- junifer/markers/utils.py +2 -40
- junifer/onthefly/read_transform.py +13 -6
- junifer/pipeline/__init__.py +1 -0
- junifer/pipeline/pipeline_step_mixin.py +105 -41
- junifer/pipeline/registry.py +17 -0
- junifer/pipeline/singleton.py +45 -0
- junifer/pipeline/tests/test_pipeline_step_mixin.py +139 -51
- junifer/pipeline/tests/test_update_meta_mixin.py +1 -0
- junifer/pipeline/tests/test_workdir_manager.py +104 -0
- junifer/pipeline/update_meta_mixin.py +8 -2
- junifer/pipeline/utils.py +154 -15
- junifer/pipeline/workdir_manager.py +246 -0
- junifer/preprocess/__init__.py +3 -0
- junifer/preprocess/ants/__init__.py +4 -0
- junifer/preprocess/ants/ants_apply_transforms_warper.py +185 -0
- junifer/preprocess/ants/tests/test_ants_apply_transforms_warper.py +56 -0
- junifer/preprocess/base.py +96 -69
- junifer/preprocess/bold_warper.py +265 -0
- junifer/preprocess/confounds/fmriprep_confound_remover.py +91 -134
- junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py +106 -111
- junifer/preprocess/fsl/__init__.py +4 -0
- junifer/preprocess/fsl/apply_warper.py +179 -0
- junifer/preprocess/fsl/tests/test_apply_warper.py +45 -0
- junifer/preprocess/tests/test_bold_warper.py +159 -0
- junifer/preprocess/tests/test_preprocess_base.py +6 -6
- junifer/preprocess/warping/__init__.py +6 -0
- junifer/preprocess/warping/_ants_warper.py +167 -0
- junifer/preprocess/warping/_fsl_warper.py +109 -0
- junifer/preprocess/warping/space_warper.py +213 -0
- junifer/preprocess/warping/tests/test_space_warper.py +198 -0
- junifer/stats.py +18 -4
- junifer/storage/base.py +9 -1
- junifer/storage/hdf5.py +8 -3
- junifer/storage/pandas_base.py +2 -1
- junifer/storage/sqlite.py +1 -0
- junifer/storage/tests/test_hdf5.py +2 -1
- junifer/storage/tests/test_sqlite.py +8 -8
- junifer/storage/tests/test_utils.py +6 -6
- junifer/storage/utils.py +1 -0
- junifer/testing/datagrabbers.py +11 -7
- junifer/testing/utils.py +1 -0
- junifer/tests/test_stats.py +2 -0
- junifer/utils/__init__.py +1 -0
- junifer/utils/helpers.py +53 -0
- junifer/utils/logging.py +14 -3
- junifer/utils/tests/test_helpers.py +35 -0
- {junifer-0.0.3.dev186.dist-info → junifer-0.0.4.dist-info}/METADATA +59 -28
- junifer-0.0.4.dist-info/RECORD +257 -0
- {junifer-0.0.3.dev186.dist-info → junifer-0.0.4.dist-info}/WHEEL +1 -1
- junifer/markers/falff/falff_estimator.py +0 -334
- junifer/markers/falff/tests/test_falff_estimator.py +0 -238
- junifer/markers/reho/reho_estimator.py +0 -515
- junifer/markers/reho/tests/test_reho_estimator.py +0 -260
- junifer-0.0.3.dev186.dist-info/RECORD +0 -199
- {junifer-0.0.3.dev186.dist-info → junifer-0.0.4.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.3.dev186.dist-info → junifer-0.0.4.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.3.dev186.dist-info → junifer-0.0.4.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.3.dev186.dist-info → junifer-0.0.4.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,145 @@
|
|
1
|
+
"""Provide class for the AUC of range entropy of a time series."""
|
2
|
+
|
3
|
+
# Authors: Amir Omidvarnia <a.omidvarnia@fz-juelich.de>
|
4
|
+
# Leonard Sasse <l.sasse@fz-juelich.de>
|
5
|
+
# License: AGPL
|
6
|
+
|
7
|
+
from typing import Dict, List, Optional, Union
|
8
|
+
|
9
|
+
import neurokit2 as nk
|
10
|
+
import numpy as np
|
11
|
+
|
12
|
+
from ...api.decorators import register_marker
|
13
|
+
from ...utils import logger, warn_with_log
|
14
|
+
from .complexity_base import ComplexityBase
|
15
|
+
|
16
|
+
|
17
|
+
@register_marker
|
18
|
+
class RangeEntropyAUC(ComplexityBase):
|
19
|
+
"""Class for AUC of range entropy values of a time series over r = 0 to 1.
|
20
|
+
|
21
|
+
Parameters
|
22
|
+
----------
|
23
|
+
parcellation : str or list of str
|
24
|
+
The name(s) of the parcellation(s). Check valid options by calling
|
25
|
+
:func:`junifer.data.parcellations.list_parcellations`.
|
26
|
+
agg_method : str, optional
|
27
|
+
The method to perform aggregation using. Check valid options in
|
28
|
+
:func:`junifer.stats.get_aggfunc_by_name` (default "mean").
|
29
|
+
agg_method_params : dict, optional
|
30
|
+
Parameters to pass to the aggregation function. Check valid options in
|
31
|
+
:func:`junifer.stats.get_aggfunc_by_name` (default None).
|
32
|
+
masks : str, dict or list of dict or str, optional
|
33
|
+
The specification of the masks to apply to regions before extracting
|
34
|
+
signals. Check :ref:`Using Masks <using_masks>` for more details.
|
35
|
+
If None, will not apply any mask (default None).
|
36
|
+
params : dict, optional
|
37
|
+
Parameters to pass to the range entropy calculation function. For more
|
38
|
+
information, check out ``junifer.markers.utils._range_entropy``.
|
39
|
+
If None, value is set to {"m": 2, "delay": 1, "n_r": 10}
|
40
|
+
(default None).
|
41
|
+
name : str, optional
|
42
|
+
The name of the marker. If None, it will use the class name
|
43
|
+
(default None).
|
44
|
+
|
45
|
+
Warnings
|
46
|
+
--------
|
47
|
+
This class is not automatically imported by junifer and requires you to
|
48
|
+
import it explicitly. You can do it programmatically by
|
49
|
+
``from junifer.markers.complexity import RangeEntropyAUC`` or in the YAML
|
50
|
+
by ``with: junifer.markers.complexity``.
|
51
|
+
|
52
|
+
"""
|
53
|
+
|
54
|
+
def __init__(
|
55
|
+
self,
|
56
|
+
parcellation: Union[str, List[str]],
|
57
|
+
agg_method: str = "mean",
|
58
|
+
agg_method_params: Optional[Dict] = None,
|
59
|
+
masks: Union[str, Dict, List[Union[Dict, str]], None] = None,
|
60
|
+
params: Optional[Dict] = None,
|
61
|
+
name: Optional[str] = None,
|
62
|
+
) -> None:
|
63
|
+
super().__init__(
|
64
|
+
parcellation=parcellation,
|
65
|
+
agg_method=agg_method,
|
66
|
+
agg_method_params=agg_method_params,
|
67
|
+
masks=masks,
|
68
|
+
name=name,
|
69
|
+
)
|
70
|
+
if params is None:
|
71
|
+
self.params = {"m": 2, "delay": 1, "n_r": 10}
|
72
|
+
else:
|
73
|
+
self.params = params
|
74
|
+
|
75
|
+
def compute_complexity(
|
76
|
+
self,
|
77
|
+
extracted_bold_values: np.ndarray,
|
78
|
+
) -> np.ndarray:
|
79
|
+
"""Compute complexity measure.
|
80
|
+
|
81
|
+
Take a timeseries of brain areas, calculate range entropy according to
|
82
|
+
the method outlined in [1] across the range of tolerance value r from 0
|
83
|
+
to 1, and compute its area under the curve.
|
84
|
+
|
85
|
+
Parameters
|
86
|
+
----------
|
87
|
+
extracted_bold_values : numpy.ndarray
|
88
|
+
The BOLD values extracted via parcel aggregation.
|
89
|
+
|
90
|
+
Returns
|
91
|
+
-------
|
92
|
+
numpy.ndarray
|
93
|
+
The values after computing complexity measure.
|
94
|
+
|
95
|
+
References
|
96
|
+
----------
|
97
|
+
.. [1] A. Omidvarnia et al. (2018)
|
98
|
+
Range Entropy: A Bridge between Signal Complexity and
|
99
|
+
Self-Similarity.
|
100
|
+
Entropy, vol. 20, no. 12, p. 962, 2018.
|
101
|
+
|
102
|
+
See Also
|
103
|
+
--------
|
104
|
+
neurokit2.entropy_range
|
105
|
+
|
106
|
+
"""
|
107
|
+
logger.info("Calculating AUC of range entropy.")
|
108
|
+
|
109
|
+
emb_dim = self.params["m"]
|
110
|
+
delay = self.params["delay"]
|
111
|
+
n_r = self.params["n_r"]
|
112
|
+
|
113
|
+
assert isinstance(emb_dim, int), "Embedding dimension must be integer."
|
114
|
+
assert isinstance(delay, int), "Delay must be integer."
|
115
|
+
assert isinstance(n_r, int), "n_r must be an integer."
|
116
|
+
|
117
|
+
r_span = np.arange(0, 1, 1 / n_r) # Tolerance r span
|
118
|
+
_, n_roi = extracted_bold_values.shape
|
119
|
+
range_en_auc_roi = np.zeros((n_roi, 1))
|
120
|
+
|
121
|
+
for idx_roi in range(n_roi):
|
122
|
+
sig = extracted_bold_values[:, idx_roi]
|
123
|
+
|
124
|
+
range_ent_vec = np.zeros(n_r)
|
125
|
+
idx_r = 0
|
126
|
+
for tolerance in r_span:
|
127
|
+
range_en_auc_roi_tmp = nk.entropy_range(
|
128
|
+
sig,
|
129
|
+
dimension=emb_dim,
|
130
|
+
delay=delay,
|
131
|
+
tolerance=tolerance,
|
132
|
+
method="mSampEn", # RangeEn B
|
133
|
+
)
|
134
|
+
|
135
|
+
range_ent_vec[idx_r] = range_en_auc_roi_tmp[0]
|
136
|
+
idx_r = idx_r + 1
|
137
|
+
|
138
|
+
range_en_auc_roi[idx_roi] = np.trapz(range_ent_vec)
|
139
|
+
|
140
|
+
range_en_auc_roi = range_en_auc_roi / n_r
|
141
|
+
|
142
|
+
if np.isnan(np.sum(range_en_auc_roi)):
|
143
|
+
warn_with_log("There is NaN in the auc of range entropy values!")
|
144
|
+
|
145
|
+
return range_en_auc_roi.T # 1 X n_roi
|
@@ -0,0 +1,134 @@
|
|
1
|
+
"""Provide class for sample entropy of a time series."""
|
2
|
+
|
3
|
+
# Authors: Amir Omidvarnia <a.omidvarnia@fz-juelich.de>
|
4
|
+
# Leonard Sasse <l.sasse@fz-juelich.de>
|
5
|
+
# License: AGPL
|
6
|
+
|
7
|
+
from typing import Dict, List, Optional, Union
|
8
|
+
|
9
|
+
import neurokit2 as nk
|
10
|
+
import numpy as np
|
11
|
+
|
12
|
+
from ...api.decorators import register_marker
|
13
|
+
from ...utils import logger, warn_with_log
|
14
|
+
from .complexity_base import ComplexityBase
|
15
|
+
|
16
|
+
|
17
|
+
@register_marker
|
18
|
+
class SampleEntropy(ComplexityBase):
|
19
|
+
"""Class for sample entropy of a time series.
|
20
|
+
|
21
|
+
Parameters
|
22
|
+
----------
|
23
|
+
parcellation : str or list of str
|
24
|
+
The name(s) of the parcellation(s). Check valid options by calling
|
25
|
+
:func:`junifer.data.parcellations.list_parcellations`.
|
26
|
+
agg_method : str, optional
|
27
|
+
The method to perform aggregation using. Check valid options in
|
28
|
+
:func:`junifer.stats.get_aggfunc_by_name` (default "mean").
|
29
|
+
agg_method_params : dict, optional
|
30
|
+
Parameters to pass to the aggregation function. Check valid options in
|
31
|
+
:func:`junifer.stats.get_aggfunc_by_name` (default None).
|
32
|
+
masks : str, dict or list of dict or str, optional
|
33
|
+
The specification of the masks to apply to regions before extracting
|
34
|
+
signals. Check :ref:`Using Masks <using_masks>` for more details.
|
35
|
+
If None, will not apply any mask (default None).
|
36
|
+
params : dict, optional
|
37
|
+
Parameters to pass to the sample entropy calculation function.
|
38
|
+
For more information, check out
|
39
|
+
``junifer.markers.utils._sample_entropy``.
|
40
|
+
If None, value is set to
|
41
|
+
{"m": 2, "delay": 1, "tol": 0.5} (default None).
|
42
|
+
name : str, optional
|
43
|
+
The name of the marker. If None, it will use the class name
|
44
|
+
(default None).
|
45
|
+
|
46
|
+
Warnings
|
47
|
+
--------
|
48
|
+
This class is not automatically imported by junifer and requires you to
|
49
|
+
import it explicitly. You can do it programmatically by
|
50
|
+
``from junifer.markers.complexity import SampleEntropy`` or in the YAML by
|
51
|
+
``with: junifer.markers.complexity``.
|
52
|
+
|
53
|
+
"""
|
54
|
+
|
55
|
+
def __init__(
|
56
|
+
self,
|
57
|
+
parcellation: Union[str, List[str]],
|
58
|
+
agg_method: str = "mean",
|
59
|
+
agg_method_params: Optional[Dict] = None,
|
60
|
+
masks: Union[str, Dict, List[Union[Dict, str]], None] = None,
|
61
|
+
params: Optional[Dict] = None,
|
62
|
+
name: Optional[str] = None,
|
63
|
+
) -> None:
|
64
|
+
super().__init__(
|
65
|
+
parcellation=parcellation,
|
66
|
+
agg_method=agg_method,
|
67
|
+
agg_method_params=agg_method_params,
|
68
|
+
masks=masks,
|
69
|
+
name=name,
|
70
|
+
)
|
71
|
+
if params is None:
|
72
|
+
self.params = {"m": 4, "delay": 1, "tol": 0.5}
|
73
|
+
else:
|
74
|
+
self.params = params
|
75
|
+
|
76
|
+
def compute_complexity(
|
77
|
+
self,
|
78
|
+
extracted_bold_values: np.ndarray,
|
79
|
+
) -> np.ndarray:
|
80
|
+
"""Compute complexity measure.
|
81
|
+
|
82
|
+
Take a timeseries of brain areas, and calculate sample entropy [1].
|
83
|
+
|
84
|
+
Parameters
|
85
|
+
----------
|
86
|
+
extracted_bold_values : numpy.ndarray
|
87
|
+
The BOLD values extracted via parcel aggregation.
|
88
|
+
|
89
|
+
Returns
|
90
|
+
-------
|
91
|
+
numpy.ndarray
|
92
|
+
The values after computing complexity measure.
|
93
|
+
|
94
|
+
References
|
95
|
+
----------
|
96
|
+
.. [1] Richman, J., Moorman, J.
|
97
|
+
Physiological time-series analysis using approximate entropy and
|
98
|
+
sample entropy.
|
99
|
+
Am. J. Physiol. Heart Circ. Physiol., 278 (6) (2000),
|
100
|
+
pp. H2039-2049
|
101
|
+
|
102
|
+
See Also
|
103
|
+
--------
|
104
|
+
neurokit2.entropy_sample
|
105
|
+
|
106
|
+
"""
|
107
|
+
logger.info("Calculating sample entropy.")
|
108
|
+
|
109
|
+
emb_dim = self.params["m"]
|
110
|
+
delay = self.params["delay"]
|
111
|
+
tol = self.params["tol"]
|
112
|
+
|
113
|
+
assert isinstance(emb_dim, int), "Embedding dimension must be integer."
|
114
|
+
assert isinstance(delay, int), "Delay must be integer."
|
115
|
+
assert isinstance(
|
116
|
+
tol, float
|
117
|
+
), "Tolerance must be a positive float number."
|
118
|
+
|
119
|
+
_, n_roi = extracted_bold_values.shape
|
120
|
+
samp_en_roi = np.zeros((n_roi, 1))
|
121
|
+
|
122
|
+
for idx_roi in range(n_roi):
|
123
|
+
sig = extracted_bold_values[:, idx_roi]
|
124
|
+
tol_corrected = tol * np.std(sig)
|
125
|
+
tmp = nk.entropy_sample(
|
126
|
+
sig, dimension=emb_dim, delay=delay, tolerance=tol_corrected
|
127
|
+
)
|
128
|
+
|
129
|
+
samp_en_roi[idx_roi] = tmp[0]
|
130
|
+
|
131
|
+
if np.isnan(np.sum(samp_en_roi)):
|
132
|
+
warn_with_log("There is NaN in the entropy values!")
|
133
|
+
|
134
|
+
return samp_en_roi.T # 1 X n_roi
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"""Provide tests for base complexity marker."""
|
2
|
+
|
3
|
+
# Authors: Synchon Mandal <s.mandal@fz-juelich.de>
|
4
|
+
# License: AGPL
|
5
|
+
|
6
|
+
import pytest
|
7
|
+
|
8
|
+
|
9
|
+
pytest.importorskip("neurokit2")
|
10
|
+
|
11
|
+
from junifer.markers.complexity.complexity_base import ( # noqa: E402
|
12
|
+
ComplexityBase,
|
13
|
+
)
|
14
|
+
|
15
|
+
|
16
|
+
def test_base_complexity_marker_abstractness() -> None:
|
17
|
+
"""Test ComplexityBase is an abstract base class."""
|
18
|
+
with pytest.raises(TypeError, match="abstract"):
|
19
|
+
ComplexityBase()
|
@@ -0,0 +1,69 @@
|
|
1
|
+
"""Provide test for Hurst exponent."""
|
2
|
+
|
3
|
+
# Authors: Amir Omidvarnia <a.omidvarnia@fz-juelich.de>
|
4
|
+
# Synchon Mandal <s.mandal@fz-juelich.de>
|
5
|
+
# License: AGPL
|
6
|
+
|
7
|
+
from pathlib import Path
|
8
|
+
|
9
|
+
import pytest
|
10
|
+
|
11
|
+
|
12
|
+
pytest.importorskip("neurokit2")
|
13
|
+
|
14
|
+
|
15
|
+
from junifer.datareader import DefaultDataReader # noqa: E402
|
16
|
+
from junifer.markers.complexity import HurstExponent # noqa: E402
|
17
|
+
from junifer.storage import SQLiteFeatureStorage # noqa: E402
|
18
|
+
from junifer.testing.datagrabbers import ( # noqa: E402
|
19
|
+
SPMAuditoryTestingDataGrabber,
|
20
|
+
)
|
21
|
+
|
22
|
+
|
23
|
+
# Set parcellation
|
24
|
+
PARCELLATION = "Schaefer100x17"
|
25
|
+
|
26
|
+
|
27
|
+
def test_compute() -> None:
|
28
|
+
"""Test HurstExponent compute()."""
|
29
|
+
with SPMAuditoryTestingDataGrabber() as dg:
|
30
|
+
# Fetch element
|
31
|
+
element = dg["sub001"]
|
32
|
+
# Fetch element data
|
33
|
+
element_data = DefaultDataReader().fit_transform(element)
|
34
|
+
# Initialize the marker
|
35
|
+
marker = HurstExponent(parcellation=PARCELLATION)
|
36
|
+
# Compute the marker
|
37
|
+
feature_map = marker.fit_transform(element_data)
|
38
|
+
# Assert the dimension of timeseries
|
39
|
+
assert feature_map["BOLD"]["data"].ndim == 2
|
40
|
+
|
41
|
+
|
42
|
+
def test_get_output_type() -> None:
|
43
|
+
"""Test HurstExponent get_output_type()."""
|
44
|
+
marker = HurstExponent(parcellation=PARCELLATION)
|
45
|
+
assert marker.get_output_type("BOLD") == "vector"
|
46
|
+
|
47
|
+
|
48
|
+
def test_store(tmp_path: Path) -> None:
|
49
|
+
"""Test HurstExponent store().
|
50
|
+
|
51
|
+
Parameters
|
52
|
+
----------
|
53
|
+
tmp_path : pathlib.Path
|
54
|
+
The path to the test directory.
|
55
|
+
|
56
|
+
"""
|
57
|
+
with SPMAuditoryTestingDataGrabber() as dg:
|
58
|
+
# Fetch element
|
59
|
+
element = dg["sub001"]
|
60
|
+
# Fetch element data
|
61
|
+
element_data = DefaultDataReader().fit_transform(element)
|
62
|
+
# Initialize the marker
|
63
|
+
marker = HurstExponent(parcellation=PARCELLATION)
|
64
|
+
# Create storage
|
65
|
+
storage = SQLiteFeatureStorage(
|
66
|
+
uri=tmp_path / "test_hurst_exponent.sqlite"
|
67
|
+
)
|
68
|
+
# Compute the marker and store
|
69
|
+
marker.fit_transform(input=element_data, storage=storage)
|
@@ -0,0 +1,68 @@
|
|
1
|
+
"""Provide test for the AUC of multiscale entropy."""
|
2
|
+
|
3
|
+
# Authors: Amir Omidvarnia <a.omidvarnia@fz-juelich.de>
|
4
|
+
# Synchon Mandal <s.mandal@fz-juelich.de>
|
5
|
+
# License: AGPL
|
6
|
+
|
7
|
+
from pathlib import Path
|
8
|
+
|
9
|
+
import pytest
|
10
|
+
|
11
|
+
|
12
|
+
pytest.importorskip("neurokit2")
|
13
|
+
|
14
|
+
from junifer.datareader import DefaultDataReader # noqa: E402
|
15
|
+
from junifer.markers.complexity import MultiscaleEntropyAUC # noqa: E402
|
16
|
+
from junifer.storage import SQLiteFeatureStorage # noqa: E402
|
17
|
+
from junifer.testing.datagrabbers import ( # noqa: E402
|
18
|
+
SPMAuditoryTestingDataGrabber,
|
19
|
+
)
|
20
|
+
|
21
|
+
|
22
|
+
# Set parcellation
|
23
|
+
PARCELLATION = "Schaefer100x17"
|
24
|
+
|
25
|
+
|
26
|
+
def test_compute() -> None:
|
27
|
+
"""Test MultiscaleEntropyAUC compute()."""
|
28
|
+
with SPMAuditoryTestingDataGrabber() as dg:
|
29
|
+
# Fetch element
|
30
|
+
element = dg["sub001"]
|
31
|
+
# Fetch element data
|
32
|
+
element_data = DefaultDataReader().fit_transform(element)
|
33
|
+
# Initialize the marker
|
34
|
+
marker = MultiscaleEntropyAUC(parcellation=PARCELLATION)
|
35
|
+
# Compute the marker
|
36
|
+
feature_map = marker.fit_transform(element_data)
|
37
|
+
# Assert the dimension of timeseries
|
38
|
+
assert feature_map["BOLD"]["data"].ndim == 2
|
39
|
+
|
40
|
+
|
41
|
+
def test_get_output_type() -> None:
|
42
|
+
"""Test MultiscaleEntropyAUC get_output_type()."""
|
43
|
+
marker = MultiscaleEntropyAUC(parcellation=PARCELLATION)
|
44
|
+
assert marker.get_output_type("BOLD") == "vector"
|
45
|
+
|
46
|
+
|
47
|
+
def test_store(tmp_path: Path) -> None:
|
48
|
+
"""Test MultiscaleEntropyAUC store().
|
49
|
+
|
50
|
+
Parameters
|
51
|
+
----------
|
52
|
+
tmp_path : pathlib.Path
|
53
|
+
The path to the test directory.
|
54
|
+
|
55
|
+
"""
|
56
|
+
with SPMAuditoryTestingDataGrabber() as dg:
|
57
|
+
# Fetch element
|
58
|
+
element = dg["sub001"]
|
59
|
+
# Fetch element data
|
60
|
+
element_data = DefaultDataReader().fit_transform(element)
|
61
|
+
# Initialize the marker
|
62
|
+
marker = MultiscaleEntropyAUC(parcellation=PARCELLATION)
|
63
|
+
# Create storage
|
64
|
+
storage = SQLiteFeatureStorage(
|
65
|
+
uri=tmp_path / "test_multiscale_entropy_auc.sqlite"
|
66
|
+
)
|
67
|
+
# Compute the marker and store
|
68
|
+
marker.fit_transform(input=element_data, storage=storage)
|
@@ -0,0 +1,68 @@
|
|
1
|
+
"""Provide test for permutation entropy."""
|
2
|
+
|
3
|
+
# Authors: Amir Omidvarnia <a.omidvarnia@fz-juelich.de>
|
4
|
+
# Synchon Mandal <s.mandal@fz-juelich.de>
|
5
|
+
# License: AGPL
|
6
|
+
|
7
|
+
from pathlib import Path
|
8
|
+
|
9
|
+
import pytest
|
10
|
+
|
11
|
+
|
12
|
+
pytest.importorskip("neurokit2")
|
13
|
+
|
14
|
+
from junifer.datareader import DefaultDataReader # noqa: E402
|
15
|
+
from junifer.markers.complexity import PermEntropy # noqa: E402
|
16
|
+
from junifer.storage import SQLiteFeatureStorage # noqa: E402
|
17
|
+
from junifer.testing.datagrabbers import ( # noqa: E402
|
18
|
+
SPMAuditoryTestingDataGrabber,
|
19
|
+
)
|
20
|
+
|
21
|
+
|
22
|
+
# Set parcellation
|
23
|
+
PARCELLATION = "Schaefer100x17"
|
24
|
+
|
25
|
+
|
26
|
+
def test_compute() -> None:
|
27
|
+
"""Test PermEntropy compute()."""
|
28
|
+
with SPMAuditoryTestingDataGrabber() as dg:
|
29
|
+
# Fetch element
|
30
|
+
element = dg["sub001"]
|
31
|
+
# Fetch element data
|
32
|
+
element_data = DefaultDataReader().fit_transform(element)
|
33
|
+
# Initialize the marker
|
34
|
+
marker = PermEntropy(parcellation=PARCELLATION)
|
35
|
+
# Compute the marker
|
36
|
+
feature_map = marker.fit_transform(element_data)
|
37
|
+
# Assert the dimension of timeseries
|
38
|
+
assert feature_map["BOLD"]["data"].ndim == 2
|
39
|
+
|
40
|
+
|
41
|
+
def test_get_output_type() -> None:
|
42
|
+
"""Test PermEntropy get_output_type()."""
|
43
|
+
marker = PermEntropy(parcellation=PARCELLATION)
|
44
|
+
assert marker.get_output_type("BOLD") == "vector"
|
45
|
+
|
46
|
+
|
47
|
+
def test_store(tmp_path: Path) -> None:
|
48
|
+
"""Test PermEntropy store().
|
49
|
+
|
50
|
+
Parameters
|
51
|
+
----------
|
52
|
+
tmp_path : pathlib.Path
|
53
|
+
The path to the test directory.
|
54
|
+
|
55
|
+
"""
|
56
|
+
with SPMAuditoryTestingDataGrabber() as dg:
|
57
|
+
# Fetch element
|
58
|
+
element = dg["sub001"]
|
59
|
+
# Fetch element data
|
60
|
+
element_data = DefaultDataReader().fit_transform(element)
|
61
|
+
# Initialize the marker
|
62
|
+
marker = PermEntropy(parcellation=PARCELLATION)
|
63
|
+
# Create storage
|
64
|
+
storage = SQLiteFeatureStorage(
|
65
|
+
uri=tmp_path / "test_perm_entropy.sqlite"
|
66
|
+
)
|
67
|
+
# Compute the marker and store
|
68
|
+
marker.fit_transform(input=element_data, storage=storage)
|
@@ -0,0 +1,69 @@
|
|
1
|
+
"""Provide test for range entropy."""
|
2
|
+
|
3
|
+
# Authors: Amir Omidvarnia <a.omidvarnia@fz-juelich.de>
|
4
|
+
# Synchon Mandal <s.mandal@fz-juelich.de>
|
5
|
+
# License: AGPL
|
6
|
+
|
7
|
+
from pathlib import Path
|
8
|
+
|
9
|
+
import pytest
|
10
|
+
|
11
|
+
|
12
|
+
pytest.importorskip("neurokit2")
|
13
|
+
|
14
|
+
|
15
|
+
from junifer.datareader import DefaultDataReader # noqa: E402
|
16
|
+
from junifer.markers.complexity import RangeEntropy # noqa: E402
|
17
|
+
from junifer.storage import SQLiteFeatureStorage # noqa: E402
|
18
|
+
from junifer.testing.datagrabbers import ( # noqa: E402
|
19
|
+
SPMAuditoryTestingDataGrabber,
|
20
|
+
)
|
21
|
+
|
22
|
+
|
23
|
+
# Set parcellation
|
24
|
+
PARCELLATION = "Schaefer100x17"
|
25
|
+
|
26
|
+
|
27
|
+
def test_compute() -> None:
|
28
|
+
"""Test RangeEntropy compute()."""
|
29
|
+
with SPMAuditoryTestingDataGrabber() as dg:
|
30
|
+
# Fetch element
|
31
|
+
element = dg["sub001"]
|
32
|
+
# Fetch element data
|
33
|
+
element_data = DefaultDataReader().fit_transform(element)
|
34
|
+
# Initialize the marker
|
35
|
+
marker = RangeEntropy(parcellation=PARCELLATION)
|
36
|
+
# Compute the marker
|
37
|
+
feature_map = marker.fit_transform(element_data)
|
38
|
+
# Assert the dimension of timeseries
|
39
|
+
assert feature_map["BOLD"]["data"].ndim == 2
|
40
|
+
|
41
|
+
|
42
|
+
def test_get_output_type() -> None:
|
43
|
+
"""Test RangeEntropy get_output_type()."""
|
44
|
+
marker = RangeEntropy(parcellation=PARCELLATION)
|
45
|
+
assert marker.get_output_type("BOLD") == "vector"
|
46
|
+
|
47
|
+
|
48
|
+
def test_store(tmp_path: Path) -> None:
|
49
|
+
"""Test RangeEntropy store().
|
50
|
+
|
51
|
+
Parameters
|
52
|
+
----------
|
53
|
+
tmp_path : pathlib.Path
|
54
|
+
The path to the test directory.
|
55
|
+
|
56
|
+
"""
|
57
|
+
with SPMAuditoryTestingDataGrabber() as dg:
|
58
|
+
# Fetch element
|
59
|
+
element = dg["sub001"]
|
60
|
+
# Fetch element data
|
61
|
+
element_data = DefaultDataReader().fit_transform(element)
|
62
|
+
# Initialize the marker
|
63
|
+
marker = RangeEntropy(parcellation=PARCELLATION)
|
64
|
+
# Create storage
|
65
|
+
storage = SQLiteFeatureStorage(
|
66
|
+
uri=tmp_path / "test_range_entropy.sqlite"
|
67
|
+
)
|
68
|
+
# Compute the marker and store
|
69
|
+
marker.fit_transform(input=element_data, storage=storage)
|
@@ -0,0 +1,69 @@
|
|
1
|
+
"""Provide test for the AUC of range entropy."""
|
2
|
+
|
3
|
+
# Authors: Amir Omidvarnia <a.omidvarnia@fz-juelich.de>
|
4
|
+
# Synchon Mandal <s.mandal@fz-juelich.de>
|
5
|
+
# License: AGPL
|
6
|
+
|
7
|
+
from pathlib import Path
|
8
|
+
|
9
|
+
import pytest
|
10
|
+
|
11
|
+
|
12
|
+
pytest.importorskip("neurokit2")
|
13
|
+
|
14
|
+
|
15
|
+
from junifer.datareader import DefaultDataReader # noqa: E402
|
16
|
+
from junifer.markers.complexity import RangeEntropyAUC # noqa: E402
|
17
|
+
from junifer.storage import SQLiteFeatureStorage # noqa: E402
|
18
|
+
from junifer.testing.datagrabbers import ( # noqa: E402
|
19
|
+
SPMAuditoryTestingDataGrabber,
|
20
|
+
)
|
21
|
+
|
22
|
+
|
23
|
+
# Set parcellation
|
24
|
+
PARCELLATION = "Schaefer100x17"
|
25
|
+
|
26
|
+
|
27
|
+
def test_compute() -> None:
|
28
|
+
"""Test RangeEntropyAUC compute()."""
|
29
|
+
with SPMAuditoryTestingDataGrabber() as dg:
|
30
|
+
# Fetch element
|
31
|
+
element = dg["sub001"]
|
32
|
+
# Fetch element data
|
33
|
+
element_data = DefaultDataReader().fit_transform(element)
|
34
|
+
# Initialize the marker
|
35
|
+
marker = RangeEntropyAUC(parcellation=PARCELLATION)
|
36
|
+
# Compute the marker
|
37
|
+
feature_map = marker.fit_transform(element_data)
|
38
|
+
# Assert the dimension of timeseries
|
39
|
+
assert feature_map["BOLD"]["data"].ndim == 2
|
40
|
+
|
41
|
+
|
42
|
+
def test_get_output_type() -> None:
|
43
|
+
"""Test RangeEntropyAUC get_output_type()."""
|
44
|
+
marker = RangeEntropyAUC(parcellation=PARCELLATION)
|
45
|
+
assert marker.get_output_type("BOLD") == "vector"
|
46
|
+
|
47
|
+
|
48
|
+
def test_store(tmp_path: Path) -> None:
|
49
|
+
"""Test RangeEntropyAUC store().
|
50
|
+
|
51
|
+
Parameters
|
52
|
+
----------
|
53
|
+
tmp_path : pathlib.Path
|
54
|
+
The path to the test directory.
|
55
|
+
|
56
|
+
"""
|
57
|
+
with SPMAuditoryTestingDataGrabber() as dg:
|
58
|
+
# Fetch element
|
59
|
+
element = dg["sub001"]
|
60
|
+
# Fetch element data
|
61
|
+
element_data = DefaultDataReader().fit_transform(element)
|
62
|
+
# Initialize the marker
|
63
|
+
marker = RangeEntropyAUC(parcellation=PARCELLATION)
|
64
|
+
# Create storage
|
65
|
+
storage = SQLiteFeatureStorage(
|
66
|
+
uri=tmp_path / "test_range_entropy_auc.sqlite"
|
67
|
+
)
|
68
|
+
# Compute the marker and store
|
69
|
+
marker.fit_transform(input=element_data, storage=storage)
|