junifer 0.0.5.dev242__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.
Files changed (279) hide show
  1. junifer/__init__.py +2 -31
  2. junifer/__init__.pyi +37 -0
  3. junifer/_version.py +9 -4
  4. junifer/api/__init__.py +3 -5
  5. junifer/api/__init__.pyi +4 -0
  6. junifer/api/decorators.py +14 -19
  7. junifer/api/functions.py +165 -109
  8. junifer/api/py.typed +0 -0
  9. junifer/api/queue_context/__init__.py +2 -4
  10. junifer/api/queue_context/__init__.pyi +5 -0
  11. junifer/api/queue_context/gnu_parallel_local_adapter.py +22 -6
  12. junifer/api/queue_context/htcondor_adapter.py +23 -6
  13. junifer/api/queue_context/py.typed +0 -0
  14. junifer/api/queue_context/tests/test_gnu_parallel_local_adapter.py +3 -3
  15. junifer/api/queue_context/tests/test_htcondor_adapter.py +3 -3
  16. junifer/api/tests/test_functions.py +168 -74
  17. junifer/cli/__init__.py +24 -0
  18. junifer/cli/__init__.pyi +3 -0
  19. junifer/{api → cli}/cli.py +141 -125
  20. junifer/cli/parser.py +235 -0
  21. junifer/cli/py.typed +0 -0
  22. junifer/{api → cli}/tests/test_cli.py +8 -8
  23. junifer/{api/tests/test_api_utils.py → cli/tests/test_cli_utils.py} +5 -4
  24. junifer/{api → cli}/tests/test_parser.py +2 -2
  25. junifer/{api → cli}/utils.py +6 -16
  26. junifer/configs/juseless/__init__.py +2 -2
  27. junifer/configs/juseless/__init__.pyi +3 -0
  28. junifer/configs/juseless/datagrabbers/__init__.py +2 -12
  29. junifer/configs/juseless/datagrabbers/__init__.pyi +13 -0
  30. junifer/configs/juseless/datagrabbers/ixi_vbm.py +2 -2
  31. junifer/configs/juseless/datagrabbers/py.typed +0 -0
  32. junifer/configs/juseless/datagrabbers/tests/test_ucla.py +2 -2
  33. junifer/configs/juseless/datagrabbers/ucla.py +4 -4
  34. junifer/configs/juseless/py.typed +0 -0
  35. junifer/conftest.py +25 -0
  36. junifer/data/__init__.py +2 -42
  37. junifer/data/__init__.pyi +29 -0
  38. junifer/data/_dispatch.py +248 -0
  39. junifer/data/coordinates/__init__.py +9 -0
  40. junifer/data/coordinates/__init__.pyi +5 -0
  41. junifer/data/coordinates/_ants_coordinates_warper.py +104 -0
  42. junifer/data/coordinates/_coordinates.py +385 -0
  43. junifer/data/coordinates/_fsl_coordinates_warper.py +81 -0
  44. junifer/data/{tests → coordinates/tests}/test_coordinates.py +26 -33
  45. junifer/data/masks/__init__.py +9 -0
  46. junifer/data/masks/__init__.pyi +6 -0
  47. junifer/data/masks/_ants_mask_warper.py +177 -0
  48. junifer/data/masks/_fsl_mask_warper.py +106 -0
  49. junifer/data/masks/_masks.py +802 -0
  50. junifer/data/{tests → masks/tests}/test_masks.py +67 -63
  51. junifer/data/parcellations/__init__.py +9 -0
  52. junifer/data/parcellations/__init__.pyi +6 -0
  53. junifer/data/parcellations/_ants_parcellation_warper.py +166 -0
  54. junifer/data/parcellations/_fsl_parcellation_warper.py +89 -0
  55. junifer/data/parcellations/_parcellations.py +1388 -0
  56. junifer/data/{tests → parcellations/tests}/test_parcellations.py +165 -295
  57. junifer/data/pipeline_data_registry_base.py +76 -0
  58. junifer/data/py.typed +0 -0
  59. junifer/data/template_spaces.py +44 -79
  60. junifer/data/tests/test_data_utils.py +1 -2
  61. junifer/data/tests/test_template_spaces.py +8 -4
  62. junifer/data/utils.py +109 -4
  63. junifer/datagrabber/__init__.py +2 -26
  64. junifer/datagrabber/__init__.pyi +27 -0
  65. junifer/datagrabber/aomic/__init__.py +2 -4
  66. junifer/datagrabber/aomic/__init__.pyi +5 -0
  67. junifer/datagrabber/aomic/id1000.py +81 -52
  68. junifer/datagrabber/aomic/piop1.py +83 -55
  69. junifer/datagrabber/aomic/piop2.py +85 -56
  70. junifer/datagrabber/aomic/py.typed +0 -0
  71. junifer/datagrabber/aomic/tests/test_id1000.py +19 -12
  72. junifer/datagrabber/aomic/tests/test_piop1.py +52 -18
  73. junifer/datagrabber/aomic/tests/test_piop2.py +50 -17
  74. junifer/datagrabber/base.py +22 -18
  75. junifer/datagrabber/datalad_base.py +71 -34
  76. junifer/datagrabber/dmcc13_benchmark.py +31 -18
  77. junifer/datagrabber/hcp1200/__init__.py +2 -3
  78. junifer/datagrabber/hcp1200/__init__.pyi +4 -0
  79. junifer/datagrabber/hcp1200/datalad_hcp1200.py +3 -3
  80. junifer/datagrabber/hcp1200/hcp1200.py +26 -15
  81. junifer/datagrabber/hcp1200/py.typed +0 -0
  82. junifer/datagrabber/hcp1200/tests/test_hcp1200.py +8 -2
  83. junifer/datagrabber/multiple.py +14 -9
  84. junifer/datagrabber/pattern.py +132 -96
  85. junifer/datagrabber/pattern_validation_mixin.py +206 -94
  86. junifer/datagrabber/py.typed +0 -0
  87. junifer/datagrabber/tests/test_datalad_base.py +27 -12
  88. junifer/datagrabber/tests/test_dmcc13_benchmark.py +28 -11
  89. junifer/datagrabber/tests/test_multiple.py +48 -2
  90. junifer/datagrabber/tests/test_pattern_datalad.py +1 -1
  91. junifer/datagrabber/tests/test_pattern_validation_mixin.py +6 -6
  92. junifer/datareader/__init__.py +2 -2
  93. junifer/datareader/__init__.pyi +3 -0
  94. junifer/datareader/default.py +6 -6
  95. junifer/datareader/py.typed +0 -0
  96. junifer/external/nilearn/__init__.py +2 -3
  97. junifer/external/nilearn/__init__.pyi +4 -0
  98. junifer/external/nilearn/junifer_connectivity_measure.py +25 -17
  99. junifer/external/nilearn/junifer_nifti_spheres_masker.py +4 -4
  100. junifer/external/nilearn/py.typed +0 -0
  101. junifer/external/nilearn/tests/test_junifer_connectivity_measure.py +17 -16
  102. junifer/external/nilearn/tests/test_junifer_nifti_spheres_masker.py +2 -3
  103. junifer/markers/__init__.py +2 -38
  104. junifer/markers/__init__.pyi +37 -0
  105. junifer/markers/base.py +11 -14
  106. junifer/markers/brainprint.py +12 -14
  107. junifer/markers/complexity/__init__.py +2 -18
  108. junifer/markers/complexity/__init__.pyi +17 -0
  109. junifer/markers/complexity/complexity_base.py +9 -11
  110. junifer/markers/complexity/hurst_exponent.py +7 -7
  111. junifer/markers/complexity/multiscale_entropy_auc.py +7 -7
  112. junifer/markers/complexity/perm_entropy.py +7 -7
  113. junifer/markers/complexity/py.typed +0 -0
  114. junifer/markers/complexity/range_entropy.py +7 -7
  115. junifer/markers/complexity/range_entropy_auc.py +7 -7
  116. junifer/markers/complexity/sample_entropy.py +7 -7
  117. junifer/markers/complexity/tests/test_complexity_base.py +1 -1
  118. junifer/markers/complexity/tests/test_hurst_exponent.py +5 -5
  119. junifer/markers/complexity/tests/test_multiscale_entropy_auc.py +5 -5
  120. junifer/markers/complexity/tests/test_perm_entropy.py +5 -5
  121. junifer/markers/complexity/tests/test_range_entropy.py +5 -5
  122. junifer/markers/complexity/tests/test_range_entropy_auc.py +5 -5
  123. junifer/markers/complexity/tests/test_sample_entropy.py +5 -5
  124. junifer/markers/complexity/tests/test_weighted_perm_entropy.py +5 -5
  125. junifer/markers/complexity/weighted_perm_entropy.py +7 -7
  126. junifer/markers/ets_rss.py +12 -11
  127. junifer/markers/falff/__init__.py +2 -3
  128. junifer/markers/falff/__init__.pyi +4 -0
  129. junifer/markers/falff/_afni_falff.py +38 -45
  130. junifer/markers/falff/_junifer_falff.py +16 -19
  131. junifer/markers/falff/falff_base.py +7 -11
  132. junifer/markers/falff/falff_parcels.py +9 -9
  133. junifer/markers/falff/falff_spheres.py +8 -8
  134. junifer/markers/falff/py.typed +0 -0
  135. junifer/markers/falff/tests/test_falff_spheres.py +3 -1
  136. junifer/markers/functional_connectivity/__init__.py +2 -12
  137. junifer/markers/functional_connectivity/__init__.pyi +13 -0
  138. junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +9 -8
  139. junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +8 -8
  140. junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +7 -7
  141. junifer/markers/functional_connectivity/functional_connectivity_base.py +13 -12
  142. junifer/markers/functional_connectivity/functional_connectivity_parcels.py +8 -8
  143. junifer/markers/functional_connectivity/functional_connectivity_spheres.py +7 -7
  144. junifer/markers/functional_connectivity/py.typed +0 -0
  145. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +1 -2
  146. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +1 -2
  147. junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +6 -6
  148. junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +5 -5
  149. junifer/markers/parcel_aggregation.py +22 -17
  150. junifer/markers/py.typed +0 -0
  151. junifer/markers/reho/__init__.py +2 -3
  152. junifer/markers/reho/__init__.pyi +4 -0
  153. junifer/markers/reho/_afni_reho.py +29 -35
  154. junifer/markers/reho/_junifer_reho.py +13 -14
  155. junifer/markers/reho/py.typed +0 -0
  156. junifer/markers/reho/reho_base.py +7 -11
  157. junifer/markers/reho/reho_parcels.py +10 -10
  158. junifer/markers/reho/reho_spheres.py +9 -9
  159. junifer/markers/sphere_aggregation.py +22 -17
  160. junifer/markers/temporal_snr/__init__.py +2 -3
  161. junifer/markers/temporal_snr/__init__.pyi +4 -0
  162. junifer/markers/temporal_snr/py.typed +0 -0
  163. junifer/markers/temporal_snr/temporal_snr_base.py +11 -10
  164. junifer/markers/temporal_snr/temporal_snr_parcels.py +8 -8
  165. junifer/markers/temporal_snr/temporal_snr_spheres.py +7 -7
  166. junifer/markers/tests/test_ets_rss.py +3 -3
  167. junifer/markers/tests/test_parcel_aggregation.py +24 -24
  168. junifer/markers/tests/test_sphere_aggregation.py +6 -6
  169. junifer/markers/utils.py +3 -3
  170. junifer/onthefly/__init__.py +2 -1
  171. junifer/onthefly/_brainprint.py +138 -0
  172. junifer/onthefly/read_transform.py +5 -8
  173. junifer/pipeline/__init__.py +2 -10
  174. junifer/pipeline/__init__.pyi +13 -0
  175. junifer/{markers/collection.py → pipeline/marker_collection.py} +8 -14
  176. junifer/pipeline/pipeline_component_registry.py +294 -0
  177. junifer/pipeline/pipeline_step_mixin.py +15 -11
  178. junifer/pipeline/py.typed +0 -0
  179. junifer/{markers/tests/test_collection.py → pipeline/tests/test_marker_collection.py} +2 -3
  180. junifer/pipeline/tests/test_pipeline_component_registry.py +200 -0
  181. junifer/pipeline/tests/test_pipeline_step_mixin.py +36 -37
  182. junifer/pipeline/tests/test_update_meta_mixin.py +4 -4
  183. junifer/pipeline/tests/test_workdir_manager.py +43 -0
  184. junifer/pipeline/update_meta_mixin.py +21 -17
  185. junifer/pipeline/utils.py +6 -6
  186. junifer/pipeline/workdir_manager.py +19 -5
  187. junifer/preprocess/__init__.py +2 -10
  188. junifer/preprocess/__init__.pyi +11 -0
  189. junifer/preprocess/base.py +10 -10
  190. junifer/preprocess/confounds/__init__.py +2 -2
  191. junifer/preprocess/confounds/__init__.pyi +3 -0
  192. junifer/preprocess/confounds/fmriprep_confound_remover.py +243 -64
  193. junifer/preprocess/confounds/py.typed +0 -0
  194. junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py +121 -14
  195. junifer/preprocess/py.typed +0 -0
  196. junifer/preprocess/smoothing/__init__.py +2 -2
  197. junifer/preprocess/smoothing/__init__.pyi +3 -0
  198. junifer/preprocess/smoothing/_afni_smoothing.py +40 -40
  199. junifer/preprocess/smoothing/_fsl_smoothing.py +22 -32
  200. junifer/preprocess/smoothing/_nilearn_smoothing.py +35 -14
  201. junifer/preprocess/smoothing/py.typed +0 -0
  202. junifer/preprocess/smoothing/smoothing.py +11 -13
  203. junifer/preprocess/warping/__init__.py +2 -2
  204. junifer/preprocess/warping/__init__.pyi +3 -0
  205. junifer/preprocess/warping/_ants_warper.py +136 -32
  206. junifer/preprocess/warping/_fsl_warper.py +73 -22
  207. junifer/preprocess/warping/py.typed +0 -0
  208. junifer/preprocess/warping/space_warper.py +39 -11
  209. junifer/preprocess/warping/tests/test_space_warper.py +5 -9
  210. junifer/py.typed +0 -0
  211. junifer/stats.py +5 -5
  212. junifer/storage/__init__.py +2 -10
  213. junifer/storage/__init__.pyi +11 -0
  214. junifer/storage/base.py +47 -13
  215. junifer/storage/hdf5.py +95 -33
  216. junifer/storage/pandas_base.py +12 -11
  217. junifer/storage/py.typed +0 -0
  218. junifer/storage/sqlite.py +11 -11
  219. junifer/storage/tests/test_hdf5.py +86 -4
  220. junifer/storage/tests/test_sqlite.py +2 -2
  221. junifer/storage/tests/test_storage_base.py +5 -2
  222. junifer/storage/tests/test_utils.py +33 -7
  223. junifer/storage/utils.py +95 -9
  224. junifer/testing/__init__.py +2 -3
  225. junifer/testing/__init__.pyi +4 -0
  226. junifer/testing/datagrabbers.py +10 -11
  227. junifer/testing/py.typed +0 -0
  228. junifer/testing/registry.py +4 -7
  229. junifer/testing/tests/test_testing_registry.py +9 -17
  230. junifer/tests/test_stats.py +2 -2
  231. junifer/typing/__init__.py +9 -0
  232. junifer/typing/__init__.pyi +31 -0
  233. junifer/typing/_typing.py +68 -0
  234. junifer/utils/__init__.py +2 -12
  235. junifer/utils/__init__.pyi +18 -0
  236. junifer/utils/_config.py +110 -0
  237. junifer/utils/_yaml.py +16 -0
  238. junifer/utils/helpers.py +6 -6
  239. junifer/utils/logging.py +117 -8
  240. junifer/utils/py.typed +0 -0
  241. junifer/{pipeline → utils}/singleton.py +19 -14
  242. junifer/utils/tests/test_config.py +59 -0
  243. {junifer-0.0.5.dev242.dist-info → junifer-0.0.6.dist-info}/METADATA +43 -38
  244. junifer-0.0.6.dist-info/RECORD +350 -0
  245. {junifer-0.0.5.dev242.dist-info → junifer-0.0.6.dist-info}/WHEEL +1 -1
  246. junifer-0.0.6.dist-info/entry_points.txt +2 -0
  247. junifer/api/parser.py +0 -118
  248. junifer/data/coordinates.py +0 -408
  249. junifer/data/masks.py +0 -670
  250. junifer/data/parcellations.py +0 -1828
  251. junifer/pipeline/registry.py +0 -177
  252. junifer/pipeline/tests/test_registry.py +0 -150
  253. junifer-0.0.5.dev242.dist-info/RECORD +0 -275
  254. junifer-0.0.5.dev242.dist-info/entry_points.txt +0 -2
  255. /junifer/{api → cli}/tests/data/gmd_mean.yaml +0 -0
  256. /junifer/{api → cli}/tests/data/gmd_mean_htcondor.yaml +0 -0
  257. /junifer/{api → cli}/tests/data/partly_cloudy_agg_mean_tian.yml +0 -0
  258. /junifer/data/{VOIs → coordinates/VOIs}/meta/AutobiographicalMemory_VOIs.txt +0 -0
  259. /junifer/data/{VOIs → coordinates/VOIs}/meta/CogAC_VOIs.txt +0 -0
  260. /junifer/data/{VOIs → coordinates/VOIs}/meta/CogAR_VOIs.txt +0 -0
  261. /junifer/data/{VOIs → coordinates/VOIs}/meta/DMNBuckner_VOIs.txt +0 -0
  262. /junifer/data/{VOIs → coordinates/VOIs}/meta/Dosenbach2010_MNI_VOIs.txt +0 -0
  263. /junifer/data/{VOIs → coordinates/VOIs}/meta/Empathy_VOIs.txt +0 -0
  264. /junifer/data/{VOIs → coordinates/VOIs}/meta/Motor_VOIs.txt +0 -0
  265. /junifer/data/{VOIs → coordinates/VOIs}/meta/MultiTask_VOIs.txt +0 -0
  266. /junifer/data/{VOIs → coordinates/VOIs}/meta/PhysioStress_VOIs.txt +0 -0
  267. /junifer/data/{VOIs → coordinates/VOIs}/meta/Power2011_MNI_VOIs.txt +0 -0
  268. /junifer/data/{VOIs → coordinates/VOIs}/meta/Power2013_MNI_VOIs.tsv +0 -0
  269. /junifer/data/{VOIs → coordinates/VOIs}/meta/Rew_VOIs.txt +0 -0
  270. /junifer/data/{VOIs → coordinates/VOIs}/meta/Somatosensory_VOIs.txt +0 -0
  271. /junifer/data/{VOIs → coordinates/VOIs}/meta/ToM_VOIs.txt +0 -0
  272. /junifer/data/{VOIs → coordinates/VOIs}/meta/VigAtt_VOIs.txt +0 -0
  273. /junifer/data/{VOIs → coordinates/VOIs}/meta/WM_VOIs.txt +0 -0
  274. /junifer/data/{VOIs → coordinates/VOIs}/meta/eMDN_VOIs.txt +0 -0
  275. /junifer/data/{VOIs → coordinates/VOIs}/meta/eSAD_VOIs.txt +0 -0
  276. /junifer/data/{VOIs → coordinates/VOIs}/meta/extDMN_VOIs.txt +0 -0
  277. {junifer-0.0.5.dev242.dist-info → junifer-0.0.6.dist-info/licenses}/AUTHORS.rst +0 -0
  278. {junifer-0.0.5.dev242.dist-info → junifer-0.0.6.dist-info/licenses}/LICENSE.md +0 -0
  279. {junifer-0.0.5.dev242.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": "b87897cbe51bf0ee5514becaa5c7dd76491db5ad",
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 ContextManager, Dict, List, Union
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, List[str], List[int]],
190
- replacements: Union[str, List[str], List[int]],
191
- patterns: Union[str, Dict[str, Dict[str, str]]],
192
- expect: ContextManager,
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
 
