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.
Files changed (206) hide show
  1. junifer/__init__.py +17 -0
  2. junifer/_version.py +2 -2
  3. junifer/api/__init__.py +4 -1
  4. junifer/api/cli.py +91 -1
  5. junifer/api/decorators.py +9 -0
  6. junifer/api/functions.py +56 -10
  7. junifer/api/parser.py +3 -0
  8. junifer/api/queue_context/__init__.py +4 -1
  9. junifer/api/queue_context/gnu_parallel_local_adapter.py +16 -6
  10. junifer/api/queue_context/htcondor_adapter.py +16 -5
  11. junifer/api/queue_context/tests/test_gnu_parallel_local_adapter.py +41 -12
  12. junifer/api/queue_context/tests/test_htcondor_adapter.py +48 -15
  13. junifer/api/res/afni/run_afni_docker.sh +1 -1
  14. junifer/api/res/ants/run_ants_docker.sh +1 -1
  15. junifer/api/res/freesurfer/mri_binarize +3 -0
  16. junifer/api/res/freesurfer/mri_mc +3 -0
  17. junifer/api/res/freesurfer/mri_pretess +3 -0
  18. junifer/api/res/freesurfer/mris_convert +3 -0
  19. junifer/api/res/freesurfer/run_freesurfer_docker.sh +61 -0
  20. junifer/api/res/fsl/run_fsl_docker.sh +1 -1
  21. junifer/api/res/{run_conda.sh → run_conda.bash} +1 -1
  22. junifer/api/res/run_conda.zsh +23 -0
  23. junifer/api/res/run_venv.bash +22 -0
  24. junifer/api/res/{run_venv.sh → run_venv.zsh} +1 -1
  25. junifer/api/tests/test_api_utils.py +4 -2
  26. junifer/api/tests/test_cli.py +83 -0
  27. junifer/api/tests/test_functions.py +27 -2
  28. junifer/configs/__init__.py +1 -1
  29. junifer/configs/juseless/__init__.py +4 -1
  30. junifer/configs/juseless/datagrabbers/__init__.py +10 -1
  31. junifer/configs/juseless/datagrabbers/aomic_id1000_vbm.py +4 -3
  32. junifer/configs/juseless/datagrabbers/camcan_vbm.py +3 -0
  33. junifer/configs/juseless/datagrabbers/ixi_vbm.py +4 -3
  34. junifer/configs/juseless/datagrabbers/tests/test_ucla.py +1 -3
  35. junifer/configs/juseless/datagrabbers/ucla.py +12 -9
  36. junifer/configs/juseless/datagrabbers/ukb_vbm.py +3 -0
  37. junifer/data/__init__.py +21 -1
  38. junifer/data/coordinates.py +10 -19
  39. junifer/data/masks/ukb/UKB_15K_GM_template.nii.gz +0 -0
  40. junifer/data/masks.py +58 -87
  41. junifer/data/parcellations.py +14 -3
  42. junifer/data/template_spaces.py +4 -1
  43. junifer/data/tests/test_masks.py +26 -37
  44. junifer/data/utils.py +3 -0
  45. junifer/datagrabber/__init__.py +18 -1
  46. junifer/datagrabber/aomic/__init__.py +3 -0
  47. junifer/datagrabber/aomic/id1000.py +70 -37
  48. junifer/datagrabber/aomic/piop1.py +69 -36
  49. junifer/datagrabber/aomic/piop2.py +71 -38
  50. junifer/datagrabber/aomic/tests/test_id1000.py +44 -100
  51. junifer/datagrabber/aomic/tests/test_piop1.py +65 -108
  52. junifer/datagrabber/aomic/tests/test_piop2.py +45 -102
  53. junifer/datagrabber/base.py +13 -6
  54. junifer/datagrabber/datalad_base.py +13 -1
  55. junifer/datagrabber/dmcc13_benchmark.py +36 -53
  56. junifer/datagrabber/hcp1200/__init__.py +3 -0
  57. junifer/datagrabber/hcp1200/datalad_hcp1200.py +3 -0
  58. junifer/datagrabber/hcp1200/hcp1200.py +4 -1
  59. junifer/datagrabber/multiple.py +45 -6
  60. junifer/datagrabber/pattern.py +170 -62
  61. junifer/datagrabber/pattern_datalad.py +25 -12
  62. junifer/datagrabber/pattern_validation_mixin.py +388 -0
  63. junifer/datagrabber/tests/test_datalad_base.py +4 -4
  64. junifer/datagrabber/tests/test_dmcc13_benchmark.py +46 -19
  65. junifer/datagrabber/tests/test_multiple.py +161 -84
  66. junifer/datagrabber/tests/test_pattern.py +45 -0
  67. junifer/datagrabber/tests/test_pattern_datalad.py +4 -4
  68. junifer/datagrabber/tests/test_pattern_validation_mixin.py +249 -0
  69. junifer/datareader/__init__.py +4 -1
  70. junifer/datareader/default.py +95 -43
  71. junifer/external/BrainPrint/brainprint/__init__.py +4 -0
  72. junifer/external/BrainPrint/brainprint/_version.py +3 -0
  73. junifer/external/BrainPrint/brainprint/asymmetry.py +91 -0
  74. junifer/external/BrainPrint/brainprint/brainprint.py +441 -0
  75. junifer/external/BrainPrint/brainprint/surfaces.py +258 -0
  76. junifer/external/BrainPrint/brainprint/utils/__init__.py +1 -0
  77. junifer/external/BrainPrint/brainprint/utils/_config.py +112 -0
  78. junifer/external/BrainPrint/brainprint/utils/utils.py +188 -0
  79. junifer/external/__init__.py +1 -1
  80. junifer/external/nilearn/__init__.py +5 -1
  81. junifer/external/nilearn/junifer_connectivity_measure.py +483 -0
  82. junifer/external/nilearn/junifer_nifti_spheres_masker.py +23 -9
  83. junifer/external/nilearn/tests/test_junifer_connectivity_measure.py +1089 -0
  84. junifer/external/nilearn/tests/test_junifer_nifti_spheres_masker.py +76 -1
  85. junifer/markers/__init__.py +23 -1
  86. junifer/markers/base.py +68 -28
  87. junifer/markers/brainprint.py +459 -0
  88. junifer/markers/collection.py +10 -2
  89. junifer/markers/complexity/__init__.py +10 -0
  90. junifer/markers/complexity/complexity_base.py +26 -43
  91. junifer/markers/complexity/hurst_exponent.py +3 -0
  92. junifer/markers/complexity/multiscale_entropy_auc.py +3 -0
  93. junifer/markers/complexity/perm_entropy.py +3 -0
  94. junifer/markers/complexity/range_entropy.py +3 -0
  95. junifer/markers/complexity/range_entropy_auc.py +3 -0
  96. junifer/markers/complexity/sample_entropy.py +3 -0
  97. junifer/markers/complexity/tests/test_hurst_exponent.py +11 -3
  98. junifer/markers/complexity/tests/test_multiscale_entropy_auc.py +11 -3
  99. junifer/markers/complexity/tests/test_perm_entropy.py +11 -3
  100. junifer/markers/complexity/tests/test_range_entropy.py +11 -3
  101. junifer/markers/complexity/tests/test_range_entropy_auc.py +11 -3
  102. junifer/markers/complexity/tests/test_sample_entropy.py +11 -3
  103. junifer/markers/complexity/tests/test_weighted_perm_entropy.py +11 -3
  104. junifer/markers/complexity/weighted_perm_entropy.py +3 -0
  105. junifer/markers/ets_rss.py +27 -42
  106. junifer/markers/falff/__init__.py +3 -0
  107. junifer/markers/falff/_afni_falff.py +5 -2
  108. junifer/markers/falff/_junifer_falff.py +3 -0
  109. junifer/markers/falff/falff_base.py +20 -46
  110. junifer/markers/falff/falff_parcels.py +56 -27
  111. junifer/markers/falff/falff_spheres.py +60 -29
  112. junifer/markers/falff/tests/test_falff_parcels.py +39 -23
  113. junifer/markers/falff/tests/test_falff_spheres.py +39 -23
  114. junifer/markers/functional_connectivity/__init__.py +9 -0
  115. junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +63 -60
  116. junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +45 -32
  117. junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +49 -36
  118. junifer/markers/functional_connectivity/functional_connectivity_base.py +71 -70
  119. junifer/markers/functional_connectivity/functional_connectivity_parcels.py +34 -25
  120. junifer/markers/functional_connectivity/functional_connectivity_spheres.py +40 -30
  121. junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py +11 -7
  122. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +27 -7
  123. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +28 -12
  124. junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +35 -11
  125. junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +36 -62
  126. junifer/markers/parcel_aggregation.py +47 -61
  127. junifer/markers/reho/__init__.py +3 -0
  128. junifer/markers/reho/_afni_reho.py +5 -2
  129. junifer/markers/reho/_junifer_reho.py +4 -1
  130. junifer/markers/reho/reho_base.py +8 -27
  131. junifer/markers/reho/reho_parcels.py +28 -17
  132. junifer/markers/reho/reho_spheres.py +27 -18
  133. junifer/markers/reho/tests/test_reho_parcels.py +8 -3
  134. junifer/markers/reho/tests/test_reho_spheres.py +8 -3
  135. junifer/markers/sphere_aggregation.py +43 -59
  136. junifer/markers/temporal_snr/__init__.py +3 -0
  137. junifer/markers/temporal_snr/temporal_snr_base.py +23 -32
  138. junifer/markers/temporal_snr/temporal_snr_parcels.py +9 -6
  139. junifer/markers/temporal_snr/temporal_snr_spheres.py +9 -6
  140. junifer/markers/temporal_snr/tests/test_temporal_snr_parcels.py +6 -3
  141. junifer/markers/temporal_snr/tests/test_temporal_snr_spheres.py +6 -3
  142. junifer/markers/tests/test_brainprint.py +58 -0
  143. junifer/markers/tests/test_collection.py +9 -8
  144. junifer/markers/tests/test_ets_rss.py +15 -9
  145. junifer/markers/tests/test_markers_base.py +17 -18
  146. junifer/markers/tests/test_parcel_aggregation.py +93 -32
  147. junifer/markers/tests/test_sphere_aggregation.py +72 -19
  148. junifer/onthefly/__init__.py +4 -1
  149. junifer/onthefly/read_transform.py +3 -0
  150. junifer/pipeline/__init__.py +9 -1
  151. junifer/pipeline/pipeline_step_mixin.py +21 -4
  152. junifer/pipeline/registry.py +3 -0
  153. junifer/pipeline/singleton.py +3 -0
  154. junifer/pipeline/tests/test_registry.py +1 -1
  155. junifer/pipeline/update_meta_mixin.py +3 -0
  156. junifer/pipeline/utils.py +67 -1
  157. junifer/pipeline/workdir_manager.py +3 -0
  158. junifer/preprocess/__init__.py +10 -2
  159. junifer/preprocess/base.py +6 -3
  160. junifer/preprocess/confounds/__init__.py +3 -0
  161. junifer/preprocess/confounds/fmriprep_confound_remover.py +47 -60
  162. junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py +72 -113
  163. junifer/preprocess/smoothing/__init__.py +9 -0
  164. junifer/preprocess/smoothing/_afni_smoothing.py +119 -0
  165. junifer/preprocess/smoothing/_fsl_smoothing.py +116 -0
  166. junifer/preprocess/smoothing/_nilearn_smoothing.py +69 -0
  167. junifer/preprocess/smoothing/smoothing.py +174 -0
  168. junifer/preprocess/smoothing/tests/test_smoothing.py +94 -0
  169. junifer/preprocess/warping/__init__.py +3 -0
  170. junifer/preprocess/warping/_ants_warper.py +3 -0
  171. junifer/preprocess/warping/_fsl_warper.py +3 -0
  172. junifer/stats.py +4 -1
  173. junifer/storage/__init__.py +9 -1
  174. junifer/storage/base.py +40 -1
  175. junifer/storage/hdf5.py +71 -9
  176. junifer/storage/pandas_base.py +3 -0
  177. junifer/storage/sqlite.py +3 -0
  178. junifer/storage/tests/test_hdf5.py +82 -10
  179. junifer/storage/utils.py +9 -0
  180. junifer/testing/__init__.py +4 -1
  181. junifer/testing/datagrabbers.py +13 -6
  182. junifer/testing/tests/test_partlycloudytesting_datagrabber.py +7 -7
  183. junifer/testing/utils.py +3 -0
  184. junifer/utils/__init__.py +13 -2
  185. junifer/utils/fs.py +3 -0
  186. junifer/utils/helpers.py +32 -1
  187. junifer/utils/logging.py +33 -4
  188. junifer/utils/tests/test_logging.py +8 -0
  189. {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/METADATA +17 -16
  190. junifer-0.0.5.dist-info/RECORD +275 -0
  191. {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/WHEEL +1 -1
  192. junifer/datagrabber/tests/test_datagrabber_utils.py +0 -218
  193. junifer/datagrabber/utils.py +0 -230
  194. junifer/preprocess/ants/__init__.py +0 -4
  195. junifer/preprocess/ants/ants_apply_transforms_warper.py +0 -185
  196. junifer/preprocess/ants/tests/test_ants_apply_transforms_warper.py +0 -56
  197. junifer/preprocess/bold_warper.py +0 -265
  198. junifer/preprocess/fsl/__init__.py +0 -4
  199. junifer/preprocess/fsl/apply_warper.py +0 -179
  200. junifer/preprocess/fsl/tests/test_apply_warper.py +0 -45
  201. junifer/preprocess/tests/test_bold_warper.py +0 -159
  202. junifer-0.0.4.dev831.dist-info/RECORD +0 -257
  203. {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/AUTHORS.rst +0 -0
  204. {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/LICENSE.md +0 -0
  205. {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/entry_points.txt +0 -0
  206. {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
- [None, "restingstate"],
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(tasks: Optional[str]) -> None:
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
- tasks : str or None
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
- sub, task = test_element
41
-
67
+ # Get test element data
42
68
  out = dg[test_element]
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"]
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 sub == meta["element"]["subject"]
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", "BOLD_confounds"],
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
- [None, "restingstate"],
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(tasks: Optional[str]) -> None:
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
- tasks : str or None
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
- sub, task = test_element
62
+ # Get test element data
46
63
  out = dg[test_element]
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"]
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 sub == meta["element"]["subject"]
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", "BOLD_confounds"],
93
+ ["BOLD", "VBM_CSF"],
151
94
  ["T1w", "VBM_CSF"],
152
95
  ["VBM_GM", "VBM_WM"],
153
96
  ["DWI", "BOLD"],
@@ -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
- from .utils import validate_types
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
- Attributes
31
- ----------
32
- datadir : pathlib.Path
33
- The directory where the data is / will be stored.
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
- validate_types(types)
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 = [v["path"] for v in out.values() if "path" in v]
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", "BOLD_confounds", "T1w", "VBM_CSF", "VBM_GM", \
29
- "VBM_WM"} or a list of the options, optional
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 list of \
33
- the options, optional
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
- list of the options, optional
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
- "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",
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
- "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",
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
- "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",
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:
@@ -5,3 +5,6 @@
5
5
 
6
6
  from .hcp1200 import HCP1200
7
7
  from .datalad_hcp1200 import DataladHCP1200
8
+
9
+
10
+ __all__ = ["HCP1200", "DataladHCP1200"]
@@ -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
- from ..utils import raise_error
15
+
16
+
17
+ __all__ = ["HCP1200"]
15
18
 
16
19
 
17
20
  @register_datagrabber