junifer 0.0.5__py3-none-any.whl → 0.0.5.dev24__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 (194) hide show
  1. junifer/__init__.py +0 -17
  2. junifer/_version.py +2 -2
  3. junifer/api/__init__.py +1 -4
  4. junifer/api/cli.py +1 -91
  5. junifer/api/decorators.py +0 -9
  6. junifer/api/functions.py +10 -56
  7. junifer/api/parser.py +0 -3
  8. junifer/api/queue_context/__init__.py +1 -4
  9. junifer/api/res/afni/run_afni_docker.sh +1 -1
  10. junifer/api/res/ants/run_ants_docker.sh +1 -1
  11. junifer/api/res/fsl/run_fsl_docker.sh +1 -1
  12. junifer/api/tests/test_api_utils.py +2 -4
  13. junifer/api/tests/test_cli.py +0 -83
  14. junifer/api/tests/test_functions.py +2 -27
  15. junifer/configs/__init__.py +1 -1
  16. junifer/configs/juseless/__init__.py +1 -4
  17. junifer/configs/juseless/datagrabbers/__init__.py +1 -10
  18. junifer/configs/juseless/datagrabbers/aomic_id1000_vbm.py +0 -3
  19. junifer/configs/juseless/datagrabbers/camcan_vbm.py +0 -3
  20. junifer/configs/juseless/datagrabbers/ixi_vbm.py +0 -3
  21. junifer/configs/juseless/datagrabbers/tests/test_ucla.py +3 -1
  22. junifer/configs/juseless/datagrabbers/ucla.py +9 -12
  23. junifer/configs/juseless/datagrabbers/ukb_vbm.py +0 -3
  24. junifer/data/__init__.py +1 -21
  25. junifer/data/coordinates.py +19 -10
  26. junifer/data/masks.py +87 -58
  27. junifer/data/parcellations.py +3 -14
  28. junifer/data/template_spaces.py +1 -4
  29. junifer/data/tests/test_masks.py +37 -26
  30. junifer/data/utils.py +0 -3
  31. junifer/datagrabber/__init__.py +1 -18
  32. junifer/datagrabber/aomic/__init__.py +0 -3
  33. junifer/datagrabber/aomic/id1000.py +37 -70
  34. junifer/datagrabber/aomic/piop1.py +36 -69
  35. junifer/datagrabber/aomic/piop2.py +38 -71
  36. junifer/datagrabber/aomic/tests/test_id1000.py +99 -44
  37. junifer/datagrabber/aomic/tests/test_piop1.py +108 -65
  38. junifer/datagrabber/aomic/tests/test_piop2.py +102 -45
  39. junifer/datagrabber/base.py +6 -13
  40. junifer/datagrabber/datalad_base.py +1 -13
  41. junifer/datagrabber/dmcc13_benchmark.py +53 -36
  42. junifer/datagrabber/hcp1200/__init__.py +0 -3
  43. junifer/datagrabber/hcp1200/datalad_hcp1200.py +0 -3
  44. junifer/datagrabber/hcp1200/hcp1200.py +1 -4
  45. junifer/datagrabber/multiple.py +6 -45
  46. junifer/datagrabber/pattern.py +62 -170
  47. junifer/datagrabber/pattern_datalad.py +12 -25
  48. junifer/datagrabber/tests/test_datagrabber_utils.py +218 -0
  49. junifer/datagrabber/tests/test_datalad_base.py +4 -4
  50. junifer/datagrabber/tests/test_dmcc13_benchmark.py +19 -46
  51. junifer/datagrabber/tests/test_multiple.py +84 -161
  52. junifer/datagrabber/tests/test_pattern.py +0 -45
  53. junifer/datagrabber/tests/test_pattern_datalad.py +4 -4
  54. junifer/datagrabber/utils.py +230 -0
  55. junifer/datareader/__init__.py +1 -4
  56. junifer/datareader/default.py +43 -95
  57. junifer/external/__init__.py +1 -1
  58. junifer/external/nilearn/__init__.py +1 -5
  59. junifer/external/nilearn/junifer_nifti_spheres_masker.py +9 -23
  60. junifer/external/nilearn/tests/test_junifer_nifti_spheres_masker.py +1 -76
  61. junifer/markers/__init__.py +1 -23
  62. junifer/markers/base.py +28 -68
  63. junifer/markers/collection.py +2 -10
  64. junifer/markers/complexity/__init__.py +0 -10
  65. junifer/markers/complexity/complexity_base.py +43 -26
  66. junifer/markers/complexity/hurst_exponent.py +0 -3
  67. junifer/markers/complexity/multiscale_entropy_auc.py +0 -3
  68. junifer/markers/complexity/perm_entropy.py +0 -3
  69. junifer/markers/complexity/range_entropy.py +0 -3
  70. junifer/markers/complexity/range_entropy_auc.py +0 -3
  71. junifer/markers/complexity/sample_entropy.py +0 -3
  72. junifer/markers/complexity/tests/test_hurst_exponent.py +3 -11
  73. junifer/markers/complexity/tests/test_multiscale_entropy_auc.py +3 -11
  74. junifer/markers/complexity/tests/test_perm_entropy.py +3 -11
  75. junifer/markers/complexity/tests/test_range_entropy.py +3 -11
  76. junifer/markers/complexity/tests/test_range_entropy_auc.py +3 -11
  77. junifer/markers/complexity/tests/test_sample_entropy.py +3 -11
  78. junifer/markers/complexity/tests/test_weighted_perm_entropy.py +3 -11
  79. junifer/markers/complexity/weighted_perm_entropy.py +0 -3
  80. junifer/markers/ets_rss.py +42 -27
  81. junifer/markers/falff/__init__.py +0 -3
  82. junifer/markers/falff/_afni_falff.py +2 -5
  83. junifer/markers/falff/_junifer_falff.py +0 -3
  84. junifer/markers/falff/falff_base.py +46 -20
  85. junifer/markers/falff/falff_parcels.py +27 -56
  86. junifer/markers/falff/falff_spheres.py +29 -60
  87. junifer/markers/falff/tests/test_falff_parcels.py +23 -39
  88. junifer/markers/falff/tests/test_falff_spheres.py +23 -39
  89. junifer/markers/functional_connectivity/__init__.py +0 -9
  90. junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +60 -63
  91. junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +32 -45
  92. junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +36 -49
  93. junifer/markers/functional_connectivity/functional_connectivity_base.py +70 -71
  94. junifer/markers/functional_connectivity/functional_connectivity_parcels.py +25 -34
  95. junifer/markers/functional_connectivity/functional_connectivity_spheres.py +30 -40
  96. junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py +7 -11
  97. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +7 -27
  98. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +12 -28
  99. junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +11 -35
  100. junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +62 -36
  101. junifer/markers/parcel_aggregation.py +61 -47
  102. junifer/markers/reho/__init__.py +0 -3
  103. junifer/markers/reho/_afni_reho.py +2 -5
  104. junifer/markers/reho/_junifer_reho.py +1 -4
  105. junifer/markers/reho/reho_base.py +27 -8
  106. junifer/markers/reho/reho_parcels.py +17 -28
  107. junifer/markers/reho/reho_spheres.py +18 -27
  108. junifer/markers/reho/tests/test_reho_parcels.py +3 -8
  109. junifer/markers/reho/tests/test_reho_spheres.py +3 -8
  110. junifer/markers/sphere_aggregation.py +59 -43
  111. junifer/markers/temporal_snr/__init__.py +0 -3
  112. junifer/markers/temporal_snr/temporal_snr_base.py +32 -23
  113. junifer/markers/temporal_snr/temporal_snr_parcels.py +6 -9
  114. junifer/markers/temporal_snr/temporal_snr_spheres.py +6 -9
  115. junifer/markers/temporal_snr/tests/test_temporal_snr_parcels.py +3 -6
  116. junifer/markers/temporal_snr/tests/test_temporal_snr_spheres.py +3 -6
  117. junifer/markers/tests/test_collection.py +8 -9
  118. junifer/markers/tests/test_ets_rss.py +9 -15
  119. junifer/markers/tests/test_markers_base.py +18 -17
  120. junifer/markers/tests/test_parcel_aggregation.py +32 -93
  121. junifer/markers/tests/test_sphere_aggregation.py +19 -72
  122. junifer/onthefly/__init__.py +1 -4
  123. junifer/onthefly/read_transform.py +0 -3
  124. junifer/pipeline/__init__.py +1 -9
  125. junifer/pipeline/pipeline_step_mixin.py +4 -21
  126. junifer/pipeline/registry.py +0 -3
  127. junifer/pipeline/singleton.py +0 -3
  128. junifer/pipeline/tests/test_registry.py +1 -1
  129. junifer/pipeline/update_meta_mixin.py +0 -3
  130. junifer/pipeline/utils.py +1 -67
  131. junifer/pipeline/workdir_manager.py +0 -3
  132. junifer/preprocess/__init__.py +2 -9
  133. junifer/preprocess/ants/__init__.py +4 -0
  134. junifer/preprocess/ants/ants_apply_transforms_warper.py +185 -0
  135. junifer/preprocess/ants/tests/test_ants_apply_transforms_warper.py +56 -0
  136. junifer/preprocess/base.py +3 -6
  137. junifer/preprocess/bold_warper.py +265 -0
  138. junifer/preprocess/confounds/__init__.py +0 -3
  139. junifer/preprocess/confounds/fmriprep_confound_remover.py +60 -47
  140. junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py +113 -72
  141. junifer/preprocess/fsl/__init__.py +4 -0
  142. junifer/preprocess/fsl/apply_warper.py +179 -0
  143. junifer/preprocess/fsl/tests/test_apply_warper.py +45 -0
  144. junifer/preprocess/smoothing/__init__.py +0 -3
  145. junifer/preprocess/smoothing/_afni_smoothing.py +1 -1
  146. junifer/preprocess/tests/test_bold_warper.py +159 -0
  147. junifer/preprocess/warping/__init__.py +0 -3
  148. junifer/preprocess/warping/_ants_warper.py +0 -3
  149. junifer/preprocess/warping/_fsl_warper.py +0 -3
  150. junifer/stats.py +1 -4
  151. junifer/storage/__init__.py +1 -9
  152. junifer/storage/base.py +1 -40
  153. junifer/storage/hdf5.py +9 -71
  154. junifer/storage/pandas_base.py +0 -3
  155. junifer/storage/sqlite.py +0 -3
  156. junifer/storage/tests/test_hdf5.py +10 -82
  157. junifer/storage/utils.py +0 -9
  158. junifer/testing/__init__.py +1 -4
  159. junifer/testing/datagrabbers.py +6 -13
  160. junifer/testing/tests/test_partlycloudytesting_datagrabber.py +7 -7
  161. junifer/testing/utils.py +0 -3
  162. junifer/utils/__init__.py +2 -13
  163. junifer/utils/fs.py +0 -3
  164. junifer/utils/helpers.py +1 -32
  165. junifer/utils/logging.py +4 -33
  166. junifer/utils/tests/test_logging.py +0 -8
  167. {junifer-0.0.5.dist-info → junifer-0.0.5.dev24.dist-info}/METADATA +16 -17
  168. junifer-0.0.5.dev24.dist-info/RECORD +265 -0
  169. {junifer-0.0.5.dist-info → junifer-0.0.5.dev24.dist-info}/WHEEL +1 -1
  170. junifer/api/res/freesurfer/mri_binarize +0 -3
  171. junifer/api/res/freesurfer/mri_mc +0 -3
  172. junifer/api/res/freesurfer/mri_pretess +0 -3
  173. junifer/api/res/freesurfer/mris_convert +0 -3
  174. junifer/api/res/freesurfer/run_freesurfer_docker.sh +0 -61
  175. junifer/data/masks/ukb/UKB_15K_GM_template.nii.gz +0 -0
  176. junifer/datagrabber/pattern_validation_mixin.py +0 -388
  177. junifer/datagrabber/tests/test_pattern_validation_mixin.py +0 -249
  178. junifer/external/BrainPrint/brainprint/__init__.py +0 -4
  179. junifer/external/BrainPrint/brainprint/_version.py +0 -3
  180. junifer/external/BrainPrint/brainprint/asymmetry.py +0 -91
  181. junifer/external/BrainPrint/brainprint/brainprint.py +0 -441
  182. junifer/external/BrainPrint/brainprint/surfaces.py +0 -258
  183. junifer/external/BrainPrint/brainprint/utils/__init__.py +0 -1
  184. junifer/external/BrainPrint/brainprint/utils/_config.py +0 -112
  185. junifer/external/BrainPrint/brainprint/utils/utils.py +0 -188
  186. junifer/external/nilearn/junifer_connectivity_measure.py +0 -483
  187. junifer/external/nilearn/tests/test_junifer_connectivity_measure.py +0 -1089
  188. junifer/markers/brainprint.py +0 -459
  189. junifer/markers/tests/test_brainprint.py +0 -58
  190. junifer-0.0.5.dist-info/RECORD +0 -275
  191. {junifer-0.0.5.dist-info → junifer-0.0.5.dev24.dist-info}/AUTHORS.rst +0 -0
  192. {junifer-0.0.5.dist-info → junifer-0.0.5.dev24.dist-info}/LICENSE.md +0 -0
  193. {junifer-0.0.5.dist-info → junifer-0.0.5.dev24.dist-info}/entry_points.txt +0 -0
  194. {junifer-0.0.5.dist-info → junifer-0.0.5.dev24.dist-info}/top_level.txt +0 -0
