junifer 0.0.5.dev180__py3-none-any.whl → 0.0.5.dev202__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 (60) hide show
  1. junifer/_version.py +2 -2
  2. junifer/data/masks/ukb/UKB_15K_GM_template.nii.gz +0 -0
  3. junifer/data/masks.py +36 -0
  4. junifer/data/tests/test_masks.py +17 -0
  5. junifer/datagrabber/tests/test_datalad_base.py +4 -4
  6. junifer/datagrabber/tests/test_pattern_datalad.py +4 -4
  7. junifer/markers/base.py +49 -23
  8. junifer/markers/brainprint.py +56 -265
  9. junifer/markers/complexity/complexity_base.py +23 -43
  10. junifer/markers/complexity/tests/test_hurst_exponent.py +4 -3
  11. junifer/markers/complexity/tests/test_multiscale_entropy_auc.py +4 -3
  12. junifer/markers/complexity/tests/test_perm_entropy.py +4 -3
  13. junifer/markers/complexity/tests/test_range_entropy.py +4 -3
  14. junifer/markers/complexity/tests/test_range_entropy_auc.py +4 -3
  15. junifer/markers/complexity/tests/test_sample_entropy.py +4 -3
  16. junifer/markers/complexity/tests/test_weighted_perm_entropy.py +4 -3
  17. junifer/markers/ets_rss.py +24 -42
  18. junifer/markers/falff/falff_base.py +17 -46
  19. junifer/markers/falff/falff_parcels.py +53 -27
  20. junifer/markers/falff/falff_spheres.py +57 -29
  21. junifer/markers/falff/tests/test_falff_parcels.py +39 -23
  22. junifer/markers/falff/tests/test_falff_spheres.py +39 -23
  23. junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +32 -48
  24. junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +16 -10
  25. junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +13 -9
  26. junifer/markers/functional_connectivity/functional_connectivity_base.py +26 -40
  27. junifer/markers/functional_connectivity/functional_connectivity_parcels.py +6 -6
  28. junifer/markers/functional_connectivity/functional_connectivity_spheres.py +6 -6
  29. junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py +8 -4
  30. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +6 -3
  31. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +6 -3
  32. junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +6 -3
  33. junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +10 -5
  34. junifer/markers/parcel_aggregation.py +40 -59
  35. junifer/markers/reho/reho_base.py +6 -27
  36. junifer/markers/reho/reho_parcels.py +23 -15
  37. junifer/markers/reho/reho_spheres.py +22 -16
  38. junifer/markers/reho/tests/test_reho_parcels.py +8 -3
  39. junifer/markers/reho/tests/test_reho_spheres.py +8 -3
  40. junifer/markers/sphere_aggregation.py +40 -59
  41. junifer/markers/temporal_snr/temporal_snr_base.py +20 -32
  42. junifer/markers/temporal_snr/temporal_snr_parcels.py +6 -6
  43. junifer/markers/temporal_snr/temporal_snr_spheres.py +6 -6
  44. junifer/markers/temporal_snr/tests/test_temporal_snr_parcels.py +6 -3
  45. junifer/markers/temporal_snr/tests/test_temporal_snr_spheres.py +6 -3
  46. junifer/markers/tests/test_brainprint.py +23 -12
  47. junifer/markers/tests/test_collection.py +9 -8
  48. junifer/markers/tests/test_ets_rss.py +15 -9
  49. junifer/markers/tests/test_markers_base.py +17 -18
  50. junifer/markers/tests/test_parcel_aggregation.py +93 -32
  51. junifer/markers/tests/test_sphere_aggregation.py +72 -19
  52. junifer/pipeline/pipeline_step_mixin.py +11 -1
  53. junifer/pipeline/tests/test_registry.py +1 -1
  54. {junifer-0.0.5.dev180.dist-info → junifer-0.0.5.dev202.dist-info}/METADATA +1 -1
  55. {junifer-0.0.5.dev180.dist-info → junifer-0.0.5.dev202.dist-info}/RECORD +60 -59
  56. {junifer-0.0.5.dev180.dist-info → junifer-0.0.5.dev202.dist-info}/WHEEL +1 -1
  57. {junifer-0.0.5.dev180.dist-info → junifer-0.0.5.dev202.dist-info}/AUTHORS.rst +0 -0
  58. {junifer-0.0.5.dev180.dist-info → junifer-0.0.5.dev202.dist-info}/LICENSE.md +0 -0
  59. {junifer-0.0.5.dev180.dist-info → junifer-0.0.5.dev202.dist-info}/entry_points.txt +0 -0
  60. {junifer-0.0.5.dev180.dist-info → junifer-0.0.5.dev202.dist-info}/top_level.txt +0 -0
