junifer 0.0.4.dev831__py3-none-any.whl → 0.0.5__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 (206) hide show
  1. junifer/__init__.py +17 -0
  2. junifer/_version.py +2 -2
  3. junifer/api/__init__.py +4 -1
  4. junifer/api/cli.py +91 -1
  5. junifer/api/decorators.py +9 -0
  6. junifer/api/functions.py +56 -10
  7. junifer/api/parser.py +3 -0
  8. junifer/api/queue_context/__init__.py +4 -1
  9. junifer/api/queue_context/gnu_parallel_local_adapter.py +16 -6
  10. junifer/api/queue_context/htcondor_adapter.py +16 -5
  11. junifer/api/queue_context/tests/test_gnu_parallel_local_adapter.py +41 -12
  12. junifer/api/queue_context/tests/test_htcondor_adapter.py +48 -15
  13. junifer/api/res/afni/run_afni_docker.sh +1 -1
  14. junifer/api/res/ants/run_ants_docker.sh +1 -1
  15. junifer/api/res/freesurfer/mri_binarize +3 -0
  16. junifer/api/res/freesurfer/mri_mc +3 -0
  17. junifer/api/res/freesurfer/mri_pretess +3 -0
  18. junifer/api/res/freesurfer/mris_convert +3 -0
  19. junifer/api/res/freesurfer/run_freesurfer_docker.sh +61 -0
  20. junifer/api/res/fsl/run_fsl_docker.sh +1 -1
  21. junifer/api/res/{run_conda.sh → run_conda.bash} +1 -1
  22. junifer/api/res/run_conda.zsh +23 -0
  23. junifer/api/res/run_venv.bash +22 -0
  24. junifer/api/res/{run_venv.sh → run_venv.zsh} +1 -1
  25. junifer/api/tests/test_api_utils.py +4 -2
  26. junifer/api/tests/test_cli.py +83 -0
  27. junifer/api/tests/test_functions.py +27 -2
  28. junifer/configs/__init__.py +1 -1
  29. junifer/configs/juseless/__init__.py +4 -1
  30. junifer/configs/juseless/datagrabbers/__init__.py +10 -1
  31. junifer/configs/juseless/datagrabbers/aomic_id1000_vbm.py +4 -3
  32. junifer/configs/juseless/datagrabbers/camcan_vbm.py +3 -0
  33. junifer/configs/juseless/datagrabbers/ixi_vbm.py +4 -3
  34. junifer/configs/juseless/datagrabbers/tests/test_ucla.py +1 -3
  35. junifer/configs/juseless/datagrabbers/ucla.py +12 -9
  36. junifer/configs/juseless/datagrabbers/ukb_vbm.py +3 -0
  37. junifer/data/__init__.py +21 -1
  38. junifer/data/coordinates.py +10 -19
  39. junifer/data/masks/ukb/UKB_15K_GM_template.nii.gz +0 -0
  40. junifer/data/masks.py +58 -87
  41. junifer/data/parcellations.py +14 -3
  42. junifer/data/template_spaces.py +4 -1
  43. junifer/data/tests/test_masks.py +26 -37
  44. junifer/data/utils.py +3 -0
  45. junifer/datagrabber/__init__.py +18 -1
  46. junifer/datagrabber/aomic/__init__.py +3 -0
  47. junifer/datagrabber/aomic/id1000.py +70 -37
  48. junifer/datagrabber/aomic/piop1.py +69 -36
  49. junifer/datagrabber/aomic/piop2.py +71 -38
  50. junifer/datagrabber/aomic/tests/test_id1000.py +44 -100
  51. junifer/datagrabber/aomic/tests/test_piop1.py +65 -108
  52. junifer/datagrabber/aomic/tests/test_piop2.py +45 -102
  53. junifer/datagrabber/base.py +13 -6
  54. junifer/datagrabber/datalad_base.py +13 -1
  55. junifer/datagrabber/dmcc13_benchmark.py +36 -53
  56. junifer/datagrabber/hcp1200/__init__.py +3 -0
  57. junifer/datagrabber/hcp1200/datalad_hcp1200.py +3 -0
  58. junifer/datagrabber/hcp1200/hcp1200.py +4 -1
  59. junifer/datagrabber/multiple.py +45 -6
  60. junifer/datagrabber/pattern.py +170 -62
  61. junifer/datagrabber/pattern_datalad.py +25 -12
  62. junifer/datagrabber/pattern_validation_mixin.py +388 -0
  63. junifer/datagrabber/tests/test_datalad_base.py +4 -4
  64. junifer/datagrabber/tests/test_dmcc13_benchmark.py +46 -19
  65. junifer/datagrabber/tests/test_multiple.py +161 -84
  66. junifer/datagrabber/tests/test_pattern.py +45 -0
  67. junifer/datagrabber/tests/test_pattern_datalad.py +4 -4
  68. junifer/datagrabber/tests/test_pattern_validation_mixin.py +249 -0
  69. junifer/datareader/__init__.py +4 -1
  70. junifer/datareader/default.py +95 -43
  71. junifer/external/BrainPrint/brainprint/__init__.py +4 -0
  72. junifer/external/BrainPrint/brainprint/_version.py +3 -0
  73. junifer/external/BrainPrint/brainprint/asymmetry.py +91 -0
  74. junifer/external/BrainPrint/brainprint/brainprint.py +441 -0
  75. junifer/external/BrainPrint/brainprint/surfaces.py +258 -0
  76. junifer/external/BrainPrint/brainprint/utils/__init__.py +1 -0
  77. junifer/external/BrainPrint/brainprint/utils/_config.py +112 -0
  78. junifer/external/BrainPrint/brainprint/utils/utils.py +188 -0
  79. junifer/external/__init__.py +1 -1
  80. junifer/external/nilearn/__init__.py +5 -1
  81. junifer/external/nilearn/junifer_connectivity_measure.py +483 -0
  82. junifer/external/nilearn/junifer_nifti_spheres_masker.py +23 -9
  83. junifer/external/nilearn/tests/test_junifer_connectivity_measure.py +1089 -0
  84. junifer/external/nilearn/tests/test_junifer_nifti_spheres_masker.py +76 -1
  85. junifer/markers/__init__.py +23 -1
  86. junifer/markers/base.py +68 -28
  87. junifer/markers/brainprint.py +459 -0
  88. junifer/markers/collection.py +10 -2
  89. junifer/markers/complexity/__init__.py +10 -0
  90. junifer/markers/complexity/complexity_base.py +26 -43
  91. junifer/markers/complexity/hurst_exponent.py +3 -0
  92. junifer/markers/complexity/multiscale_entropy_auc.py +3 -0
  93. junifer/markers/complexity/perm_entropy.py +3 -0
  94. junifer/markers/complexity/range_entropy.py +3 -0
  95. junifer/markers/complexity/range_entropy_auc.py +3 -0
  96. junifer/markers/complexity/sample_entropy.py +3 -0
  97. junifer/markers/complexity/tests/test_hurst_exponent.py +11 -3
  98. junifer/markers/complexity/tests/test_multiscale_entropy_auc.py +11 -3
  99. junifer/markers/complexity/tests/test_perm_entropy.py +11 -3
  100. junifer/markers/complexity/tests/test_range_entropy.py +11 -3
  101. junifer/markers/complexity/tests/test_range_entropy_auc.py +11 -3
  102. junifer/markers/complexity/tests/test_sample_entropy.py +11 -3
  103. junifer/markers/complexity/tests/test_weighted_perm_entropy.py +11 -3
  104. junifer/markers/complexity/weighted_perm_entropy.py +3 -0
  105. junifer/markers/ets_rss.py +27 -42
  106. junifer/markers/falff/__init__.py +3 -0
  107. junifer/markers/falff/_afni_falff.py +5 -2
  108. junifer/markers/falff/_junifer_falff.py +3 -0
  109. junifer/markers/falff/falff_base.py +20 -46
  110. junifer/markers/falff/falff_parcels.py +56 -27
  111. junifer/markers/falff/falff_spheres.py +60 -29
  112. junifer/markers/falff/tests/test_falff_parcels.py +39 -23
  113. junifer/markers/falff/tests/test_falff_spheres.py +39 -23
  114. junifer/markers/functional_connectivity/__init__.py +9 -0
  115. junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +63 -60
  116. junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +45 -32
  117. junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +49 -36
  118. junifer/markers/functional_connectivity/functional_connectivity_base.py +71 -70
  119. junifer/markers/functional_connectivity/functional_connectivity_parcels.py +34 -25
  120. junifer/markers/functional_connectivity/functional_connectivity_spheres.py +40 -30
  121. junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py +11 -7
  122. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +27 -7
  123. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +28 -12
  124. junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +35 -11
  125. junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +36 -62
  126. junifer/markers/parcel_aggregation.py +47 -61
  127. junifer/markers/reho/__init__.py +3 -0
  128. junifer/markers/reho/_afni_reho.py +5 -2
  129. junifer/markers/reho/_junifer_reho.py +4 -1
  130. junifer/markers/reho/reho_base.py +8 -27
  131. junifer/markers/reho/reho_parcels.py +28 -17
  132. junifer/markers/reho/reho_spheres.py +27 -18
  133. junifer/markers/reho/tests/test_reho_parcels.py +8 -3
  134. junifer/markers/reho/tests/test_reho_spheres.py +8 -3
  135. junifer/markers/sphere_aggregation.py +43 -59
  136. junifer/markers/temporal_snr/__init__.py +3 -0
  137. junifer/markers/temporal_snr/temporal_snr_base.py +23 -32
  138. junifer/markers/temporal_snr/temporal_snr_parcels.py +9 -6
  139. junifer/markers/temporal_snr/temporal_snr_spheres.py +9 -6
  140. junifer/markers/temporal_snr/tests/test_temporal_snr_parcels.py +6 -3
  141. junifer/markers/temporal_snr/tests/test_temporal_snr_spheres.py +6 -3
  142. junifer/markers/tests/test_brainprint.py +58 -0
  143. junifer/markers/tests/test_collection.py +9 -8
  144. junifer/markers/tests/test_ets_rss.py +15 -9
  145. junifer/markers/tests/test_markers_base.py +17 -18
  146. junifer/markers/tests/test_parcel_aggregation.py +93 -32
  147. junifer/markers/tests/test_sphere_aggregation.py +72 -19
  148. junifer/onthefly/__init__.py +4 -1
  149. junifer/onthefly/read_transform.py +3 -0
  150. junifer/pipeline/__init__.py +9 -1
  151. junifer/pipeline/pipeline_step_mixin.py +21 -4
  152. junifer/pipeline/registry.py +3 -0
  153. junifer/pipeline/singleton.py +3 -0
  154. junifer/pipeline/tests/test_registry.py +1 -1
  155. junifer/pipeline/update_meta_mixin.py +3 -0
  156. junifer/pipeline/utils.py +67 -1
  157. junifer/pipeline/workdir_manager.py +3 -0
  158. junifer/preprocess/__init__.py +10 -2
  159. junifer/preprocess/base.py +6 -3
  160. junifer/preprocess/confounds/__init__.py +3 -0
  161. junifer/preprocess/confounds/fmriprep_confound_remover.py +47 -60
  162. junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py +72 -113
  163. junifer/preprocess/smoothing/__init__.py +9 -0
  164. junifer/preprocess/smoothing/_afni_smoothing.py +119 -0
  165. junifer/preprocess/smoothing/_fsl_smoothing.py +116 -0
  166. junifer/preprocess/smoothing/_nilearn_smoothing.py +69 -0
  167. junifer/preprocess/smoothing/smoothing.py +174 -0
  168. junifer/preprocess/smoothing/tests/test_smoothing.py +94 -0
  169. junifer/preprocess/warping/__init__.py +3 -0
  170. junifer/preprocess/warping/_ants_warper.py +3 -0
  171. junifer/preprocess/warping/_fsl_warper.py +3 -0
  172. junifer/stats.py +4 -1
  173. junifer/storage/__init__.py +9 -1
  174. junifer/storage/base.py +40 -1
  175. junifer/storage/hdf5.py +71 -9
  176. junifer/storage/pandas_base.py +3 -0
  177. junifer/storage/sqlite.py +3 -0
  178. junifer/storage/tests/test_hdf5.py +82 -10
  179. junifer/storage/utils.py +9 -0
  180. junifer/testing/__init__.py +4 -1
  181. junifer/testing/datagrabbers.py +13 -6
  182. junifer/testing/tests/test_partlycloudytesting_datagrabber.py +7 -7
  183. junifer/testing/utils.py +3 -0
  184. junifer/utils/__init__.py +13 -2
  185. junifer/utils/fs.py +3 -0
  186. junifer/utils/helpers.py +32 -1
  187. junifer/utils/logging.py +33 -4
  188. junifer/utils/tests/test_logging.py +8 -0
  189. {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/METADATA +17 -16
  190. junifer-0.0.5.dist-info/RECORD +275 -0
  191. {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/WHEEL +1 -1
  192. junifer/datagrabber/tests/test_datagrabber_utils.py +0 -218
  193. junifer/datagrabber/utils.py +0 -230
  194. junifer/preprocess/ants/__init__.py +0 -4
  195. junifer/preprocess/ants/ants_apply_transforms_warper.py +0 -185
  196. junifer/preprocess/ants/tests/test_ants_apply_transforms_warper.py +0 -56
  197. junifer/preprocess/bold_warper.py +0 -265
  198. junifer/preprocess/fsl/__init__.py +0 -4
  199. junifer/preprocess/fsl/apply_warper.py +0 -179
  200. junifer/preprocess/fsl/tests/test_apply_warper.py +0 -45
  201. junifer/preprocess/tests/test_bold_warper.py +0 -159
  202. junifer-0.0.4.dev831.dist-info/RECORD +0 -257
  203. {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/AUTHORS.rst +0 -0
  204. {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/LICENSE.md +0 -0
  205. {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/entry_points.txt +0 -0
  206. {junifer-0.0.4.dev831.dist-info → junifer-0.0.5.dist-info}/top_level.txt +0 -0
@@ -12,6 +12,9 @@ from ..utils import _ets
12
12
  from .functional_connectivity_base import FunctionalConnectivityBase
13
13
 
14
14
 
15
+ __all__ = ["EdgeCentricFCParcels"]
16
+
17
+
15
18
  @register_marker
16
19
  class EdgeCentricFCParcels(FunctionalConnectivityBase):
17
20
  """Class for edge-centric FC using parcellations.
@@ -19,36 +22,40 @@ class EdgeCentricFCParcels(FunctionalConnectivityBase):
19
22
  Parameters
20
23
  ----------
21
24
  parcellation : str or list of str
22
- The name(s) of the parcellation(s). Check valid options by calling
23
- :func:`.list_parcellations`.
25
+ The name(s) of the parcellation(s) to use.
26
+ See :func:`.list_parcellations` for options.
24
27
  agg_method : str, optional
25
- The method to perform aggregation of BOLD time series.
26
- 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
27
30
  (default "mean").
28
31
  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. 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).
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).
38
46
  masks : str, dict or list of dict or str, optional
39
47
  The specification of the masks to apply to regions before extracting
40
48
  signals. Check :ref:`Using Masks <using_masks>` for more details.
41
49
  If None, will not apply any mask (default None).
42
50
  name : str, optional
43
- The name of the marker. If None, will use the class name (default
44
- None).
51
+ The name of the marker. If None, will use
52
+ ``BOLD_EdgeCentricFCParcels`` (default None).
45
53
 
46
54
  References
47
55
  ----------
48
56
  .. [1] Jo et al. (2021)
49
- Subject identification using
50
- edge-centric functional connectivity
51
- 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
52
59
 
53
60
  """
54
61
 
@@ -57,8 +64,8 @@ class EdgeCentricFCParcels(FunctionalConnectivityBase):
57
64
  parcellation: Union[str, List[str]],
58
65
  agg_method: str = "mean",
59
66
  agg_method_params: Optional[Dict] = None,
60
- cor_method: str = "covariance",
61
- cor_method_params: Optional[Dict] = None,
67
+ conn_method: str = "correlation",
68
+ conn_method_params: Optional[Dict] = None,
62
69
  masks: Union[str, Dict, List[Union[Dict, str]], None] = None,
63
70
  name: Optional[str] = None,
64
71
  ) -> None:
@@ -66,8 +73,8 @@ class EdgeCentricFCParcels(FunctionalConnectivityBase):
66
73
  super().__init__(
67
74
  agg_method=agg_method,
68
75
  agg_method_params=agg_method_params,
69
- cor_method=cor_method,
70
- cor_method_params=cor_method_params,
76
+ conn_method=conn_method,
77
+ conn_method_params=conn_method_params,
71
78
  masks=masks,
72
79
  name=name,
73
80
  )
@@ -95,23 +102,29 @@ class EdgeCentricFCParcels(FunctionalConnectivityBase):
95
102
  to the user or stored in the storage by calling the store method
96
103
  with this as a parameter. The dictionary has the following keys:
97
104
 
98
- * ``data`` : the actual computed values as a numpy.ndarray
99
- * ``col_names`` : the column labels for the computed values as list
105
+ * ``aggregation`` : dictionary with the following keys:
106
+
107
+ - ``data`` : ROI values as ``numpy.ndarray``
108
+ - ``col_names`` : ROI labels as list of str
100
109
 
101
110
  """
102
- parcel_aggregation = ParcelAggregation(
111
+ # Perform aggregation
112
+ aggregation = ParcelAggregation(
103
113
  parcellation=self.parcellation,
104
114
  method=self.agg_method,
105
115
  method_params=self.agg_method_params,
106
116
  masks=self.masks,
107
117
  on="BOLD",
108
- )
109
-
110
- bold_aggregated = parcel_aggregation.compute(
111
- input, extra_input=extra_input
112
- )
118
+ ).compute(input, extra_input=extra_input)
119
+ # Compute edgewise timeseries
113
120
  ets, edge_names = _ets(
114
- bold_aggregated["data"], bold_aggregated["col_names"]
121
+ bold_ts=aggregation["aggregation"]["data"],
122
+ roi_names=aggregation["aggregation"]["col_names"],
115
123
  )
116
124
 
117
- return {"data": ets, "col_names": edge_names}
125
+ return {
126
+ "aggregation": {
127
+ "data": ets,
128
+ "col_names": edge_names,
129
+ },
130
+ }
@@ -12,6 +12,9 @@ from ..utils import _ets, raise_error
12
12
  from .functional_connectivity_base import FunctionalConnectivityBase
13
13
 
14
14
 
15
+ __all__ = ["EdgeCentricFCSpheres"]
16
+
17
+
15
18
  @register_marker
16
19
  class EdgeCentricFCSpheres(FunctionalConnectivityBase):
17
20
  """Class for edge-centric FC using coordinates (spheres).
@@ -19,42 +22,48 @@ class EdgeCentricFCSpheres(FunctionalConnectivityBase):
19
22
  Parameters
20
23
  ----------
21
24
  coords : str
22
- The name of the coordinates list to use. See
23
- :func:`.list_coordinates` for options.
24
- radius : float, optional
25
- The radius of the sphere in mm. If None, the signal will be extracted
26
- from a single voxel. See :class:`nilearn.maskers.NiftiSpheresMasker`
27
- 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).
28
32
  allow_overlap : bool, optional
29
33
  Whether to allow overlapping spheres. If False, an error is raised if
30
- the spheres overlap (default is False).
34
+ the spheres overlap (default False).
31
35
  agg_method : str, optional
32
- The aggregation method to use.
33
- See :func:`.get_aggfunc_by_name` for more information
34
- (default None).
36
+ The method to perform aggregation using.
37
+ See :func:`.get_aggfunc_by_name` for options
38
+ (default "mean").
35
39
  agg_method_params : dict, optional
36
- The parameters to pass to the aggregation method (default None).
37
- cor_method : str, optional
38
- The method to perform correlation using. Check valid options in
39
- :class:`nilearn.connectome.ConnectivityMeasure` (default "covariance").
40
- cor_method_params : dict, optional
41
- Parameters to pass to the correlation function. Check valid options in
42
- :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).
43
54
  masks : str, dict or list of dict or str, optional
44
55
  The specification of the masks to apply to regions before extracting
45
56
  signals. Check :ref:`Using Masks <using_masks>` for more details.
46
57
  If None, will not apply any mask (default None).
47
58
  name : str, optional
48
- The name of the marker. By default, it will use
49
- KIND_EdgeCentricFCSpheres where KIND is the kind of data it
50
- was applied to (default None).
59
+ The name of the marker. If None, will use
60
+ ``BOLD_EdgeCentricFCSpheres`` (default None).
51
61
 
52
62
  References
53
63
  ----------
54
64
  .. [1] Jo et al. (2021)
55
- Subject identification using
56
- edge-centric functional connectivity
57
- 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
58
67
 
59
68
  """
60
69
 
@@ -65,8 +74,8 @@ class EdgeCentricFCSpheres(FunctionalConnectivityBase):
65
74
  allow_overlap: bool = False,
66
75
  agg_method: str = "mean",
67
76
  agg_method_params: Optional[Dict] = None,
68
- cor_method: str = "covariance",
69
- cor_method_params: Optional[Dict] = None,
77
+ conn_method: str = "correlation",
78
+ conn_method_params: Optional[Dict] = None,
70
79
  masks: Union[str, Dict, List[Union[Dict, str]], None] = None,
71
80
  name: Optional[str] = None,
72
81
  ) -> None:
@@ -78,8 +87,8 @@ class EdgeCentricFCSpheres(FunctionalConnectivityBase):
78
87
  super().__init__(
79
88
  agg_method=agg_method,
80
89
  agg_method_params=agg_method_params,
81
- cor_method=cor_method,
82
- cor_method_params=cor_method_params,
90
+ conn_method=conn_method,
91
+ conn_method_params=conn_method_params,
83
92
  masks=masks,
84
93
  name=name,
85
94
  )
@@ -107,11 +116,14 @@ class EdgeCentricFCSpheres(FunctionalConnectivityBase):
107
116
  to the user or stored in the storage by calling the store method
108
117
  with this as a parameter. The dictionary has the following keys:
109
118
 
110
- * ``data`` : the actual computed values as a numpy.ndarray
111
- * ``col_names`` : the column labels for the computed values as list
119
+ * ``aggregation`` : dictionary with the following keys:
120
+
121
+ - ``data`` : ROI values as ``numpy.ndarray``
122
+ - ``col_names`` : ROI labels as list of str
112
123
 
113
124
  """
114
- sphere_aggregation = SphereAggregation(
125
+ # Perform aggregation
126
+ aggregation = SphereAggregation(
115
127
  coords=self.coords,
116
128
  radius=self.radius,
117
129
  allow_overlap=self.allow_overlap,
@@ -119,12 +131,13 @@ class EdgeCentricFCSpheres(FunctionalConnectivityBase):
119
131
  method_params=self.agg_method_params,
120
132
  masks=self.masks,
121
133
  on="BOLD",
122
- )
123
- bold_aggregated = sphere_aggregation.compute(
124
- input, extra_input=extra_input
125
- )
134
+ ).compute(input, extra_input=extra_input)
135
+ # Compute edgewise timeseries
126
136
  ets, edge_names = _ets(
127
- bold_aggregated["data"], bold_aggregated["col_names"]
137
+ bold_ts=aggregation["aggregation"]["data"],
138
+ roi_names=aggregation["aggregation"]["col_names"],
128
139
  )
129
140
 
130
- return {"data": ets, "col_names": edge_names}
141
+ return {
142
+ "aggregation": {"data": ets, "col_names": edge_names},
143
+ }
@@ -7,60 +7,74 @@
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
 
16
16
 
17
+ __all__ = ["FunctionalConnectivityBase"]
18
+
19
+
17
20
  class FunctionalConnectivityBase(BaseMarker):
18
21
  """Abstract base class for functional connectivity markers.
19
22
 
20
23
  Parameters
21
24
  ----------
22
25
  agg_method : str, optional
23
- The method to perform aggregation using. Check valid options in
24
- :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").
25
29
  agg_method_params : dict, optional
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).
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).
35
44
  masks : str, dict or list of dict or str, optional
36
45
  The specification of the masks to apply to regions before extracting
37
46
  signals. Check :ref:`Using Masks <using_masks>` for more details.
38
47
  If None, will not apply any mask (default None).
39
48
  name : str, optional
40
- The name of the marker. If None, will use the class name (default
41
- None).
49
+ The name of the marker. If None, will use ``BOLD_<class_name>``
50
+ (default None).
42
51
 
43
52
  """
44
53
 
45
54
  _DEPENDENCIES: ClassVar[Set[str]] = {"nilearn", "scikit-learn"}
46
55
 
56
+ _MARKER_INOUT_MAPPINGS: ClassVar[Dict[str, Dict[str, str]]] = {
57
+ "BOLD": {
58
+ "functional_connectivity": "matrix",
59
+ },
60
+ }
61
+
47
62
  def __init__(
48
63
  self,
49
64
  agg_method: str = "mean",
50
65
  agg_method_params: Optional[Dict] = None,
51
- cor_method: str = "covariance",
52
- cor_method_params: Optional[Dict] = None,
66
+ conn_method: str = "correlation",
67
+ conn_method_params: Optional[Dict] = None,
53
68
  masks: Union[str, Dict, List[Union[Dict, str]], None] = None,
54
69
  name: Optional[str] = None,
55
70
  ) -> None:
56
71
  self.agg_method = agg_method
57
72
  self.agg_method_params = agg_method_params
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
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
64
78
  )
65
79
  self.masks = masks
66
80
  super().__init__(on="BOLD", name=name)
@@ -77,33 +91,6 @@ class FunctionalConnectivityBase(BaseMarker):
77
91
  klass=NotImplementedError,
78
92
  )