@@ -7,74 +7,60 @@
7
7
  from abc import abstractmethod
8
8
  from typing import Any, ClassVar, Dict, List, Optional, Set, Union
9
9
 
10
- from sklearn.covariance import EmpiricalCovariance, LedoitWolf
10
+ from nilearn.connectome import ConnectivityMeasure
11
+ from sklearn.covariance import EmpiricalCovariance
11
12
 
12
- from ...external.nilearn import JuniferConnectivityMeasure
13
13
  from ...utils import raise_error
14
14
  from ..base import BaseMarker
15
15
 
16
16
 
17
- __all__ = ["FunctionalConnectivityBase"]
18
-
19
-
20
17
  class FunctionalConnectivityBase(BaseMarker):
21
18
  """Abstract base class for functional connectivity markers.
22
19
 
23
20
  Parameters
24
21
  ----------
25
22
  agg_method : str, optional
26
- The method to perform aggregation using.
27
- Check valid options in :func:`.get_aggfunc_by_name`
28
- (default "mean").
23
+ The method to perform aggregation using. Check valid options in
24
+ :func:`.get_aggfunc_by_name` (default "mean").
29
25
  agg_method_params : dict, optional
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).
26
+ Parameters to pass to the aggregation function. Check valid options in
27
+ :func:`.get_aggfunc_by_name` (default None).
28
+ cor_method : str, optional
29
+ The method to perform correlation using. Check valid options in
30
+ :class:`nilearn.connectome.ConnectivityMeasure`
31
+ (default "covariance").
32
+ cor_method_params : dict, optional
33
+ Parameters to pass to the correlation function. Check valid options in
34
+ :class:`nilearn.connectome.ConnectivityMeasure` (default None).
44
35
  masks : str, dict or list of dict or str, optional
45
36
  The specification of the masks to apply to regions before extracting
46
37
  signals. Check :ref:`Using Masks <using_masks>` for more details.
47
38
  If None, will not apply any mask (default None).
48
39
  name : str, optional
49
- The name of the marker. If None, will use ``BOLD_<class_name>``
50
- (default None).
40
+ The name of the marker. If None, will use the class name (default
41
+ None).
51
42
 
52
43
  """