@@ -35,11 +35,13 @@ def test_FunctionalConnectivityParcels(tmp_path: Path) -> None:
35
35
  parcellation="TianxS1x3TxMNInonlinear2009cAsym"
36
36
  )
37
37
  # Check correct output
38
- assert marker.get_output_type("BOLD") == "matrix"
38
+ assert "matrix" == marker.get_output_type(
39
+ input_type="BOLD", output_feature="functional_connectivity"
40
+ )
39
41
 
40
42
  # Fit-transform the data
41
43
  fc = marker.fit_transform(element_data)
42
- fc_bold = fc["BOLD"]
44
+ fc_bold = fc["BOLD"]["functional_connectivity"]
43
45
 
44
46
  assert "data" in fc_bold
45
47
  assert "row_names" in fc_bold
@@ -83,6 +85,7 @@ def test_FunctionalConnectivityParcels(tmp_path: Path) -> None:
83
85
  marker.fit_transform(input=element_data, storage=storage)
84
86
  features = storage.list_features()
85
87
  assert any(
86
- x["name"] == "BOLD_FunctionalConnectivityParcels"
88
+ x["name"]
89
+ == "BOLD_FunctionalConnectivityParcels_functional_connectivity"
87
90
  for x in features.values()
88
91
  )
@@ -38,11 +38,13 @@ def test_FunctionalConnectivitySpheres(tmp_path: Path) -> None:
38
38
  coords="DMNBuckner", radius=5.0, cor_method="correlation"
39
39
  )
40
40
  # Check correct output
41
- assert marker.get_output_type("BOLD") == "matrix"
41
+ assert "matrix" == marker.get_output_type(
42
+ input_type="BOLD", output_feature="functional_connectivity"
43
+ )
42
44
 
43
45
  # Fit-transform the data
44
46
  fc = marker.fit_transform(element_data)
45
- fc_bold = fc["BOLD"]
47
+ fc_bold = fc["BOLD"]["functional_connectivity"]
46
48
 
47
49
  assert "data" in fc_bold
48
50
  assert "row_names" in fc_bold
@@ -80,7 +82,8 @@ def test_FunctionalConnectivitySpheres(tmp_path: Path) -> None:
80
82
  marker.fit_transform(input=element_data, storage=storage)
81
83
  features = storage.list_features()
82
84
  assert any(
83
- x["name"] == "BOLD_FunctionalConnectivitySpheres"
85
+ x["name"]
86
+ == "BOLD_FunctionalConnectivitySpheres_functional_connectivity"
84
87
  for x in features.values()
85
88
  )
86
89
 
@@ -103,11 +106,13 @@ def test_FunctionalConnectivitySpheres_empirical(tmp_path: Path) -> None:
103
106
  cor_method_params={"empirical": True},
104
107
  )
105
108
  # Check correct output
106
- assert marker.get_output_type("BOLD") == "matrix"
109
+ assert "matrix" == marker.get_output_type(
110
+ input_type="BOLD", output_feature="functional_connectivity"
111
+ )
107
112
 
108
113
  # Fit-transform the data
109
114
  fc = marker.fit_transform(element_data)
110
- fc_bold = fc["BOLD"]
115
+ fc_bold = fc["BOLD"]["functional_connectivity"]
111
116
 
112
117
  assert "data" in fc_bold
113
118
  assert "row_names" in fc_bold
@@ -63,6 +63,36 @@ class ParcelAggregation(BaseMarker):
63
63
 
64
64
  _DEPENDENCIES: ClassVar[Set[str]] = {"nilearn", "numpy"}
65
65
 
