junifer 0.0.5.dev202__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.
Files changed (22) hide show
  1. junifer/_version.py +2 -2
  2. junifer/external/nilearn/__init__.py +2 -1
  3. junifer/external/nilearn/junifer_connectivity_measure.py +483 -0
  4. junifer/external/nilearn/tests/test_junifer_connectivity_measure.py +1089 -0
  5. junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +31 -15
  6. junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +26 -22
  7. junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +33 -27
  8. junifer/markers/functional_connectivity/functional_connectivity_base.py +42 -30
  9. junifer/markers/functional_connectivity/functional_connectivity_parcels.py +25 -19
  10. junifer/markers/functional_connectivity/functional_connectivity_spheres.py +31 -24
  11. junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py +3 -3
  12. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +21 -4
  13. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +22 -9
  14. junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +29 -8
  15. junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +30 -61
  16. {junifer-0.0.5.dev202.dist-info → junifer-0.0.5.dev219.dist-info}/METADATA +1 -1
  17. {junifer-0.0.5.dev202.dist-info → junifer-0.0.5.dev219.dist-info}/RECORD +22 -20
  18. {junifer-0.0.5.dev202.dist-info → junifer-0.0.5.dev219.dist-info}/WHEEL +1 -1
  19. {junifer-0.0.5.dev202.dist-info → junifer-0.0.5.dev219.dist-info}/AUTHORS.rst +0 -0
  20. {junifer-0.0.5.dev202.dist-info → junifer-0.0.5.dev219.dist-info}/LICENSE.md +0 -0
  21. {junifer-0.0.5.dev202.dist-info → junifer-0.0.5.dev219.dist-info}/entry_points.txt +0 -0
  22. {junifer-0.0.5.dev202.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
- aggregation_method : str, optional
32
- The aggregation method (default "mean").
33
- correlation_method : str, optional
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
- :any:`pandas.DataFrame.corr` (default "pearson").
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 the class name
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
- aggregation_method: str = "mean",
59
- correlation_method: str = "pearson",
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.aggregation_method = aggregation_method
70
- self.correlation_method = correlation_method
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.aggregation_method,
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.aggregation_method,
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,11 +145,15 @@ class CrossParcellationFC(BaseMarker):
133
145
  pd.DataFrame(
134
146
  aggregation_parcellation_two["aggregation"]["data"]
135
147
  ),
136
- method=self.correlation_method,
148
+ method=self.corr_method,
137
149
  ).values,
138
150
  # Columns should be named after parcellation 1
139
- "col_names": aggregation_parcellation_one["col_names"],
151
+ "col_names": aggregation_parcellation_one["aggregation"][
152
+ "col_names"
153
+ ],
140
154
  # Rows should be named after parcellation 2
141
- "row_names": aggregation_parcellation_two["col_names"],
155
+ "row_names": aggregation_parcellation_two["aggregation"][
156
+ "col_names"
157
+ ],
142
158
  },
143
159
  }
@@ -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). Check valid options by calling
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 of BOLD time series.
29
- Check valid options in :func:`.get_aggfunc_by_name`
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. Check valid options in
33
- :func:`.get_aggfunc_by_name` (default None).
34
- cor_method : str, optional
35
- The method to perform correlation. Check valid options in
36
- :class:`nilearn.connectome.ConnectivityMeasure`
37
- (default "covariance").
38
- cor_method_params : dict, optional
39
- Parameters to pass to the correlation function. Check valid options in
40
- :class:`nilearn.connectome.ConnectivityMeasure` (default None).
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 the class name (default
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
- Subject identification using
53
- edge-centric functional connectivity
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
- cor_method: str = "covariance",
64
- cor_method_params: Optional[Dict] = None,
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
- cor_method=cor_method,
73
- cor_method_params=cor_method_params,
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. See
26
- :func:`.list_coordinates` for options.
27
- radius : float, optional
28
- The radius of the sphere in mm. If None, the signal will be extracted
29
- from a single voxel. See :class:`nilearn.maskers.NiftiSpheresMasker`
30
- for more information (default None).
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 is False).
34
+ the spheres overlap (default False).
34
35
  agg_method : str, optional