53
44
 
54
45
  _DEPENDENCIES: ClassVar[Set[str]] = {"nilearn", "scikit-learn"}
55
46
 
56
- _MARKER_INOUT_MAPPINGS: ClassVar[Dict[str, Dict[str, str]]] = {
57
- "BOLD": {
58
- "functional_connectivity": "matrix",
59
- },
60
- }
61
-
62
47
  def __init__(
63
48
  self,
64
49
  agg_method: str = "mean",
65
50
  agg_method_params: Optional[Dict] = None,
66
- conn_method: str = "correlation",
67
- conn_method_params: Optional[Dict] = None,
51
+ cor_method: str = "covariance",
52
+ cor_method_params: Optional[Dict] = None,
68
53
  masks: Union[str, Dict, List[Union[Dict, str]], None] = None,
69
54
  name: Optional[str] = None,
70
55
  ) -> None:
71
56
  self.agg_method = agg_method
72
57
  self.agg_method_params = agg_method_params
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
58
+ self.cor_method = cor_method
59
+ self.cor_method_params = cor_method_params or {}
60
+
61
+ # default to nilearn behavior
62
+ self.cor_method_params["empirical"] = self.cor_method_params.get(
63
+ "empirical", False
78
64
  )
79
65
  self.masks = masks
80
66
  super().__init__(on="BOLD", name=name)
