junifer 0.0.5.dev208__py3-none-any.whl → 0.0.5.dev219__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/external/nilearn/__init__.py +2 -1
- junifer/external/nilearn/junifer_connectivity_measure.py +483 -0
- junifer/external/nilearn/tests/test_junifer_connectivity_measure.py +1089 -0
- junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +25 -13
- junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +26 -22
- junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +33 -27
- junifer/markers/functional_connectivity/functional_connectivity_base.py +42 -30
- junifer/markers/functional_connectivity/functional_connectivity_parcels.py +25 -19
- junifer/markers/functional_connectivity/functional_connectivity_spheres.py +31 -24
- junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py +3 -3
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +21 -4
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +22 -9
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +29 -8
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +30 -61
- {junifer-0.0.5.dev208.dist-info → junifer-0.0.5.dev219.dist-info}/METADATA +1 -1
- {junifer-0.0.5.dev208.dist-info → junifer-0.0.5.dev219.dist-info}/RECORD +22 -20
- {junifer-0.0.5.dev208.dist-info → junifer-0.0.5.dev219.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.5.dev208.dist-info → junifer-0.0.5.dev219.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.5.dev208.dist-info → junifer-0.0.5.dev219.dist-info}/WHEEL +0 -0
- {junifer-0.0.5.dev208.dist-info → junifer-0.0.5.dev219.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.5.dev208.dist-info → junifer-0.0.5.dev219.dist-info}/top_level.txt +0 -0
@@ -28,18 +28,24 @@ class CrossParcellationFC(BaseMarker):
|
|
28
28
|
The name of the first parcellation.
|
29
29
|
parcellation_two : str
|
30
30
|
The name of the second parcellation.
|
31
|
-
|
32
|
-
The
|
33
|
-
|
31
|
+
agg_method : str, optional
|
32
|
+
The method to perform aggregation using.
|
33
|
+
See :func:`.get_aggfunc_by_name` for options
|
34
|
+
(default "mean").
|
35
|
+
agg_method_params : dict, optional
|
36
|
+
Parameters to pass to the aggregation function.
|
37
|
+
See :func:`.get_aggfunc_by_name` for options
|
38
|
+
(default None).
|
39
|
+
corr_method : str, optional
|
34
40
|
Any method that can be passed to
|
35
|
-
:
|
41
|
+
:meth:`pandas.DataFrame.corr` (default "pearson").
|
36
42
|
masks : str, dict or list of dict or str, optional
|
37
43
|
The specification of the masks to apply to regions before extracting
|
38
44
|
signals. Check :ref:`Using Masks <using_masks>` for more details.
|
39
45
|
If None, will not apply any mask (default None).
|
40
46
|
name : str, optional
|
41
|
-
The name of the marker. If None, will use
|
42
|
-
(default None).
|
47
|
+
The name of the marker. If None, will use
|
48
|
+
``BOLD_CrossParcellationFC`` (default None).
|
43
49
|
|
44
50
|
"""
|
45
51
|
|
@@ -55,8 +61,9 @@ class CrossParcellationFC(BaseMarker):
|
|
55
61
|
self,
|
56
62
|
parcellation_one: str,
|
57
63
|
parcellation_two: str,
|
58
|
-
|
59
|
-
|
64
|
+
agg_method: str = "mean",
|
65
|
+
agg_method_params: Optional[Dict] = None,
|
66
|
+
corr_method: str = "pearson",
|
60
67
|
masks: Union[str, Dict, List[Union[Dict, str]], None] = None,
|
61
68
|
name: Optional[str] = None,
|
62
69
|
) -> None:
|
@@ -66,8 +73,9 @@ class CrossParcellationFC(BaseMarker):
|
|
66
73
|
)
|
67
74
|
self.parcellation_one = parcellation_one
|
68
75
|
self.parcellation_two = parcellation_two
|
69
|
-
self.
|
70
|
-
self.
|
76
|
+
self.agg_method = agg_method
|
77
|
+
self.agg_method_params = agg_method_params
|
78
|
+
self.corr_method = corr_method
|
71
79
|
self.masks = masks
|
72
80
|
super().__init__(on=["BOLD"], name=name)
|
73
81
|
|
@@ -115,13 +123,17 @@ class CrossParcellationFC(BaseMarker):
|
|
115
123
|
# Perform aggregation using two parcellations
|
116
124
|
aggregation_parcellation_one = ParcelAggregation(
|
117
125
|
parcellation=self.parcellation_one,
|
118
|
-
method=self.
|
126
|
+
method=self.agg_method,
|
127
|
+
method_params=self.agg_method_params,
|
119
128
|
masks=self.masks,
|
129
|
+
on="BOLD",
|
120
130
|
).compute(input, extra_input=extra_input)
|
121
131
|
aggregation_parcellation_two = ParcelAggregation(
|
122
132
|
parcellation=self.parcellation_two,
|
123
|
-
method=self.
|
133
|
+
method=self.agg_method,
|
134
|
+
method_params=self.agg_method_params,
|
124
135
|
masks=self.masks,
|
136
|
+
on="BOLD",
|
125
137
|
).compute(input, extra_input=extra_input)
|
126
138
|
|
127
139
|
return {
|
@@ -133,7 +145,7 @@ class CrossParcellationFC(BaseMarker):
|
|
133
145
|
pd.DataFrame(
|
134
146
|
aggregation_parcellation_two["aggregation"]["data"]
|
135
147
|
),
|
136
|
-
method=self.
|
148
|
+
method=self.corr_method,
|
137
149
|
).values,
|
138
150
|
# Columns should be named after parcellation 1
|
139
151
|
"col_names": aggregation_parcellation_one["aggregation"][
|
@@ -22,36 +22,40 @@ class EdgeCentricFCParcels(FunctionalConnectivityBase):
|
|
22
22
|
Parameters
|
23
23
|
----------
|
24
24
|
parcellation : str or list of str
|
25
|
-
The name(s) of the parcellation(s)
|
26
|
-
:func:`.list_parcellations
|
25
|
+
The name(s) of the parcellation(s) to use.
|
26
|
+
See :func:`.list_parcellations` for options.
|
27
27
|
agg_method : str, optional
|
28
|
-
The method to perform aggregation
|
29
|
-
|
28
|
+
The method to perform aggregation using.
|
29
|
+
See :func:`.get_aggfunc_by_name` for options
|
30
30
|
(default "mean").
|
31
31
|
agg_method_params : dict, optional
|
32
|
-
Parameters to pass to the aggregation function.
|
33
|
-
:func:`.get_aggfunc_by_name`
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
:class
|
32
|
+
Parameters to pass to the aggregation function.
|
33
|
+
See :func:`.get_aggfunc_by_name` for options
|
34
|
+
(default None).
|
35
|
+
conn_method : str, optional
|
36
|
+
The method to perform connectivity measure using.
|
37
|
+
See :class:`.JuniferConnectivityMeasure` for options
|
38
|
+
(default "correlation").
|
39
|
+
conn_method_params : dict, optional
|
40
|
+
Parameters to pass to :class:`.JuniferConnectivityMeasure`.
|
41
|
+
If None, ``{"empirical": True}`` will be used, which would mean
|
42
|
+
:class:`sklearn.covariance.EmpiricalCovariance` is used to compute
|
43
|
+
covariance. If usage of :class:`sklearn.covariance.LedoitWolf` is
|
44
|
+
desired, ``{"empirical": False}`` should be passed
|
45
|
+
(default None).
|
41
46
|
masks : str, dict or list of dict or str, optional
|
42
47
|
The specification of the masks to apply to regions before extracting
|
43
48
|
signals. Check :ref:`Using Masks <using_masks>` for more details.
|
44
49
|
If None, will not apply any mask (default None).
|
45
50
|
name : str, optional
|
46
|
-
The name of the marker. If None, will use
|
47
|
-
None).
|
51
|
+
The name of the marker. If None, will use
|
52
|
+
``BOLD_EdgeCentricFCParcels`` (default None).
|
48
53
|
|
49
54
|
References
|
50
55
|
----------
|
51
56
|
.. [1] Jo et al. (2021)
|
52
|
-
|
53
|
-
|
54
|
-
doi: https://doi.org/10.1016/j.neuroimage.2021.118204
|
57
|
+
Subject identification using edge-centric functional connectivity.
|
58
|
+
https://doi.org/10.1016/j.neuroimage.2021.118204
|
55
59
|
|
56
60
|
"""
|
57
61
|
|
@@ -60,8 +64,8 @@ class EdgeCentricFCParcels(FunctionalConnectivityBase):
|
|
60
64
|
parcellation: Union[str, List[str]],
|
61
65
|
agg_method: str = "mean",
|
62
66
|
agg_method_params: Optional[Dict] = None,
|
63
|
-
|
64
|
-
|
67
|
+
conn_method: str = "correlation",
|
68
|
+
conn_method_params: Optional[Dict] = None,
|
65
69
|
masks: Union[str, Dict, List[Union[Dict, str]], None] = None,
|
66
70
|
name: Optional[str] = None,
|
67
71
|
) -> None:
|
@@ -69,8 +73,8 @@ class EdgeCentricFCParcels(FunctionalConnectivityBase):
|
|
69
73
|
super().__init__(
|
70
74
|
agg_method=agg_method,
|
71
75
|
agg_method_params=agg_method_params,
|
72
|
-
|
73
|
-
|
76
|
+
conn_method=conn_method,
|
77
|
+
conn_method_params=conn_method_params,
|
74
78
|
masks=masks,
|
75
79
|
name=name,
|
76
80
|
)
|
@@ -22,42 +22,48 @@ class EdgeCentricFCSpheres(FunctionalConnectivityBase):
|
|
22
22
|
Parameters
|
23
23
|
----------
|
24
24
|
coords : str
|
25
|
-
The name of the coordinates list to use.
|
26
|
-
:func:`.list_coordinates` for options.
|
27
|
-
radius : float, optional
|
28
|
-
The radius of the sphere
|
29
|
-
from a single voxel.
|
30
|
-
for more information
|
25
|
+
The name of the coordinates list to use.
|
26
|
+
See :func:`.list_coordinates` for options.
|
27
|
+
radius : positive float, optional
|
28
|
+
The radius of the sphere around each coordinates in millimetres.
|
29
|
+
If None, the signal will be extracted from a single voxel.
|
30
|
+
See :class:`.JuniferNiftiSpheresMasker` for more information
|
31
|
+
(default None).
|
31
32
|
allow_overlap : bool, optional
|
32
33
|
Whether to allow overlapping spheres. If False, an error is raised if
|
33
|
-
the spheres overlap (default
|
34
|
+
the spheres overlap (default False).
|
34
35
|
agg_method : str, optional
|
35
|
-
The
|
36
|
-
See :func:`.get_aggfunc_by_name` for
|
37
|
-
(default
|
36
|
+
The method to perform aggregation using.
|
37
|
+
See :func:`.get_aggfunc_by_name` for options
|
38
|
+
(default "mean").
|
38
39
|
agg_method_params : dict, optional
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
Parameters to pass to the aggregation function.
|
41
|
+
See :func:`.get_aggfunc_by_name` for options
|
42
|
+
(default None).
|
43
|
+
conn_method : str, optional
|
44
|
+
The method to perform connectivity measure using.
|
45
|
+
See :class:`.JuniferConnectivityMeasure` for options
|
46
|
+
(default "correlation").
|
47
|
+
conn_method_params : dict, optional
|
48
|
+
Parameters to pass to :class:`.JuniferConnectivityMeasure`.
|
49
|
+
If None, ``{"empirical": True}`` will be used, which would mean
|
50
|
+
:class:`sklearn.covariance.EmpiricalCovariance` is used to compute
|
51
|
+
covariance. If usage of :class:`sklearn.covariance.LedoitWolf` is
|
52
|
+
desired, ``{"empirical": False}`` should be passed
|
53
|
+
(default None).
|
46
54
|
masks : str, dict or list of dict or str, optional
|
47
55
|
The specification of the masks to apply to regions before extracting
|
48
56
|
signals. Check :ref:`Using Masks <using_masks>` for more details.
|
49
57
|
If None, will not apply any mask (default None).
|
50
58
|
name : str, optional
|
51
|
-
The name of the marker.
|
52
|
-
|
53
|
-
was applied to (default None).
|
59
|
+
The name of the marker. If None, will use
|
60
|
+
``BOLD_EdgeCentricFCSpheres`` (default None).
|
54
61
|
|
55
62
|
References
|
56
63
|
----------
|
57
64
|
.. [1] Jo et al. (2021)
|
58
|
-
|
59
|
-
|
60
|
-
doi: https://doi.org/10.1016/j.neuroimage.2021.118204
|
65
|
+
Subject identification using edge-centric functional connectivity.
|
66
|
+
https://doi.org/10.1016/j.neuroimage.2021.118204
|
61
67
|
|
62
68
|
"""
|
63
69
|
|
@@ -68,8 +74,8 @@ class EdgeCentricFCSpheres(FunctionalConnectivityBase):
|
|
68
74
|
allow_overlap: bool = False,
|
69
75
|
agg_method: str = "mean",
|
70
76
|
agg_method_params: Optional[Dict] = None,
|
71
|
-
|
72
|
-
|
77
|
+
conn_method: str = "correlation",
|
78
|
+
conn_method_params: Optional[Dict] = None,
|
73
79
|
masks: Union[str, Dict, List[Union[Dict, str]], None] = None,
|
74
80
|
name: Optional[str] = None,
|
75
81
|
) -> None:
|
@@ -81,8 +87,8 @@ class EdgeCentricFCSpheres(FunctionalConnectivityBase):
|
|
81
87
|
super().__init__(
|
82
88
|
agg_method=agg_method,
|
83
89
|
agg_method_params=agg_method_params,
|
84
|
-
|
85
|
-
|
90
|
+
conn_method=conn_method,
|
91
|
+
conn_method_params=conn_method_params,
|
86
92
|
masks=masks,
|
87
93
|
name=name,
|
88
94
|
)
|
@@ -7,9 +7,9 @@
|
|
7
7
|
from abc import abstractmethod
|
8
8
|
from typing import Any, ClassVar, Dict, List, Optional, Set, Union
|
9
9
|
|
10
|
-
from
|
11
|
-
from sklearn.covariance import EmpiricalCovariance
|
10
|
+
from sklearn.covariance import EmpiricalCovariance, LedoitWolf
|
12
11
|
|
12
|
+
from ...external.nilearn import JuniferConnectivityMeasure
|
13
13
|
from ...utils import raise_error
|
14
14
|
from ..base import BaseMarker
|
15
15
|
|
@@ -23,25 +23,31 @@ class FunctionalConnectivityBase(BaseMarker):
|
|
23
23
|
Parameters
|
24
24
|
----------
|
25
25
|
agg_method : str, optional
|
26
|
-
The method to perform aggregation using.
|
27
|
-
:func:`.get_aggfunc_by_name`
|
26
|
+
The method to perform aggregation using.
|
27
|
+
Check valid options in :func:`.get_aggfunc_by_name`
|
28
|
+
(default "mean").
|
28
29
|
agg_method_params : dict, optional
|
29
|
-
Parameters to pass to the aggregation function.
|
30
|
-
:func:`.get_aggfunc_by_name`
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
:class
|
30
|
+
Parameters to pass to the aggregation function.
|
31
|
+
Check valid options in :func:`.get_aggfunc_by_name`
|
32
|
+
(default None).
|
33
|
+
conn_method : str, optional
|
34
|
+
The method to perform connectivity measure using.
|
35
|
+
Check valid options in :class:`.JuniferConnectivityMeasure`
|
36
|
+
(default "correlation").
|
37
|
+
conn_method_params : dict, optional
|
38
|
+
Parameters to pass to :class:`.JuniferConnectivityMeasure`.
|
39
|
+
If None, ``{"empirical": True}`` will be used, which would mean
|
40
|
+
:class:`sklearn.covariance.EmpiricalCovariance` is used to compute
|
41
|
+
covariance. If usage of :class:`sklearn.covariance.LedoitWolf` is
|
42
|
+
desired, ``{"empirical": False}`` should be passed
|
43
|
+
(default None).
|
38
44
|
masks : str, dict or list of dict or str, optional
|
39
45
|
The specification of the masks to apply to regions before extracting
|
40
46
|
signals. Check :ref:`Using Masks <using_masks>` for more details.
|
41
47
|
If None, will not apply any mask (default None).
|
42
48
|
name : str, optional
|
43
|
-
The name of the marker. If None, will use
|
44
|
-
None).
|
49
|
+
The name of the marker. If None, will use ``BOLD_<class_name>``
|
50
|
+
(default None).
|
45
51
|
|
46
52
|
"""
|
47
53
|
|
@@ -57,19 +63,18 @@ class FunctionalConnectivityBase(BaseMarker):
|
|
57
63
|
self,
|
58
64
|
agg_method: str = "mean",
|
59
65
|
agg_method_params: Optional[Dict] = None,
|
60
|
-
|
61
|
-
|
66
|
+
conn_method: str = "correlation",
|
67
|
+
conn_method_params: Optional[Dict] = None,
|
62
68
|
masks: Union[str, Dict, List[Union[Dict, str]], None] = None,
|
63
69
|
name: Optional[str] = None,
|
64
70
|
) -> None:
|
65
71
|
self.agg_method = agg_method
|
66
72
|
self.agg_method_params = agg_method_params
|
67
|
-
self.
|
68
|
-
self.
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
"empirical", False
|
73
|
+
self.conn_method = conn_method
|
74
|
+
self.conn_method_params = conn_method_params or {}
|
75
|
+
# Reverse of nilearn behavior
|
76
|
+
self.conn_method_params["empirical"] = self.conn_method_params.get(
|
77
|
+
"empirical", True
|
73
78
|
)
|
74
79
|
self.masks = masks
|
75
80
|
super().__init__(on="BOLD", name=name)
|
@@ -121,14 +126,21 @@ class FunctionalConnectivityBase(BaseMarker):
|
|
121
126
|
"""
|
122
127
|
# Perform necessary aggregation
|
123
128
|
aggregation = self.aggregate(input, extra_input=extra_input)
|
124
|
-
#
|
125
|
-
if self.
|
126
|
-
|
127
|
-
cov_estimator=EmpiricalCovariance(), # type: ignore
|
128
|
-
kind=self.cor_method,
|
129
|
-
)
|
129
|
+
# Set covariance estimator
|
130
|
+
if self.conn_method_params["empirical"]:
|
131
|
+
cov_estimator = EmpiricalCovariance(store_precision=False)
|
130
132
|
else:
|
131
|
-
|
133
|
+
cov_estimator = LedoitWolf(store_precision=False)
|
134
|
+
# Compute correlation
|
135
|
+
connectivity = JuniferConnectivityMeasure(
|
136
|
+
cov_estimator=cov_estimator,
|
137
|
+
kind=self.conn_method,
|
138
|
+
**{
|
139
|
+
k: v
|
140
|
+
for k, v in self.conn_method_params.items()
|
141
|
+
if k != "empirical"
|
142
|
+
},
|
143
|
+
)
|
132
144
|
# Create dictionary for output
|
133
145
|
return {
|
134
146
|
"functional_connectivity": {
|
@@ -22,28 +22,34 @@ class FunctionalConnectivityParcels(FunctionalConnectivityBase):
|
|
22
22
|
Parameters
|
23
23
|
----------
|
24
24
|
parcellation : str or list of str
|
25
|
-
The name(s) of the parcellation(s)
|
26
|
-
:func:`.list_parcellations
|
25
|
+
The name(s) of the parcellation(s) to use.
|
26
|
+
See :func:`.list_parcellations` for options.
|
27
27
|
agg_method : str, optional
|
28
|
-
The method to perform aggregation using.
|
29
|
-
:func:`.get_aggfunc_by_name`
|
28
|
+
The method to perform aggregation using.
|
29
|
+
See :func:`.get_aggfunc_by_name` for options
|
30
|
+
(default "mean").
|
30
31
|
agg_method_params : dict, optional
|
31
|
-
Parameters to pass to the aggregation function.
|
32
|
-
:func:`.get_aggfunc_by_name`
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
:class
|
32
|
+
Parameters to pass to the aggregation function.
|
33
|
+
See :func:`.get_aggfunc_by_name` for options
|
34
|
+
(default None).
|
35
|
+
conn_method : str, optional
|
36
|
+
The method to perform connectivity measure using.
|
37
|
+
See :class:`.JuniferConnectivityMeasure` for options
|
38
|
+
(default "correlation").
|
39
|
+
conn_method_params : dict, optional
|
40
|
+
Parameters to pass to :class:`.JuniferConnectivityMeasure`.
|
41
|
+
If None, ``{"empirical": True}`` will be used, which would mean
|
42
|
+
:class:`sklearn.covariance.EmpiricalCovariance` is used to compute
|
43
|
+
covariance. If usage of :class:`sklearn.covariance.LedoitWolf` is
|
44
|
+
desired, ``{"empirical": False}`` should be passed
|
45
|
+
(default None).
|
40
46
|
masks : str, dict or list of dict or str, optional
|
41
47
|
The specification of the masks to apply to regions before extracting
|
42
48
|
signals. Check :ref:`Using Masks <using_masks>` for more details.
|
43
49
|
If None, will not apply any mask (default None).
|
44
50
|
name : str, optional
|
45
|
-
The name of the marker. If None, will use
|
46
|
-
None).
|
51
|
+
The name of the marker. If None, will use
|
52
|
+
``BOLD_FunctionalConnectivityParcels`` (default None).
|
47
53
|
|
48
54
|
"""
|
49
55
|
|
@@ -52,8 +58,8 @@ class FunctionalConnectivityParcels(FunctionalConnectivityBase):
|
|
52
58
|
parcellation: Union[str, List[str]],
|
53
59
|
agg_method: str = "mean",
|
54
60
|
agg_method_params: Optional[Dict] = None,
|
55
|
-
|
56
|
-
|
61
|
+
conn_method: str = "correlation",
|
62
|
+
conn_method_params: Optional[Dict] = None,
|
57
63
|
masks: Union[str, Dict, List[Union[Dict, str]], None] = None,
|
58
64
|
name: Optional[str] = None,
|
59
65
|
) -> None:
|
@@ -61,8 +67,8 @@ class FunctionalConnectivityParcels(FunctionalConnectivityBase):
|
|
61
67
|
super().__init__(
|
62
68
|
agg_method=agg_method,
|
63
69
|
agg_method_params=agg_method_params,
|
64
|
-
|
65
|
-
|
70
|
+
conn_method=conn_method,
|
71
|
+
conn_method_params=conn_method_params,
|
66
72
|
masks=masks,
|
67
73
|
name=name,
|
68
74
|
)
|
@@ -23,35 +23,42 @@ class FunctionalConnectivitySpheres(FunctionalConnectivityBase):
|
|
23
23
|
Parameters
|
24
24
|
----------
|
25
25
|
coords : str
|
26
|
-
The name of the coordinates list to use.
|
27
|
-
:func:`.list_coordinates` for options.
|
28
|
-
radius : float, optional
|
29
|
-
The radius of the sphere
|
30
|
-
from a single voxel.
|
31
|
-
for more information
|
26
|
+
The name of the coordinates list to use.
|
27
|
+
See :func:`.list_coordinates` for options.
|
28
|
+
radius : positive float, optional
|
29
|
+
The radius of the sphere around each coordinates in millimetres.
|
30
|
+
If None, the signal will be extracted from a single voxel.
|
31
|
+
See :class:`.JuniferNiftiSpheresMasker` for more information
|
32
|
+
(default None).
|
32
33
|
allow_overlap : bool, optional
|
33
34
|
Whether to allow overlapping spheres. If False, an error is raised if
|
34
|
-
the spheres overlap (default
|
35
|
+
the spheres overlap (default False).
|
35
36
|
agg_method : str, optional
|
36
|
-
The
|
37
|
-
See :func:`.get_aggfunc_by_name` for
|
38
|
-
(default
|
37
|
+
The method to perform aggregation using.
|
38
|
+
See :func:`.get_aggfunc_by_name` for options
|
39
|
+
(default "mean").
|
39
40
|
agg_method_params : dict, optional
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
Parameters to pass to the aggregation function.
|
42
|
+
See :func:`.get_aggfunc_by_name` for options
|
43
|
+
(default None).
|
44
|
+
conn_method : str, optional
|
45
|
+
The method to perform connectivity measure using.
|
46
|
+
See :class:`.JuniferConnectivityMeasure` for options
|
47
|
+
(default "correlation").
|
48
|
+
conn_method_params : dict, optional
|
49
|
+
Parameters to pass to :class:`.JuniferConnectivityMeasure`.
|
50
|
+
If None, ``{"empirical": True}`` will be used, which would mean
|
51
|
+
:class:`sklearn.covariance.EmpiricalCovariance` is used to compute
|
52
|
+
covariance. If usage of :class:`sklearn.covariance.LedoitWolf` is
|
53
|
+
desired, ``{"empirical": False}`` should be passed
|
54
|
+
(default None).
|
47
55
|
masks : str, dict or list of dict or str, optional
|
48
56
|
The specification of the masks to apply to regions before extracting
|
49
57
|
signals. Check :ref:`Using Masks <using_masks>` for more details.
|
50
58
|
If None, will not apply any mask (default None).
|
51
59
|
name : str, optional
|
52
|
-
The name of the marker.
|
53
|
-
|
54
|
-
was applied to (default None).
|
60
|
+
The name of the marker. If None, will use
|
61
|
+
``BOLD_FunctionalConnectivitySpheres`` (default None).
|
55
62
|
|
56
63
|
"""
|
57
64
|
|
@@ -62,8 +69,8 @@ class FunctionalConnectivitySpheres(FunctionalConnectivityBase):
|
|
62
69
|
allow_overlap: bool = False,
|
63
70
|
agg_method: str = "mean",
|
64
71
|
agg_method_params: Optional[Dict] = None,
|
65
|
-
|
66
|
-
|
72
|
+
conn_method: str = "correlation",
|
73
|
+
conn_method_params: Optional[Dict] = None,
|
67
74
|
masks: Union[str, Dict, List[Union[Dict, str]], None] = None,
|
68
75
|
name: Optional[str] = None,
|
69
76
|
) -> None:
|
@@ -75,8 +82,8 @@ class FunctionalConnectivitySpheres(FunctionalConnectivityBase):
|
|
75
82
|
super().__init__(
|
76
83
|
agg_method=agg_method,
|
77
84
|
agg_method_params=agg_method_params,
|
78
|
-
|
79
|
-
|
85
|
+
conn_method=conn_method,
|
86
|
+
conn_method_params=conn_method_params,
|
80
87
|
masks=masks,
|
81
88
|
name=name,
|
82
89
|
)
|
junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py
CHANGED
@@ -27,7 +27,7 @@ def test_init() -> None:
|
|
27
27
|
CrossParcellationFC(
|
28
28
|
parcellation_one="a",
|
29
29
|
parcellation_two="a",
|
30
|
-
|
30
|
+
corr_method="pearson",
|
31
31
|
)
|
32
32
|
|
33
33
|
|
@@ -58,7 +58,7 @@ def test_compute(tmp_path: Path) -> None:
|
|
58
58
|
crossparcellation = CrossParcellationFC(
|
59
59
|
parcellation_one=parcellation_one,
|
60
60
|
parcellation_two=parcellation_two,
|
61
|
-
|
61
|
+
corr_method="spearman",
|
62
62
|
)
|
63
63
|
out = crossparcellation.compute(element_data["BOLD"])[
|
64
64
|
"functional_connectivity"
|
@@ -86,7 +86,7 @@ def test_store(tmp_path: Path) -> None:
|
|
86
86
|
crossparcellation = CrossParcellationFC(
|
87
87
|
parcellation_one=parcellation_one,
|
88
88
|
parcellation_two=parcellation_two,
|
89
|
-
|
89
|
+
corr_method="spearman",
|
90
90
|
)
|
91
91
|
storage = SQLiteFeatureStorage(
|
92
92
|
uri=tmp_path / "test_crossparcellation.sqlite", upsert="ignore"
|
@@ -5,6 +5,9 @@
|
|
5
5
|
# License: AGPL
|
6
6
|
|
7
7
|
from pathlib import Path
|
8
|
+
from typing import Dict
|
9
|
+
|
10
|
+
import pytest
|
8
11
|
|
9
12
|
from junifer.datareader import DefaultDataReader
|
10
13
|
from junifer.markers.functional_connectivity import EdgeCentricFCParcels
|
@@ -12,20 +15,35 @@ from junifer.storage import SQLiteFeatureStorage
|
|
12
15
|
from junifer.testing.datagrabbers import PartlyCloudyTestingDataGrabber
|
13
16
|
|
14
17
|
|
15
|
-
|
18
|
+
@pytest.mark.parametrize(
|
19
|
+
"conn_method_params",
|
20
|
+
[
|
21
|
+
{"empirical": False},
|
22
|
+
{"empirical": True},
|
23
|
+
],
|
24
|
+
)
|
25
|
+
def test_EdgeCentricFCParcels(
|
26
|
+
tmp_path: Path,
|
27
|
+
conn_method_params: Dict[str, bool],
|
28
|
+
) -> None:
|
16
29
|
"""Test EdgeCentricFCParcels.
|
17
30
|
|
18
31
|
Parameters
|
19
32
|
----------
|
20
33
|
tmp_path : pathlib.Path
|
21
34
|
The path to the test directory.
|
35
|
+
conn_method_params : dict
|
36
|
+
The parametrized parameters to connectivity measure method.
|
22
37
|
|
23
38
|
"""
|
24
39
|
with PartlyCloudyTestingDataGrabber() as dg:
|
40
|
+
# Get element data
|
25
41
|
element_data = DefaultDataReader().fit_transform(dg["sub-01"])
|
42
|
+
# Setup marker
|
26
43
|
marker = EdgeCentricFCParcels(
|
27
44
|
parcellation="TianxS1x3TxMNInonlinear2009cAsym",
|
28
|
-
|
45
|
+
conn_method="correlation",
|
46
|
+
conn_method_params=conn_method_params,
|
29
47
|
)
|
30
48
|
# Check correct output
|
31
49
|
assert "matrix" == marker.get_output_type(
|
@@ -41,8 +59,7 @@ def test_EdgeCentricFCParcels(tmp_path: Path) -> None:
|
|
41
59
|
assert "data" in edge_fc_bold
|
42
60
|
assert "row_names" in edge_fc_bold
|
43
61
|
assert "col_names" in edge_fc_bold
|
44
|
-
assert edge_fc_bold["data"].shape
|
45
|
-
assert edge_fc_bold["data"].shape[1] == n_edges
|
62
|
+
assert edge_fc_bold["data"].shape == (n_edges, n_edges)
|
46
63
|
assert len(set(edge_fc_bold["row_names"])) == n_edges
|
47
64
|
assert len(set(edge_fc_bold["col_names"])) == n_edges
|
48
65
|
|