35
- The aggregation method to use.
36
- See :func:`.get_aggfunc_by_name` for more information
37
- (default None).
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
- The parameters to pass to the aggregation method (default None).
40
- cor_method : str, optional
41
- The method to perform correlation using. Check valid options in
42
- :class:`nilearn.connectome.ConnectivityMeasure` (default "covariance").
43
- cor_method_params : dict, optional
44
- Parameters to pass to the correlation function. Check valid options in
45
- :class:`nilearn.connectome.ConnectivityMeasure` (default None).
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. By default, it will use
52
- KIND_EdgeCentricFCSpheres where KIND is the kind of data it
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
- Subject identification using
59
- edge-centric functional connectivity
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
- cor_method: str = "covariance",
72
- cor_method_params: Optional[Dict] = None,
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
- cor_method=cor_method,
85
- cor_method_params=cor_method_params,
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 nilearn.connectome import ConnectivityMeasure
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. Check valid options in
27
- :func:`.get_aggfunc_by_name` (default "mean").
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. Check valid options in
30
- :func:`.get_aggfunc_by_name` (default None).
31
- cor_method : str, optional
32
- The method to perform correlation using. Check valid options in
33
- :class:`nilearn.connectome.ConnectivityMeasure`
34
- (default "covariance").
35
- cor_method_params : dict, optional
36
- Parameters to pass to the correlation function. Check valid options in
37
- :class:`nilearn.connectome.ConnectivityMeasure` (default None).
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 the class name (default
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
- cor_method: str = "covariance",
61
- cor_method_params: Optional[Dict] = None,
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.cor_method = cor_method
68
- self.cor_method_params = cor_method_params or {}
69
-
70
- # default to nilearn behavior
71
- self.cor_method_params["empirical"] = self.cor_method_params.get(
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
- # Compute correlation
125
- if self.cor_method_params["empirical"]:
126
- connectivity = ConnectivityMeasure(
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
- connectivity = ConnectivityMeasure(kind=self.cor_method)
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). Check valid options by calling
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. Check valid options in
29
- :func:`.get_aggfunc_by_name` (default "mean").
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. Check valid options in
32
- :func:`.get_aggfunc_by_name` (default None).
33
- cor_method : str, optional
34
- The method to perform correlation using. Check valid options in
35
- :class:`nilearn.connectome.ConnectivityMeasure`
36
- (default "covariance").
37
- cor_method_params : dict, optional
38
- Parameters to pass to the correlation function. Check valid options in
39
- :class:`nilearn.connectome.ConnectivityMeasure` (default None).
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 the class name (default
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
- cor_method: str = "covariance",
56
- cor_method_params: Optional[Dict] = None,
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
- cor_method=cor_method,
65
- cor_method_params=cor_method_params,
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. See
27
- :func:`.list_coordinates` for options.
28
- radius : float, optional
29
- The radius of the sphere in mm. If None, the signal will be extracted
30
- from a single voxel. See :class:`nilearn.maskers.NiftiSpheresMasker`
31
- for more information (default None).
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 is False).
35
+ the spheres overlap (default False).
35
36
  agg_method : str, optional
36
- The aggregation method to use.
37
- See :func:`.get_aggfunc_by_name` for more information
38
- (default None).
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
- The parameters to pass to the aggregation method (default None).
41
- cor_method : str, optional
42
- The method to perform correlation using. Check valid options in
43
- :class:`nilearn.connectome.ConnectivityMeasure` (default "covariance").
44
- cor_method_params : dict, optional
45
- Parameters to pass to the correlation function. Check valid options in
46
- :class:`nilearn.connectome.ConnectivityMeasure` (default None).
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. By default, it will use
53
- KIND_FunctionalConnectivitySpheres where KIND is the kind of data it
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
- cor_method: str = "covariance",
66
- cor_method_params: Optional[Dict] = None,
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
- cor_method=cor_method,
79
- cor_method_params=cor_method_params,
85
+ conn_method=conn_method,
86
+ conn_method_params=conn_method_params,
80
87
  masks=masks,
81
88
  name=name,
82
89
  )
@@ -27,7 +27,7 @@ def test_init() -> None:
27
27
  CrossParcellationFC(
28
28
  parcellation_one="a",
29
29
  parcellation_two="a",
30
- correlation_method="pearson",
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
- correlation_method="spearman",
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
- correlation_method="spearman",
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
- def test_EdgeCentricFCParcels(tmp_path: Path) -> None:
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
- cor_method_params={"empirical": True},
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[0] == n_edges
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