@@ -91,6 +77,33 @@ class FunctionalConnectivityBase(BaseMarker):
91
77
  klass=NotImplementedError,
92
78
  )
93
79
 
80
+ def get_valid_inputs(self) -> List[str]:
81
+ """Get valid data types for input.
82
+
83
+ Returns
84
+ -------
85
+ list of str
86
+ The list of data types that can be used as input for this marker.
87
+
88
+ """
89
+ return ["BOLD"]
90
+
91
+ def get_output_type(self, input_type: str) -> str:
92
+ """Get output type.
93
+
94
+ Parameters
95
+ ----------
96
+ input_type : str
97
+ The data type input to the marker.
98
+
99
+ Returns
100
+ -------
101
+ str
102
+ The storage type output by the marker.
103
+
104
+ """
105
+ return "matrix"
106
+
94
107
  def compute(
95
108
  self,
96
109
  input: Dict[str, Any],
@@ -112,44 +125,30 @@ class FunctionalConnectivityBase(BaseMarker):
112
125
  Returns
113
126
  -------
114
127
  dict
115
- The computed result as dictionary. This will be either returned
116
- to the user or stored in the storage by calling the store method
117
- with this as a parameter. The dictionary has the following keys:
118
-
119
- * ``functional_connectivity`` : dictionary with the following keys:
128
+ The computed result as dictionary. The following keys will be
129
+ included in the dictionary:
120
130
 
121
- - ``data`` : functional connectivity matrix as ``numpy.ndarray``
122
- - ``row_names`` : ROI labels as list of str
123
- - ``col_names`` : ROI labels as list of str
124
- - ``matrix_kind`` : the kind of matrix (tril, triu or full)
131
+ * ``data`` : functional connectivity matrix as a ``numpy.ndarray``.
132
+ * ``row_names`` : row names as a list
133
+ * ``col_names`` : column names as a list
134
+ * ``matrix_kind`` : the kind of matrix (tril, triu or full)
125
135
 
126
136
  """
127
137
  # Perform necessary aggregation
128
138
  aggregation = self.aggregate(input, extra_input=extra_input)
129
- # Set covariance estimator
130
- if self.conn_method_params["empirical"]:
131
- cov_estimator = EmpiricalCovariance(store_precision=False)
132
- else:
133
- cov_estimator = LedoitWolf(store_precision=False)
134
139
  # 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
- )
140
+ if self.cor_method_params["empirical"]:
141
+ connectivity = ConnectivityMeasure(
142
+ cov_estimator=EmpiricalCovariance(), # type: ignore
143
+ kind=self.cor_method,
144
+ )
145
+ else:
146
+ connectivity = ConnectivityMeasure(kind=self.cor_method)
144
147
  # Create dictionary for output
145
- return {
146
- "functional_connectivity": {
147
- "data": connectivity.fit_transform(
148
- [aggregation["aggregation"]["data"]]
149
- )[0],
150
- # Create column names
151
- "row_names": aggregation["aggregation"]["col_names"],
152
- "col_names": aggregation["aggregation"]["col_names"],
153
- "matrix_kind": "tril",
154
- },
155
- }
148
+ out = {}
149
+ out["data"] = connectivity.fit_transform([aggregation["data"]])[0]
150
+ # Create column names
151
+ out["row_names"] = aggregation["col_names"]
152
+ out["col_names"] = aggregation["col_names"]
153
+ out["matrix_kind"] = "tril"
154
+ return out
@@ -12,9 +12,6 @@ from ..parcel_aggregation import ParcelAggregation
12
12
  from .functional_connectivity_base import FunctionalConnectivityBase
13
13
 
14
14
 
15
- __all__ = ["FunctionalConnectivityParcels"]
16
-
17
-
18
15
  @register_marker
19
16
  class FunctionalConnectivityParcels(FunctionalConnectivityBase):
20
17
  """Class for functional connectivity using parcellations.
@@ -22,34 +19,28 @@ class FunctionalConnectivityParcels(FunctionalConnectivityBase):
22
19
  Parameters
23
20
  ----------
24
21
  parcellation : str or list of str
25
- The name(s) of the parcellation(s) to use.
26
- See :func:`.list_parcellations` for options.
22
+ The name(s) of the parcellation(s). Check valid options by calling
23
+ :func:`.list_parcellations`.
27
24
  agg_method : str, optional
28
- The method to perform aggregation using.
29
- See :func:`.get_aggfunc_by_name` for options
30
- (default "mean").
25
+ The method to perform aggregation using. Check valid options in
26
+ :func:`.get_aggfunc_by_name` (default "mean").
31
27
  agg_method_params : dict, optional
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).
28
+ Parameters to pass to the aggregation function. Check valid options in
29
+ :func:`.get_aggfunc_by_name` (default None).
30
+ cor_method : str, optional
31
+ The method to perform correlation using. Check valid options in
32
+ :class:`nilearn.connectome.ConnectivityMeasure`
33
+ (default "covariance").
34
+ cor_method_params : dict, optional
35
+ Parameters to pass to the correlation function. Check valid options in
36
+ :class:`nilearn.connectome.ConnectivityMeasure` (default None).
46
37
  masks : str, dict or list of dict or str, optional