66
+ _MARKER_INOUT_MAPPINGS: ClassVar[Dict[str, Dict[str, str]]] = {
67
+ "T1w": {
68
+ "aggregation": "vector",
69
+ },
70
+ "T2w": {
71
+ "aggregation": "vector",
72
+ },
73
+ "BOLD": {
74
+ "aggregation": "timeseries",
75
+ },
76
+ "VBM_GM": {
77
+ "aggregation": "vector",
78
+ },
79
+ "VBM_WM": {
80
+ "aggregation": "vector",
81
+ },
82
+ "VBM_CSF": {
83
+ "aggregation": "vector",
84
+ },
85
+ "fALFF": {
86
+ "aggregation": "vector",
87
+ },
88
+ "GCOR": {
89
+ "aggregation": "vector",
90
+ },
91
+ "LCOR": {
92
+ "aggregation": "vector",
93
+ },
94
+ }
95
+
66
96
  def __init__(
67
97
  self,
68
98
  parcellation: Union[str, List[str]],
@@ -96,61 +126,6 @@ class ParcelAggregation(BaseMarker):
96
126
  self.time_method = time_method
97
127
  self.time_method_params = time_method_params or {}
98
128
 
99
- def get_valid_inputs(self) -> List[str]:
100
- """Get valid data types for input.
101
-
102
- Returns
103
- -------
104
- list of str
105
- The list of data types that can be used as input for this marker.
106
-
107
- """
108
- return [
109
- "T1w",
110
- "T2w",
111
- "BOLD",
112
- "VBM_GM",
113
- "VBM_WM",
114
- "VBM_CSF",
115
- "fALFF",
116
- "GCOR",
117
- "LCOR",
118
- ]
119
-
120
- def get_output_type(self, input_type: str) -> str:
121
- """Get output type.
122
-
123
- Parameters
124
- ----------
125
- input_type : str
126
- The data type input to the marker.
127
-
128
- Returns
129
- -------
130
- str
131
- The storage type output by the marker.
132
-
133
- Raises
134
- ------
135
- ValueError
136
- If the ``input_type`` is invalid.
137
-
138
- """
139
-
140
- if input_type in [
141
- "VBM_GM",
142
- "VBM_WM",
143
- "VBM_CSF",
144
- "fALFF",
145
- "GCOR",
146
- "LCOR",
147
- ]:
148
- return "vector"
149
- elif input_type == "BOLD":
150
- return "timeseries"
151
- else:
152
- raise_error(f"Unknown input kind for {input_type}")
153
-
154
129
  def compute(
155
130
  self, input: Dict[str, Any], extra_input: Optional[Dict] = None
156
131
  ) -> Dict:
@@ -174,8 +149,10 @@ class ParcelAggregation(BaseMarker):
174
149
  to the user or stored in the storage by calling the store method
175
150
  with this as a parameter. The dictionary has the following keys:
176
151
 
177
- * ``data`` : the actual computed values as a numpy.ndarray
178
- * ``col_names`` : the column labels for the computed values as list
152
+ * ``aggregation`` : dictionary with the following keys:
153
+
154
+ - ``data`` : ROI values as ``numpy.ndarray``
155
+ - ``col_names`` : ROI labels as list of str
179
156
 
180
157
  Warns
181
158
  -----
@@ -253,5 +230,9 @@ class ParcelAggregation(BaseMarker):
253
230
  "available."
254
231
  )
255
232
  # Format the output
256
- out = {"data": out_values, "col_names": labels}
257
- return out
233
+ return {
234
+ "aggregation": {
235
+ "data": out_values,
236
+ "col_names": labels,
237
+ },
238
+ }
@@ -62,6 +62,12 @@ class ReHoBase(BaseMarker):
62
62
  },
63
63
  ]
64
64
 
