junifer 0.0.4.dev829__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.
- junifer/__init__.py +17 -0
- junifer/_version.py +2 -2
- junifer/api/__init__.py +4 -1
- junifer/api/cli.py +91 -1
- junifer/api/decorators.py +9 -0
- junifer/api/functions.py +56 -10
- junifer/api/parser.py +3 -0
- junifer/api/queue_context/__init__.py +4 -1
- junifer/api/queue_context/gnu_parallel_local_adapter.py +16 -6
- junifer/api/queue_context/htcondor_adapter.py +16 -5
- junifer/api/queue_context/tests/test_gnu_parallel_local_adapter.py +41 -12
- junifer/api/queue_context/tests/test_htcondor_adapter.py +48 -15
- junifer/api/res/afni/run_afni_docker.sh +1 -1
- junifer/api/res/ants/run_ants_docker.sh +1 -1
- junifer/api/res/freesurfer/mri_binarize +3 -0
- junifer/api/res/freesurfer/mri_mc +3 -0
- junifer/api/res/freesurfer/mri_pretess +3 -0
- junifer/api/res/freesurfer/mris_convert +3 -0
- junifer/api/res/freesurfer/run_freesurfer_docker.sh +61 -0
- junifer/api/res/fsl/run_fsl_docker.sh +1 -1
- junifer/api/res/{run_conda.sh → run_conda.bash} +1 -1
- junifer/api/res/run_conda.zsh +23 -0
- junifer/api/res/run_venv.bash +22 -0
- junifer/api/res/{run_venv.sh → run_venv.zsh} +1 -1
- junifer/api/tests/test_api_utils.py +4 -2
- junifer/api/tests/test_cli.py +83 -0
- junifer/api/tests/test_functions.py +27 -2
- junifer/configs/__init__.py +1 -1
- junifer/configs/juseless/__init__.py +4 -1
- junifer/configs/juseless/datagrabbers/__init__.py +10 -1
- junifer/configs/juseless/datagrabbers/aomic_id1000_vbm.py +4 -3
- junifer/configs/juseless/datagrabbers/camcan_vbm.py +3 -0
- junifer/configs/juseless/datagrabbers/ixi_vbm.py +4 -3
- junifer/configs/juseless/datagrabbers/tests/test_ucla.py +1 -3
- junifer/configs/juseless/datagrabbers/ucla.py +12 -9
- junifer/configs/juseless/datagrabbers/ukb_vbm.py +3 -0
- junifer/data/__init__.py +21 -1
- junifer/data/coordinates.py +10 -19
- junifer/data/masks/ukb/UKB_15K_GM_template.nii.gz +0 -0
- junifer/data/masks.py +58 -87
- junifer/data/parcellations.py +14 -3
- junifer/data/template_spaces.py +4 -1
- junifer/data/tests/test_masks.py +26 -37
- junifer/data/utils.py +3 -0
- junifer/datagrabber/__init__.py +18 -1
- junifer/datagrabber/aomic/__init__.py +3 -0
- junifer/datagrabber/aomic/id1000.py +70 -37
- junifer/datagrabber/aomic/piop1.py +69 -36
- junifer/datagrabber/aomic/piop2.py +71 -38
- junifer/datagrabber/aomic/tests/test_id1000.py +44 -100
- junifer/datagrabber/aomic/tests/test_piop1.py +65 -108
- junifer/datagrabber/aomic/tests/test_piop2.py +45 -102
- junifer/datagrabber/base.py +13 -6
- junifer/datagrabber/datalad_base.py +13 -1
- junifer/datagrabber/dmcc13_benchmark.py +36 -53
- junifer/datagrabber/hcp1200/__init__.py +3 -0
- junifer/datagrabber/hcp1200/datalad_hcp1200.py +3 -0
- junifer/datagrabber/hcp1200/hcp1200.py +4 -1
- junifer/datagrabber/multiple.py +45 -6
- junifer/datagrabber/pattern.py +170 -62
- junifer/datagrabber/pattern_datalad.py +25 -12
- junifer/datagrabber/pattern_validation_mixin.py +388 -0
- junifer/datagrabber/tests/test_datalad_base.py +4 -4
- junifer/datagrabber/tests/test_dmcc13_benchmark.py +46 -19
- junifer/datagrabber/tests/test_multiple.py +161 -84
- junifer/datagrabber/tests/test_pattern.py +45 -0
- junifer/datagrabber/tests/test_pattern_datalad.py +4 -4
- junifer/datagrabber/tests/test_pattern_validation_mixin.py +249 -0
- junifer/datareader/__init__.py +4 -1
- junifer/datareader/default.py +95 -43
- junifer/external/BrainPrint/brainprint/__init__.py +4 -0
- junifer/external/BrainPrint/brainprint/_version.py +3 -0
- junifer/external/BrainPrint/brainprint/asymmetry.py +91 -0
- junifer/external/BrainPrint/brainprint/brainprint.py +441 -0
- junifer/external/BrainPrint/brainprint/surfaces.py +258 -0
- junifer/external/BrainPrint/brainprint/utils/__init__.py +1 -0
- junifer/external/BrainPrint/brainprint/utils/_config.py +112 -0
- junifer/external/BrainPrint/brainprint/utils/utils.py +188 -0
- junifer/external/__init__.py +1 -1
- junifer/external/nilearn/__init__.py +5 -1
- junifer/external/nilearn/junifer_connectivity_measure.py +483 -0
- junifer/external/nilearn/junifer_nifti_spheres_masker.py +23 -9
- junifer/external/nilearn/tests/test_junifer_connectivity_measure.py +1089 -0
- junifer/external/nilearn/tests/test_junifer_nifti_spheres_masker.py +76 -1
- junifer/markers/__init__.py +23 -1
- junifer/markers/base.py +68 -28
- junifer/markers/brainprint.py +459 -0
- junifer/markers/collection.py +10 -2
- junifer/markers/complexity/__init__.py +10 -0
- junifer/markers/complexity/complexity_base.py +26 -43
- junifer/markers/complexity/hurst_exponent.py +3 -0
- junifer/markers/complexity/multiscale_entropy_auc.py +3 -0
- junifer/markers/complexity/perm_entropy.py +3 -0
- junifer/markers/complexity/range_entropy.py +3 -0
- junifer/markers/complexity/range_entropy_auc.py +3 -0
- junifer/markers/complexity/sample_entropy.py +3 -0
- junifer/markers/complexity/tests/test_hurst_exponent.py +11 -3
- junifer/markers/complexity/tests/test_multiscale_entropy_auc.py +11 -3
- junifer/markers/complexity/tests/test_perm_entropy.py +11 -3
- junifer/markers/complexity/tests/test_range_entropy.py +11 -3
- junifer/markers/complexity/tests/test_range_entropy_auc.py +11 -3
- junifer/markers/complexity/tests/test_sample_entropy.py +11 -3
- junifer/markers/complexity/tests/test_weighted_perm_entropy.py +11 -3
- junifer/markers/complexity/weighted_perm_entropy.py +3 -0
- junifer/markers/ets_rss.py +27 -42
- junifer/markers/falff/__init__.py +3 -0
- junifer/markers/falff/_afni_falff.py +5 -2
- junifer/markers/falff/_junifer_falff.py +3 -0
- junifer/markers/falff/falff_base.py +20 -46
- junifer/markers/falff/falff_parcels.py +56 -27
- junifer/markers/falff/falff_spheres.py +60 -29
- junifer/markers/falff/tests/test_falff_parcels.py +39 -23
- junifer/markers/falff/tests/test_falff_spheres.py +39 -23
- junifer/markers/functional_connectivity/__init__.py +9 -0
- junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +63 -60
- junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +45 -32
- junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +49 -36
- junifer/markers/functional_connectivity/functional_connectivity_base.py +71 -70
- junifer/markers/functional_connectivity/functional_connectivity_parcels.py +34 -25
- junifer/markers/functional_connectivity/functional_connectivity_spheres.py +40 -30
- junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py +11 -7
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +27 -7
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +28 -12
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +35 -11
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +36 -62
- junifer/markers/parcel_aggregation.py +47 -61
- junifer/markers/reho/__init__.py +3 -0
- junifer/markers/reho/_afni_reho.py +5 -2
- junifer/markers/reho/_junifer_reho.py +4 -1
- junifer/markers/reho/reho_base.py +8 -27
- junifer/markers/reho/reho_parcels.py +28 -17
- junifer/markers/reho/reho_spheres.py +27 -18
- junifer/markers/reho/tests/test_reho_parcels.py +8 -3
- junifer/markers/reho/tests/test_reho_spheres.py +8 -3
- junifer/markers/sphere_aggregation.py +43 -59
- junifer/markers/temporal_snr/__init__.py +3 -0
- junifer/markers/temporal_snr/temporal_snr_base.py +23 -32
- junifer/markers/temporal_snr/temporal_snr_parcels.py +9 -6
- junifer/markers/temporal_snr/temporal_snr_spheres.py +9 -6
- junifer/markers/temporal_snr/tests/test_temporal_snr_parcels.py +6 -3
- junifer/markers/temporal_snr/tests/test_temporal_snr_spheres.py +6 -3
- junifer/markers/tests/test_brainprint.py +58 -0
- junifer/markers/tests/test_collection.py +9 -8
- junifer/markers/tests/test_ets_rss.py +15 -9
- junifer/markers/tests/test_markers_base.py +17 -18
- junifer/markers/tests/test_parcel_aggregation.py +93 -32
- junifer/markers/tests/test_sphere_aggregation.py +72 -19
- junifer/onthefly/__init__.py +4 -1
- junifer/onthefly/read_transform.py +3 -0
- junifer/pipeline/__init__.py +9 -1
- junifer/pipeline/pipeline_step_mixin.py +21 -4
- junifer/pipeline/registry.py +3 -0
- junifer/pipeline/singleton.py +3 -0
- junifer/pipeline/tests/test_registry.py +1 -1
- junifer/pipeline/update_meta_mixin.py +3 -0
- junifer/pipeline/utils.py +67 -1
- junifer/pipeline/workdir_manager.py +3 -0
- junifer/preprocess/__init__.py +10 -2
- junifer/preprocess/base.py +6 -3
- junifer/preprocess/confounds/__init__.py +3 -0
- junifer/preprocess/confounds/fmriprep_confound_remover.py +47 -60
- junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py +72 -113
- junifer/preprocess/smoothing/__init__.py +9 -0
- junifer/preprocess/smoothing/_afni_smoothing.py +119 -0
- junifer/preprocess/smoothing/_fsl_smoothing.py +116 -0
- junifer/preprocess/smoothing/_nilearn_smoothing.py +69 -0
- junifer/preprocess/smoothing/smoothing.py +174 -0
- junifer/preprocess/smoothing/tests/test_smoothing.py +94 -0
- junifer/preprocess/warping/__init__.py +3 -0
- junifer/preprocess/warping/_ants_warper.py +3 -0
- junifer/preprocess/warping/_fsl_warper.py +3 -0
- junifer/stats.py +4 -1
- junifer/storage/__init__.py +9 -1
- junifer/storage/base.py +40 -1
- junifer/storage/hdf5.py +71 -9
- junifer/storage/pandas_base.py +3 -0
- junifer/storage/sqlite.py +3 -0
- junifer/storage/tests/test_hdf5.py +82 -10
- junifer/storage/utils.py +9 -0
- junifer/testing/__init__.py +4 -1
- junifer/testing/datagrabbers.py +13 -6
- junifer/testing/tests/test_partlycloudytesting_datagrabber.py +7 -7
- junifer/testing/utils.py +3 -0
- junifer/utils/__init__.py +13 -2
- junifer/utils/fs.py +3 -0
- junifer/utils/helpers.py +32 -1
- junifer/utils/logging.py +33 -4
- junifer/utils/tests/test_logging.py +8 -0
- {junifer-0.0.4.dev829.dist-info → junifer-0.0.5.dist-info}/METADATA +17 -16
- junifer-0.0.5.dist-info/RECORD +275 -0
- {junifer-0.0.4.dev829.dist-info → junifer-0.0.5.dist-info}/WHEEL +1 -1
- junifer/datagrabber/tests/test_datagrabber_utils.py +0 -218
- junifer/datagrabber/utils.py +0 -230
- junifer/preprocess/ants/__init__.py +0 -4
- junifer/preprocess/ants/ants_apply_transforms_warper.py +0 -185
- junifer/preprocess/ants/tests/test_ants_apply_transforms_warper.py +0 -56
- junifer/preprocess/bold_warper.py +0 -265
- junifer/preprocess/fsl/__init__.py +0 -4
- junifer/preprocess/fsl/apply_warper.py +0 -179
- junifer/preprocess/fsl/tests/test_apply_warper.py +0 -45
- junifer/preprocess/tests/test_bold_warper.py +0 -159
- junifer-0.0.4.dev829.dist-info/RECORD +0 -257
- {junifer-0.0.4.dev829.dist-info → junifer-0.0.5.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.4.dev829.dist-info → junifer-0.0.5.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.4.dev829.dist-info → junifer-0.0.5.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.4.dev829.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)
|
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
|
26
|
-
|
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.
|
30
|
-
:func:`.get_aggfunc_by_name`
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
:class
|
32
|
+
Parameters to pass to the aggregation function.
|
33
|
+
See :func:`.get_aggfunc_by_name` for options
|
34
|
+
(default None).
|
35
|
+
conn_method : str, optional
|
36
|
+
The method to perform connectivity measure using.
|
37
|
+
See :class:`.JuniferConnectivityMeasure` for options
|
38
|
+
(default "correlation").
|
39
|
+
conn_method_params : dict, optional
|
40
|
+
Parameters to pass to :class:`.JuniferConnectivityMeasure`.
|
41
|
+
If None, ``{"empirical": True}`` will be used, which would mean
|
42
|
+
:class:`sklearn.covariance.EmpiricalCovariance` is used to compute
|
43
|
+
covariance. If usage of :class:`sklearn.covariance.LedoitWolf` is
|
44
|
+
desired, ``{"empirical": False}`` should be passed
|
45
|
+
(default None).
|
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
|
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
|
-
|
50
|
-
|
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
|
-
|
61
|
-
|
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
|
-
|
70
|
-
|
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
|
-
* ``
|
99
|
-
|
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
|
-
|
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
|
-
|
121
|
+
bold_ts=aggregation["aggregation"]["data"],
|
122
|
+
roi_names=aggregation["aggregation"]["col_names"],
|
115
123
|
)
|
116
124
|
|
117
|
-
return {
|
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.
|
23
|
-
:func:`.list_coordinates` for options.
|
24
|
-
radius : float, optional
|
25
|
-
The radius of the sphere
|
26
|
-
from a single voxel.
|
27
|
-
for more information
|
25
|
+
The name of the coordinates list to use.
|
26
|
+
See :func:`.list_coordinates` for options.
|
27
|
+
radius : positive float, optional
|
28
|
+
The radius of the sphere around each coordinates in millimetres.
|
29
|
+
If None, the signal will be extracted from a single voxel.
|
30
|
+
See :class:`.JuniferNiftiSpheresMasker` for more information
|
31
|
+
(default None).
|
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
|
34
|
+
the spheres overlap (default False).
|
31
35
|
agg_method : str, optional
|
32
|
-
The
|
33
|
-
See :func:`.get_aggfunc_by_name` for
|
34
|
-
(default
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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.
|
49
|
-
|
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
|
-
|
56
|
-
|
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
|
-
|
69
|
-
|
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
|
-
|
82
|
-
|
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
|
-
* ``
|
111
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
137
|
+
bold_ts=aggregation["aggregation"]["data"],
|
138
|
+
roi_names=aggregation["aggregation"]["col_names"],
|
128
139
|
)
|
129
140
|
|
130
|
-
return {
|
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
|
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.
|
24
|
-
:func:`.get_aggfunc_by_name`
|
26
|
+
The method to perform aggregation using.
|
27
|
+
Check valid options in :func:`.get_aggfunc_by_name`
|
28
|
+
(default "mean").
|
25
29
|
agg_method_params : dict, optional
|
26
|
-
Parameters to pass to the aggregation function.
|
27
|
-
:func:`.get_aggfunc_by_name`
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
:class
|
30
|
+
Parameters to pass to the aggregation function.
|
31
|
+
Check valid options in :func:`.get_aggfunc_by_name`
|
32
|
+
(default None).
|
33
|
+
conn_method : str, optional
|
34
|
+
The method to perform connectivity measure using.
|
35
|
+
Check valid options in :class:`.JuniferConnectivityMeasure`
|
36
|
+
(default "correlation").
|
37
|
+
conn_method_params : dict, optional
|
38
|
+
Parameters to pass to :class:`.JuniferConnectivityMeasure`.
|
39
|
+
If None, ``{"empirical": True}`` will be used, which would mean
|
40
|
+
:class:`sklearn.covariance.EmpiricalCovariance` is used to compute
|
41
|
+
covariance. If usage of :class:`sklearn.covariance.LedoitWolf` is
|
42
|
+
desired, ``{"empirical": False}`` should be passed
|
43
|
+
(default None).
|
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
|
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
|
-
|
52
|
-
|
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.
|
59
|
-
self.
|
60
|
-
|
61
|
-
|
62
|
-
|
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.
|
129
|
-
|
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
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
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
|
-
#
|
140
|
-
if self.
|
141
|
-
|
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
|
-
|
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
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
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)
|
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.
|
26
|
-
:func:`.get_aggfunc_by_name`
|
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.
|
29
|
-
:func:`.get_aggfunc_by_name`
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
:class
|
32
|
+
Parameters to pass to the aggregation function.
|
33
|
+
See :func:`.get_aggfunc_by_name` for options
|
34
|
+
(default None).
|
35
|
+
conn_method : str, optional
|
36
|
+
The method to perform connectivity measure using.
|
37
|
+
See :class:`.JuniferConnectivityMeasure` for options
|
38
|
+
(default "correlation").
|
39
|
+
conn_method_params : dict, optional
|
40
|
+
Parameters to pass to :class:`.JuniferConnectivityMeasure`.
|
41
|
+
If None, ``{"empirical": True}`` will be used, which would mean
|
42
|
+
:class:`sklearn.covariance.EmpiricalCovariance` is used to compute
|
43
|
+
covariance. If usage of :class:`sklearn.covariance.LedoitWolf` is
|
44
|
+
desired, ``{"empirical": False}`` should be passed
|
45
|
+
(default None).
|
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
|
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
|
-
|
53
|
-
|
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
|
-
|
62
|
-
|
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
|
-
* ``
|
91
|
-
|
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
|
-
|
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)
|