47
38
  The specification of the masks to apply to regions before extracting
48
39
  signals. Check :ref:`Using Masks <using_masks>` for more details.
49
40
  If None, will not apply any mask (default None).
50
41
  name : str, optional
51
- The name of the marker. If None, will use
52
- ``BOLD_FunctionalConnectivityParcels`` (default None).
42
+ The name of the marker. If None, will use the class name (default
43
+ None).
53
44
 
54
45
  """
55
46
 
@@ -58,8 +49,8 @@ class FunctionalConnectivityParcels(FunctionalConnectivityBase):
58
49
  parcellation: Union[str, List[str]],
59
50
  agg_method: str = "mean",
60
51
  agg_method_params: Optional[Dict] = None,
61
- conn_method: str = "correlation",
62
- conn_method_params: Optional[Dict] = None,
52
+ cor_method: str = "covariance",
53
+ cor_method_params: Optional[Dict] = None,
63
54
  masks: Union[str, Dict, List[Union[Dict, str]], None] = None,
64
55
  name: Optional[str] = None,
65
56
  ) -> None:
@@ -67,8 +58,8 @@ class FunctionalConnectivityParcels(FunctionalConnectivityBase):
67
58
  super().__init__(
68
59
  agg_method=agg_method,
69
60
  agg_method_params=agg_method_params,
70
- conn_method=conn_method,
71
- conn_method_params=conn_method_params,
61
+ cor_method=cor_method,
62
+ cor_method_params=cor_method_params,
72
63
  masks=masks,
73
64
  name=name,
74
65
  )
@@ -96,16 +87,16 @@ class FunctionalConnectivityParcels(FunctionalConnectivityBase):
96
87
  to the user or stored in the storage by calling the store method
97
88
  with this as a parameter. The dictionary has the following keys:
98
89
 
99
- * ``aggregation`` : dictionary with the following keys:
100
-
101
- - ``data`` : ROI values as ``numpy.ndarray``
102
- - ``col_names`` : ROI labels as list of str
90
+ * ``data`` : the actual computed values as a numpy.ndarray
91
+ * ``col_names`` : the column labels for the computed values as list
103
92
 
104
93
  """