@@ -5,7 +5,7 @@
5
5
  # Synchon Mandal <s.mandal@fz-juelich.de>
6
6
  # License: AGPL
7
7
 
8
- from .default import DefaultDataReader
8
+ import lazy_loader as lazy
9
9
 
10
10
 
11
- __all__ = ["DefaultDataReader"]
11
+ __getattr__, __dir__, __all__ = lazy.attach_stub(__name__, __file__)
@@ -0,0 +1,3 @@
1
+ __all__ = ["DefaultDataReader"]
2
+
3
+ from .default import DefaultDataReader
@@ -5,7 +5,7 @@
5
5
  # License: AGPL
6
6
 
7
7
  from pathlib import Path
8
- from typing import Dict, List, Optional, Union
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: List[str]) -> List[str]:
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: Dict[str, Dict],
79
- params: Optional[Dict] = None,
80
- ) -> Dict:
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: Dict
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
- from .junifer_nifti_spheres_masker import JuniferNiftiSpheresMasker
7
- from .junifer_connectivity_measure import JuniferConnectivityMeasure
6
+ import lazy_loader as lazy
8
7
 
9
8
 
10
- __all__ = ["JuniferNiftiSpheresMasker", "JuniferConnectivityMeasure"]
9
+ __getattr__, __dir__, __all__ = lazy.attach_stub(__name__, __file__)
@@ -0,0 +1,4 @@
1
+ __all__ = ["JuniferNiftiSpheresMasker", "JuniferConnectivityMeasure"]
2
+
3
+ from .junifer_nifti_spheres_masker import JuniferNiftiSpheresMasker
4
+ from .junifer_connectivity_measure import JuniferConnectivityMeasure
@@ -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, List, Optional
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: List[np.ndarray],
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", "partial correlation", \
324
- "tangent", "precision"}, optional
325
- The matrix kind. For the use of ``"tangent"`` see [1]_
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 == "correlation":
404
- covariances_std = [
405
- self.cov_estimator_.fit(
406
- signal.standardize_signal(
407
- x,
408
- detrend=False,
409
- standardize=self.standardize,
410
- )
411
- ).covariance_
412
- for x in X
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, List, Optional, Tuple, Union
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
- ) -> Tuple["ArrayLike", None]:
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", List, None
375
+ str, "Path", "ArrayLike", "DataFrame", list, None
376
376
  ] = None,