65
+ _MARKER_INOUT_MAPPINGS: ClassVar[Dict[str, Dict[str, str]]] = {
66
+ "BOLD": {
67
+ "reho": "vector",
68
+ },
69
+ }
70
+
65
71
  def __init__(
66
72
  self,
67
73
  using: str,
@@ -76,33 +82,6 @@ class ReHoBase(BaseMarker):
76
82
  self.using = using
77
83
  super().__init__(on="BOLD", name=name)
78
84
 
79
- def get_valid_inputs(self) -> List[str]:
80
- """Get valid data types for input.
81
-
82
- Returns
83
- -------
84
- list of str
85
- The list of data types that can be used as input for this marker.
86
-
87
- """
88
- return ["BOLD"]
89
-
90
- def get_output_type(self, input_type: str) -> str:
91
- """Get output type.
92
-
93
- Parameters
94
- ----------
95
- input_type : str
96
- The data type input to the marker.
97
-
98
- Returns
99
- -------
100
- str
101
- The storage type output by the marker.
102
-
103
- """
104
- return "vector"
105
-
106
85
  def _compute(
107
86
  self,
108
87
  input_data: Dict[str, Any],
@@ -125,11 +125,14 @@ class ReHoParcels(ReHoBase):
125
125
  Returns
126
126
  -------
127
127
  dict
128
- The computed result as dictionary. The dictionary has the following
129
- keys:
128
+ The computed result as dictionary. This will be either returned
129
+ to the user or stored in the storage by calling the store method
130
+ with this as a parameter. The dictionary has the following keys:
130
131
 
131
- * ``data`` : the actual computed values as a 1D numpy.ndarray
132
- * ``col_names`` : the column labels for the parcels as a list
132
+ * ``reho`` : dictionary with the following keys:
133
+
134
+ - ``data`` : ROI values as ``numpy.ndarray``
135
+ - ``col_names`` : ROI labels as list of str
133
136
 
134
137
  """
135
138
  logger.info("Calculating ReHo for parcels")
@@ -145,22 +148,27 @@ class ReHoParcels(ReHoBase):
145
148
  else:
146
149
  reho_map, reho_file_path = self._compute(input_data=input)
147
150
 
148
- # Initialize parcel aggregation
151
+ # Perform aggregation on reho map
152
+ aggregation_input = dict(input.items())
153
+ aggregation_input["data"] = reho_map
154
+ aggregation_input["path"] = reho_file_path
149
155
  parcel_aggregation = ParcelAggregation(
150
156
  parcellation=self.parcellation,
151
157
  method=self.agg_method,
152
158
  method_params=self.agg_method_params,
153
159
  masks=self.masks,
154
160
  on="BOLD",
155
- )
156
- # Perform aggregation on reho map
157
- parcel_aggregation_input = dict(input.items())
158
- parcel_aggregation_input["data"] = reho_map
159
- parcel_aggregation_input["path"] = reho_file_path
160
- output = parcel_aggregation.compute(
161
- input=parcel_aggregation_input,
161
+ ).compute(
162
+ input=aggregation_input,
162
163
  extra_input=extra_input,
163
164
  )
164
- # Only use the first row and expand row dimension
165
- output["data"] = output["data"][0][np.newaxis, :]
166
- return output
165
+
166
+ return {
167
+ "reho": {
168
+ # Only use the first row and expand row dimension
169
+ "data": parcel_aggregation["aggregation"]["data"][0][
170
+ np.newaxis, :
171
+ ],
172
+ "col_names": parcel_aggregation["aggregation"]["col_names"],
173
+ }
174
+ }
@@ -140,11 +140,14 @@ class ReHoSpheres(ReHoBase):
140
140
  Returns
141
141
  -------
142
142
  dict
143
- The computed result as dictionary. The dictionary has the following
144
- keys:
143
+ The computed result as dictionary. This will be either returned
144
+ to the user or stored in the storage by calling the store method
145
+ with this as a parameter. The dictionary has the following keys:
145
146
 
146
- * ``data`` : the actual computed values as a 1D numpy.ndarray
147
- * ``col_names`` : the column labels for the spheres as a list
147
+ * ``reho`` : dictionary with the following keys:
148
+
149
+ - ``data`` : ROI values as ``numpy.ndarray``
150
+ - ``col_names`` : ROI labels as list of str
148
151
 
149
152
  """
150
153
  logger.info("Calculating ReHo for spheres")
@@ -160,7 +163,10 @@ class ReHoSpheres(ReHoBase):
160
163
  else:
161
164
  reho_map, reho_file_path = self._compute(input_data=input)
162
165
 
163
- # Initialize sphere aggregation
166
+ # Perform aggregation on reho map
167
+ aggregation_input = dict(input.items())
168
+ aggregation_input["data"] = reho_map
169
+ aggregation_input["path"] = reho_file_path
164
170
  sphere_aggregation = SphereAggregation(
165
171
  coords=self.coords,
166
172
  radius=self.radius,
@@ -169,14 +175,14 @@ class ReHoSpheres(ReHoBase):
169
175
  method_params=self.agg_method_params,
170
176
  masks=self.masks,
171
177
  on="BOLD",
172
- )
173
- # Perform aggregation on reho map
174
- sphere_aggregation_input = dict(input.items())
175
- sphere_aggregation_input["data"] = reho_map
176
- sphere_aggregation_input["path"] = reho_file_path
177
- output = sphere_aggregation.compute(
178
- input=sphere_aggregation_input, extra_input=extra_input
179
- )
180
- # Only use the first row and expand row dimension
181
- output["data"] = output["data"][0][np.newaxis, :]
182
- return output
178
+ ).compute(input=aggregation_input, extra_input=extra_input)
179
+
180
+ return {
181
+ "reho": {
182
+ # Only use the first row and expand row dimension
183
+ "data": sphere_aggregation["aggregation"]["data"][0][
184
+ np.newaxis, :
185
+ ],
186
+ "col_names": sphere_aggregation["aggregation"]["col_names"],
187
+ }
188
+ }
@@ -42,6 +42,11 @@ def test_ReHoParcels(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None:
42
42
  parcellation="TianxS1x3TxMNInonlinear2009cAsym",
43
43
  using="junifer",
44
44
  )
45
+ # Check correct output
46
+ assert "vector" == marker.get_output_type(
47
+ input_type="BOLD", output_feature="reho"
48
+ )
49
+
45
50
  # Fit transform marker on data
46
51
  output = marker.fit_transform(element_data)
47
52
 
@@ -49,7 +54,7 @@ def test_ReHoParcels(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None:
49
54
 
50
55
  # Get BOLD output
51
56
  assert "BOLD" in output
52
- output_bold = output["BOLD"]
57
+ output_bold = output["BOLD"]["reho"]
53
58
  # Assert BOLD output keys
54
59
  assert "data" in output_bold
55
60
  assert "col_names" in output_bold
@@ -102,14 +107,14 @@ def test_ReHoParcels_comparison(tmp_path: Path) -> None:
102
107
  # Fit transform marker on data
103
108
  junifer_output = junifer_marker.fit_transform(element_data)
104
109
  # Get BOLD output
105
- junifer_output_bold = junifer_output["BOLD"]
110
+ junifer_output_bold = junifer_output["BOLD"]["reho"]
106
111
 
107
112
  # Initialize marker
108
113
  afni_marker = ReHoParcels(parcellation="Schaefer100x7", using="afni")
109
114
  # Fit transform marker on data
110
115
  afni_output = afni_marker.fit_transform(element_data)
111
116
  # Get BOLD output
112
- afni_output_bold = afni_output["BOLD"]
117
+ afni_output_bold = afni_output["BOLD"]["reho"]
113
118
 
114
119
  # Check for Pearson correlation coefficient
115
120
  r, _ = sp.stats.pearsonr(
@@ -40,6 +40,11 @@ def test_ReHoSpheres(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None:
40
40
  marker = ReHoSpheres(
41
41
  coords=COORDINATES, using="junifer", radius=10.0
42
42
  )
43
+ # Check correct output
44
+ assert "vector" == marker.get_output_type(
45
+ input_type="BOLD", output_feature="reho"
46
+ )
47
+
43
48
  # Fit transform marker on data
44
49
  output = marker.fit_transform(element_data)
45
50
 
@@ -47,7 +52,7 @@ def test_ReHoSpheres(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None:
47
52
 
48
53
  # Get BOLD output
49
54
  assert "BOLD" in output
50
- output_bold = output["BOLD"]
55
+ output_bold = output["BOLD"]["reho"]
51
56
  # Assert BOLD output keys
52
57
  assert "data" in output_bold
53
58
  assert "col_names" in output_bold
@@ -99,7 +104,7 @@ def test_ReHoSpheres_comparison(tmp_path: Path) -> None:
99
104
  # Fit transform marker on data
100
105
  junifer_output = junifer_marker.fit_transform(element_data)
101
106
  # Get BOLD output
102
- junifer_output_bold = junifer_output["BOLD"]
107
+ junifer_output_bold = junifer_output["BOLD"]["reho"]
103
108
 
104
109
  # Initialize marker
105
110
  afni_marker = ReHoSpheres(
@@ -110,7 +115,7 @@ def test_ReHoSpheres_comparison(tmp_path: Path) -> None:
110
115
  # Fit transform marker on data
111
116
  afni_output = afni_marker.fit_transform(element_data)
112
117
  # Get BOLD output
113
- afni_output_bold = afni_output["BOLD"]
118
+ afni_output_bold = afni_output["BOLD"]["reho"]
114
119
 
115
120
  # Check for Pearson correlation coefficient
116
121
  r, _ = sp.stats.pearsonr(
@@ -68,6 +68,36 @@ class SphereAggregation(BaseMarker):
68
68
 
69
69
  _DEPENDENCIES: ClassVar[Set[str]] = {"nilearn", "numpy"}
70
70
 
71
+ _MARKER_INOUT_MAPPINGS: ClassVar[Dict[str, Dict[str, str]]] = {
72
+ "T1w": {
73
+ "aggregation": "vector",
74
+ },
75
+ "T2w": {
76
+ "aggregation": "vector",
77
+ },
78
+ "BOLD": {
79
+ "aggregation": "timeseries",
80
+ },
81
+ "VBM_GM": {
82
+ "aggregation": "vector",
83
+ },
84
+ "VBM_WM": {
85
+ "aggregation": "vector",
86
+ },
87
+ "VBM_CSF": {
88
+ "aggregation": "vector",
89
+ },
90
+ "fALFF": {
91
+ "aggregation": "vector",
92
+ },
93
+ "GCOR": {
94
+ "aggregation": "vector",
95
+ },
96
+ "LCOR": {
97
+ "aggregation": "vector",
98
+ },
99
+ }
100
+
71
101
  def __init__(
72
102
  self,
73
103
  coords: str,
@@ -103,61 +133,6 @@ class SphereAggregation(BaseMarker):
103
133
  self.time_method = time_method
104
134
  self.time_method_params = time_method_params or {}
105
135
 
106
- def get_valid_inputs(self) -> List[str]:
107
- """Get valid data types for input.
108
-
109
- Returns
110
- -------
111
- list of str
112
- The list of data types that can be used as input for this marker.
113
-
114
- """
115
- return [
116
- "T1w",
117
- "T2w",
118
- "BOLD",
119
- "VBM_GM",
120
- "VBM_WM",
121
- "VBM_CSF",
122
- "fALFF",
123
- "GCOR",
124
- "LCOR",
125
- ]
126
-
127
- def get_output_type(self, input_type: str) -> str:
128
- """Get output type.
129
-
130
- Parameters
131
- ----------
132
- input_type : str
133
- The data type input to the marker.
134
-
135
- Returns
136
- -------
137
- str
138
- The storage type output by the marker.
139
-
140
- Raises
141
- ------
142
- ValueError
143
- If the ``input_type`` is invalid.
144
-
145
- """
146
-
147
- if input_type in [
148
- "VBM_GM",
149
- "VBM_WM",
150
- "VBM_CSF",
151
- "fALFF",
152
- "GCOR",
153
- "LCOR",
154
- ]:
155
- return "vector"
156
- elif input_type == "BOLD":
157
- return "timeseries"
158
- else:
159
- raise_error(f"Unknown input kind for {input_type}")
160
-
161
136
  def compute(
162
137
  self,
163
138
  input: Dict[str, Any],
@@ -183,8 +158,10 @@ class SphereAggregation(BaseMarker):
183
158
  to the user or stored in the storage by calling the store method
184
159
  with this as a parameter. The dictionary has the following keys:
185
160
 
186
- * ``data`` : the actual computed values as a numpy.ndarray
187
- * ``col_names`` : the column labels for the computed values as list
161
+ * ``aggregation`` : dictionary with the following keys:
162
+
163
+ - ``data`` : ROI values as ``numpy.ndarray``
164
+ - ``col_names`` : ROI labels as list of str
188
165
 
189
166
  Warns
190
167
  -----
@@ -241,5 +218,9 @@ class SphereAggregation(BaseMarker):
241
218
  "available."
242
219
  )
243
220
  # Format the output
244
- out = {"data": out_values, "col_names": labels}
245
- return out
221
+ return {
222
+ "aggregation": {
223
+ "data": out_values,
224
+ "col_names": labels,
225
+ },
226
+ }
@@ -39,6 +39,12 @@ class TemporalSNRBase(BaseMarker):
39
39
 
40
40
  _DEPENDENCIES: ClassVar[Set[str]] = {"nilearn"}
41
41
 
42
+ _MARKER_INOUT_MAPPINGS: ClassVar[Dict[str, Dict[str, str]]] = {
43
+ "BOLD": {
44
+ "tsnr": "vector",
45
+ },
46
+ }
47
+
42
48
  def __init__(
43
49
  self,
44
50
  agg_method: str = "mean",
@@ -61,33 +67,6 @@ class TemporalSNRBase(BaseMarker):
61
67
  klass=NotImplementedError,
62
68
  )
63
69
 
64
- def get_valid_inputs(self) -> List[str]:
65
- """Get valid data types for input.
66
-
67
- Returns
68
- -------
69
- list of str
70
- The list of data types that can be used as input for this marker.
71
-
72
- """
73
- return ["BOLD"]
74
-
75
- def get_output_type(self, input_type: str) -> str:
76
- """Get output type.
77
-
78
- Parameters
79
- ----------
80
- input_type : str
81
- The data type input to the marker.
82
-
83
- Returns
84
- -------
85
- str
86
- The storage type output by the marker.
87
-
88
- """
89
- return "vector"
90
-
91
70
  def compute(
92
71
  self,
93
72
  input: Dict[str, Any],
@@ -107,11 +86,14 @@ class TemporalSNRBase(BaseMarker):
107
86
  Returns
108
87
  -------
109
88
  dict
110
- The computed result as dictionary. The following keys will be
111
- included in the dictionary:
89
+ The computed result as dictionary. This will be either returned
90
+ to the user or stored in the storage by calling the store method
91
+ with this as a parameter. The dictionary has the following keys:
92
+
93
+ * ``tsnr`` : dictionary with the following keys:
112
94
 
113
- * ``data`` : the computed values as a ``numpy.ndarray``
114
- * ``col_names`` : the column labels for the computed values as list
95
+ - ``data`` : computed tSNR as ``numpy.ndarray``
96
+ - ``col_names`` : ROI labels as list of str
115
97
 
116
98
  """
117
99
  # Calculate voxelwise temporal signal-to-noise ratio in an image
@@ -129,4 +111,10 @@ class TemporalSNRBase(BaseMarker):
129
111
  mask_img=mask_img,
130
112
  )
131
113
  # Perform necessary aggregation and return
132
- return self.aggregate(input=input, extra_input=extra_input)
114
+ return {
115
+ "tsnr": {
116
+ **self.aggregate(input=input, extra_input=extra_input)[
117
+ "aggregation"
118
+ ]
119
+ }
120
+ }
@@ -77,16 +77,16 @@ class TemporalSNRParcels(TemporalSNRBase):
77
77
  to the user or stored in the storage by calling the store method
78
78
  with this as a parameter. The dictionary has the following keys:
79
79
 
80
- * ``data`` : ROI-wise temporal SNR as a ``numpy.ndarray``
81
- * ``col_names`` : the ROI labels for the computed values as list
80
+ * ``aggregation`` : dictionary with the following keys:
81
+
82
+ - ``data`` : ROI-wise tSNR values as ``numpy.ndarray``
83
+ - ``col_names`` : ROI labels as list of str
82
84
 
83
85
  """
84
- parcel_aggregation = ParcelAggregation(
86
+ return ParcelAggregation(
85
87
  parcellation=self.parcellation,
86
88
  method=self.agg_method,
87
89
  method_params=self.agg_method_params,
88
90
  masks=self.masks,
89
91
  on="BOLD",
90
- )
91
- # Return the 2D timeseries after parcel aggregation
92
- return parcel_aggregation.compute(input=input, extra_input=extra_input)
92
+ ).compute(input=input, extra_input=extra_input)
@@ -92,11 +92,13 @@ class TemporalSNRSpheres(TemporalSNRBase):
92
92
  to the user or stored in the storage by calling the store method
93
93
  with this as a parameter. The dictionary has the following keys:
94
94
 
95
- * ``data`` : VOI-wise temporal SNR as a ``numpy.ndarray``
96
- * ``col_names`` : the VOI labels for the computed values as list
95
+ * ``aggregation`` : dictionary with the following keys:
96
+
97
+ - ``data`` : ROI-wise tSNR values as ``numpy.ndarray``
98
+ - ``col_names`` : ROI labels as list of str
97
99
 
98
100
  """
99
- sphere_aggregation = SphereAggregation(
101
+ return SphereAggregation(
100
102
  coords=self.coords,
101
103
  radius=self.radius,
102
104
  allow_overlap=self.allow_overlap,
@@ -104,6 +106,4 @@ class TemporalSNRSpheres(TemporalSNRBase):
104
106
  method_params=self.agg_method_params,
105
107
  masks=self.masks,
106
108
  on="BOLD",
107
- )
108
- # Return the 2D timeseries after sphere aggregation
109
- return sphere_aggregation.compute(input=input, extra_input=extra_input)
109
+ ).compute(input=input, extra_input=extra_input)