105
- return ParcelAggregation(
94
+ parcel_aggregation = ParcelAggregation(
106
95
  parcellation=self.parcellation,
107
96
  method=self.agg_method,
108
97
  method_params=self.agg_method_params,
109
98
  masks=self.masks,
110
99
  on="BOLD",
111
- ).compute(input=input, extra_input=extra_input)
100
+ )
101
+ # Return the 2D timeseries after parcel aggregation
102
+ return parcel_aggregation.compute(input, extra_input=extra_input)
@@ -13,9 +13,6 @@ from ..utils import raise_error
13
13
  from .functional_connectivity_base import FunctionalConnectivityBase
14
14
 
15
15
 
16
- __all__ = ["FunctionalConnectivitySpheres"]
17
-
18
-
19
16
  @register_marker
20
17
  class FunctionalConnectivitySpheres(FunctionalConnectivityBase):
21
18
  """Class for functional connectivity using coordinates (spheres).
@@ -23,42 +20,35 @@ class FunctionalConnectivitySpheres(FunctionalConnectivityBase):
23
20
  Parameters
24
21
  ----------
25
22
  coords : str
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).
23
+ The name of the coordinates list to use. See
24
+ :func:`.list_coordinates` for options.
25
+ radius : float, optional
26
+ The radius of the sphere in mm. If None, the signal will be extracted
27
+ from a single voxel. See :class:`nilearn.maskers.NiftiSpheresMasker`
28
+ for more information (default None).
33
29
  allow_overlap : bool, optional
34
30
  Whether to allow overlapping spheres. If False, an error is raised if
35
- the spheres overlap (default False).
31
+ the spheres overlap (default is False).
36
32
  agg_method : str, optional
37
- The method to perform aggregation using.
38
- See :func:`.get_aggfunc_by_name` for options
39
- (default "mean").
40
- agg_method_params : dict, optional
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
33
+ The aggregation method to use.
34
+ See :func:`.get_aggfunc_by_name` for more information
54
35
  (default None).
36
+ agg_method_params : dict, optional
37
+ The parameters to pass to the aggregation method (default None).
38
+ cor_method : str, optional
39
+ The method to perform correlation using. Check valid options in
40
+ :class:`nilearn.connectome.ConnectivityMeasure` (default "covariance").
41
+ cor_method_params : dict, optional
42
+ Parameters to pass to the correlation function. Check valid options in
43
+ :class:`nilearn.connectome.ConnectivityMeasure` (default None).
55
44
  masks : str, dict or list of dict or str, optional
56
45
  The specification of the masks to apply to regions before extracting
57
46
  signals. Check :ref:`Using Masks <using_masks>` for more details.
58
47
  If None, will not apply any mask (default None).
59
48
  name : str, optional
60
- The name of the marker. If None, will use
61
- ``BOLD_FunctionalConnectivitySpheres`` (default None).
49
+ The name of the marker. By default, it will use
50
+ KIND_FunctionalConnectivitySpheres where KIND is the kind of data it
51
+ was applied to (default None).
62
52
 
63
53
  """
64
54
 
@@ -69,8 +59,8 @@ class FunctionalConnectivitySpheres(FunctionalConnectivityBase):
69
59
  allow_overlap: bool = False,
70
60
  agg_method: str = "mean",
71
61
  agg_method_params: Optional[Dict] = None,
72
- conn_method: str = "correlation",
73
- conn_method_params: Optional[Dict] = None,
62
+ cor_method: str = "covariance",
63
+ cor_method_params: Optional[Dict] = None,
74
64
  masks: Union[str, Dict, List[Union[Dict, str]], None] = None,
75
65
  name: Optional[str] = None,
76
66
  ) -> None:
@@ -82,8 +72,8 @@ class FunctionalConnectivitySpheres(FunctionalConnectivityBase):
82
72
  super().__init__(
83
73
  agg_method=agg_method,
84
74
  agg_method_params=agg_method_params,
85
- conn_method=conn_method,
86
- conn_method_params=conn_method_params,
75
+ cor_method=cor_method,
76
+ cor_method_params=cor_method_params,
87
77
  masks=masks,
88
78
  name=name,
89
79
  )
@@ -111,13 +101,11 @@ class FunctionalConnectivitySpheres(FunctionalConnectivityBase):
111
101
  to the user or stored in the storage by calling the store method
112
102
  with this as a parameter. The dictionary has the following keys:
113
103
 
114
- * ``aggregation`` : dictionary with the following keys:
115
-
116
- - ``data`` : ROI values as ``numpy.ndarray``
117
- - ``col_names`` : ROI labels as list of str
104
+ * ``data`` : the actual computed values as a numpy.ndarray
105
+ * ``col_names`` : the column labels for the computed values as list
118
106
 
