junifer 0.0.5.dev98__py3-none-any.whl → 0.0.5.dev131__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 (34) hide show
  1. junifer/_version.py +2 -2
  2. junifer/api/tests/test_api_utils.py +2 -0
  3. junifer/data/tests/test_masks.py +1 -1
  4. junifer/datagrabber/aomic/id1000.py +35 -2
  5. junifer/datagrabber/aomic/piop1.py +35 -2
  6. junifer/datagrabber/aomic/piop2.py +35 -2
  7. junifer/datagrabber/aomic/tests/test_id1000.py +43 -97
  8. junifer/datagrabber/aomic/tests/test_piop1.py +64 -106
  9. junifer/datagrabber/aomic/tests/test_piop2.py +44 -100
  10. junifer/datagrabber/pattern.py +2 -1
  11. junifer/datagrabber/utils.py +11 -0
  12. junifer/datareader/default.py +2 -2
  13. junifer/external/BrainPrint/brainprint/__init__.py +4 -0
  14. junifer/external/BrainPrint/brainprint/_version.py +3 -0
  15. junifer/external/BrainPrint/brainprint/asymmetry.py +91 -0
  16. junifer/external/BrainPrint/brainprint/brainprint.py +441 -0
  17. junifer/external/BrainPrint/brainprint/surfaces.py +258 -0
  18. junifer/external/BrainPrint/brainprint/utils/__init__.py +1 -0
  19. junifer/external/BrainPrint/brainprint/utils/_config.py +112 -0
  20. junifer/external/BrainPrint/brainprint/utils/utils.py +188 -0
  21. junifer/markers/__init__.py +1 -0
  22. junifer/markers/brainprint.py +662 -0
  23. junifer/markers/reho/_afni_reho.py +1 -1
  24. junifer/markers/reho/_junifer_reho.py +1 -1
  25. junifer/markers/reho/reho_parcels.py +2 -2
  26. junifer/markers/reho/reho_spheres.py +2 -2
  27. junifer/markers/tests/test_brainprint.py +47 -0
  28. {junifer-0.0.5.dev98.dist-info → junifer-0.0.5.dev131.dist-info}/METADATA +2 -1
  29. {junifer-0.0.5.dev98.dist-info → junifer-0.0.5.dev131.dist-info}/RECORD +34 -24
  30. {junifer-0.0.5.dev98.dist-info → junifer-0.0.5.dev131.dist-info}/AUTHORS.rst +0 -0
  31. {junifer-0.0.5.dev98.dist-info → junifer-0.0.5.dev131.dist-info}/LICENSE.md +0 -0
  32. {junifer-0.0.5.dev98.dist-info → junifer-0.0.5.dev131.dist-info}/WHEEL +0 -0
  33. {junifer-0.0.5.dev98.dist-info → junifer-0.0.5.dev131.dist-info}/entry_points.txt +0 -0
  34. {junifer-0.0.5.dev98.dist-info → junifer-0.0.5.dev131.dist-info}/top_level.txt +0 -0
junifer/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.0.5.dev98'
16
- __version_tuple__ = version_tuple = (0, 0, 5, 'dev98')
15
+ __version__ = version = '0.0.5.dev131'
16
+ __version_tuple__ = version_tuple = (0, 0, 5, 'dev131')
@@ -45,6 +45,7 @@ def test_get_dependency_information_short() -> None:
45
45
  "httpx",
46
46
  "tqdm",
47
47
  "templateflow",
48
+ "lapy",
48
49
  "looseversion",
49
50
  ]
50
51
 
@@ -74,6 +75,7 @@ def test_get_dependency_information_long() -> None:
74
75
  "httpx",
75
76
  "tqdm",
76
77
  "templateflow",
78
+ "lapy",
77
79
  ]
78
80
  for key in dependency_list:
79
81
  assert key in dependency_information_keys
@@ -350,7 +350,7 @@ def test_get_mask_errors() -> None:
350
350
  with pytest.raises(ValueError, match=r"callable params"):
351
351
  get_mask(masks={"GM_prob0.2": {"param": 1}}, target_data=vbm_gm)
352
352
 