377
- sample_mask: Union["ArrayLike", List, Tuple, None] = None,
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, List, Optional, Tuple, Type, Union
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
- ) -> Tuple[List[np.ndarray], np.ndarray]:
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() -> List[np.ndarray]:
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
- ) -> Tuple[List[np.ndarray], List[float]]:
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
- ) -> List[float]:
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: Type["BaseEstimator"],
618
- signals_and_covariances: Tuple[List[np.ndarray], List[float]],
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: Type["BaseEstimator"],
781
- signals_and_covariances: Tuple[List[np.ndarray], List[float]],
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: List[np.ndarray]
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: List[np.ndarray]
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: List[np.ndarray]
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: List[np.ndarray]
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: List[np.ndarray],
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: List[np.ndarray],
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: Tuple[int, ...],
363
+ shape: tuple[int, ...],
365
364
  radius: float,
366
365
  allow_overlap: bool,
367
- coords: List[Tuple[int, int, int]],
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
 
@@ -5,43 +5,7 @@
5
5
  # Synchon Mandal <s.mandal@fz-juelich.de>
6
6
  # License: AGPL
7
7
 
8
- from .base import BaseMarker
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 TYPE_CHECKING, Any, Dict, List, Optional, Union
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[List[str], str]] = None,
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: List[str]) -> List[str]:
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) -> List[str]:
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: Dict, extra_input: Optional[Dict] = None) -> Dict:
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: Dict[str, Any],
162
- storage: "BaseFeatureStorage",
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: Dict[str, Dict],
185
- storage: Optional["BaseFeatureStorage"] = None,
186
- ) -> Dict:
181
+ input: dict[str, dict],
182
+ storage: Optional[StorageLike] = None,
183
+ ) -> dict:
187
184
  """Fit and transform.
188
185
 
189
186
  Parameters