junifer 0.0.5.dev240__py3-none-any.whl → 0.0.6__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/__init__.py +2 -31
- junifer/__init__.pyi +37 -0
- junifer/_version.py +9 -4
- junifer/api/__init__.py +3 -5
- junifer/api/__init__.pyi +4 -0
- junifer/api/decorators.py +14 -19
- junifer/api/functions.py +165 -109
- junifer/api/py.typed +0 -0
- junifer/api/queue_context/__init__.py +2 -4
- junifer/api/queue_context/__init__.pyi +5 -0
- junifer/api/queue_context/gnu_parallel_local_adapter.py +22 -6
- junifer/api/queue_context/htcondor_adapter.py +23 -6
- junifer/api/queue_context/py.typed +0 -0
- junifer/api/queue_context/tests/test_gnu_parallel_local_adapter.py +3 -3
- junifer/api/queue_context/tests/test_htcondor_adapter.py +3 -3
- junifer/api/tests/test_functions.py +168 -74
- junifer/cli/__init__.py +24 -0
- junifer/cli/__init__.pyi +3 -0
- junifer/{api → cli}/cli.py +141 -125
- junifer/cli/parser.py +235 -0
- junifer/cli/py.typed +0 -0
- junifer/{api → cli}/tests/test_cli.py +8 -8
- junifer/{api/tests/test_api_utils.py → cli/tests/test_cli_utils.py} +5 -4
- junifer/{api → cli}/tests/test_parser.py +2 -2
- junifer/{api → cli}/utils.py +6 -16
- junifer/configs/juseless/__init__.py +2 -2
- junifer/configs/juseless/__init__.pyi +3 -0
- junifer/configs/juseless/datagrabbers/__init__.py +2 -12
- junifer/configs/juseless/datagrabbers/__init__.pyi +13 -0
- junifer/configs/juseless/datagrabbers/ixi_vbm.py +2 -2
- junifer/configs/juseless/datagrabbers/py.typed +0 -0
- junifer/configs/juseless/datagrabbers/tests/test_ucla.py +2 -2
- junifer/configs/juseless/datagrabbers/ucla.py +4 -4
- junifer/configs/juseless/py.typed +0 -0
- junifer/conftest.py +25 -0
- junifer/data/__init__.py +2 -42
- junifer/data/__init__.pyi +29 -0
- junifer/data/_dispatch.py +248 -0
- junifer/data/coordinates/__init__.py +9 -0
- junifer/data/coordinates/__init__.pyi +5 -0
- junifer/data/coordinates/_ants_coordinates_warper.py +104 -0
- junifer/data/coordinates/_coordinates.py +385 -0
- junifer/data/coordinates/_fsl_coordinates_warper.py +81 -0
- junifer/data/{tests → coordinates/tests}/test_coordinates.py +26 -33
- junifer/data/masks/__init__.py +9 -0
- junifer/data/masks/__init__.pyi +6 -0
- junifer/data/masks/_ants_mask_warper.py +177 -0
- junifer/data/masks/_fsl_mask_warper.py +106 -0
- junifer/data/masks/_masks.py +802 -0
- junifer/data/{tests → masks/tests}/test_masks.py +67 -63
- junifer/data/parcellations/__init__.py +9 -0
- junifer/data/parcellations/__init__.pyi +6 -0
- junifer/data/parcellations/_ants_parcellation_warper.py +166 -0
- junifer/data/parcellations/_fsl_parcellation_warper.py +89 -0
- junifer/data/parcellations/_parcellations.py +1388 -0
- junifer/data/{tests → parcellations/tests}/test_parcellations.py +165 -295
- junifer/data/pipeline_data_registry_base.py +76 -0
- junifer/data/py.typed +0 -0
- junifer/data/template_spaces.py +44 -79
- junifer/data/tests/test_data_utils.py +1 -2
- junifer/data/tests/test_template_spaces.py +8 -4
- junifer/data/utils.py +109 -4
- junifer/datagrabber/__init__.py +2 -26
- junifer/datagrabber/__init__.pyi +27 -0
- junifer/datagrabber/aomic/__init__.py +2 -4
- junifer/datagrabber/aomic/__init__.pyi +5 -0
- junifer/datagrabber/aomic/id1000.py +81 -52
- junifer/datagrabber/aomic/piop1.py +83 -55
- junifer/datagrabber/aomic/piop2.py +85 -56
- junifer/datagrabber/aomic/py.typed +0 -0
- junifer/datagrabber/aomic/tests/test_id1000.py +19 -12
- junifer/datagrabber/aomic/tests/test_piop1.py +52 -18
- junifer/datagrabber/aomic/tests/test_piop2.py +50 -17
- junifer/datagrabber/base.py +22 -18
- junifer/datagrabber/datalad_base.py +71 -34
- junifer/datagrabber/dmcc13_benchmark.py +31 -18
- junifer/datagrabber/hcp1200/__init__.py +2 -3
- junifer/datagrabber/hcp1200/__init__.pyi +4 -0
- junifer/datagrabber/hcp1200/datalad_hcp1200.py +3 -3
- junifer/datagrabber/hcp1200/hcp1200.py +26 -15
- junifer/datagrabber/hcp1200/py.typed +0 -0
- junifer/datagrabber/hcp1200/tests/test_hcp1200.py +8 -2
- junifer/datagrabber/multiple.py +14 -9
- junifer/datagrabber/pattern.py +132 -96
- junifer/datagrabber/pattern_validation_mixin.py +206 -94
- junifer/datagrabber/py.typed +0 -0
- junifer/datagrabber/tests/test_datalad_base.py +27 -12
- junifer/datagrabber/tests/test_dmcc13_benchmark.py +28 -11
- junifer/datagrabber/tests/test_multiple.py +48 -2
- junifer/datagrabber/tests/test_pattern_datalad.py +1 -1
- junifer/datagrabber/tests/test_pattern_validation_mixin.py +6 -6
- junifer/datareader/__init__.py +2 -2
- junifer/datareader/__init__.pyi +3 -0
- junifer/datareader/default.py +6 -6
- junifer/datareader/py.typed +0 -0
- junifer/external/nilearn/__init__.py +2 -3
- junifer/external/nilearn/__init__.pyi +4 -0
- junifer/external/nilearn/junifer_connectivity_measure.py +25 -17
- junifer/external/nilearn/junifer_nifti_spheres_masker.py +4 -4
- junifer/external/nilearn/py.typed +0 -0
- junifer/external/nilearn/tests/test_junifer_connectivity_measure.py +17 -16
- junifer/external/nilearn/tests/test_junifer_nifti_spheres_masker.py +2 -3
- junifer/markers/__init__.py +2 -38
- junifer/markers/__init__.pyi +37 -0
- junifer/markers/base.py +11 -14
- junifer/markers/brainprint.py +12 -14
- junifer/markers/complexity/__init__.py +2 -18
- junifer/markers/complexity/__init__.pyi +17 -0
- junifer/markers/complexity/complexity_base.py +9 -11
- junifer/markers/complexity/hurst_exponent.py +7 -7
- junifer/markers/complexity/multiscale_entropy_auc.py +7 -7
- junifer/markers/complexity/perm_entropy.py +7 -7
- junifer/markers/complexity/py.typed +0 -0
- junifer/markers/complexity/range_entropy.py +7 -7
- junifer/markers/complexity/range_entropy_auc.py +7 -7
- junifer/markers/complexity/sample_entropy.py +7 -7
- junifer/markers/complexity/tests/test_complexity_base.py +1 -1
- junifer/markers/complexity/tests/test_hurst_exponent.py +5 -5
- junifer/markers/complexity/tests/test_multiscale_entropy_auc.py +5 -5
- junifer/markers/complexity/tests/test_perm_entropy.py +5 -5
- junifer/markers/complexity/tests/test_range_entropy.py +5 -5
- junifer/markers/complexity/tests/test_range_entropy_auc.py +5 -5
- junifer/markers/complexity/tests/test_sample_entropy.py +5 -5
- junifer/markers/complexity/tests/test_weighted_perm_entropy.py +5 -5
- junifer/markers/complexity/weighted_perm_entropy.py +7 -7
- junifer/markers/ets_rss.py +12 -11
- junifer/markers/falff/__init__.py +2 -3
- junifer/markers/falff/__init__.pyi +4 -0
- junifer/markers/falff/_afni_falff.py +38 -45
- junifer/markers/falff/_junifer_falff.py +16 -19
- junifer/markers/falff/falff_base.py +7 -11
- junifer/markers/falff/falff_parcels.py +9 -9
- junifer/markers/falff/falff_spheres.py +8 -8
- junifer/markers/falff/py.typed +0 -0
- junifer/markers/falff/tests/test_falff_spheres.py +3 -1
- junifer/markers/functional_connectivity/__init__.py +2 -12
- junifer/markers/functional_connectivity/__init__.pyi +13 -0
- junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +9 -8
- junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +8 -8
- junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +7 -7
- junifer/markers/functional_connectivity/functional_connectivity_base.py +13 -12
- junifer/markers/functional_connectivity/functional_connectivity_parcels.py +8 -8
- junifer/markers/functional_connectivity/functional_connectivity_spheres.py +7 -7
- junifer/markers/functional_connectivity/py.typed +0 -0
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +1 -2
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +1 -2
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +6 -6
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +5 -5
- junifer/markers/parcel_aggregation.py +22 -17
- junifer/markers/py.typed +0 -0
- junifer/markers/reho/__init__.py +2 -3
- junifer/markers/reho/__init__.pyi +4 -0
- junifer/markers/reho/_afni_reho.py +29 -35
- junifer/markers/reho/_junifer_reho.py +13 -14
- junifer/markers/reho/py.typed +0 -0
- junifer/markers/reho/reho_base.py +7 -11
- junifer/markers/reho/reho_parcels.py +10 -10
- junifer/markers/reho/reho_spheres.py +9 -9
- junifer/markers/sphere_aggregation.py +22 -17
- junifer/markers/temporal_snr/__init__.py +2 -3
- junifer/markers/temporal_snr/__init__.pyi +4 -0
- junifer/markers/temporal_snr/py.typed +0 -0
- junifer/markers/temporal_snr/temporal_snr_base.py +11 -10
- junifer/markers/temporal_snr/temporal_snr_parcels.py +8 -8
- junifer/markers/temporal_snr/temporal_snr_spheres.py +7 -7
- junifer/markers/tests/test_ets_rss.py +3 -3
- junifer/markers/tests/test_parcel_aggregation.py +24 -24
- junifer/markers/tests/test_sphere_aggregation.py +6 -6
- junifer/markers/utils.py +3 -3
- junifer/onthefly/__init__.py +2 -1
- junifer/onthefly/_brainprint.py +138 -0
- junifer/onthefly/read_transform.py +5 -8
- junifer/pipeline/__init__.py +2 -10
- junifer/pipeline/__init__.pyi +13 -0
- junifer/{markers/collection.py → pipeline/marker_collection.py} +8 -14
- junifer/pipeline/pipeline_component_registry.py +294 -0
- junifer/pipeline/pipeline_step_mixin.py +15 -11
- junifer/pipeline/py.typed +0 -0
- junifer/{markers/tests/test_collection.py → pipeline/tests/test_marker_collection.py} +2 -3
- junifer/pipeline/tests/test_pipeline_component_registry.py +200 -0
- junifer/pipeline/tests/test_pipeline_step_mixin.py +36 -37
- junifer/pipeline/tests/test_update_meta_mixin.py +4 -4
- junifer/pipeline/tests/test_workdir_manager.py +43 -0
- junifer/pipeline/update_meta_mixin.py +21 -17
- junifer/pipeline/utils.py +6 -6
- junifer/pipeline/workdir_manager.py +19 -5
- junifer/preprocess/__init__.py +2 -10
- junifer/preprocess/__init__.pyi +11 -0
- junifer/preprocess/base.py +10 -10
- junifer/preprocess/confounds/__init__.py +2 -2
- junifer/preprocess/confounds/__init__.pyi +3 -0
- junifer/preprocess/confounds/fmriprep_confound_remover.py +243 -64
- junifer/preprocess/confounds/py.typed +0 -0
- junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py +121 -14
- junifer/preprocess/py.typed +0 -0
- junifer/preprocess/smoothing/__init__.py +2 -2
- junifer/preprocess/smoothing/__init__.pyi +3 -0
- junifer/preprocess/smoothing/_afni_smoothing.py +40 -40
- junifer/preprocess/smoothing/_fsl_smoothing.py +22 -32
- junifer/preprocess/smoothing/_nilearn_smoothing.py +35 -14
- junifer/preprocess/smoothing/py.typed +0 -0
- junifer/preprocess/smoothing/smoothing.py +11 -13
- junifer/preprocess/warping/__init__.py +2 -2
- junifer/preprocess/warping/__init__.pyi +3 -0
- junifer/preprocess/warping/_ants_warper.py +136 -32
- junifer/preprocess/warping/_fsl_warper.py +73 -22
- junifer/preprocess/warping/py.typed +0 -0
- junifer/preprocess/warping/space_warper.py +39 -11
- junifer/preprocess/warping/tests/test_space_warper.py +5 -9
- junifer/py.typed +0 -0
- junifer/stats.py +5 -5
- junifer/storage/__init__.py +2 -10
- junifer/storage/__init__.pyi +11 -0
- junifer/storage/base.py +47 -13
- junifer/storage/hdf5.py +95 -33
- junifer/storage/pandas_base.py +12 -11
- junifer/storage/py.typed +0 -0
- junifer/storage/sqlite.py +11 -11
- junifer/storage/tests/test_hdf5.py +86 -4
- junifer/storage/tests/test_sqlite.py +2 -2
- junifer/storage/tests/test_storage_base.py +5 -2
- junifer/storage/tests/test_utils.py +33 -7
- junifer/storage/utils.py +95 -9
- junifer/testing/__init__.py +2 -3
- junifer/testing/__init__.pyi +4 -0
- junifer/testing/datagrabbers.py +10 -11
- junifer/testing/py.typed +0 -0
- junifer/testing/registry.py +4 -7
- junifer/testing/tests/test_testing_registry.py +9 -17
- junifer/tests/test_stats.py +2 -2
- junifer/typing/__init__.py +9 -0
- junifer/typing/__init__.pyi +31 -0
- junifer/typing/_typing.py +68 -0
- junifer/utils/__init__.py +2 -12
- junifer/utils/__init__.pyi +18 -0
- junifer/utils/_config.py +110 -0
- junifer/utils/_yaml.py +16 -0
- junifer/utils/helpers.py +6 -6
- junifer/utils/logging.py +117 -8
- junifer/utils/py.typed +0 -0
- junifer/{pipeline → utils}/singleton.py +19 -14
- junifer/utils/tests/test_config.py +59 -0
- {junifer-0.0.5.dev240.dist-info → junifer-0.0.6.dist-info}/METADATA +43 -38
- junifer-0.0.6.dist-info/RECORD +350 -0
- {junifer-0.0.5.dev240.dist-info → junifer-0.0.6.dist-info}/WHEEL +1 -1
- junifer-0.0.6.dist-info/entry_points.txt +2 -0
- junifer/api/parser.py +0 -118
- junifer/data/coordinates.py +0 -408
- junifer/data/masks.py +0 -670
- junifer/data/parcellations.py +0 -1828
- junifer/pipeline/registry.py +0 -177
- junifer/pipeline/tests/test_registry.py +0 -150
- junifer-0.0.5.dev240.dist-info/RECORD +0 -275
- junifer-0.0.5.dev240.dist-info/entry_points.txt +0 -2
- /junifer/{api → cli}/tests/data/gmd_mean.yaml +0 -0
- /junifer/{api → cli}/tests/data/gmd_mean_htcondor.yaml +0 -0
- /junifer/{api → cli}/tests/data/partly_cloudy_agg_mean_tian.yml +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/AutobiographicalMemory_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/CogAC_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/CogAR_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/DMNBuckner_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/Dosenbach2010_MNI_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/Empathy_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/Motor_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/MultiTask_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/PhysioStress_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/Power2011_MNI_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/Power2013_MNI_VOIs.tsv +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/Rew_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/Somatosensory_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/ToM_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/VigAtt_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/WM_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/eMDN_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/eSAD_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/extDMN_VOIs.txt +0 -0
- {junifer-0.0.5.dev240.dist-info → junifer-0.0.6.dist-info/licenses}/AUTHORS.rst +0 -0
- {junifer-0.0.5.dev240.dist-info → junifer-0.0.6.dist-info/licenses}/LICENSE.md +0 -0
- {junifer-0.0.5.dev240.dist-info → junifer-0.0.6.dist-info}/top_level.txt +0 -0
@@ -29,7 +29,7 @@ def test_MultipleDataGrabber() -> None:
|
|
29
29
|
dg1 = PatternDataladDataGrabber(
|
30
30
|
rootdir=rootdir,
|
31
31
|
uri=repo_uri,
|
32
|
-
types=["T1w"],
|
32
|
+
types=["T1w", "Warp"],
|
33
33
|
patterns={
|
34
34
|
"T1w": {
|
35
35
|
"pattern": (
|
@@ -44,6 +44,28 @@ def test_MultipleDataGrabber() -> None:
|
|
44
44
|
"space": "native",
|
45
45
|
},
|
46
46
|
},
|
47
|
+
"Warp": [
|
48
|
+
{
|
49
|
+
"pattern": (
|
50
|
+
"{subject}/{session}/anat/"
|
51
|
+
"{subject}_{session}_from-MNI152NLin2009cAsym_to-T1w_"
|
52
|
+
"xfm.h5"
|
53
|
+
),
|
54
|
+
"src": "MNI152NLin2009cAsym",
|
55
|
+
"dst": "native",
|
56
|
+
"warper": "ants",
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"pattern": (
|
60
|
+
"{subject}/{session}/anat/"
|
61
|
+
"{subject}_{session}_from-T1w_to-MNI152NLin2009cAsym_"
|
62
|
+
"xfm.h5"
|
63
|
+
),
|
64
|
+
"src": "native",
|
65
|
+
"dst": "MNI152NLin2009cAsym",
|
66
|
+
"warper": "ants",
|
67
|
+
},
|
68
|
+
],
|
47
69
|
},
|
48
70
|
replacements=replacements,
|
49
71
|
)
|
@@ -75,6 +97,7 @@ def test_MultipleDataGrabber() -> None:
|
|
75
97
|
|
76
98
|
types = dg.get_types()
|
77
99
|
assert "T1w" in types
|
100
|
+
assert "Warp" in types
|
78
101
|
assert "BOLD" in types
|
79
102
|
|
80
103
|
expected_subs = [
|
@@ -90,6 +113,7 @@ def test_MultipleDataGrabber() -> None:
|
|
90
113
|
elem = dg[("sub-01", "ses-01")]
|
91
114
|
# Check data types
|
92
115
|
assert "T1w" in elem
|
116
|
+
assert "Warp" in elem
|
93
117
|
assert "BOLD" in elem
|
94
118
|
# Check meta
|
95
119
|
assert "meta" in elem["BOLD"]
|
@@ -111,7 +135,7 @@ def test_MultipleDataGrabber_no_intersection() -> None:
|
|
111
135
|
dg1 = PatternDataladDataGrabber(
|
112
136
|
rootdir=rootdir,
|
113
137
|
uri=_testing_dataset["example_bids"]["uri"],
|
114
|
-
types=["T1w"],
|
138
|
+
types=["T1w", "Warp"],
|
115
139
|
patterns={
|
116
140
|
"T1w": {
|
117
141
|
"pattern": (
|
@@ -119,6 +143,28 @@ def test_MultipleDataGrabber_no_intersection() -> None:
|
|
119
143
|
),
|
120
144
|
"space": "native",
|
121
145
|
},
|
146
|
+
"Warp": [
|
147
|
+
{
|
148
|
+
"pattern": (
|
149
|
+
"{subject}/{session}/anat/"
|
150
|
+
"{subject}_{session}_from-MNI152NLin2009cAsym_to-T1w_"
|
151
|
+
"xfm.h5"
|
152
|
+
),
|
153
|
+
"src": "MNI152NLin2009cAsym",
|
154
|
+
"dst": "native",
|
155
|
+
"warper": "ants",
|
156
|
+
},
|
157
|
+
{
|
158
|
+
"pattern": (
|
159
|
+
"{subject}/{session}/anat/"
|
160
|
+
"{subject}_{session}_from-T1w_to-MNI152NLin2009cAsym_"
|
161
|
+
"xfm.h5"
|
162
|
+
),
|
163
|
+
"src": "native",
|
164
|
+
"dst": "MNI152NLin2009cAsym",
|
165
|
+
"warper": "ants",
|
166
|
+
},
|
167
|
+
],
|
122
168
|
},
|
123
169
|
replacements=replacements,
|
124
170
|
)
|
@@ -15,7 +15,7 @@ from junifer.datagrabber import PatternDataladDataGrabber
|
|
15
15
|
_testing_dataset = {
|
16
16
|
"example_bids": {
|
17
17
|
"uri": "https://gin.g-node.org/juaml/datalad-example-bids",
|
18
|
-
"commit": "
|
18
|
+
"commit": "3f288c8725207ae0c9b3616e093e78cda192b570",
|
19
19
|
"id": "8fddff30-6993-420a-9d1e-b5b028c59468",
|
20
20
|
},
|
21
21
|
"example_bids_ses": {
|
@@ -4,8 +4,8 @@
|
|
4
4
|
# Synchon Mandal <s.mandal@fz-juelich.de>
|
5
5
|
# License: AGPL
|
6
6
|
|
7
|
-
from contextlib import nullcontext
|
8
|
-
from typing import
|
7
|
+
from contextlib import AbstractContextManager, nullcontext
|
8
|
+
from typing import Union
|
9
9
|
|
10
10
|
import pytest
|
11
11
|
|
@@ -186,10 +186,10 @@ from junifer.datagrabber.pattern_validation_mixin import PatternValidationMixin
|
|
186
186
|
],
|
187
187
|
)
|
188
188
|
def test_PatternValidationMixin(
|
189
|
-
types: Union[str,
|
190
|
-
replacements: Union[str,
|
191
|
-
patterns: Union[str,
|
192
|
-
expect:
|
189
|
+
types: Union[str, list[str], list[int]],
|
190
|
+
replacements: Union[str, list[str], list[int]],
|
191
|
+
patterns: Union[str, dict[str, dict[str, str]]],
|
192
|
+
expect: AbstractContextManager,
|
193
193
|
) -> None:
|
194
194
|
"""Test validation.
|
195
195
|
|
junifer/datareader/__init__.py
CHANGED
junifer/datareader/default.py
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# License: AGPL
|
6
6
|
|
7
7
|
from pathlib import Path
|
8
|
-
from typing import
|
8
|
+
from typing import Optional, Union
|
9
9
|
|
10
10
|
import nibabel as nib
|
11
11
|
import pandas as pd
|
@@ -37,7 +37,7 @@ _readers["TSV"] = {"func": pd.read_csv, "params": {"sep": "\t"}}
|
|
37
37
|
class DefaultDataReader(PipelineStepMixin, UpdateMetaMixin):
|
38
38
|
"""Concrete implementation for common data reading."""
|
39
39
|
|
40
|
-
def validate_input(self, input:
|
40
|
+
def validate_input(self, input: list[str]) -> list[str]:
|
41
41
|
"""Validate input.
|
42
42
|
|
43
43
|
Parameters
|
@@ -75,9 +75,9 @@ class DefaultDataReader(PipelineStepMixin, UpdateMetaMixin):
|
|
75
75
|
|
76
76
|
def _fit_transform(
|
77
77
|
self,
|
78
|
-
input:
|
79
|
-
params: Optional[
|
80
|
-
) ->
|
78
|
+
input: dict[str, dict],
|
79
|
+
params: Optional[dict] = None,
|
80
|
+
) -> dict:
|
81
81
|
"""Fit and transform.
|
82
82
|
|
83
83
|
Parameters
|
@@ -165,7 +165,7 @@ class DefaultDataReader(PipelineStepMixin, UpdateMetaMixin):
|
|
165
165
|
|
166
166
|
|
167
167
|
def _read_data(
|
168
|
-
data_type: str, path: Path, read_params:
|
168
|
+
data_type: str, path: Path, read_params: dict
|
169
169
|
) -> Union[nib.Nifti1Image, pd.DataFrame, None]:
|
170
170
|
"""Read data for data type.
|
171
171
|
|
File without changes
|
@@ -3,8 +3,7 @@
|
|
3
3
|
# Authors: Synchon Mandal <s.mandal@fz-juelich.de>
|
4
4
|
# License: AGPL
|
5
5
|
|
6
|
-
|
7
|
-
from .junifer_connectivity_measure import JuniferConnectivityMeasure
|
6
|
+
import lazy_loader as lazy
|
8
7
|
|
9
8
|
|
10
|
-
__all__ =
|
9
|
+
__getattr__, __dir__, __all__ = lazy.attach_stub(__name__, __file__)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Authors: Synchon Mandal <s.mandal@fz-juelich.de>
|
4
4
|
# License: AGPL
|
5
5
|
|
6
|
-
from typing import Callable,
|
6
|
+
from typing import Callable, Optional
|
7
7
|
|
8
8
|
import numpy as np
|
9
9
|
from nilearn import signal
|
@@ -13,7 +13,7 @@ from nilearn.connectome import (
|
|
13
13
|
prec_to_partial,
|
14
14
|
sym_matrix_to_vec,
|
15
15
|
)
|
16
|
-
from scipy import linalg
|
16
|
+
from scipy import linalg, stats
|
17
17
|
from sklearn.base import clone
|
18
18
|
from sklearn.covariance import EmpiricalCovariance
|
19
19
|
|
@@ -186,7 +186,7 @@ def _map_eigenvalues(
|
|
186
186
|
|
187
187
|
|
188
188
|
def _geometric_mean(
|
189
|
-
matrices:
|
189
|
+
matrices: list[np.ndarray],
|
190
190
|
init: Optional[np.ndarray] = None,
|
191
191
|
max_iter: int = 10,
|
192
192
|
tol: Optional[float] = 1e-7,
|
@@ -314,15 +314,18 @@ class JuniferConnectivityMeasure(ConnectivityMeasure):
|
|
314
314
|
* default ``cov_estimator`` is
|
315
315
|
:class:`sklearn.covariance.EmpiricalCovariance`
|
316
316
|
* default ``kind`` is ``"correlation"``
|
317
|
+
* supports Spearman's correlation via ``kind="spearman correlation"``
|
317
318
|
|
318
319
|
Parameters
|
319
320
|
----------
|
320
321
|
cov_estimator : estimator object, optional
|
321
322
|
The covariance estimator
|
322
323
|
(default ``EmpiricalCovariance(store_precision=False)``).
|
323
|
-
kind : {"covariance", "correlation", "
|
324
|
-
"tangent", "precision"}, optional
|
325
|
-
The matrix kind.
|
324
|
+
kind : {"covariance", "correlation", "spearman correlation", \
|
325
|
+
"partial correlation", "tangent", "precision"}, optional
|
326
|
+
The matrix kind. The default value uses Pearson's correlation.
|
327
|
+
If ``"spearman correlation"`` is used, the data will be ranked before
|
328
|
+
estimating the covariance. For the use of ``"tangent"`` see [1]_
|
326
329
|
(default "correlation").
|
327
330
|
vectorize : bool, optional
|
328
331
|
If True, connectivity matrices are reshaped into 1D arrays and only
|
@@ -400,17 +403,22 @@ class JuniferConnectivityMeasure(ConnectivityMeasure):
|
|
400
403
|
self.cov_estimator_ = clone(self.cov_estimator)
|
401
404
|
|
402
405
|
# Compute all the matrices, stored in "connectivities"
|
403
|
-
if self.kind
|
404
|
-
covariances_std = [
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
406
|
+
if self.kind in ["correlation", "spearman correlation"]:
|
407
|
+
covariances_std = []
|
408
|
+
for x in X:
|
409
|
+
x = signal.standardize_signal(
|
410
|
+
x,
|
411
|
+
detrend=False,
|
412
|
+
standardize=self.standardize,
|
413
|
+
)
|
414
|
+
|
415
|
+
# rank data if spearman correlation
|
416
|
+
# before calculating covariance
|
417
|
+
if self.kind == "spearman correlation":
|
418
|
+
x = stats.rankdata(x, axis=0)
|
419
|
+
|
420
|
+
covariances_std.append(self.cov_estimator_.fit(x).covariance_)
|
421
|
+
|
414
422
|
connectivities = [cov_to_corr(cov) for cov in covariances_std]
|
415
423
|
else:
|
416
424
|
covariances = [self.cov_estimator_.fit(x).covariance_ for x in X]
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Authors: Synchon Mandal <s.mandal@fz-juelich.de>
|
4
4
|
# License: AGPL
|
5
5
|
|
6
|
-
from typing import TYPE_CHECKING, Callable,
|
6
|
+
from typing import TYPE_CHECKING, Callable, Optional, Union
|
7
7
|
|
8
8
|
import numpy as np
|
9
9
|
from nilearn import image, masking
|
@@ -271,7 +271,7 @@ class _JuniferExtractionFunctor:
|
|
271
271
|
def __call__(
|
272
272
|
self,
|
273
273
|
imgs: Union["Nifti1Image", "Nifti2Image"],
|
274
|
-
) ->
|
274
|
+
) -> tuple["ArrayLike", None]:
|
275
275
|
"""Implement function call overloading.
|
276
276
|
|
277
277
|
Parameters
|
@@ -372,9 +372,9 @@ class JuniferNiftiSpheresMasker(NiftiSpheresMasker):
|
|
372
372
|
self,
|
373
373
|
imgs: Union["Nifti1Image", "Nifti2Image"],
|
374
374
|
confounds: Union[
|
375
|
-
str, "Path", "ArrayLike", "DataFrame",
|
375
|
+
str, "Path", "ArrayLike", "DataFrame", list, None
|
376
376
|
] = None,
|
377
|
-
sample_mask: Union["ArrayLike",
|
377
|
+
sample_mask: Union["ArrayLike", list, tuple, None] = None,
|
378
378
|
) -> "ArrayLike":
|
379
379
|
"""Extract signals from a single 4D niimg.
|
380
380
|
|
File without changes
|
@@ -6,7 +6,7 @@
|
|
6
6
|
import copy
|
7
7
|
import warnings
|
8
8
|
from math import cosh, exp, log, sinh, sqrt
|
9
|
-
from typing import TYPE_CHECKING,
|
9
|
+
from typing import TYPE_CHECKING, Optional, Union
|
10
10
|
|
11
11
|
import numpy as np
|
12
12
|
import pytest
|
@@ -71,6 +71,7 @@ CONNECTIVITY_KINDS = (
|
|
71
71
|
"tangent",
|
72
72
|
"precision",
|
73
73
|
"partial correlation",
|
74
|
+
"spearman correlation",
|
74
75
|
)
|
75
76
|
|
76
77
|
N_FEATURES = 49
|
@@ -148,7 +149,7 @@ def random_spd(
|
|
148
149
|
|
149
150
|
def _signals(
|
150
151
|
n_subjects: int = N_SUBJECTS,
|
151
|
-
) ->
|
152
|
+
) -> tuple[list[np.ndarray], np.ndarray]:
|
152
153
|
"""Generate signals and compute covariances while applying confounds.
|
153
154
|
|
154
155
|
Parameters
|
@@ -177,15 +178,15 @@ def _signals(
|
|
177
178
|
|
178
179
|
|
179
180
|
@pytest.fixture
|
180
|
-
def signals() ->
|
181
|
+
def signals() -> list[np.ndarray]:
|
181
182
|
"""Return signals as list of np.ndarray."""
|
182
183
|
return _signals(N_SUBJECTS)[0]
|
183
184
|
|
184
185
|
|
185
186
|
@pytest.fixture
|
186
187
|
def signals_and_covariances(
|
187
|
-
cov_estimator: Union[LedoitWolf, EmpiricalCovariance]
|
188
|
-
) ->
|
188
|
+
cov_estimator: Union[LedoitWolf, EmpiricalCovariance],
|
189
|
+
) -> tuple[list[np.ndarray], list[float]]:
|
189
190
|
"""Return signals and covariances for a covariance estimator.
|
190
191
|
|
191
192
|
Parameters
|
@@ -416,7 +417,7 @@ def grad_geometric_mean(
|
|
416
417
|
init: Optional["ArrayLike"] = None,
|
417
418
|
max_iter: int = 10,
|
418
419
|
tol: float = 1e-7,
|
419
|
-
) ->
|
420
|
+
) -> list[float]:
|
420
421
|
"""Compute gradient of geometric mean.
|
421
422
|
|
422
423
|
Return the norm of the covariant derivative at each iteration step
|
@@ -614,8 +615,8 @@ def test_connectivity_measure_errors():
|
|
614
615
|
@pytest.mark.parametrize("kind", CONNECTIVITY_KINDS)
|
615
616
|
def test_connectivity_measure_generic(
|
616
617
|
kind: str,
|
617
|
-
cov_estimator:
|
618
|
-
signals_and_covariances:
|
618
|
+
cov_estimator: type["BaseEstimator"],
|
619
|
+
signals_and_covariances: tuple[list[np.ndarray], list[float]],
|
619
620
|
) -> None:
|
620
621
|
"""Test generic JuniferConnectivityMeasure.
|
621
622
|
|
@@ -777,8 +778,8 @@ def _assert_connectivity_partial_correlation(connectivities, covs) -> None:
|
|
777
778
|
)
|
778
779
|
def test_connectivity_measure_specific_for_each_kind(
|
779
780
|
kind: str,
|
780
|
-
cov_estimator:
|
781
|
-
signals_and_covariances:
|
781
|
+
cov_estimator: type["BaseEstimator"],
|
782
|
+
signals_and_covariances: tuple[list[np.ndarray], list[float]],
|
782
783
|
) -> None:
|
783
784
|
"""Test connectivity matrix for each kind.
|
784
785
|
|
@@ -811,7 +812,7 @@ def test_connectivity_measure_specific_for_each_kind(
|
|
811
812
|
|
812
813
|
@pytest.mark.parametrize("kind", CONNECTIVITY_KINDS)
|
813
814
|
def test_connectivity_measure_check_mean(
|
814
|
-
kind: str, signals:
|
815
|
+
kind: str, signals: list[np.ndarray]
|
815
816
|
) -> None:
|
816
817
|
"""Test mean of connectivity matrix for each kind.
|
817
818
|
|
@@ -845,7 +846,7 @@ def test_connectivity_measure_check_mean(
|
|
845
846
|
|
846
847
|
@pytest.mark.parametrize("kind", CONNECTIVITY_KINDS)
|
847
848
|
def test_connectivity_measure_check_vectorization_option(
|
848
|
-
kind: str, signals:
|
849
|
+
kind: str, signals: list[np.ndarray]
|
849
850
|
) -> None:
|
850
851
|
"""Test vectorization of connectivity matrix for each kind.
|
851
852
|
|
@@ -878,7 +879,7 @@ def test_connectivity_measure_check_vectorization_option(
|
|
878
879
|
["covariance", "correlation", "precision", "partial correlation"],
|
879
880
|
)
|
880
881
|
def test_connectivity_measure_check_inverse_transformation(
|
881
|
-
kind: str, signals:
|
882
|
+
kind: str, signals: list[np.ndarray]
|
882
883
|
) -> None:
|
883
884
|
"""Test inverse transform.
|
884
885
|
|
@@ -914,7 +915,7 @@ def test_connectivity_measure_check_inverse_transformation(
|
|
914
915
|
["covariance", "correlation", "precision", "partial correlation"],
|
915
916
|
)
|
916
917
|
def test_connectivity_measure_check_inverse_transformation_discard_diag(
|
917
|
-
kind: str, signals:
|
918
|
+
kind: str, signals: list[np.ndarray]
|
918
919
|
) -> None:
|
919
920
|
"""Test diagonal for inverse transform.
|
920
921
|
|
@@ -956,7 +957,7 @@ def test_connectivity_measure_check_inverse_transformation_discard_diag(
|
|
956
957
|
|
957
958
|
|
958
959
|
def test_connectivity_measure_inverse_transform_tangent(
|
959
|
-
signals:
|
960
|
+
signals: list[np.ndarray],
|
960
961
|
) -> None:
|
961
962
|
"""Test that for 'tangent' kind, covariance matrices are reconstructed.
|
962
963
|
|
@@ -1066,7 +1067,7 @@ def test_confounds_connectivity_measure_errors() -> None:
|
|
1066
1067
|
|
1067
1068
|
|
1068
1069
|
def test_connectivity_measure_standardize(
|
1069
|
-
signals:
|
1070
|
+
signals: list[np.ndarray],
|
1070
1071
|
) -> None:
|
1071
1072
|
"""Check warning is raised and then suppressed with setting standardize.
|
1072
1073
|
|
@@ -4,7 +4,6 @@
|
|
4
4
|
# License: AGPL
|
5
5
|
|
6
6
|
import warnings
|
7
|
-
from typing import List, Tuple
|
8
7
|
|
9
8
|
import nibabel
|
10
9
|
import numpy as np
|
@@ -361,10 +360,10 @@ def test_nifti_spheres_masker_io_shapes() -> None:
|
|
361
360
|
],
|
362
361
|
)
|
363
362
|
def test_junifer_and_nilearn_mean_agg_are_equal(
|
364
|
-
shape:
|
363
|
+
shape: tuple[int, ...],
|
365
364
|
radius: float,
|
366
365
|
allow_overlap: bool,
|
367
|
-
coords:
|
366
|
+
coords: list[tuple[int, int, int]],
|
368
367
|
) -> None:
|
369
368
|
"""Test junifer's masker behaves same as nilearn's when agg is mean.
|
370
369
|
|
junifer/markers/__init__.py
CHANGED
@@ -5,43 +5,7 @@
|
|
5
5
|
# Synchon Mandal <s.mandal@fz-juelich.de>
|
6
6
|
# License: AGPL
|
7
7
|
|
8
|
-
|
9
|
-
from .collection import MarkerCollection
|
10
|
-
from .ets_rss import RSSETSMarker
|
11
|
-
from .parcel_aggregation import ParcelAggregation
|
12
|
-
from .sphere_aggregation import SphereAggregation
|
13
|
-
from .functional_connectivity import (
|
14
|
-
FunctionalConnectivityParcels,
|
15
|
-
FunctionalConnectivitySpheres,
|
16
|
-
CrossParcellationFC,
|
17
|
-
EdgeCentricFCParcels,
|
18
|
-
EdgeCentricFCSpheres,
|
19
|
-
)
|
20
|
-
from .reho import ReHoParcels, ReHoSpheres
|
21
|
-
from .falff import ALFFParcels, ALFFSpheres
|
22
|
-
from .temporal_snr import (
|
23
|
-
TemporalSNRParcels,
|
24
|
-
TemporalSNRSpheres,
|
25
|
-
)
|
26
|
-
from .brainprint import BrainPrint
|
8
|
+
import lazy_loader as lazy
|
27
9
|
|
28
10
|
|
29
|
-
__all__ =
|
30
|
-
"BaseMarker",
|
31
|
-
"MarkerCollection",
|
32
|
-
"RSSETSMarker",
|
33
|
-
"ParcelAggregation",
|
34
|
-
"SphereAggregation",
|
35
|
-
"FunctionalConnectivityParcels",
|
36
|
-
"FunctionalConnectivitySpheres",
|
37
|
-
"CrossParcellationFC",
|
38
|
-
"EdgeCentricFCParcels",
|
39
|
-
"EdgeCentricFCSpheres",
|
40
|
-
"ReHoParcels",
|
41
|
-
"ReHoSpheres",
|
42
|
-
"ALFFParcels",
|
43
|
-
"ALFFSpheres",
|
44
|
-
"TemporalSNRParcels",
|
45
|
-
"TemporalSNRSpheres",
|
46
|
-
"BrainPrint",
|
47
|
-
]
|
11
|
+
__getattr__, __dir__, __all__ = lazy.attach_stub(__name__, __file__)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
__all__ = [
|
2
|
+
"BaseMarker",
|
3
|
+
"RSSETSMarker",
|
4
|
+
"ParcelAggregation",
|
5
|
+
"SphereAggregation",
|
6
|
+
"FunctionalConnectivityParcels",
|
7
|
+
"FunctionalConnectivitySpheres",
|
8
|
+
"CrossParcellationFC",
|
9
|
+
"EdgeCentricFCParcels",
|
10
|
+
"EdgeCentricFCSpheres",
|
11
|
+
"ReHoParcels",
|
12
|
+
"ReHoSpheres",
|
13
|
+
"ALFFParcels",
|
14
|
+
"ALFFSpheres",
|
15
|
+
"TemporalSNRParcels",
|
16
|
+
"TemporalSNRSpheres",
|
17
|
+
"BrainPrint",
|
18
|
+
]
|
19
|
+
|
20
|
+
from .base import BaseMarker
|
21
|
+
from .ets_rss import RSSETSMarker
|
22
|
+
from .parcel_aggregation import ParcelAggregation
|
23
|
+
from .sphere_aggregation import SphereAggregation
|
24
|
+
from .functional_connectivity import (
|
25
|
+
FunctionalConnectivityParcels,
|
26
|
+
FunctionalConnectivitySpheres,
|
27
|
+
CrossParcellationFC,
|
28
|
+
EdgeCentricFCParcels,
|
29
|
+
EdgeCentricFCSpheres,
|
30
|
+
)
|
31
|
+
from .reho import ReHoParcels, ReHoSpheres
|
32
|
+
from .falff import ALFFParcels, ALFFSpheres
|
33
|
+
from .temporal_snr import (
|
34
|
+
TemporalSNRParcels,
|
35
|
+
TemporalSNRSpheres,
|
36
|
+
)
|
37
|
+
from .brainprint import BrainPrint
|
junifer/markers/base.py
CHANGED
@@ -6,16 +6,13 @@
|
|
6
6
|
|
7
7
|
from abc import ABC, abstractmethod
|
8
8
|
from copy import deepcopy
|
9
|
-
from typing import
|
9
|
+
from typing import Any, Optional, Union
|
10
10
|
|
11
11
|
from ..pipeline import PipelineStepMixin, UpdateMetaMixin
|
12
|
+
from ..typing import StorageLike
|
12
13
|
from ..utils import logger, raise_error
|
13
14
|
|
14
15
|
|
15
|
-
if TYPE_CHECKING:
|
16
|
-
from junifer.storage import BaseFeatureStorage
|
17
|
-
|
18
|
-
|
19
16
|
__all__ = ["BaseMarker"]
|
20
17
|
|
21
18
|
|
@@ -45,7 +42,7 @@ class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin):
|
|
45
42
|
|
46
43
|
def __init__(
|
47
44
|
self,
|
48
|
-
on: Optional[Union[
|
45
|
+
on: Optional[Union[list[str], str]] = None,
|
49
46
|
name: Optional[str] = None,
|
50
47
|
) -> None:
|
51
48
|
# Check for missing mapping attribute
|
@@ -68,7 +65,7 @@ class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin):
|
|
68
65
|
raise_error(f"{self.name} cannot be computed on {wrong_on}")
|
69
66
|
self._on = on
|
70
67
|
|
71
|
-
def validate_input(self, input:
|
68
|
+
def validate_input(self, input: list[str]) -> list[str]:
|
72
69
|
"""Validate input.
|
73
70
|
|
74
71
|
Parameters
|
@@ -97,7 +94,7 @@ class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin):
|
|
97
94
|
)
|
98
95
|
return [x for x in self._on if x in input]
|
99
96
|
|
100
|
-
def get_valid_inputs(self) ->
|
97
|
+
def get_valid_inputs(self) -> list[str]:
|
101
98
|
"""Get valid data types for input.
|
102
99
|
|
103
100
|
Returns
|
@@ -127,7 +124,7 @@ class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin):
|
|
127
124
|
return self._MARKER_INOUT_MAPPINGS[input_type][output_feature]
|
128
125
|
|
129
126
|
@abstractmethod
|
130
|
-
def compute(self, input:
|
127
|
+
def compute(self, input: dict, extra_input: Optional[dict] = None) -> dict:
|
131
128
|
"""Compute.
|
132
129
|
|
133
130
|
Parameters
|
@@ -158,8 +155,8 @@ class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin):
|
|
158
155
|
self,
|
159
156
|
type_: str,
|
160
157
|
feature: str,
|
161
|
-
out:
|
162
|
-
storage:
|
158
|
+
out: dict[str, Any],
|
159
|
+
storage: StorageLike,
|
163
160
|
) -> None:
|
164
161
|
"""Store.
|
165
162
|
|
@@ -181,9 +178,9 @@ class BaseMarker(ABC, PipelineStepMixin, UpdateMetaMixin):
|
|
181
178
|
|
182
179
|
def _fit_transform(
|
183
180
|
self,
|
184
|
-
input:
|
185
|
-
storage: Optional[
|
186
|
-
) ->
|
181
|
+
input: dict[str, dict],
|
182
|
+
storage: Optional[StorageLike] = None,
|
183
|
+
) -> dict:
|
187
184
|
"""Fit and transform.
|
188
185
|
|
189
186
|
Parameters
|