353
- # Pass only parametesr to the intersection function
353
+ # Pass only parameters to the intersection function
354
354
  with pytest.raises(
355
355
  ValueError, match=r" At least one mask is required."
356
356
  ):
@@ -24,8 +24,8 @@ class DataladAOMICID1000(PatternDataladDataGrabber):
24
24
  The directory where the datalad dataset will be cloned. If None,
25
25
  the datalad dataset will be cloned into a temporary directory
26
26
  (default None).
27
- types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI"} or \
28
- list of the options, optional
27
+ types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI", \
28
+ "FreeSurfer"} or list of the options, optional
29
29
  AOMIC data types. If None, all available data types are selected.
30
30
  (default None).
31
31
  native_t1w : bool, optional
@@ -112,6 +112,39 @@ class DataladAOMICID1000(PatternDataladDataGrabber):
112
112
  "{subject}_desc-preproc_dwi.nii.gz"
113
113
  ),
114
114
  },
115
+ "FreeSurfer": {
116
+ "pattern": "derivatives/freesurfer/[!f]{subject}/mri/T1.mg[z]",
117
+ "aseg": {
118
+ "pattern": (
119
+ "derivatives/freesurfer/[!f]{subject}/mri/aseg.mg[z]"
120
+ )
121
+ },
122
+ "norm": {
123
+ "pattern": (
124
+ "derivatives/freesurfer/[!f]{subject}/mri/norm.mg[z]"
125
+ )
126
+ },
127
+ "lh_white": {
128
+ "pattern": (
129
+ "derivatives/freesurfer/[!f]{subject}/surf/lh.whit[e]"
130
+ )
131
+ },
132
+ "rh_white": {
133
+ "pattern": (
134
+ "derivatives/freesurfer/[!f]{subject}/surf/rh.whit[e]"
135
+ )
136
+ },
137
+ "lh_pial": {
138
+ "pattern": (
139
+ "derivatives/freesurfer/[!f]{subject}/surf/lh.pia[l]"
140
+ )
141
+ },
142
+ "rh_pial": {
143
+ "pattern": (
144
+ "derivatives/freesurfer/[!f]{subject}/surf/rh.pia[l]"
145
+ )
146
+ },
147
+ },
115
148
  }
116
149
  # Use native T1w assets
117
150
  self.native_t1w = False
@@ -26,8 +26,8 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber):
26
26
  The directory where the datalad dataset will be cloned. If None,
27
27
  the datalad dataset will be cloned into a temporary directory
28
28
  (default None).
29
- types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI"} or \
30
- list of the options, optional
29
+ types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI", \
30
+ "FreeSurfer"} or list of the options, optional
31
31
  AOMIC data types. If None, all available data types are selected.
32
32
  (default None).
33
33
  tasks : {"restingstate", "anticipation", "emomatching", "faces", \
@@ -147,6 +147,39 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber):
147
147
  "{subject}_desc-preproc_dwi.nii.gz"
148
148
  ),
149
149
  },
150
+ "FreeSurfer": {
151
+ "pattern": "derivatives/freesurfer/[!f]{subject}/mri/T1.mg[z]",
152
+ "aseg": {
153
+ "pattern": (
154
+ "derivatives/freesurfer/[!f]{subject}/mri/aseg.mg[z]"
155
+ )
156
+ },
157
+ "norm": {
158
+ "pattern": (
159
+ "derivatives/freesurfer/[!f]{subject}/mri/norm.mg[z]"
160
+ )
161
+ },
162
+ "lh_white": {
163
+ "pattern": (
164
+ "derivatives/freesurfer/[!f]{subject}/surf/lh.whit[e]"
165
+ )
166
+ },
167
+ "rh_white": {
168
+ "pattern": (
169
+ "derivatives/freesurfer/[!f]{subject}/surf/rh.whit[e]"
170
+ )
171
+ },
172
+ "lh_pial": {
173
+ "pattern": (
174
+ "derivatives/freesurfer/[!f]{subject}/surf/lh.pia[l]"
175
+ )
176
+ },
177
+ "rh_pial": {
178
+ "pattern": (
179
+ "derivatives/freesurfer/[!f]{subject}/surf/rh.pia[l]"
180
+ )
181
+ },
182
+ },
150
183
  }
