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