junifer 0.0.5.dev183__py3-none-any.whl → 0.0.5.dev208__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- junifer/_version.py +2 -2
- junifer/datagrabber/tests/test_datalad_base.py +4 -4
- junifer/datagrabber/tests/test_pattern_datalad.py +4 -4
- junifer/markers/base.py +49 -23
- junifer/markers/brainprint.py +56 -265
- junifer/markers/complexity/complexity_base.py +23 -43
- junifer/markers/complexity/tests/test_hurst_exponent.py +4 -3
- junifer/markers/complexity/tests/test_multiscale_entropy_auc.py +4 -3
- junifer/markers/complexity/tests/test_perm_entropy.py +4 -3
- junifer/markers/complexity/tests/test_range_entropy.py +4 -3
- junifer/markers/complexity/tests/test_range_entropy_auc.py +4 -3
- junifer/markers/complexity/tests/test_sample_entropy.py +4 -3
- junifer/markers/complexity/tests/test_weighted_perm_entropy.py +4 -3
- junifer/markers/ets_rss.py +24 -42
- junifer/markers/falff/falff_base.py +17 -46
- junifer/markers/falff/falff_parcels.py +53 -27
- junifer/markers/falff/falff_spheres.py +57 -29
- junifer/markers/falff/tests/test_falff_parcels.py +39 -23
- junifer/markers/falff/tests/test_falff_spheres.py +39 -23
- junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +36 -48
- junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +16 -10
- junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +13 -9
- junifer/markers/functional_connectivity/functional_connectivity_base.py +26 -40
- junifer/markers/functional_connectivity/functional_connectivity_parcels.py +6 -6
- junifer/markers/functional_connectivity/functional_connectivity_spheres.py +6 -6
- junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py +8 -4
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +6 -3
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +6 -3
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +6 -3
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +10 -5
- junifer/markers/parcel_aggregation.py +40 -59
- junifer/markers/reho/reho_base.py +6 -27
- junifer/markers/reho/reho_parcels.py +23 -15
- junifer/markers/reho/reho_spheres.py +22 -16
- junifer/markers/reho/tests/test_reho_parcels.py +8 -3
- junifer/markers/reho/tests/test_reho_spheres.py +8 -3
- junifer/markers/sphere_aggregation.py +40 -59
- junifer/markers/temporal_snr/temporal_snr_base.py +20 -32
- junifer/markers/temporal_snr/temporal_snr_parcels.py +6 -6
- junifer/markers/temporal_snr/temporal_snr_spheres.py +6 -6
- junifer/markers/temporal_snr/tests/test_temporal_snr_parcels.py +6 -3
- junifer/markers/temporal_snr/tests/test_temporal_snr_spheres.py +6 -3
- junifer/markers/tests/test_brainprint.py +23 -12
- junifer/markers/tests/test_collection.py +9 -8
- junifer/markers/tests/test_ets_rss.py +15 -9
- junifer/markers/tests/test_markers_base.py +17 -18
- junifer/markers/tests/test_parcel_aggregation.py +93 -32
- junifer/markers/tests/test_sphere_aggregation.py +72 -19
- junifer/pipeline/pipeline_step_mixin.py +11 -1
- junifer/pipeline/tests/test_registry.py +1 -1
- {junifer-0.0.5.dev183.dist-info → junifer-0.0.5.dev208.dist-info}/METADATA +1 -1
- {junifer-0.0.5.dev183.dist-info → junifer-0.0.5.dev208.dist-info}/RECORD +57 -57
- {junifer-0.0.5.dev183.dist-info → junifer-0.0.5.dev208.dist-info}/WHEEL +1 -1
- {junifer-0.0.5.dev183.dist-info → junifer-0.0.5.dev208.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.5.dev183.dist-info → junifer-0.0.5.dev208.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.5.dev183.dist-info → junifer-0.0.5.dev208.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.5.dev183.dist-info → junifer-0.0.5.dev208.dist-info}/top_level.txt +0 -0
@@ -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
|
-
* ``
|
178
|
-
|
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
|
-
|
257
|
-
|
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.
|
129
|
-
|
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
|
-
* ``
|
132
|
-
|
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
|
-
#
|
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
|
-
|
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
|
-
|
165
|
-
|
166
|
-
|
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.
|
144
|
-
|
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
|
-
* ``
|
147
|
-
|
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
|
-
#
|
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
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
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
|
-
* ``
|
187
|
-
|
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
|
-
|
245
|
-
|
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.
|
111
|
-
|
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
|
-
|
114
|
-
|
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
|
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
|
-
* ``
|
81
|
-
|
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
|
-
|
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
|
-
* ``
|
96
|
-
|
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
|
-
|
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)
|
@@ -20,11 +20,13 @@ def test_TemporalSNRParcels_computation() -> None:
|
|
20
20
|
parcellation="TianxS1x3TxMNInonlinear2009cAsym"
|
21
21
|
)
|
22
22
|
# Check correct output
|
23
|
-
assert
|
23
|
+
assert "vector" == marker.get_output_type(
|
24
|
+
input_type="BOLD", output_feature="tsnr"
|
25
|
+
)
|
24
26
|
|
25
27
|
# Fit-transform the data
|
26
28
|
tsnr_parcels = marker.fit_transform(element_data)
|
27
|
-
tsnr_parcels_bold = tsnr_parcels["BOLD"]
|
29
|
+
tsnr_parcels_bold = tsnr_parcels["BOLD"]["tsnr"]
|
28
30
|
|
29
31
|
assert "data" in tsnr_parcels_bold
|
30
32
|
assert "col_names" in tsnr_parcels_bold
|
@@ -51,5 +53,6 @@ def test_TemporalSNRParcels_storage(tmp_path: Path) -> None:
|
|
51
53
|
marker.fit_transform(input=element_data, storage=storage)
|
52
54
|
features = storage.list_features()
|
53
55
|
assert any(
|
54
|
-
x["name"] == "
|
56
|
+
x["name"] == "BOLD_TemporalSNRParcels_tsnr"
|
57
|
+
for x in features.values()
|
55
58
|
)
|
@@ -20,11 +20,13 @@ def test_TemporalSNRSpheres_computation() -> None:
|
|
20
20
|
element_data = DefaultDataReader().fit_transform(dg["sub001"])
|
21
21
|
marker = TemporalSNRSpheres(coords="DMNBuckner", radius=5.0)
|
22
22
|
# Check correct output
|
23
|
-
assert
|
23
|
+
assert "vector" == marker.get_output_type(
|
24
|
+
input_type="BOLD", output_feature="tsnr"
|
25
|
+
)
|
24
26
|
|
25
27
|
# Fit-transform the data
|
26
28
|
tsnr_spheres = marker.fit_transform(element_data)
|
27
|
-
tsnr_spheres_bold = tsnr_spheres["BOLD"]
|
29
|
+
tsnr_spheres_bold = tsnr_spheres["BOLD"]["tsnr"]
|
28
30
|
|
29
31
|
assert "data" in tsnr_spheres_bold
|
30
32
|
assert "col_names" in tsnr_spheres_bold
|
@@ -49,7 +51,8 @@ def test_TemporalSNRSpheres_storage(tmp_path: Path) -> None:
|
|
49
51
|
marker.fit_transform(input=element_data, storage=storage)
|
50
52
|
features = storage.list_features()
|
51
53
|
assert any(
|
52
|
-
x["name"] == "
|
54
|
+
x["name"] == "BOLD_TemporalSNRSpheres_tsnr"
|
55
|
+
for x in features.values()
|
53
56
|
)
|
54
57
|
|
55
58
|
|