79
93
 
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
-
107
94
  def compute(
108
95
  self,
109
96
  input: Dict[str, Any],
@@ -125,30 +112,44 @@ class FunctionalConnectivityBase(BaseMarker):
125
112
  Returns
126
113
  -------
127
114
  dict
128
- The computed result as dictionary. The following keys will be
129
- included in the dictionary:
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:
130
120
 
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)
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)
135
125
 
136
126
  """
137
127
  # Perform necessary aggregation
138
128
  aggregation = self.aggregate(input, extra_input=extra_input)
139
- # Compute correlation
140
- if self.cor_method_params["empirical"]:
141
- connectivity = ConnectivityMeasure(
142
- cov_estimator=EmpiricalCovariance(), # type: ignore
143
- kind=self.cor_method,
144
- )
129
+ # Set covariance estimator
130
+ if self.conn_method_params["empirical"]:
131
+ cov_estimator = EmpiricalCovariance(store_precision=False)
145
132
  else:
146
- 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
+ )
147
144
  # Create dictionary for output
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
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
+ }
@@ -12,6 +12,9 @@ from ..parcel_aggregation import ParcelAggregation
12
12
  from .functional_connectivity_base import FunctionalConnectivityBase
13
13
 
14
14
 
15
+ __all__ = ["FunctionalConnectivityParcels"]
16
+
17
+
15
18
  @register_marker
16
19
  class FunctionalConnectivityParcels(FunctionalConnectivityBase):
17
20
  """Class for functional connectivity using parcellations.