151
184
  # Use native T1w assets
152
185
  self.native_t1w = False
@@ -26,8 +26,8 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
26
26
  The directory where the datalad dataset will be cloned. If None,
27
27
  the datalad dataset will be cloned into a temporary directory
28
28
  (default None).
29
- types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI"} or \
30
- list of the options, optional
29
+ types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI", \
30
+ "FreeSurfer"} or list of the options, optional
31
31
  AOMIC data types. If None, all available data types are selected.
32
32
  (default None).
33
33
  tasks : {"restingstate", "stopsignal", "workingmemory"} or \
@@ -144,6 +144,39 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
144
144
  "{subject}_desc-preproc_dwi.nii.gz"
145
145
  ),
146
146
  },
147
+ "FreeSurfer": {
148
+ "pattern": "derivatives/freesurfer/[!f]{subject}/mri/T1.mg[z]",
149
+ "aseg": {
150
+ "pattern": (
151
+ "derivatives/freesurfer/[!f]{subject}/mri/aseg.mg[z]"
152
+ )
153
+ },
154
+ "norm": {
155
+ "pattern": (
156
+ "derivatives/freesurfer/[!f]{subject}/mri/norm.mg[z]"
157
+ )
158
+ },
159
+ "lh_white": {
160
+ "pattern": (
161
+ "derivatives/freesurfer/[!f]{subject}/surf/lh.whit[e]"
162
+ )
163
+ },
164
+ "rh_white": {
165
+ "pattern": (
166
+ "derivatives/freesurfer/[!f]{subject}/surf/rh.whit[e]"
167
+ )
168
+ },
169
+ "lh_pial": {
170
+ "pattern": (
171
+ "derivatives/freesurfer/[!f]{subject}/surf/lh.pia[l]"
172
+ )
173
+ },
174
+ "rh_pial": {
175
+ "pattern": (
176
+ "derivatives/freesurfer/[!f]{subject}/surf/rh.pia[l]"
177
+ )
178
+ },
179
+ },
147
180
  }
148
181
  # Use native T1w assets
149
182
  self.native_t1w = False
@@ -7,7 +7,7 @@
7
7
  # Synchon Mandal <s.mandal@fz-juelich.de>
8
8
  # License: AGPL
9
9
 
10
- from typing import List, Union
10
+ from typing import List, Optional, Union
11
11
 
12
12
  import pytest
13
13
 
@@ -17,112 +17,58 @@ from junifer.datagrabber.aomic.id1000 import DataladAOMICID1000
17
17
  URI = "https://gin.g-node.org/juaml/datalad-example-aomic1000"
18
18
 
19
19
 
20
- def test_DataladAOMICID1000() -> None:
21
- """Test DataladAOMICID1000 DataGrabber."""
22
- dg = DataladAOMICID1000()
20
+ @pytest.mark.parametrize(
21
+ "type_, nested_types",
22
+ [
23
+ ("BOLD", ["confounds", "mask"]),
24
+ ("T1w", ["mask"]),
25
+ ("VBM_CSF", None),
26
+ ("VBM_GM", None),
27
+ ("VBM_WM", None),
28
+ ("DWI", None),
29
+ ("FreeSurfer", None),
30
+ ],
31
+ )
32
+ def test_DataladAOMICID1000(
33
+ type_: str,
34
+ nested_types: Optional[List[str]],
35
+ ) -> None:
36
+ """Test DataladAOMICID1000 DataGrabber.
37
+
38
+ Parameters
39
+ ----------
40
+ type_ : str
41
+ The parametrized type.
42
+ nested_types : list of str or None
43
+ The parametrized nested types.
44
+
45
+ """
46
+ dg = DataladAOMICID1000(types=type_)
23
47
  # Set URI to Gin
24
48
  dg.uri = URI
25
49
 
26
50
  with dg:
51
+ # Get all elements
27
52
  all_elements = dg.get_elements()
53
+ # Get test element
28
54
  test_element = all_elements[0]
