junifer 0.0.4.dev831__py3-none-any.whl → 0.0.5__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 +17 -0
- junifer/_version.py +2 -2
- junifer/api/__init__.py +4 -1
- junifer/api/cli.py +91 -1
- junifer/api/decorators.py +9 -0
- junifer/api/functions.py +56 -10
- junifer/api/parser.py +3 -0
- junifer/api/queue_context/__init__.py +4 -1
- junifer/api/queue_context/gnu_parallel_local_adapter.py +16 -6
- junifer/api/queue_context/htcondor_adapter.py +16 -5
- junifer/api/queue_context/tests/test_gnu_parallel_local_adapter.py +41 -12
- junifer/api/queue_context/tests/test_htcondor_adapter.py +48 -15
- junifer/api/res/afni/run_afni_docker.sh +1 -1
- junifer/api/res/ants/run_ants_docker.sh +1 -1
- junifer/api/res/freesurfer/mri_binarize +3 -0
- junifer/api/res/freesurfer/mri_mc +3 -0
- junifer/api/res/freesurfer/mri_pretess +3 -0
- junifer/api/res/freesurfer/mris_convert +3 -0
- junifer/api/res/freesurfer/run_freesurfer_docker.sh +61 -0
- junifer/api/res/fsl/run_fsl_docker.sh +1 -1
- junifer/api/res/{run_conda.sh → run_conda.bash} +1 -1
- junifer/api/res/run_conda.zsh +23 -0
- junifer/api/res/run_venv.bash +22 -0
- junifer/api/res/{run_venv.sh → run_venv.zsh} +1 -1
- junifer/api/tests/test_api_utils.py +4 -2
- junifer/api/tests/test_cli.py +83 -0
- junifer/api/tests/test_functions.py +27 -2
- junifer/configs/__init__.py +1 -1
- junifer/configs/juseless/__init__.py +4 -1
- junifer/configs/juseless/datagrabbers/__init__.py +10 -1
- junifer/configs/juseless/datagrabbers/aomic_id1000_vbm.py +4 -3
- junifer/configs/juseless/datagrabbers/camcan_vbm.py +3 -0
- junifer/configs/juseless/datagrabbers/ixi_vbm.py +4 -3
- junifer/configs/juseless/datagrabbers/tests/test_ucla.py +1 -3
- junifer/configs/juseless/datagrabbers/ucla.py +12 -9
- junifer/configs/juseless/datagrabbers/ukb_vbm.py +3 -0
- junifer/data/__init__.py +21 -1
- junifer/data/coordinates.py +10 -19
- junifer/data/masks/ukb/UKB_15K_GM_template.nii.gz +0 -0
- junifer/data/masks.py +58 -87
- junifer/data/parcellations.py +14 -3
- junifer/data/template_spaces.py +4 -1
- junifer/data/tests/test_masks.py +26 -37
- junifer/data/utils.py +3 -0
- junifer/datagrabber/__init__.py +18 -1
- junifer/datagrabber/aomic/__init__.py +3 -0
- junifer/datagrabber/aomic/id1000.py +70 -37
- junifer/datagrabber/aomic/piop1.py +69 -36
- junifer/datagrabber/aomic/piop2.py +71 -38
- junifer/datagrabber/aomic/tests/test_id1000.py +44 -100
- junifer/datagrabber/aomic/tests/test_piop1.py +65 -108
- junifer/datagrabber/aomic/tests/test_piop2.py +45 -102
- junifer/datagrabber/base.py +13 -6
- junifer/datagrabber/datalad_base.py +13 -1
- junifer/datagrabber/dmcc13_benchmark.py +36 -53
- junifer/datagrabber/hcp1200/__init__.py +3 -0
- junifer/datagrabber/hcp1200/datalad_hcp1200.py +3 -0
- junifer/datagrabber/hcp1200/hcp1200.py +4 -1
- junifer/datagrabber/multiple.py +45 -6
- junifer/datagrabber/pattern.py +170 -62
- junifer/datagrabber/pattern_datalad.py +25 -12
- junifer/datagrabber/pattern_validation_mixin.py +388 -0
- junifer/datagrabber/tests/test_datalad_base.py +4 -4
- junifer/datagrabber/tests/test_dmcc13_benchmark.py +46 -19
- junifer/datagrabber/tests/test_multiple.py +161 -84
- junifer/datagrabber/tests/test_pattern.py +45 -0
- junifer/datagrabber/tests/test_pattern_datalad.py +4 -4
- junifer/datagrabber/tests/test_pattern_validation_mixin.py +249 -0
- junifer/datareader/__init__.py +4 -1
- junifer/datareader/default.py +95 -43
- junifer/external/BrainPrint/brainprint/__init__.py +4 -0
- junifer/external/BrainPrint/brainprint/_version.py +3 -0
- junifer/external/BrainPrint/brainprint/asymmetry.py +91 -0
- junifer/external/BrainPrint/brainprint/brainprint.py +441 -0
- junifer/external/BrainPrint/brainprint/surfaces.py +258 -0
- junifer/external/BrainPrint/brainprint/utils/__init__.py +1 -0
- junifer/external/BrainPrint/brainprint/utils/_config.py +112 -0
- junifer/external/BrainPrint/brainprint/utils/utils.py +188 -0
- junifer/external/__init__.py +1 -1
- junifer/external/nilearn/__init__.py +5 -1
- junifer/external/nilearn/junifer_connectivity_measure.py +483 -0
- junifer/external/nilearn/junifer_nifti_spheres_masker.py +23 -9
- junifer/external/nilearn/tests/test_junifer_connectivity_measure.py +1089 -0
- junifer/external/nilearn/tests/test_junifer_nifti_spheres_masker.py +76 -1
- junifer/markers/__init__.py +23 -1
- junifer/markers/base.py +68 -28
- junifer/markers/brainprint.py +459 -0
- junifer/markers/collection.py +10 -2
- junifer/markers/complexity/__init__.py +10 -0
- junifer/markers/complexity/complexity_base.py +26 -43
- junifer/markers/complexity/hurst_exponent.py +3 -0
- junifer/markers/complexity/multiscale_entropy_auc.py +3 -0
- junifer/markers/complexity/perm_entropy.py +3 -0
- junifer/markers/complexity/range_entropy.py +3 -0
- junifer/markers/complexity/range_entropy_auc.py +3 -0
- junifer/markers/complexity/sample_entropy.py +3 -0
- junifer/markers/complexity/tests/test_hurst_exponent.py +11 -3
- junifer/markers/complexity/tests/test_multiscale_entropy_auc.py +11 -3
- junifer/markers/complexity/tests/test_perm_entropy.py +11 -3
- junifer/markers/complexity/tests/test_range_entropy.py +11 -3
- junifer/markers/complexity/tests/test_range_entropy_auc.py +11 -3
- junifer/markers/complexity/tests/test_sample_entropy.py +11 -3
- junifer/markers/complexity/tests/test_weighted_perm_entropy.py +11 -3
- junifer/markers/complexity/weighted_perm_entropy.py +3 -0
- junifer/markers/ets_rss.py +27 -42
- junifer/markers/falff/__init__.py +3 -0
- junifer/markers/falff/_afni_falff.py +5 -2
- junifer/markers/falff/_junifer_falff.py +3 -0
- junifer/markers/falff/falff_base.py +20 -46
- junifer/markers/falff/falff_parcels.py +56 -27
- junifer/markers/falff/falff_spheres.py +60 -29
- junifer/markers/falff/tests/test_falff_parcels.py +39 -23
- junifer/markers/falff/tests/test_falff_spheres.py +39 -23
- junifer/markers/functional_connectivity/__init__.py +9 -0
- junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +63 -60
- junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +45 -32
- junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +49 -36
- junifer/markers/functional_connectivity/functional_connectivity_base.py +71 -70
- junifer/markers/functional_connectivity/functional_connectivity_parcels.py +34 -25
- junifer/markers/functional_connectivity/functional_connectivity_spheres.py +40 -30
- junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py +11 -7
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +27 -7
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +28 -12
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +35 -11
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +36 -62
- junifer/markers/parcel_aggregation.py +47 -61
- junifer/markers/reho/__init__.py +3 -0
- junifer/markers/reho/_afni_reho.py +5 -2
- junifer/markers/reho/_junifer_reho.py +4 -1
- junifer/markers/reho/reho_base.py +8 -27
- junifer/markers/reho/reho_parcels.py +28 -17
- junifer/markers/reho/reho_spheres.py +27 -18
- junifer/markers/reho/tests/test_reho_parcels.py +8 -3
- junifer/markers/reho/tests/test_reho_spheres.py +8 -3
- junifer/markers/sphere_aggregation.py +43 -59
- junifer/markers/temporal_snr/__init__.py +3 -0
- junifer/markers/temporal_snr/temporal_snr_base.py +23 -32
- junifer/markers/temporal_snr/temporal_snr_parcels.py +9 -6
- junifer/markers/temporal_snr/temporal_snr_spheres.py +9 -6
- junifer/markers/temporal_snr/tests/test_temporal_snr_parcels.py +6 -3
- junifer/markers/temporal_snr/tests/test_temporal_snr_spheres.py +6 -3
- junifer/markers/tests/test_brainprint.py +58 -0
- junifer/markers/tests/test_collection.py +9 -8
- junifer/markers/tests/test_ets_rss.py +15 -9
- junifer/markers/tests/test_markers_base.py +17 -18
- junifer/markers/tests/test_parcel_aggregation.py +93 -32
- junifer/markers/tests/test_sphere_aggregation.py +72 -19
- junifer/onthefly/__init__.py +4 -1
- junifer/onthefly/read_transform.py +3 -0
- junifer/pipeline/__init__.py +9 -1
- junifer/pipeline/pipeline_step_mixin.py +21 -4
- junifer/pipeline/registry.py +3 -0
- junifer/pipeline/singleton.py +3 -0
- junifer/pipeline/tests/test_registry.py +1 -1
- junifer/pipeline/update_meta_mixin.py +3 -0
- junifer/pipeline/utils.py +67 -1
- junifer/pipeline/workdir_manager.py +3 -0
- junifer/preprocess/__init__.py +10 -2
- junifer/preprocess/base.py +6 -3
- junifer/preprocess/confounds/__init__.py +3 -0
- junifer/preprocess/confounds/fmriprep_confound_remover.py +47 -60
- junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py +72 -113
- junifer/preprocess/smoothing/__init__.py +9 -0
- junifer/preprocess/smoothing/_afni_smoothing.py +119 -0
- junifer/preprocess/smoothing/_fsl_smoothing.py +116 -0
- junifer/preprocess/smoothing/_nilearn_smoothing.py +69 -0
- junifer/preprocess/smoothing/smoothing.py +174 -0
- junifer/preprocess/smoothing/tests/test_smoothing.py +94 -0
- junifer/preprocess/warping/__init__.py +3 -0
- junifer/preprocess/warping/_ants_warper.py +3 -0
- junifer/preprocess/warping/_fsl_warper.py +3 -0
- junifer/stats.py +4 -1
- junifer/storage/__init__.py +9 -1
- junifer/storage/base.py +40 -1
- junifer/storage/hdf5.py +71 -9
- junifer/storage/pandas_base.py +3 -0
- junifer/storage/sqlite.py +3 -0
- junifer/storage/tests/test_hdf5.py +82 -10
- junifer/storage/utils.py +9 -0
- junifer/testing/__init__.py +4 -1
- junifer/testing/datagrabbers.py +13 -6
- junifer/testing/tests/test_partlycloudytesting_datagrabber.py +7 -7
- junifer/testing/utils.py +3 -0
- junifer/utils/__init__.py +13 -2
- junifer/utils/fs.py +3 -0
- junifer/utils/helpers.py +32 -1
- junifer/utils/logging.py +33 -4
- junifer/utils/tests/test_logging.py +8 -0
- {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/METADATA +17 -16
- junifer-0.0.5.dist-info/RECORD +275 -0
- {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/WHEEL +1 -1
- junifer/datagrabber/tests/test_datagrabber_utils.py +0 -218
- junifer/datagrabber/utils.py +0 -230
- junifer/preprocess/ants/__init__.py +0 -4
- junifer/preprocess/ants/ants_apply_transforms_warper.py +0 -185
- junifer/preprocess/ants/tests/test_ants_apply_transforms_warper.py +0 -56
- junifer/preprocess/bold_warper.py +0 -265
- junifer/preprocess/fsl/__init__.py +0 -4
- junifer/preprocess/fsl/apply_warper.py +0 -179
- junifer/preprocess/fsl/tests/test_apply_warper.py +0 -45
- junifer/preprocess/tests/test_bold_warper.py +0 -159
- junifer-0.0.4.dev831.dist-info/RECORD +0 -257
- {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/top_level.txt +0 -0
@@ -18,142 +18,99 @@ URI = "https://gin.g-node.org/juaml/datalad-example-aomicpiop1"
|
|
18
18
|
|
19
19
|
|
20
20
|
@pytest.mark.parametrize(
|
21
|
-
"tasks",
|
22
|
-
[
|
21
|
+
"type_, nested_types, tasks",
|
22
|
+
[
|
23
|
+
("BOLD", ["confounds", "mask"], None),
|
24
|
+
("BOLD", ["confounds", "mask"], ["anticipation"]),
|
25
|
+
("BOLD", ["confounds", "mask"], ["emomatching", "faces"]),
|
26
|
+
("BOLD", ["confounds", "mask"], ["restingstate"]),
|
27
|
+
("BOLD", ["confounds", "mask"], ["workingmemory", "gstroop"]),
|
28
|
+
(
|
29
|
+
"BOLD",
|
30
|
+
["confounds", "mask"],
|
31
|
+
["anticipation", "faces", "restingstate"],
|
32
|
+
),
|
33
|
+
("T1w", ["mask"], None),
|
34
|
+
("VBM_CSF", None, None),
|
35
|
+
("VBM_GM", None, None),
|
36
|
+
("VBM_WM", None, None),
|
37
|
+
("DWI", None, None),
|
38
|
+
("FreeSurfer", None, None),
|
39
|
+
],
|
23
40
|
)
|
24
|
-
def test_DataladAOMICPIOP1(
|
41
|
+
def test_DataladAOMICPIOP1(
|
42
|
+
type_: str,
|
43
|
+
nested_types: Optional[List[str]],
|
44
|
+
tasks: Optional[List[str]],
|
45
|
+
) -> None:
|
25
46
|
"""Test DataladAOMICPIOP1 DataGrabber.
|
26
47
|
|
27
48
|
Parameters
|
28
49
|
----------
|
29
|
-
|
50
|
+
type_ : str
|
51
|
+
The parametrized type.
|
52
|
+
nested_types : list of str or None
|
53
|
+
The parametrized nested types.
|
54
|
+
tasks : list of str or None
|
30
55
|
The parametrized task values.
|
31
56
|
|
32
57
|
"""
|
33
|
-
dg = DataladAOMICPIOP1(tasks=tasks)
|
58
|
+
dg = DataladAOMICPIOP1(types=type_, tasks=tasks)
|
34
59
|
# Set URI to Gin
|
35
60
|
dg.uri = URI
|
36
61
|
|
37
62
|
with dg:
|
63
|
+
# Get all elements
|
38
64
|
all_elements = dg.get_elements()
|
65
|
+
# Get test element
|
39
66
|
test_element = all_elements[0]
|
40
|
-
|
41
|
-
|
67
|
+
# Get test element data
|
42
68
|
out = dg[test_element]
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
#
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
assert out[
|
64
|
-
assert out[
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
assert (
|
70
|
-
out["BOLD_confounds"]["path"].name == f"{sub}_task-{new_task}_"
|
71
|
-
"desc-confounds_regressors.tsv"
|
72
|
-
)
|
73
|
-
|
74
|
-
assert out["BOLD_confounds"]["path"].exists()
|
75
|
-
assert out["BOLD_confounds"]["path"].is_file()
|
76
|
-
|
77
|
-
# assert BOLD_mask
|
78
|
-
assert out["BOLD_mask"]["path"].exists()
|
79
|
-
|
80
|
-
# asserts type "T1w"
|
81
|
-
assert "T1w" in out
|
82
|
-
|
83
|
-
assert (
|
84
|
-
out["T1w"]["path"].name == f"{sub}_space-MNI152NLin2009cAsym_"
|
85
|
-
"desc-preproc_T1w.nii.gz"
|
86
|
-
)
|
87
|
-
|
88
|
-
assert out["T1w"]["path"].exists()
|
89
|
-
assert out["T1w"]["path"].is_file()
|
90
|
-
|
91
|
-
# asserts T1w_mask
|
92
|
-
assert out["T1w_mask"]["path"].exists()
|
93
|
-
|
94
|
-
# asserts type "VBM_CSF"
|
95
|
-
assert "VBM_CSF" in out
|
96
|
-
|
97
|
-
assert (
|
98
|
-
out["VBM_CSF"]["path"].name
|
99
|
-
== f"{sub}_space-MNI152NLin2009cAsym_label-"
|
100
|
-
"CSF_probseg.nii.gz"
|
101
|
-
)
|
102
|
-
|
103
|
-
assert out["VBM_CSF"]["path"].exists()
|
104
|
-
assert out["VBM_CSF"]["path"].is_file()
|
105
|
-
|
106
|
-
# asserts type "VBM_GM"
|
107
|
-
assert "VBM_GM" in out
|
108
|
-
|
109
|
-
assert (
|
110
|
-
out["VBM_GM"]["path"].name
|
111
|
-
== f"{sub}_space-MNI152NLin2009cAsym_label-"
|
112
|
-
"GM_probseg.nii.gz"
|
113
|
-
)
|
114
|
-
|
115
|
-
assert out["VBM_GM"]["path"].exists()
|
116
|
-
assert out["VBM_GM"]["path"].is_file()
|
117
|
-
|
118
|
-
# asserts type "VBM_WM"
|
119
|
-
assert "VBM_WM" in out
|
120
|
-
|
121
|
-
assert (
|
122
|
-
out["VBM_WM"]["path"].name
|
123
|
-
== f"{sub}_space-MNI152NLin2009cAsym_label-"
|
124
|
-
"WM_probseg.nii.gz"
|
125
|
-
)
|
126
|
-
|
127
|
-
assert out["VBM_WM"]["path"].exists()
|
128
|
-
assert out["VBM_WM"]["path"].is_file()
|
129
|
-
|
130
|
-
# asserts type "DWI"
|
131
|
-
assert "DWI" in out
|
132
|
-
|
133
|
-
assert out["DWI"]["path"].name == f"{sub}_desc-preproc_dwi.nii.gz"
|
134
|
-
|
135
|
-
assert out["DWI"]["path"].exists()
|
136
|
-
assert out["DWI"]["path"].is_file()
|
137
|
-
|
138
|
-
# asserts meta
|
139
|
-
assert "meta" in out["BOLD"]
|
140
|
-
meta = out["BOLD"]["meta"]
|
69
|
+
# Get all elements
|
70
|
+
all_elements = dg.get_elements()
|
71
|
+
# Get test element
|
72
|
+
test_element = all_elements[0]
|
73
|
+
# Get test element data
|
74
|
+
out = dg[test_element]
|
75
|
+
# Assert data type
|
76
|
+
assert type_ in out
|
77
|
+
# Check task name if BOLD
|
78
|
+
if type_ == "BOLD" and tasks is not None:
|
79
|
+
# Depending on task 'acquisition is different'
|
80
|
+
task_acqs = {
|
81
|
+
"anticipation": "seq",
|
82
|
+
"emomatching": "seq",
|
83
|
+
"faces": "mb3",
|
84
|
+
"gstroop": "seq",
|
85
|
+
"restingstate": "mb3",
|
86
|
+
"workingmemory": "seq",
|
87
|
+
}
|
88
|
+
assert task_acqs[test_element[1]] in out[type_]["path"].name
|
89
|
+
assert out[type_]["path"].exists()
|
90
|
+
assert out[type_]["path"].is_file()
|
91
|
+
# Asserts data type metadata
|
92
|
+
assert "meta" in out[type_]
|
93
|
+
meta = out[type_]["meta"]
|
141
94
|
assert "element" in meta
|
142
95
|
assert "subject" in meta["element"]
|
143
|
-
assert
|
96
|
+
assert test_element[0] == meta["element"]["subject"]
|
97
|
+
# Assert nested data type if not None
|
98
|
+
if nested_types is not None:
|
99
|
+
for nested_type in nested_types:
|
100
|
+
assert out[type_][nested_type]["path"].exists()
|
101
|
+
assert out[type_][nested_type]["path"].is_file()
|
144
102
|
|
145
103
|
|
146
104
|
@pytest.mark.parametrize(
|
147
105
|
"types",
|
148
106
|
[
|
149
107
|
"BOLD",
|
150
|
-
"BOLD_confounds",
|
151
108
|
"T1w",
|
152
109
|
"VBM_CSF",
|
153
110
|
"VBM_GM",
|
154
111
|
"VBM_WM",
|
155
112
|
"DWI",
|
156
|
-
["BOLD", "
|
113
|
+
["BOLD", "VBM_CSF"],
|
157
114
|
["T1w", "VBM_CSF"],
|
158
115
|
["VBM_GM", "VBM_WM"],
|
159
116
|
["DWI", "BOLD"],
|
@@ -18,136 +18,79 @@ URI = "https://gin.g-node.org/juaml/datalad-example-aomicpiop2"
|
|
18
18
|
|
19
19
|
|
20
20
|
@pytest.mark.parametrize(
|
21
|
-
"tasks",
|
22
|
-
[
|
21
|
+
"type_, nested_types, tasks",
|
22
|
+
[
|
23
|
+
("BOLD", ["confounds", "mask"], None),
|
24
|
+
("BOLD", ["confounds", "mask"], ["restingstate"]),
|
25
|
+
("BOLD", ["confounds", "mask"], ["restingstate", "stopsignal"]),
|
26
|
+
("BOLD", ["confounds", "mask"], ["workingmemory", "stopsignal"]),
|
27
|
+
("BOLD", ["confounds", "mask"], ["workingmemory"]),
|
28
|
+
("T1w", ["mask"], None),
|
29
|
+
("VBM_CSF", None, None),
|
30
|
+
("VBM_GM", None, None),
|
31
|
+
("VBM_WM", None, None),
|
32
|
+
("DWI", None, None),
|
33
|
+
("FreeSurfer", None, None),
|
34
|
+
],
|
23
35
|
)
|
24
|
-
def test_DataladAOMICPIOP2(
|
36
|
+
def test_DataladAOMICPIOP2(
|
37
|
+
type_: str,
|
38
|
+
nested_types: Optional[List[str]],
|
39
|
+
tasks: Optional[List[str]],
|
40
|
+
) -> None:
|
25
41
|
"""Test DataladAOMICPIOP2 DataGrabber.
|
26
42
|
|
27
43
|
Parameters
|
28
44
|
----------
|
29
|
-
|
45
|
+
type_ : str
|
46
|
+
The parametrized type.
|
47
|
+
nested_types : list of str or None
|
48
|
+
The parametrized nested types.
|
49
|
+
tasks : list of str or None
|
30
50
|
The parametrized task values.
|
31
51
|
|
32
52
|
"""
|
33
|
-
dg = DataladAOMICPIOP2(tasks=tasks)
|
53
|
+
dg = DataladAOMICPIOP2(types=type_, tasks=tasks)
|
34
54
|
# Set URI to Gin
|
35
55
|
dg.uri = URI
|
36
56
|
|
37
57
|
with dg:
|
58
|
+
# Get all elements
|
38
59
|
all_elements = dg.get_elements()
|
39
|
-
|
40
|
-
if tasks == "restingstate":
|
41
|
-
for el in all_elements:
|
42
|
-
assert el[1] == "restingstate"
|
43
|
-
|
60
|
+
# Get test element
|
44
61
|
test_element = all_elements[0]
|
45
|
-
|
62
|
+
# Get test element data
|
46
63
|
out = dg[test_element]
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
assert (
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
assert out["BOLD"]["path"].exists()
|
58
|
-
assert out["BOLD"]["path"].is_file()
|
59
|
-
|
60
|
-
# asserts type "BOLD_confounds"
|
61
|
-
assert "BOLD_confounds" in out
|
62
|
-
|
63
|
-
assert (
|
64
|
-
out["BOLD_confounds"]["path"].name == f"{sub}_task-{new_task}_"
|
65
|
-
"desc-confounds_regressors.tsv"
|
66
|
-
)
|
67
|
-
|
68
|
-
assert out["BOLD_confounds"]["path"].exists()
|
69
|
-
assert out["BOLD_confounds"]["path"].is_file()
|
70
|
-
|
71
|
-
# assert BOLD_mask
|
72
|
-
assert out["BOLD_mask"]["path"].exists()
|
73
|
-
|
74
|
-
# asserts type "T1w"
|
75
|
-
assert "T1w" in out
|
76
|
-
|
77
|
-
assert (
|
78
|
-
out["T1w"]["path"].name == f"{sub}_space-MNI152NLin2009cAsym_"
|
79
|
-
"desc-preproc_T1w.nii.gz"
|
80
|
-
)
|
81
|
-
|
82
|
-
assert out["T1w"]["path"].exists()
|
83
|
-
assert out["T1w"]["path"].is_file()
|
84
|
-
|
85
|
-
# asserts T1w_mask
|
86
|
-
assert out["T1w_mask"]["path"].exists()
|
87
|
-
|
88
|
-
# asserts type "VBM_CSF"
|
89
|
-
assert "VBM_CSF" in out
|
90
|
-
|
91
|
-
assert (
|
92
|
-
out["VBM_CSF"]["path"].name
|
93
|
-
== f"{sub}_space-MNI152NLin2009cAsym_label-"
|
94
|
-
"CSF_probseg.nii.gz"
|
95
|
-
)
|
96
|
-
|
97
|
-
assert out["VBM_CSF"]["path"].exists()
|
98
|
-
assert out["VBM_CSF"]["path"].is_file()
|
99
|
-
|
100
|
-
# asserts type "VBM_GM"
|
101
|
-
assert "VBM_GM" in out
|
102
|
-
|
103
|
-
assert (
|
104
|
-
out["VBM_GM"]["path"].name
|
105
|
-
== f"{sub}_space-MNI152NLin2009cAsym_label-"
|
106
|
-
"GM_probseg.nii.gz"
|
107
|
-
)
|
108
|
-
|
109
|
-
assert out["VBM_GM"]["path"].exists()
|
110
|
-
assert out["VBM_GM"]["path"].is_file()
|
111
|
-
|
112
|
-
# asserts type "VBM_WM"
|
113
|
-
assert "VBM_WM" in out
|
114
|
-
|
115
|
-
assert (
|
116
|
-
out["VBM_WM"]["path"].name
|
117
|
-
== f"{sub}_space-MNI152NLin2009cAsym_label-"
|
118
|
-
"WM_probseg.nii.gz"
|
119
|
-
)
|
120
|
-
|
121
|
-
assert out["VBM_WM"]["path"].exists()
|
122
|
-
assert out["VBM_WM"]["path"].is_file()
|
123
|
-
|
124
|
-
# asserts type "DWI"
|
125
|
-
assert "DWI" in out
|
126
|
-
|
127
|
-
assert out["DWI"]["path"].name == f"{sub}_desc-preproc_dwi.nii.gz"
|
128
|
-
|
129
|
-
assert out["DWI"]["path"].exists()
|
130
|
-
assert out["DWI"]["path"].is_file()
|
131
|
-
|
132
|
-
# asserts meta
|
133
|
-
assert "meta" in out["BOLD"]
|
134
|
-
meta = out["BOLD"]["meta"]
|
64
|
+
# Assert data type
|
65
|
+
assert type_ in out
|
66
|
+
# Check task name if BOLD
|
67
|
+
if type_ == "BOLD" and tasks is not None:
|
68
|
+
assert test_element[1] in out[type_]["path"].name
|
69
|
+
assert out[type_]["path"].exists()
|
70
|
+
assert out[type_]["path"].is_file()
|
71
|
+
# Asserts data type metadata
|
72
|
+
assert "meta" in out[type_]
|
73
|
+
meta = out[type_]["meta"]
|
135
74
|
assert "element" in meta
|
136
75
|
assert "subject" in meta["element"]
|
137
|
-
assert
|
76
|
+
assert test_element[0] == meta["element"]["subject"]
|
77
|
+
# Assert nested data type if not None
|
78
|
+
if nested_types is not None:
|
79
|
+
for nested_type in nested_types:
|
80
|
+
assert out[type_][nested_type]["path"].exists()
|
81
|
+
assert out[type_][nested_type]["path"].is_file()
|
138
82
|
|
139
83
|
|
140
84
|
@pytest.mark.parametrize(
|
141
85
|
"types",
|
142
86
|
[
|
143
87
|
"BOLD",
|
144
|
-
"BOLD_confounds",
|
145
88
|
"T1w",
|
146
89
|
"VBM_CSF",
|
147
90
|
"VBM_GM",
|
148
91
|
"VBM_WM",
|
149
92
|
"DWI",
|
150
|
-
["BOLD", "
|
93
|
+
["BOLD", "VBM_CSF"],
|
151
94
|
["T1w", "VBM_CSF"],
|
152
95
|
["VBM_GM", "VBM_WM"],
|
153
96
|
["DWI", "BOLD"],
|
junifer/datagrabber/base.py
CHANGED
@@ -11,7 +11,9 @@ from typing import Dict, Iterator, List, Tuple, Union
|
|
11
11
|
|
12
12
|
from ..pipeline import UpdateMetaMixin
|
13
13
|
from ..utils import logger, raise_error
|
14
|
-
|
14
|
+
|
15
|
+
|
16
|
+
__all__ = ["BaseDataGrabber"]
|
15
17
|
|
16
18
|
|
17
19
|
class BaseDataGrabber(ABC, UpdateMetaMixin):
|
@@ -27,16 +29,21 @@ class BaseDataGrabber(ABC, UpdateMetaMixin):
|
|
27
29
|
datadir : str or pathlib.Path
|
28
30
|
The directory where the data is / will be stored.
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
Raises
|
33
|
+
------
|
34
|
+
TypeError
|
35
|
+
If ``types`` is not a list or if the values are not string.
|
34
36
|
|
35
37
|
"""
|
36
38
|
|
37
39
|
def __init__(self, types: List[str], datadir: Union[str, Path]) -> None:
|
38
40
|
# Validate types
|
39
|
-
|
41
|
+
if not isinstance(types, list):
|
42
|
+
raise_error(msg="`types` must be a list", klass=TypeError)
|
43
|
+
if any(not isinstance(x, str) for x in types):
|
44
|
+
raise_error(
|
45
|
+
msg="`types` must be a list of strings", klass=TypeError
|
46
|
+
)
|
40
47
|
self.types = types
|
41
48
|
|
42
49
|
# Convert str to Path
|
@@ -21,6 +21,9 @@ from ..utils import logger, raise_error, warn_with_log
|
|
21
21
|
from .base import BaseDataGrabber
|
22
22
|
|
23
23
|
|
24
|
+
__all__ = ["DataladDataGrabber"]
|
25
|
+
|
26
|
+
|
24
27
|
class DataladDataGrabber(BaseDataGrabber):
|
25
28
|
"""Abstract base class for datalad-based data fetching.
|
26
29
|
|
@@ -176,7 +179,16 @@ class DataladDataGrabber(BaseDataGrabber):
|
|
176
179
|
The unmodified input dictionary.
|
177
180
|
|
178
181
|
"""
|
179
|
-
to_get = [
|
182
|
+
to_get = []
|
183
|
+
for type_val in out.values():
|
184
|
+
# Iterate to check for nested "types" like mask
|
185
|
+
for k, v in type_val.items():
|
186
|
+
# Add base data type path
|
187
|
+
if k == "path":
|
188
|
+
to_get.append(v)
|
189
|
+
# Add nested data type path
|
190
|
+
if isinstance(v, dict) and "path" in v:
|
191
|
+
to_get.append(v["path"])
|
180
192
|
|
181
193
|
if len(to_get) > 0:
|
182
194
|
logger.debug(f"Getting {len(to_get)} files using datalad:")
|
@@ -25,16 +25,16 @@ class DMCC13Benchmark(PatternDataladDataGrabber):
|
|
25
25
|
The directory where the datalad dataset will be cloned. If None,
|
26
26
|
the datalad dataset will be cloned into a temporary directory
|
27
27
|
(default None).
|
28
|
-
types: {"BOLD", "
|
29
|
-
|
28
|
+
types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM"} or \
|
29
|
+
list of the options, optional
|
30
30
|
DMCC data types. If None, all available data types are selected.
|
31
31
|
(default None).
|
32
|
-
sessions: {"ses-wave1bas", "ses-wave1pro", "ses-wave1rea"} or
|
33
|
-
|
32
|
+
sessions: {"ses-wave1bas", "ses-wave1pro", "ses-wave1rea"} or \
|
33
|
+
list of the options, optional
|
34
34
|
DMCC sessions. If None, all available sessions are selected
|
35
35
|
(default None).
|
36
36
|
tasks: {"Rest", "Axcpt", "Cuedts", "Stern", "Stroop"} or \
|
37
|
-
|
37
|
+
list of the options, optional
|
38
38
|
DMCC task sessions. If None, all available task sessions are selected
|
39
39
|
(default None).
|
40
40
|
phase_encodings : {"AP", "PA"} or list of the options, optional
|
@@ -147,24 +147,23 @@ class DMCC13Benchmark(PatternDataladDataGrabber):
|
|
147
147
|
"space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz"
|
148
148
|
),
|
149
149
|
"space": "MNI152NLin2009cAsym",
|
150
|
-
"
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
"
|
166
|
-
|
167
|
-
"space": "MNI152NLin2009cAsym",
|
150
|
+
"mask": {
|
151
|
+
"pattern": (
|
152
|
+
"derivatives/fmriprep-1.3.2/{subject}/{session}/"
|
153
|
+
"/func/{subject}_{session}_task-{task}_acq-mb4"
|
154
|
+
"{phase_encoding}_run-{run}_"
|
155
|
+
"space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz"
|
156
|
+
),
|
157
|
+
"space": "MNI152NLin2009cAsym",
|
158
|
+
},
|
159
|
+
"confounds": {
|
160
|
+
"pattern": (
|
161
|
+
"derivatives/fmriprep-1.3.2/{subject}/{session}/"
|
162
|
+
"func/{subject}_{session}_task-{task}_acq-mb4"
|
163
|
+
"{phase_encoding}_run-{run}_desc-confounds_regressors.tsv"
|
164
|
+
),
|
165
|
+
"format": "fmriprep",
|
166
|
+
},
|
168
167
|
},
|
169
168
|
"T1w": {
|
170
169
|
"pattern": (
|
@@ -172,14 +171,13 @@ class DMCC13Benchmark(PatternDataladDataGrabber):
|
|
172
171
|
"{subject}_space-MNI152NLin2009cAsym_desc-preproc_T1w.nii.gz"
|
173
172
|
),
|
174
173
|
"space": "MNI152NLin2009cAsym",
|
175
|
-
"
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
"
|
181
|
-
|
182
|
-
"space": "MNI152NLin2009cAsym",
|
174
|
+
"mask": {
|
175
|
+
"pattern": (
|
176
|
+
"derivatives/fmriprep-1.3.2/{subject}/anat/"
|
177
|
+
"{subject}_space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz"
|
178
|
+
),
|
179
|
+
"space": "MNI152NLin2009cAsym",
|
180
|
+
},
|
183
181
|
},
|
184
182
|
"VBM_CSF": {
|
185
183
|
"pattern": (
|
@@ -215,14 +213,13 @@ class DMCC13Benchmark(PatternDataladDataGrabber):
|
|
215
213
|
"{subject}_desc-preproc_T1w.nii.gz"
|
216
214
|
),
|
217
215
|
"space": "native",
|
218
|
-
"
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
"
|
224
|
-
|
225
|
-
"space": "native",
|
216
|
+
"mask": {
|
217
|
+
"pattern": (
|
218
|
+
"derivatives/fmriprep-1.3.2/{subject}/anat/"
|
219
|
+
"{subject}_desc-brain_mask.nii.gz"
|
220
|
+
),
|
221
|
+
"space": "native",
|
222
|
+
},
|
226
223
|
},
|
227
224
|
"Warp": {
|
228
225
|
"pattern": (
|
@@ -297,20 +294,6 @@ class DMCC13Benchmark(PatternDataladDataGrabber):
|
|
297
294
|
phase_encoding=phase_encoding,
|
298
295
|
run=run,
|
299
296
|
)
|
300
|
-
if out.get("BOLD"):
|
301
|
-
out["BOLD"]["mask_item"] = "BOLD_mask"
|
302
|
-
# Add space information
|
303
|
-
out["BOLD"].update({"space": "MNI152NLin2009cAsym"})
|
304
|
-
if out.get("T1w"):
|
305
|
-
out["T1w"]["mask_item"] = "T1w_mask"
|
306
|
-
# Add space information
|
307
|
-
if self.native_t1w:
|
308
|
-
out["T1w"].update({"space": "native"})
|
309
|
-
else:
|
310
|
-
out["T1w"].update({"space": "MNI152NLin2009cAsym"})
|
311
|
-
if out.get("Warp"):
|
312
|
-
# Add source space information
|
313
|
-
out["Warp"].update({"src": "MNI152NLin2009cAsym"})
|
314
297
|
return out
|
315
298
|
|
316
299
|
def get_elements(self) -> List:
|
@@ -14,6 +14,9 @@ from ...api.decorators import register_datagrabber
|
|
14
14
|
from .hcp1200 import HCP1200
|
15
15
|
|
16
16
|
|
17
|
+
__all__ = ["DataladHCP1200"]
|
18
|
+
|
19
|
+
|
17
20
|
@register_datagrabber
|
18
21
|
class DataladHCP1200(DataladDataGrabber, HCP1200):
|
19
22
|
"""Concrete implementation for datalad-based data fetching of HCP1200.
|
@@ -10,8 +10,11 @@ from pathlib import Path
|
|
10
10
|
from typing import Dict, List, Union
|
11
11
|
|
12
12
|
from ...api.decorators import register_datagrabber
|
13
|
+
from ...utils import raise_error
|
13
14
|
from ..pattern import PatternDataGrabber
|
14
|
-
|
15
|
+
|
16
|
+
|
17
|
+
__all__ = ["HCP1200"]
|
15
18
|
|
16
19
|
|
17
20
|
@register_datagrabber
|