@@ -19,28 +22,34 @@ class FunctionalConnectivityParcels(FunctionalConnectivityBase):
19
22
  Parameters
20
23
  ----------
21
24
  parcellation : str or list of str
22
- The name(s) of the parcellation(s). Check valid options by calling
23
- :func:`.list_parcellations`.
25
+ The name(s) of the parcellation(s) to use.
26
+ See :func:`.list_parcellations` for options.
24
27
  agg_method : str, optional
25
- The method to perform aggregation using. Check valid options in
26
- :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").
27
31
  agg_method_params : dict, optional
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).
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).
37
46
  masks : str, dict or list of dict or str, optional
38
47
  The specification of the masks to apply to regions before extracting
39
48
  signals. Check :ref:`Using Masks <using_masks>` for more details.
40
49
  If None, will not apply any mask (default None).
41
50
  name : str, optional
42
- The name of the marker. If None, will use the class name (default
43
- None).
51
+ The name of the marker. If None, will use
52
+ ``BOLD_FunctionalConnectivityParcels`` (default None).
44
53
 
45
54
  """
46
55
 
@@ -49,8 +58,8 @@ class FunctionalConnectivityParcels(FunctionalConnectivityBase):
49
58
  parcellation: Union[str, List[str]],
50
59
  agg_method: str = "mean",
51
60
  agg_method_params: Optional[Dict] = None,
52
- cor_method: str = "covariance",
53
- cor_method_params: Optional[Dict] = None,
61
+ conn_method: str = "correlation",
62
+ conn_method_params: Optional[Dict] = None,
54
63
  masks: Union[str, Dict, List[Union[Dict, str]], None] = None,
55
64
  name: Optional[str] = None,
56
65
  ) -> None:
@@ -58,8 +67,8 @@ class FunctionalConnectivityParcels(FunctionalConnectivityBase):
58
67
  super().__init__(
59
68
  agg_method=agg_method,
60
69
  agg_method_params=agg_method_params,
61
- cor_method=cor_method,
62
- cor_method_params=cor_method_params,
70
+ conn_method=conn_method,
71
+ conn_method_params=conn_method_params,
63
72
  masks=masks,
64
73
  name=name,
65
74
  )
@@ -87,16 +96,16 @@ class FunctionalConnectivityParcels(FunctionalConnectivityBase):
87
96
  to the user or stored in the storage by calling the store method
88
97
  with this as a parameter. The dictionary has the following keys:
89
98
 
90
- * ``data`` : the actual computed values as a numpy.ndarray
91
- * ``col_names`` : the column labels for the computed values as list
99
+ * ``aggregation`` : dictionary with the following keys:
100
+
101
+ - ``data`` : ROI values as ``numpy.ndarray``
102
+ - ``col_names`` : ROI labels as list of str
92
103
 
93
104
  """
94
- parcel_aggregation = ParcelAggregation(
105
+ return ParcelAggregation(
95
106
  parcellation=self.parcellation,
96
107
  method=self.agg_method,
97
108
  method_params=self.agg_method_params,
98
109
  masks=self.masks,
99
110
  on="BOLD",
100
- )
101
- # Return the 2D timeseries after parcel aggregation
102
- return parcel_aggregation.compute(input, extra_input=extra_input)
111
+ ).compute(input=input, extra_input=extra_input)