119
107
  """
120
- return SphereAggregation(
108
+ sphere_aggregation = SphereAggregation(
121
109
  coords=self.coords,
122
110
  radius=self.radius,
123
111
  allow_overlap=self.allow_overlap,
@@ -125,4 +113,6 @@ class FunctionalConnectivitySpheres(FunctionalConnectivityBase):
125
113
  method_params=self.agg_method_params,
126
114
  masks=self.masks,
127
115
  on="BOLD",
128
- ).compute(input=input, extra_input=extra_input)
116
+ )
117
+ # Return the 2D timeseries after sphere aggregation
118
+ return sphere_aggregation.compute(input, extra_input=extra_input)
@@ -27,17 +27,16 @@ def test_init() -> None:
27
27
  CrossParcellationFC(
28
28
  parcellation_one="a",
29
29
  parcellation_two="a",
30
- corr_method="pearson",
30
+ correlation_method="pearson",
31
31
  )
32
32
 
33
33
 
34
34
  def test_get_output_type() -> None:
35
35
  """Test CrossParcellationFC get_output_type()."""
36
- assert "matrix" == CrossParcellationFC(
36
+ crossparcellation = CrossParcellationFC(
37
37
  parcellation_one=parcellation_one, parcellation_two=parcellation_two
38
- ).get_output_type(
39
- input_type="BOLD", output_feature="functional_connectivity"
40
38
  )
39
+ assert "matrix" == crossparcellation.get_output_type("BOLD")
41
40
 
42
41
 
43
42
  @pytest.mark.skipif(
@@ -58,11 +57,9 @@ def test_compute(tmp_path: Path) -> None:
58
57
  crossparcellation = CrossParcellationFC(
59
58
  parcellation_one=parcellation_one,
60
59
  parcellation_two=parcellation_two,
61
- corr_method="spearman",
60
+ correlation_method="spearman",
62
61
  )
63
- out = crossparcellation.compute(element_data["BOLD"])[
64
- "functional_connectivity"
65
- ]
62
+ out = crossparcellation.compute(element_data["BOLD"])
66
63
  assert out["data"].shape == (200, 100)
67
64
  assert len(out["col_names"]) == 100
68
65
  assert len(out["row_names"]) == 200
@@ -86,7 +83,7 @@ def test_store(tmp_path: Path) -> None:
86
83
  crossparcellation = CrossParcellationFC(
87
84
  parcellation_one=parcellation_one,
88
85
  parcellation_two=parcellation_two,
89
- corr_method="spearman",
86
+ correlation_method="spearman",
90
87
  )
91
88
  storage = SQLiteFeatureStorage(
92
89
  uri=tmp_path / "test_crossparcellation.sqlite", upsert="ignore"
@@ -95,6 +92,5 @@ def test_store(tmp_path: Path) -> None:
95
92
  crossparcellation.fit_transform(input=element_data, storage=storage)
96
93
  features = storage.list_features()
97
94
  assert any(
98
- x["name"] == "BOLD_CrossParcellationFC_functional_connectivity"
99
- for x in features.values()
95
+ x["name"] == "BOLD_CrossParcellationFC" for x in features.values()
100
96
  )
@@ -5,9 +5,6 @@
5
5
  # License: AGPL
6
6
 
7
7
  from pathlib import Path
8
- from typing import Dict
9
-
10
- import pytest
11
8
 
12
9
  from junifer.datareader import DefaultDataReader
13
10
  from junifer.markers.functional_connectivity import EdgeCentricFCParcels
@@ -15,51 +12,35 @@ from junifer.storage import SQLiteFeatureStorage
15
12
  from junifer.testing.datagrabbers import PartlyCloudyTestingDataGrabber
16
13
 
17
14
 
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:
15
+ def test_EdgeCentricFCParcels(tmp_path: Path) -> None:
29
16
  """Test EdgeCentricFCParcels.
30
17
 
31
18
  Parameters
32
19
  ----------
33
20
  tmp_path : pathlib.Path
34
21
  The path to the test directory.
35
- conn_method_params : dict
36
- The parametrized parameters to connectivity measure method.
37
22
 
