junifer 0.0.4.dev733__py3-none-any.whl → 0.0.4.dev781__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.dev781.dist-info}/METADATA +1 -1
- {junifer-0.0.4.dev733.dist-info → junifer-0.0.4.dev781.dist-info}/RECORD +37 -36
- {junifer-0.0.4.dev733.dist-info → junifer-0.0.4.dev781.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.4.dev733.dist-info → junifer-0.0.4.dev781.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.4.dev733.dist-info → junifer-0.0.4.dev781.dist-info}/WHEEL +0 -0
- {junifer-0.0.4.dev733.dist-info → junifer-0.0.4.dev781.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.4.dev733.dist-info → junifer-0.0.4.dev781.dist-info}/top_level.txt +0 -0
@@ -18,7 +18,7 @@ from junifer.storage import SQLiteFeatureStorage
|
|
18
18
|
from junifer.testing.datagrabbers import PartlyCloudyTestingDataGrabber
|
19
19
|
|
20
20
|
|
21
|
-
PARCELLATION = "
|
21
|
+
PARCELLATION = "TianxS1x3TxMNInonlinear2009cAsym"
|
22
22
|
|
23
23
|
|
24
24
|
def test_ALFFParcels(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None:
|
@@ -59,7 +59,7 @@ def test_ALFFParcels(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None:
|
|
59
59
|
output_bold_data = output_bold["data"]
|
60
60
|
# Assert BOLD output data dimension
|
61
61
|
assert output_bold_data.ndim == 2
|
62
|
-
assert output_bold_data.shape == (1,
|
62
|
+
assert output_bold_data.shape == (1, 16)
|
63
63
|
|
64
64
|
# Reset log capture
|
65
65
|
caplog.clear()
|
@@ -123,4 +123,4 @@ def test_ALFFParcels_comparison(tmp_path: Path, fractional: bool) -> None:
|
|
123
123
|
junifer_output_bold["data"][0],
|
124
124
|
afni_output_bold["data"][0],
|
125
125
|
)
|
126
|
-
assert r > 0.
|
126
|
+
assert r > 0.97
|
@@ -82,14 +82,14 @@ def test_ALFFSpheres(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None:
|
|
82
82
|
"fractional", [True, False], ids=["fractional", "non-fractional"]
|
83
83
|
)
|
84
84
|
def test_ALFFSpheres_comparison(tmp_path: Path, fractional: bool) -> None:
|
85
|
-
"""Test ALFFSpheres
|
85
|
+
"""Test ALFFSpheres implementation comparison.
|
86
86
|
|
87
87
|
Parameters
|
88
88
|
----------
|
89
89
|
tmp_path : pathlib.Path
|
90
|
-
|
90
|
+
The path to the test directory.
|
91
91
|
fractional : bool
|
92
|
-
|
92
|
+
Whether to compute fractional ALFF or not.
|
93
93
|
|
94
94
|
"""
|
95
95
|
with PartlyCloudyTestingDataGrabber() as dg:
|
junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py
CHANGED
@@ -2,14 +2,17 @@
|
|
2
2
|
|
3
3
|
# Authors: Leonard Sasse <l.sasse@fz-juelich.de>
|
4
4
|
# Kaustubh R. Patil <k.patil@fz-juelich.de>
|
5
|
+
# Synchon Mandal <s.mandal@fz-juelich.de>
|
5
6
|
# License: AGPL
|
6
7
|
|
7
8
|
from pathlib import Path
|
8
9
|
|
9
10
|
import pytest
|
10
|
-
from nilearn import image
|
11
11
|
|
12
|
+
from junifer.datareader import DefaultDataReader
|
12
13
|
from junifer.markers.functional_connectivity import CrossParcellationFC
|
14
|
+
from junifer.pipeline import WorkDirManager
|
15
|
+
from junifer.pipeline.utils import _check_ants
|
13
16
|
from junifer.storage import SQLiteFeatureStorage
|
14
17
|
from junifer.testing.datagrabbers import SPMAuditoryTestingDataGrabber
|
15
18
|
|
@@ -18,32 +21,53 @@ parcellation_one = "Schaefer100x17"
|
|
18
21
|
parcellation_two = "Schaefer200x17"
|
19
22
|
|
20
23
|
|
21
|
-
def
|
22
|
-
"""Test CrossParcellationFC
|
24
|
+
def test_init() -> None:
|
25
|
+
"""Test CrossParcellationFC init()."""
|
26
|
+
with pytest.raises(ValueError, match="must be different"):
|
27
|
+
CrossParcellationFC(
|
28
|
+
parcellation_one="a",
|
29
|
+
parcellation_two="a",
|
30
|
+
correlation_method="pearson",
|
31
|
+
)
|
23
32
|
|
24
|
-
with SPMAuditoryTestingDataGrabber() as dg:
|
25
|
-
out = dg["sub001"]
|
26
|
-
niimg = image.load_img(str(out["BOLD"]["path"].absolute()))
|
27
|
-
input_dict = {
|
28
|
-
"BOLD": {
|
29
|
-
"data": niimg,
|
30
|
-
"path": out["BOLD"]["path"],
|
31
|
-
"meta": {"element": "sub001"},
|
32
|
-
"space": "MNI",
|
33
|
-
}
|
34
|
-
}
|
35
33
|
|
34
|
+
def test_get_output_type() -> None:
|
35
|
+
"""Test CrossParcellationFC get_output_type()."""
|
36
|
+
crossparcellation = CrossParcellationFC(
|
37
|
+
parcellation_one=parcellation_one, parcellation_two=parcellation_two
|
38
|
+
)
|
39
|
+
assert "matrix" == crossparcellation.get_output_type("BOLD")
|
40
|
+
|
41
|
+
|
42
|
+
@pytest.mark.skipif(
|
43
|
+
_check_ants() is False, reason="requires ANTs to be in PATH"
|
44
|
+
)
|
45
|
+
def test_compute(tmp_path: Path) -> None:
|
46
|
+
"""Test CrossParcellationFC compute().
|
47
|
+
|
48
|
+
Parameters
|
49
|
+
----------
|
50
|
+
tmp_path : pathlib.Path
|
51
|
+
The path to the test directory.
|
52
|
+
|
53
|
+
"""
|
54
|
+
with SPMAuditoryTestingDataGrabber() as dg:
|
55
|
+
element_data = DefaultDataReader().fit_transform(dg["sub001"])
|
56
|
+
WorkDirManager().workdir = tmp_path
|
36
57
|
crossparcellation = CrossParcellationFC(
|
37
58
|
parcellation_one=parcellation_one,
|
38
59
|
parcellation_two=parcellation_two,
|
39
60
|
correlation_method="spearman",
|
40
61
|
)
|
41
|
-
out = crossparcellation.compute(
|
62
|
+
out = crossparcellation.compute(element_data["BOLD"])
|
42
63
|
assert out["data"].shape == (200, 100)
|
43
64
|
assert len(out["col_names"]) == 100
|
44
65
|
assert len(out["row_names"]) == 200
|
45
66
|
|
46
67
|
|
68
|
+
@pytest.mark.skipif(
|
69
|
+
_check_ants() is False, reason="requires ANTs to be in PATH"
|
70
|
+
)
|
47
71
|
def test_store(tmp_path: Path) -> None:
|
48
72
|
"""Test CrossParcellationFC store().
|
49
73
|
|
@@ -53,43 +77,20 @@ def test_store(tmp_path: Path) -> None:
|
|
53
77
|
The path to the test directory.
|
54
78
|
|
55
79
|
"""
|
56
|
-
|
57
80
|
with SPMAuditoryTestingDataGrabber() as dg:
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
input_dict["BOLD"]["data"] = niimg
|
62
|
-
|
81
|
+
element_data = DefaultDataReader().fit_transform(dg["sub001"])
|
82
|
+
WorkDirManager().workdir = tmp_path
|
63
83
|
crossparcellation = CrossParcellationFC(
|
64
84
|
parcellation_one=parcellation_one,
|
65
85
|
parcellation_two=parcellation_two,
|
66
86
|
correlation_method="spearman",
|
67
87
|
)
|
68
|
-
|
69
|
-
|
70
|
-
|
88
|
+
storage = SQLiteFeatureStorage(
|
89
|
+
uri=tmp_path / "test_crossparcellation.sqlite", upsert="ignore"
|
90
|
+
)
|
91
|
+
# Fit transform marker on data with storage
|
92
|
+
crossparcellation.fit_transform(input=element_data, storage=storage)
|
71
93
|
features = storage.list_features()
|
72
94
|
assert any(
|
73
95
|
x["name"] == "BOLD_CrossParcellationFC" for x in features.values()
|
74
96
|
)
|
75
|
-
|
76
|
-
|
77
|
-
def test_get_output_type() -> None:
|
78
|
-
"""Test CrossParcellationFC get_output_type()."""
|
79
|
-
|
80
|
-
crossparcellation = CrossParcellationFC(
|
81
|
-
parcellation_one=parcellation_one, parcellation_two=parcellation_two
|
82
|
-
)
|
83
|
-
input_ = "BOLD"
|
84
|
-
output = crossparcellation.get_output_type(input_)
|
85
|
-
assert output == "matrix"
|
86
|
-
|
87
|
-
|
88
|
-
def test_init_() -> None:
|
89
|
-
"""Test CrossParcellationFC init()."""
|
90
|
-
with pytest.raises(ValueError, match="must be different"):
|
91
|
-
CrossParcellationFC(
|
92
|
-
parcellation_one="a",
|
93
|
-
parcellation_two="a",
|
94
|
-
correlation_method="pearson",
|
95
|
-
)
|
@@ -6,10 +6,10 @@
|
|
6
6
|
|
7
7
|
from pathlib import Path
|
8
8
|
|
9
|
-
from
|
10
|
-
|
9
|
+
from junifer.datareader import DefaultDataReader
|
11
10
|
from junifer.markers.functional_connectivity import EdgeCentricFCParcels
|
12
11
|
from junifer.storage import SQLiteFeatureStorage
|
12
|
+
from junifer.testing.datagrabbers import PartlyCloudyTestingDataGrabber
|
13
13
|
|
14
14
|
|
15
15
|
def test_EdgeCentricFCParcels(tmp_path: Path) -> None:
|
@@ -21,42 +21,35 @@ def test_EdgeCentricFCParcels(tmp_path: Path) -> None:
|
|
21
21
|
The path to the test directory.
|
22
22
|
|
23
23
|
"""
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
input = {"BOLD": {"data": fmri_img, "meta": meta, "space": "MNI"}}
|
57
|
-
all_out = efc.fit_transform(input, storage=storage)
|
58
|
-
|
59
|
-
features = storage.list_features()
|
60
|
-
assert any(
|
61
|
-
x["name"] == "BOLD_EdgeCentricFCParcels" for x in features.values()
|
62
|
-
)
|
24
|
+
with PartlyCloudyTestingDataGrabber() as dg:
|
25
|
+
element_data = DefaultDataReader().fit_transform(dg["sub-01"])
|
26
|
+
marker = EdgeCentricFCParcels(
|
27
|
+
parcellation="TianxS1x3TxMNInonlinear2009cAsym",
|
28
|
+
cor_method_params={"empirical": True},
|
29
|
+
)
|
30
|
+
# Check correct output
|
31
|
+
assert marker.get_output_type("BOLD") == "matrix"
|
32
|
+
|
33
|
+
# Fit-transform the data
|
34
|
+
edge_fc = marker.fit_transform(element_data)
|
35
|
+
edge_fc_bold = edge_fc["BOLD"]
|
36
|
+
|
37
|
+
# For 16 ROIs we should get (16 * (16 -1) / 2) edges in the ETS
|
38
|
+
n_edges = int(16 * (16 - 1) / 2)
|
39
|
+
assert "data" in edge_fc_bold
|
40
|
+
assert "row_names" in edge_fc_bold
|
41
|
+
assert "col_names" in edge_fc_bold
|
42
|
+
assert edge_fc_bold["data"].shape[0] == n_edges
|
43
|
+
assert edge_fc_bold["data"].shape[1] == n_edges
|
44
|
+
assert len(set(edge_fc_bold["row_names"])) == n_edges
|
45
|
+
assert len(set(edge_fc_bold["col_names"])) == n_edges
|
46
|
+
|
47
|
+
# Store
|
48
|
+
storage = SQLiteFeatureStorage(
|
49
|
+
uri=tmp_path / "test_edge_fc_parcels.sqlite", upsert="ignore"
|
50
|
+
)
|
51
|
+
marker.fit_transform(input=element_data, storage=storage)
|
52
|
+
features = storage.list_features()
|
53
|
+
assert any(
|
54
|
+
x["name"] == "BOLD_EdgeCentricFCParcels" for x in features.values()
|
55
|
+
)
|
@@ -6,10 +6,10 @@
|
|
6
6
|
|
7
7
|
from pathlib import Path
|
8
8
|
|
9
|
-
from
|
10
|
-
|
9
|
+
from junifer.datareader import DefaultDataReader
|
11
10
|
from junifer.markers.functional_connectivity import EdgeCentricFCSpheres
|
12
11
|
from junifer.storage import SQLiteFeatureStorage
|
12
|
+
from junifer.testing.datagrabbers import SPMAuditoryTestingDataGrabber
|
13
13
|
|
14
14
|
|
15
15
|
def test_EdgeCentricFCSpheres(tmp_path: Path) -> None:
|
@@ -21,57 +21,41 @@ def test_EdgeCentricFCSpheres(tmp_path: Path) -> None:
|
|
21
21
|
The path to the test directory.
|
22
22
|
|
23
23
|
"""
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
all_out = efc.fit_transform(
|
64
|
-
{"BOLD": {"data": fmri_img, "meta": meta, "space": "MNI"}}
|
65
|
-
)
|
66
|
-
|
67
|
-
uri = tmp_path / "test_fc_parcellation.sqlite"
|
68
|
-
# Single storage, must be the uri
|
69
|
-
storage = SQLiteFeatureStorage(uri=uri, upsert="ignore")
|
70
|
-
meta = {"element": {"subject": "test"}, "dependencies": {"numpy"}}
|
71
|
-
input = {"BOLD": {"data": fmri_img, "meta": meta, "space": "MNI"}}
|
72
|
-
all_out = efc.fit_transform(input, storage=storage)
|
73
|
-
|
74
|
-
features = storage.list_features()
|
75
|
-
assert any(
|
76
|
-
x["name"] == "BOLD_EdgeCentricFCSpheres" for x in features.values()
|
77
|
-
)
|
24
|
+
with SPMAuditoryTestingDataGrabber() as dg:
|
25
|
+
element_data = DefaultDataReader().fit_transform(dg["sub001"])
|
26
|
+
marker = EdgeCentricFCSpheres(
|
27
|
+
coords="DMNBuckner", radius=5.0, cor_method="correlation"
|
28
|
+
)
|
29
|
+
# Check correct output
|
30
|
+
assert marker.get_output_type("BOLD") == "matrix"
|
31
|
+
|
32
|
+
# Fit-transform the data
|
33
|
+
edge_fc = marker.fit_transform(element_data)
|
34
|
+
edge_fc_bold = edge_fc["BOLD"]
|
35
|
+
|
36
|
+
# There are six DMNBuckner coordinates, so
|
37
|
+
# for 6 ROIs we should get (6 * (6 -1) / 2) edges in the ETS
|
38
|
+
n_edges = int(6 * (6 - 1) / 2)
|
39
|
+
assert "data" in edge_fc_bold
|
40
|
+
assert "row_names" in edge_fc_bold
|
41
|
+
assert "col_names" in edge_fc_bold
|
42
|
+
assert edge_fc_bold["data"].shape == (n_edges, n_edges)
|
43
|
+
assert len(set(edge_fc_bold["row_names"])) == n_edges
|
44
|
+
assert len(set(edge_fc_bold["col_names"])) == n_edges
|
45
|
+
|
46
|
+
# Check empirical correlation method parameters
|
47
|
+
marker = EdgeCentricFCSpheres(
|
48
|
+
coords="DMNBuckner",
|
49
|
+
radius=5.0,
|
50
|
+
cor_method="correlation",
|
51
|
+
cor_method_params={"empirical": True},
|
52
|
+
)
|
53
|
+
# Store
|
54
|
+
storage = SQLiteFeatureStorage(
|
55
|
+
uri=tmp_path / "test_edge_fc_spheres.sqlite", upsert="ignore"
|
56
|
+
)
|
57
|
+
marker.fit_transform(input=element_data, storage=storage)
|
58
|
+
features = storage.list_features()
|
59
|
+
assert any(
|
60
|
+
x["name"] == "BOLD_EdgeCentricFCSpheres" for x in features.values()
|
61
|
+
)
|
@@ -2,20 +2,22 @@
|
|
2
2
|
|
3
3
|
# Authors: Amir Omidvarnia <a.omidvarnia@fz-juelich.de>
|
4
4
|
# Kaustubh R. Patil <k.patil@fz-juelich.de>
|
5
|
+
# Synchon Mandal <s.mandal@fz-juelich.de>
|
5
6
|
# License: AGPL
|
6
7
|
|
7
8
|
from pathlib import Path
|
8
9
|
|
9
|
-
from nilearn import datasets, image
|
10
10
|
from nilearn.connectome import ConnectivityMeasure
|
11
11
|
from nilearn.maskers import NiftiLabelsMasker
|
12
|
-
from numpy.testing import assert_array_almost_equal
|
12
|
+
from numpy.testing import assert_array_almost_equal
|
13
13
|
|
14
|
+
from junifer.data import get_parcellation
|
15
|
+
from junifer.datareader import DefaultDataReader
|
14
16
|
from junifer.markers.functional_connectivity import (
|
15
17
|
FunctionalConnectivityParcels,
|
16
18
|
)
|
17
|
-
from junifer.markers.parcel_aggregation import ParcelAggregation
|
18
19
|
from junifer.storage import SQLiteFeatureStorage
|
20
|
+
from junifer.testing.datagrabbers import PartlyCloudyTestingDataGrabber
|
19
21
|
|
20
22
|
|
21
23
|
def test_FunctionalConnectivityParcels(tmp_path: Path) -> None:
|
@@ -27,74 +29,60 @@ def test_FunctionalConnectivityParcels(tmp_path: Path) -> None:
|
|
27
29
|
The path to the test directory.
|
28
30
|
|
29
31
|
"""
|
30
|
-
|
31
|
-
|
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
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
)
|
88
|
-
|
89
|
-
uri = tmp_path / "test_fc_parcellation.sqlite"
|
90
|
-
# Single storage, must be the uri
|
91
|
-
storage = SQLiteFeatureStorage(uri=uri, upsert="ignore")
|
92
|
-
meta = {"element": {"subject": "test"}, "dependencies": {"numpy"}}
|
93
|
-
input = {"BOLD": {"data": fmri_img, "meta": meta, "space": "MNI"}}
|
94
|
-
all_out = fc.fit_transform(input, storage=storage)
|
95
|
-
|
96
|
-
features = storage.list_features()
|
97
|
-
assert any(
|
98
|
-
x["name"] == "BOLD_FunctionalConnectivityParcels"
|
99
|
-
for x in features.values()
|
100
|
-
)
|
32
|
+
with PartlyCloudyTestingDataGrabber() as dg:
|
33
|
+
element_data = DefaultDataReader().fit_transform(dg["sub-01"])
|
34
|
+
marker = FunctionalConnectivityParcels(
|
35
|
+
parcellation="TianxS1x3TxMNInonlinear2009cAsym"
|
36
|
+
)
|
37
|
+
# Check correct output
|
38
|
+
assert marker.get_output_type("BOLD") == "matrix"
|
39
|
+
|
40
|
+
# Fit-transform the data
|
41
|
+
fc = marker.fit_transform(element_data)
|
42
|
+
fc_bold = fc["BOLD"]
|
43
|
+
|
44
|
+
assert "data" in fc_bold
|
45
|
+
assert "row_names" in fc_bold
|
46
|
+
assert "col_names" in fc_bold
|
47
|
+
assert fc_bold["data"].shape == (16, 16)
|
48
|
+
assert len(set(fc_bold["row_names"])) == 16
|
49
|
+
assert len(set(fc_bold["col_names"])) == 16
|
50
|
+
|
51
|
+
# Compare with nilearn
|
52
|
+
# Load testing parcellation for the target data
|
53
|
+
testing_parcellation, _ = get_parcellation(
|
54
|
+
parcellation=["TianxS1x3TxMNInonlinear2009cAsym"],
|
55
|
+
target_data=element_data["BOLD"],
|
56
|
+
)
|
57
|
+
# Extract timeseries
|
58
|
+
nifti_labels_masker = NiftiLabelsMasker(
|
59
|
+
labels_img=testing_parcellation, standardize=False
|
60
|
+
)
|
61
|
+
extracted_timeseries = nifti_labels_masker.fit_transform(
|
62
|
+
element_data["BOLD"]["data"]
|
63
|
+
)
|
64
|
+
# Compute the connectivity measure
|
65
|
+
connectivity_measure = ConnectivityMeasure(
|
66
|
+
kind="covariance"
|
67
|
+
).fit_transform([extracted_timeseries])[0]
|
68
|
+
|
69
|
+
# Check that FC are almost equal
|
70
|
+
assert_array_almost_equal(
|
71
|
+
connectivity_measure, fc_bold["data"], decimal=3
|
72
|
+
)
|
73
|
+
|
74
|
+
# Check empirical correlation method parameters
|
75
|
+
marker = FunctionalConnectivityParcels(
|
76
|
+
parcellation="TianxS1x3TxMNInonlinear2009cAsym",
|
77
|
+
cor_method_params={"empirical": True},
|
78
|
+
)
|
79
|
+
# Store
|
80
|
+
storage = SQLiteFeatureStorage(
|
81
|
+
uri=tmp_path / "test_fc_parcels.sqlite", upsert="ignore"
|
82
|
+
)
|
83
|
+
marker.fit_transform(input=element_data, storage=storage)
|
84
|
+
features = storage.list_features()
|
85
|
+
assert any(
|
86
|
+
x["name"] == "BOLD_FunctionalConnectivityParcels"
|
87
|
+
for x in features.values()
|
88
|
+
)
|