junifer 0.0.4.dev733__py3-none-any.whl → 0.0.4.dev782__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/api/tests/data/partly_cloudy_agg_mean_tian.yml +16 -0
- junifer/api/tests/test_cli.py +7 -13
- junifer/api/tests/test_functions.py +156 -102
- junifer/data/coordinates.py +1 -1
- junifer/data/masks.py +213 -54
- junifer/data/parcellations.py +91 -42
- junifer/data/template_spaces.py +33 -6
- junifer/data/tests/test_masks.py +127 -62
- junifer/data/tests/test_parcellations.py +66 -49
- junifer/data/tests/test_template_spaces.py +42 -7
- junifer/datagrabber/aomic/id1000.py +3 -0
- junifer/datagrabber/aomic/piop1.py +3 -0
- junifer/datagrabber/aomic/piop2.py +3 -0
- junifer/datagrabber/dmcc13_benchmark.py +3 -0
- junifer/datagrabber/hcp1200/hcp1200.py +3 -0
- junifer/markers/falff/tests/test_falff_parcels.py +3 -3
- junifer/markers/falff/tests/test_falff_spheres.py +3 -3
- junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py +46 -45
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +34 -41
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +40 -56
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +62 -74
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +99 -89
- junifer/markers/reho/tests/test_reho_parcels.py +17 -11
- junifer/markers/temporal_snr/tests/test_temporal_snr_parcels.py +38 -37
- junifer/markers/temporal_snr/tests/test_temporal_snr_spheres.py +34 -38
- junifer/markers/tests/test_collection.py +38 -37
- junifer/markers/tests/test_ets_rss.py +29 -41
- junifer/markers/tests/test_parcel_aggregation.py +600 -511
- junifer/markers/tests/test_sphere_aggregation.py +209 -163
- {junifer-0.0.4.dev733.dist-info → junifer-0.0.4.dev782.dist-info}/METADATA +1 -1
- {junifer-0.0.4.dev733.dist-info → junifer-0.0.4.dev782.dist-info}/RECORD +37 -36
- {junifer-0.0.4.dev733.dist-info → junifer-0.0.4.dev782.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.4.dev733.dist-info → junifer-0.0.4.dev782.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.4.dev733.dist-info → junifer-0.0.4.dev782.dist-info}/WHEEL +0 -0
- {junifer-0.0.4.dev733.dist-info → junifer-0.0.4.dev782.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.4.dev733.dist-info → junifer-0.0.4.dev782.dist-info}/top_level.txt +0 -0
@@ -3,21 +3,24 @@
|
|
3
3
|
# Authors: Amir Omidvarnia <a.omidvarnia@fz-juelich.de>
|
4
4
|
# Kaustubh R. Patil <k.patil@fz-juelich.de>
|
5
5
|
# Federico Raimondo <f.raimondo@fz-juelich.de>
|
6
|
+
# Synchon Mandal <s.mandal@fz-juelich.de>
|
6
7
|
# License: AGPL
|
7
8
|
|
8
9
|
from pathlib import Path
|
9
10
|
|
10
11
|
import pytest
|
11
|
-
from nilearn import datasets, image
|
12
12
|
from nilearn.connectome import ConnectivityMeasure
|
13
|
+
from nilearn.maskers import NiftiSpheresMasker
|
13
14
|
from numpy.testing import assert_array_almost_equal
|
14
15
|
from sklearn.covariance import EmpiricalCovariance
|
15
16
|
|
17
|
+
from junifer.data import get_coordinates
|
18
|
+
from junifer.datareader import DefaultDataReader
|
16
19
|
from junifer.markers.functional_connectivity import (
|
17
20
|
FunctionalConnectivitySpheres,
|
18
21
|
)
|
19
|
-
from junifer.markers.sphere_aggregation import SphereAggregation
|
20
22
|
from junifer.storage import SQLiteFeatureStorage
|
23
|
+
from junifer.testing.datagrabbers import SPMAuditoryTestingDataGrabber
|
21
24
|
|
22
25
|
|
23
26
|
def test_FunctionalConnectivitySpheres(tmp_path: Path) -> None:
|
@@ -29,56 +32,57 @@ def test_FunctionalConnectivitySpheres(tmp_path: Path) -> None:
|
|
29
32
|
The path to the test directory.
|
30
33
|
|
31
34
|
"""
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
35
|
+
with SPMAuditoryTestingDataGrabber() as dg:
|
36
|
+
element_data = DefaultDataReader().fit_transform(dg["sub001"])
|
37
|
+
marker = FunctionalConnectivitySpheres(
|
38
|
+
coords="DMNBuckner", radius=5.0, cor_method="correlation"
|
39
|
+
)
|
40
|
+
# Check correct output
|
41
|
+
assert marker.get_output_type("BOLD") == "matrix"
|
42
|
+
|
43
|
+
# Fit-transform the data
|
44
|
+
fc = marker.fit_transform(element_data)
|
45
|
+
fc_bold = fc["BOLD"]
|
46
|
+
|
47
|
+
assert "data" in fc_bold
|
48
|
+
assert "row_names" in fc_bold
|
49
|
+
assert "col_names" in fc_bold
|
50
|
+
assert fc_bold["data"].shape == (6, 6)
|
51
|
+
assert len(set(fc_bold["row_names"])) == 6
|
52
|
+
assert len(set(fc_bold["col_names"])) == 6
|
53
|
+
|
54
|
+
# Compare with nilearn
|
55
|
+
# Load testing coordinates for the target data
|
56
|
+
testing_coords, _ = get_coordinates(
|
57
|
+
coords="DMNBuckner", target_data=element_data["BOLD"]
|
58
|
+
)
|
59
|
+
# Extract timeseries
|
60
|
+
nifti_spheres_masker = NiftiSpheresMasker(
|
61
|
+
seeds=testing_coords, radius=5.0
|
62
|
+
)
|
63
|
+
extracted_timeseries = nifti_spheres_masker.fit_transform(
|
64
|
+
element_data["BOLD"]["data"]
|
65
|
+
)
|
66
|
+
# Compute the connectivity measure
|
67
|
+
connectivity_measure = ConnectivityMeasure(
|
68
|
+
kind="correlation"
|
69
|
+
).fit_transform([extracted_timeseries])[0]
|
70
|
+
|
71
|
+
# Check that FC are almost equal
|
72
|
+
assert_array_almost_equal(
|
73
|
+
connectivity_measure, fc_bold["data"], decimal=3
|
74
|
+
)
|
75
|
+
|
76
|
+
# Store
|
77
|
+
storage = SQLiteFeatureStorage(
|
78
|
+
uri=tmp_path / "test_fc_spheres.sqlite", upsert="ignore"
|
79
|
+
)
|
80
|
+
marker.fit_transform(input=element_data, storage=storage)
|
81
|
+
features = storage.list_features()
|
82
|
+
assert any(
|
83
|
+
x["name"] == "BOLD_FunctionalConnectivitySpheres"
|
84
|
+
for x in features.values()
|
85
|
+
)
|
82
86
|
|
83
87
|
|
84
88
|
def test_FunctionalConnectivitySpheres_empirical(tmp_path: Path) -> None:
|
@@ -90,43 +94,49 @@ def test_FunctionalConnectivitySpheres_empirical(tmp_path: Path) -> None:
|
|
90
94
|
The path to the test directory.
|
91
95
|
|
92
96
|
"""
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
97
|
+
with SPMAuditoryTestingDataGrabber() as dg:
|
98
|
+
element_data = DefaultDataReader().fit_transform(dg["sub001"])
|
99
|
+
marker = FunctionalConnectivitySpheres(
|
100
|
+
coords="DMNBuckner",
|
101
|
+
radius=5.0,
|
102
|
+
cor_method="correlation",
|
103
|
+
cor_method_params={"empirical": True},
|
104
|
+
)
|
105
|
+
# Check correct output
|
106
|
+
assert marker.get_output_type("BOLD") == "matrix"
|
107
|
+
|
108
|
+
# Fit-transform the data
|
109
|
+
fc = marker.fit_transform(element_data)
|
110
|
+
fc_bold = fc["BOLD"]
|
111
|
+
|
112
|
+
assert "data" in fc_bold
|
113
|
+
assert "row_names" in fc_bold
|
114
|
+
assert "col_names" in fc_bold
|
115
|
+
assert fc_bold["data"].shape == (6, 6)
|
116
|
+
assert len(set(fc_bold["row_names"])) == 6
|
117
|
+
assert len(set(fc_bold["col_names"])) == 6
|
118
|
+
|
119
|
+
# Compare with nilearn
|
120
|
+
# Load testing coordinates for the target data
|
121
|
+
testing_coords, _ = get_coordinates(
|
122
|
+
coords="DMNBuckner", target_data=element_data["BOLD"]
|
123
|
+
)
|
124
|
+
# Extract timeseries
|
125
|
+
nifti_spheres_masker = NiftiSpheresMasker(
|
126
|
+
seeds=testing_coords, radius=5.0
|
127
|
+
)
|
128
|
+
extracted_timeseries = nifti_spheres_masker.fit_transform(
|
129
|
+
element_data["BOLD"]["data"]
|
130
|
+
)
|
131
|
+
# Compute the connectivity measure
|
132
|
+
connectivity_measure = ConnectivityMeasure(
|
133
|
+
cov_estimator=EmpiricalCovariance(), kind="correlation" # type: ignore
|
134
|
+
).fit_transform([extracted_timeseries])[0]
|
135
|
+
|
136
|
+
# Check that FC are almost equal
|
137
|
+
assert_array_almost_equal(
|
138
|
+
connectivity_measure, fc_bold["data"], decimal=3
|
139
|
+
)
|
130
140
|
|
131
141
|
|
132
142
|
def test_FunctionalConnectivitySpheres_error() -> None:
|
@@ -12,12 +12,12 @@ import scipy as sp
|
|
12
12
|
from junifer.datareader import DefaultDataReader
|
13
13
|
from junifer.markers import ReHoParcels
|
14
14
|
from junifer.pipeline import WorkDirManager
|
15
|
-
from junifer.pipeline.utils import _check_afni
|
15
|
+
from junifer.pipeline.utils import _check_afni, _check_ants
|
16
16
|
from junifer.storage import SQLiteFeatureStorage
|
17
|
-
from junifer.testing.datagrabbers import
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
from junifer.testing.datagrabbers import (
|
18
|
+
PartlyCloudyTestingDataGrabber,
|
19
|
+
SPMAuditoryTestingDataGrabber,
|
20
|
+
)
|
21
21
|
|
22
22
|
|
23
23
|
def test_ReHoParcels(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None:
|
@@ -32,13 +32,16 @@ def test_ReHoParcels(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None:
|
|
32
32
|
|
33
33
|
"""
|
34
34
|
with caplog.at_level(logging.DEBUG):
|
35
|
-
with
|
36
|
-
element_data = DefaultDataReader().fit_transform(dg["
|
35
|
+
with PartlyCloudyTestingDataGrabber() as dg:
|
36
|
+
element_data = DefaultDataReader().fit_transform(dg["sub-01"])
|
37
37
|
# Update workdir to current test's tmp_path
|
38
38
|
WorkDirManager().workdir = tmp_path
|
39
39
|
|
40
40
|
# Initialize marker
|
41
|
-
marker = ReHoParcels(
|
41
|
+
marker = ReHoParcels(
|
42
|
+
parcellation="TianxS1x3TxMNInonlinear2009cAsym",
|
43
|
+
using="junifer",
|
44
|
+
)
|
42
45
|
# Fit transform marker on data
|
43
46
|
output = marker.fit_transform(element_data)
|
44
47
|
|
@@ -72,6 +75,9 @@ def test_ReHoParcels(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None:
|
|
72
75
|
assert "Creating cache" not in caplog.text
|
73
76
|
|
74
77
|
|
78
|
+
@pytest.mark.skipif(
|
79
|
+
_check_ants() is False, reason="requires ANTs to be in PATH"
|
80
|
+
)
|
75
81
|
@pytest.mark.skipif(
|
76
82
|
_check_afni() is False, reason="requires AFNI to be in PATH"
|
77
83
|
)
|
@@ -91,7 +97,7 @@ def test_ReHoParcels_comparison(tmp_path: Path) -> None:
|
|
91
97
|
|
92
98
|
# Initialize marker
|
93
99
|
junifer_marker = ReHoParcels(
|
94
|
-
parcellation=
|
100
|
+
parcellation="Schaefer100x7", using="junifer"
|
95
101
|
)
|
96
102
|
# Fit transform marker on data
|
97
103
|
junifer_output = junifer_marker.fit_transform(element_data)
|
@@ -99,7 +105,7 @@ def test_ReHoParcels_comparison(tmp_path: Path) -> None:
|
|
99
105
|
junifer_output_bold = junifer_output["BOLD"]
|
100
106
|
|
101
107
|
# Initialize marker
|
102
|
-
afni_marker = ReHoParcels(parcellation=
|
108
|
+
afni_marker = ReHoParcels(parcellation="Schaefer100x7", using="afni")
|
103
109
|
# Fit transform marker on data
|
104
110
|
afni_output = afni_marker.fit_transform(element_data)
|
105
111
|
# Get BOLD output
|
@@ -110,4 +116,4 @@ def test_ReHoParcels_comparison(tmp_path: Path) -> None:
|
|
110
116
|
junifer_output_bold["data"].flatten(),
|
111
117
|
afni_output_bold["data"].flatten(),
|
112
118
|
)
|
113
|
-
assert r >= 0.
|
119
|
+
assert r >= 0.2 # this is very bad, but they differ...
|
@@ -1,18 +1,39 @@
|
|
1
1
|
"""Provide tests for temporal signal-to-noise ratio using parcellation."""
|
2
2
|
|
3
3
|
# Authors: Leonard Sasse <l.sasse@fz-juelich.de>
|
4
|
+
# Synchon Mandal <s.mandal@fz-juelich.de>
|
4
5
|
# License: AGPL
|
5
6
|
|
6
7
|
from pathlib import Path
|
7
8
|
|
8
|
-
from
|
9
|
-
|
9
|
+
from junifer.datareader import DefaultDataReader
|
10
10
|
from junifer.markers.temporal_snr import TemporalSNRParcels
|
11
|
-
from junifer.storage import
|
11
|
+
from junifer.storage import HDF5FeatureStorage
|
12
|
+
from junifer.testing.datagrabbers import PartlyCloudyTestingDataGrabber
|
13
|
+
|
14
|
+
|
15
|
+
def test_TemporalSNRParcels_computation() -> None:
|
16
|
+
"""Test TemporalSNRParcels fit-transform."""
|
17
|
+
with PartlyCloudyTestingDataGrabber() as dg:
|
18
|
+
element_data = DefaultDataReader().fit_transform(dg["sub-01"])
|
19
|
+
marker = TemporalSNRParcels(
|
20
|
+
parcellation="TianxS1x3TxMNInonlinear2009cAsym"
|
21
|
+
)
|
22
|
+
# Check correct output
|
23
|
+
assert marker.get_output_type("BOLD") == "vector"
|
24
|
+
|
25
|
+
# Fit-transform the data
|
26
|
+
tsnr_parcels = marker.fit_transform(element_data)
|
27
|
+
tsnr_parcels_bold = tsnr_parcels["BOLD"]
|
28
|
+
|
29
|
+
assert "data" in tsnr_parcels_bold
|
30
|
+
assert "col_names" in tsnr_parcels_bold
|
31
|
+
assert tsnr_parcels_bold["data"].shape == (1, 16)
|
32
|
+
assert len(set(tsnr_parcels_bold["col_names"])) == 16
|
12
33
|
|
13
34
|
|
14
|
-
def
|
15
|
-
"""Test TemporalSNRParcels.
|
35
|
+
def test_TemporalSNRParcels_storage(tmp_path: Path) -> None:
|
36
|
+
"""Test TemporalSNRParcels store.
|
16
37
|
|
17
38
|
Parameters
|
18
39
|
----------
|
@@ -20,35 +41,15 @@ def test_TemporalSNRParcels(tmp_path: Path) -> None:
|
|
20
41
|
The path to the test directory.
|
21
42
|
|
22
43
|
"""
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
assert "col_names" in out
|
36
|
-
|
37
|
-
assert out["data"].shape[0] == 1
|
38
|
-
assert out["data"].shape[1] == 100
|
39
|
-
assert len(set(out["col_names"])) == 100
|
40
|
-
|
41
|
-
# check correct output
|
42
|
-
assert tsnr_parcels.get_output_type("BOLD") == "vector"
|
43
|
-
|
44
|
-
uri = tmp_path / "test_tsnr_parcellation.sqlite"
|
45
|
-
# Single storage, must be the uri
|
46
|
-
storage = SQLiteFeatureStorage(uri=uri, upsert="ignore")
|
47
|
-
meta = {"element": {"subject": "test"}, "dependencies": {"numpy"}}
|
48
|
-
input = {"BOLD": {"data": fmri_img, "meta": meta, "space": "MNI"}}
|
49
|
-
all_out = tsnr_parcels.fit_transform(input, storage=storage)
|
50
|
-
|
51
|
-
features = storage.list_features()
|
52
|
-
assert any(
|
53
|
-
x["name"] == "BOLD_TemporalSNRParcels" for x in features.values()
|
54
|
-
)
|
44
|
+
with PartlyCloudyTestingDataGrabber() as dg:
|
45
|
+
element_data = DefaultDataReader().fit_transform(dg["sub-01"])
|
46
|
+
marker = TemporalSNRParcels(
|
47
|
+
parcellation="TianxS1x3TxMNInonlinear2009cAsym"
|
48
|
+
)
|
49
|
+
# Store
|
50
|
+
storage = HDF5FeatureStorage(tmp_path / "test_tsnr_parcels.hdf5")
|
51
|
+
marker.fit_transform(input=element_data, storage=storage)
|
52
|
+
features = storage.list_features()
|
53
|
+
assert any(
|
54
|
+
x["name"] == "BOLD_TemporalSNRParcels" for x in features.values()
|
55
|
+
)
|
@@ -1,19 +1,39 @@
|
|
1
1
|
"""Provide tests for temporal signal-to-noise spheres."""
|
2
2
|
|
3
3
|
# Authors: Leonard Sasse <l.sasse@fz-juelich.de>
|
4
|
+
# Synchon Mandal <s.mandal@fz-juelich.de>
|
4
5
|
# License: AGPL
|
5
6
|
|
6
7
|
from pathlib import Path
|
7
8
|
|
8
9
|
import pytest
|
9
|
-
from nilearn import datasets, image
|
10
10
|
|
11
|
+
from junifer.datareader import DefaultDataReader
|
11
12
|
from junifer.markers.temporal_snr import TemporalSNRSpheres
|
12
|
-
from junifer.storage import
|
13
|
+
from junifer.storage import HDF5FeatureStorage
|
14
|
+
from junifer.testing.datagrabbers import SPMAuditoryTestingDataGrabber
|
13
15
|
|
14
16
|
|
15
|
-
def
|
16
|
-
"""Test TemporalSNRSpheres.
|
17
|
+
def test_TemporalSNRSpheres_computation() -> None:
|
18
|
+
"""Test TemporalSNRSpheres fit-transform."""
|
19
|
+
with SPMAuditoryTestingDataGrabber() as dg:
|
20
|
+
element_data = DefaultDataReader().fit_transform(dg["sub001"])
|
21
|
+
marker = TemporalSNRSpheres(coords="DMNBuckner", radius=5.0)
|
22
|
+
# Check correct output
|
23
|
+
assert marker.get_output_type("BOLD") == "vector"
|
24
|
+
|
25
|
+
# Fit-transform the data
|
26
|
+
tsnr_spheres = marker.fit_transform(element_data)
|
27
|
+
tsnr_spheres_bold = tsnr_spheres["BOLD"]
|
28
|
+
|
29
|
+
assert "data" in tsnr_spheres_bold
|
30
|
+
assert "col_names" in tsnr_spheres_bold
|
31
|
+
assert tsnr_spheres_bold["data"].shape == (1, 6)
|
32
|
+
assert len(set(tsnr_spheres_bold["col_names"])) == 6
|
33
|
+
|
34
|
+
|
35
|
+
def test_TemporalSNRSpheres_storage(tmp_path: Path) -> None:
|
36
|
+
"""Test TemporalSNRSpheres store.
|
17
37
|
|
18
38
|
Parameters
|
19
39
|
----------
|
@@ -21,40 +41,16 @@ def test_TemporalSNRSpheres(tmp_path: Path) -> None:
|
|
21
41
|
The path to the test directory.
|
22
42
|
|
23
43
|
"""
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
assert "data" in out
|
36
|
-
assert "col_names" in out
|
37
|
-
assert out["data"].shape[0] == 1
|
38
|
-
assert out["data"].shape[1] == 6
|
39
|
-
assert len(set(out["col_names"])) == 6
|
40
|
-
|
41
|
-
# check correct output
|
42
|
-
assert tsnr_spheres.get_output_type("BOLD") == "vector"
|
43
|
-
|
44
|
-
uri = tmp_path / "test_tsnr_coords.sqlite"
|
45
|
-
# Single storage, must be the uri
|
46
|
-
storage = SQLiteFeatureStorage(uri=uri, upsert="ignore")
|
47
|
-
meta = {
|
48
|
-
"element": {"subject": "test"},
|
49
|
-
"dependencies": {"numpy", "nilearn"},
|
50
|
-
}
|
51
|
-
input = {"BOLD": {"data": fmri_img, "meta": meta, "space": "MNI"}}
|
52
|
-
all_out = tsnr_spheres.fit_transform(input, storage=storage)
|
53
|
-
|
54
|
-
features = storage.list_features()
|
55
|
-
assert any(
|
56
|
-
x["name"] == "BOLD_TemporalSNRSpheres" for x in features.values()
|
57
|
-
)
|
44
|
+
with SPMAuditoryTestingDataGrabber() as dg:
|
45
|
+
element_data = DefaultDataReader().fit_transform(dg["sub001"])
|
46
|
+
marker = TemporalSNRSpheres(coords="DMNBuckner", radius=5.0)
|
47
|
+
# Store
|
48
|
+
storage = HDF5FeatureStorage(tmp_path / "test_tsnr_spheres.hdf5")
|
49
|
+
marker.fit_transform(input=element_data, storage=storage)
|
50
|
+
features = storage.list_features()
|
51
|
+
assert any(
|
52
|
+
x["name"] == "BOLD_TemporalSNRSpheres" for x in features.values()
|
53
|
+
)
|
58
54
|
|
59
55
|
|
60
56
|
def test_TemporalSNRSpheres_error() -> None:
|
@@ -19,7 +19,6 @@ from junifer.pipeline import PipelineStepMixin
|
|
19
19
|
from junifer.preprocess import fMRIPrepConfoundRemover
|
20
20
|
from junifer.storage import SQLiteFeatureStorage
|
21
21
|
from junifer.testing.datagrabbers import (
|
22
|
-
OasisVBMTestingDataGrabber,
|
23
22
|
PartlyCloudyTestingDataGrabber,
|
24
23
|
)
|
25
24
|
|
@@ -46,20 +45,20 @@ def test_marker_collection() -> None:
|
|
46
45
|
"""Test MarkerCollection."""
|
47
46
|
markers = [
|
48
47
|
ParcelAggregation(
|
49
|
-
parcellation="
|
48
|
+
parcellation="TianxS2x3TxMNInonlinear2009cAsym",
|
50
49
|
method="mean",
|
51
|
-
name="
|
50
|
+
name="tian_mean",
|
52
51
|
),
|
53
52
|
ParcelAggregation(
|
54
|
-
parcellation="
|
53
|
+
parcellation="TianxS2x3TxMNInonlinear2009cAsym",
|
55
54
|
method="std",
|
56
|
-
name="
|
55
|
+
name="tian_std",
|
57
56
|
),
|
58
57
|
ParcelAggregation(
|
59
|
-
parcellation="
|
58
|
+
parcellation="TianxS2x3TxMNInonlinear2009cAsym",
|
60
59
|
method="trim_mean",
|
61
60
|
method_params={"proportiontocut": 0.1},
|
62
|
-
name="
|
61
|
+
name="tian_trim_mean90",
|
63
62
|
),
|
64
63
|
]
|
65
64
|
mc = MarkerCollection(markers=markers) # type: ignore
|
@@ -69,7 +68,7 @@ def test_marker_collection() -> None:
|
|
69
68
|
assert isinstance(mc._datareader, DefaultDataReader)
|
70
69
|
|
71
70
|
# Create testing datagrabber
|
72
|
-
dg =
|
71
|
+
dg = PartlyCloudyTestingDataGrabber()
|
73
72
|
mc.validate(dg)
|
74
73
|
|
75
74
|
with dg:
|
@@ -78,17 +77,17 @@ def test_marker_collection() -> None:
|
|
78
77
|
assert out is not None
|
79
78
|
assert isinstance(out, dict)
|
80
79
|
assert len(out) == 3
|
81
|
-
assert "
|
82
|
-
assert "
|
83
|
-
assert "
|
80
|
+
assert "tian_mean" in out
|
81
|
+
assert "tian_std" in out
|
82
|
+
assert "tian_trim_mean90" in out
|
84
83
|
|
85
84
|
for t_marker in markers:
|
86
85
|
t_name = t_marker.name
|
87
|
-
assert "
|
88
|
-
|
89
|
-
assert "data" in
|
90
|
-
assert "col_names" in
|
91
|
-
assert "meta" in
|
86
|
+
assert "BOLD" in out[t_name]
|
87
|
+
t_bold = out[t_name]["BOLD"]
|
88
|
+
assert "data" in t_bold
|
89
|
+
assert "col_names" in t_bold
|
90
|
+
assert "meta" in t_bold
|
92
91
|
|
93
92
|
# Test preprocessing
|
94
93
|
class BypassPreprocessing(PipelineStepMixin):
|
@@ -108,7 +107,7 @@ def test_marker_collection() -> None:
|
|
108
107
|
for t_marker in markers:
|
109
108
|
t_name = t_marker.name
|
110
109
|
assert_array_equal(
|
111
|
-
out[t_name]["
|
110
|
+
out[t_name]["BOLD"]["data"], out2[t_name]["BOLD"]["data"]
|
112
111
|
)
|
113
112
|
|
114
113
|
|
@@ -151,27 +150,28 @@ def test_marker_collection_storage(tmp_path: Path) -> None:
|
|
151
150
|
"""
|
152
151
|
markers = [
|
153
152
|
ParcelAggregation(
|
154
|
-
parcellation="
|
153
|
+
parcellation="TianxS2x3TxMNInonlinear2009cAsym",
|
155
154
|
method="mean",
|
156
|
-
name="
|
155
|
+
name="tian_mean",
|
157
156
|
),
|
158
157
|
ParcelAggregation(
|
159
|
-
parcellation="
|
158
|
+
parcellation="TianxS2x3TxMNInonlinear2009cAsym",
|
160
159
|
method="std",
|
161
|
-
name="
|
160
|
+
name="tian_std",
|
162
161
|
),
|
163
162
|
ParcelAggregation(
|
164
|
-
parcellation="
|
163
|
+
parcellation="TianxS2x3TxMNInonlinear2009cAsym",
|
165
164
|
method="trim_mean",
|
166
165
|
method_params={"proportiontocut": 0.1},
|
167
|
-
name="
|
166
|
+
name="tian_trim_mean90",
|
168
167
|
),
|
169
168
|
]
|
170
|
-
#
|
171
|
-
dg =
|
172
|
-
|
173
|
-
|
174
|
-
|
169
|
+
# Setup datagrabber
|
170
|
+
dg = PartlyCloudyTestingDataGrabber()
|
171
|
+
# Setup storage
|
172
|
+
storage = SQLiteFeatureStorage(
|
173
|
+
tmp_path / "test_marker_collection_storage.sqlite"
|
174
|
+
)
|
175
175
|
mc = MarkerCollection(
|
176
176
|
markers=markers, # type: ignore
|
177
177
|
storage=storage,
|
@@ -197,23 +197,24 @@ def test_marker_collection_storage(tmp_path: Path) -> None:
|
|
197
197
|
|
198
198
|
features = storage.list_features()
|
199
199
|
assert len(features) == 3
|
200
|
+
|
200
201
|
feature_md5 = next(iter(features.keys()))
|
201
202
|
t_feature = storage.read_df(feature_md5=feature_md5)
|
202
|
-
fname = "
|
203
|
-
t_data = out[fname]["
|
204
|
-
cols = out[fname]["
|
203
|
+
fname = "tian_mean"
|
204
|
+
t_data = out[fname]["BOLD"]["data"] # type: ignore
|
205
|
+
cols = out[fname]["BOLD"]["col_names"] # type: ignore
|
205
206
|
assert_array_equal(t_feature[cols].values, t_data) # type: ignore
|
206
207
|
|
207
208
|
feature_md5 = list(features.keys())[1]
|
208
209
|
t_feature = storage.read_df(feature_md5=feature_md5)
|
209
|
-
fname = "
|
210
|
-
t_data = out[fname]["
|
211
|
-
cols = out[fname]["
|
210
|
+
fname = "tian_std"
|
211
|
+
t_data = out[fname]["BOLD"]["data"] # type: ignore
|
212
|
+
cols = out[fname]["BOLD"]["col_names"] # type: ignore
|
212
213
|
assert_array_equal(t_feature[cols].values, t_data) # type: ignore
|
213
214
|
|
214
215
|
feature_md5 = list(features.keys())[2]
|
215
216
|
t_feature = storage.read_df(feature_md5=feature_md5)
|
216
|
-
fname = "
|
217
|
-
t_data = out[fname]["
|
218
|
-
cols = out[fname]["
|
217
|
+
fname = "tian_trim_mean90"
|
218
|
+
t_data = out[fname]["BOLD"]["data"] # type: ignore
|
219
|
+
cols = out[fname]["BOLD"]["col_names"] # type: ignore
|
219
220
|
assert_array_equal(t_feature[cols].values, t_data) # type: ignore
|