38
23
  """
39
24
  with PartlyCloudyTestingDataGrabber() as dg:
40
- # Get element data
41
25
  element_data = DefaultDataReader().fit_transform(dg["sub-01"])
42
- # Setup marker
43
26
  marker = EdgeCentricFCParcels(
44
27
  parcellation="TianxS1x3TxMNInonlinear2009cAsym",
45
- conn_method="correlation",
46
- conn_method_params=conn_method_params,
28
+ cor_method_params={"empirical": True},
47
29
  )
48
30
  # Check correct output
49
- assert "matrix" == marker.get_output_type(
50
- input_type="BOLD", output_feature="functional_connectivity"
51
- )
31
+ assert marker.get_output_type("BOLD") == "matrix"
52
32
 
53
33
  # Fit-transform the data
54
34
  edge_fc = marker.fit_transform(element_data)
55
- edge_fc_bold = edge_fc["BOLD"]["functional_connectivity"]
35
+ edge_fc_bold = edge_fc["BOLD"]
56
36
 
57
37
  # For 16 ROIs we should get (16 * (16 -1) / 2) edges in the ETS
58
38
  n_edges = int(16 * (16 - 1) / 2)
59
39
  assert "data" in edge_fc_bold
60
40
  assert "row_names" in edge_fc_bold
61
41
  assert "col_names" in edge_fc_bold
62
- assert edge_fc_bold["data"].shape == (n_edges, n_edges)
42
+ assert edge_fc_bold["data"].shape[0] == n_edges
43
+ assert edge_fc_bold["data"].shape[1] == n_edges
63
44
  assert len(set(edge_fc_bold["row_names"])) == n_edges
64
45
  assert len(set(edge_fc_bold["col_names"])) == n_edges
65
46
 
@@ -70,6 +51,5 @@ def test_EdgeCentricFCParcels(
70
51
  marker.fit_transform(input=element_data, storage=storage)
71
52
  features = storage.list_features()
72
53
  assert any(
73
- x["name"] == "BOLD_EdgeCentricFCParcels_functional_connectivity"
74
- for x in features.values()
54
+ x["name"] == "BOLD_EdgeCentricFCParcels" for x in features.values()
75
55
  )
@@ -5,9 +5,6 @@
5
5
  # License: AGPL
6
6
 
7
7
  from pathlib import Path
8
- from typing import Dict
9
-
10
- import pytest
11
8
 
12
9
  from junifer.datareader import DefaultDataReader
13
10
  from junifer.markers.functional_connectivity import EdgeCentricFCSpheres
@@ -15,45 +12,26 @@ from junifer.storage import SQLiteFeatureStorage
15
12
  from junifer.testing.datagrabbers import SPMAuditoryTestingDataGrabber
16
13
 
17
14
 
18
- @pytest.mark.parametrize(
19
- "conn_method_params",
20
- [
21
- {"empirical": False},
22
- {"empirical": True},
23
- ],
24
- )
25
- def test_EdgeCentricFCSpheres(
26
- tmp_path: Path,
27
- conn_method_params: Dict[str, bool],
28
- ) -> None:
15
+ def test_EdgeCentricFCSpheres(tmp_path: Path) -> None:
29
16
  """Test EdgeCentricFCSpheres.
30
17
 
31
18
  Parameters
32
19
  ----------
33
20
  tmp_path : pathlib.Path
34
21
  The path to the test directory.
35
- conn_method_params : dict
36
- The parametrized parameters to connectivity measure method.
37
22
 
38
23
  """
39
24
  with SPMAuditoryTestingDataGrabber() as dg:
40
- # Get element data
41
25
  element_data = DefaultDataReader().fit_transform(dg["sub001"])
42
- # Setup marker
43
26
  marker = EdgeCentricFCSpheres(
44
- coords="DMNBuckner",
45
- radius=5.0,
46
- conn_method="correlation",
47
- conn_method_params=conn_method_params,
27
+ coords="DMNBuckner", radius=5.0, cor_method="correlation"
48
28
  )
49
29
  # Check correct output
50
- assert "matrix" == marker.get_output_type(
51
- input_type="BOLD", output_feature="functional_connectivity"
52
- )
30
+ assert marker.get_output_type("BOLD") == "matrix"
53
31
 
54
32
  # Fit-transform the data
55
33
  edge_fc = marker.fit_transform(element_data)
56
- edge_fc_bold = edge_fc["BOLD"]["functional_connectivity"]
34
+ edge_fc_bold = edge_fc["BOLD"]
57
35
 
58
36
  # There are six DMNBuckner coordinates, so
59
37
  # for 6 ROIs we should get (6 * (6 -1) / 2) edges in the ETS
@@ -65,6 +43,13 @@ def test_EdgeCentricFCSpheres(
65
43
  assert len(set(edge_fc_bold["row_names"])) == n_edges
66
44
  assert len(set(edge_fc_bold["col_names"])) == n_edges
67
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
+ )
68
53
  # Store
69
54
  storage = SQLiteFeatureStorage(
70
55
  uri=tmp_path / "test_edge_fc_spheres.sqlite", upsert="ignore"
@@ -72,6 +57,5 @@ def test_EdgeCentricFCSpheres(
72
57
  marker.fit_transform(input=element_data, storage=storage)
73
58
  features = storage.list_features()
74
59
  assert any(
75
- x["name"] == "BOLD_EdgeCentricFCSpheres_functional_connectivity"
76
- for x in features.values()
60
+ x["name"] == "BOLD_EdgeCentricFCSpheres" for x in features.values()
77
61
  )