29
-
55
+ # Get test element data
30
56
  out = dg[test_element]
31
-
32
- # asserts type "BOLD"
33
- assert "BOLD" in out
34
-
35
- assert (
36
- out["BOLD"]["path"].name == f"{test_element}_task-moviewatching_"
37
- "space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz"
38
- )
39
-
40
- assert out["BOLD"]["path"].exists()
41
- assert out["BOLD"]["path"].is_file()
42
-
43
- # asserts type BOLD.confounds
44
- assert "confounds" in out["BOLD"]
45
-
46
- assert (
47
- out["BOLD"]["confounds"]["path"].name
48
- == f"{test_element}_task-moviewatching_"
49
- "desc-confounds_regressors.tsv"
50
- )
51
-
52
- assert out["BOLD"]["confounds"]["path"].exists()
53
- assert out["BOLD"]["confounds"]["path"].is_file()
54
-
55
- # assert BOLD.mask
56
- assert out["BOLD"]["mask"]["path"].exists()
57
-
58
- # asserts type "T1w"
59
- assert "T1w" in out
60
-
61
- assert (
62
- out["T1w"]["path"].name
63
- == f"{test_element}_space-MNI152NLin2009cAsym_"
64
- "desc-preproc_T1w.nii.gz"
65
- )
66
-
67
- assert out["T1w"]["path"].exists()
68
- assert out["T1w"]["path"].is_file()
69
-
70
- # asserts T1w.mask
71
- assert out["T1w"]["mask"]["path"].exists()
72
-
73
- # asserts type "VBM_CSF"
74
- assert "VBM_CSF" in out
75
-
76
- assert (
77
- out["VBM_CSF"]["path"].name
78
- == f"{test_element}_space-MNI152NLin2009cAsym_label-"
79
- "CSF_probseg.nii.gz"
80
- )
81
-
82
- assert out["VBM_CSF"]["path"].exists()
83
- assert out["VBM_CSF"]["path"].is_file()
84
-
85
- # asserts type "VBM_GM"
86
- assert "VBM_GM" in out
87
-
88
- assert (
89
- out["VBM_GM"]["path"].name
90
- == f"{test_element}_space-MNI152NLin2009cAsym_label-"
91
- "GM_probseg.nii.gz"
92
- )
93
-
94
- assert out["VBM_GM"]["path"].exists()
95
- assert out["VBM_GM"]["path"].is_file()
96
-
97
- # asserts type "VBM_WM"
98
- assert "VBM_WM" in out
99
-
100
- assert (
101
- out["VBM_WM"]["path"].name
102
- == f"{test_element}_space-MNI152NLin2009cAsym_label-"
103
- "WM_probseg.nii.gz"
104
- )
105
-
106
- assert out["VBM_WM"]["path"].exists()
107
- assert out["VBM_WM"]["path"].is_file()
108
-
109
- # asserts type "DWI"
110
- assert "DWI" in out
111
-
112
- assert (
113
- out["DWI"]["path"].name
114
- == f"{test_element}_desc-preproc_dwi.nii.gz"
115
- )
116
-
117
- assert out["DWI"]["path"].exists()
118
- assert out["DWI"]["path"].is_file()
119
-
120
- # asserts meta
121
- assert "meta" in out["BOLD"]
122
- meta = out["BOLD"]["meta"]
57
+ # Assert data type
58
+ assert type_ in out
59
+ assert out[type_]["path"].exists()
60
+ assert out[type_]["path"].is_file()
61
+ # Asserts data type metadata
62
+ assert "meta" in out[type_]
63
+ meta = out[type_]["meta"]
123
64
  assert "element" in meta
124
65
  assert "subject" in meta["element"]
125
66
  assert test_element == meta["element"]["subject"]
67
+ # Assert nested data type if not None
68
+ if nested_types is not None:
69
+ for nested_type in nested_types:
70
+ assert out[type_][nested_type]["path"].exists()
71
+ assert out[type_][nested_type]["path"].is_file()
126
72
 
127
73
 
128
74
  @pytest.mark.parametrize(
@@ -18,129 +18,87 @@ 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 "confounds" in out["BOLD"]
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(