junifer 0.0.5.dev242__py3-none-any.whl → 0.0.6__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 +2 -31
- junifer/__init__.pyi +37 -0
- junifer/_version.py +9 -4
- junifer/api/__init__.py +3 -5
- junifer/api/__init__.pyi +4 -0
- junifer/api/decorators.py +14 -19
- junifer/api/functions.py +165 -109
- junifer/api/py.typed +0 -0
- junifer/api/queue_context/__init__.py +2 -4
- junifer/api/queue_context/__init__.pyi +5 -0
- junifer/api/queue_context/gnu_parallel_local_adapter.py +22 -6
- junifer/api/queue_context/htcondor_adapter.py +23 -6
- junifer/api/queue_context/py.typed +0 -0
- junifer/api/queue_context/tests/test_gnu_parallel_local_adapter.py +3 -3
- junifer/api/queue_context/tests/test_htcondor_adapter.py +3 -3
- junifer/api/tests/test_functions.py +168 -74
- junifer/cli/__init__.py +24 -0
- junifer/cli/__init__.pyi +3 -0
- junifer/{api → cli}/cli.py +141 -125
- junifer/cli/parser.py +235 -0
- junifer/cli/py.typed +0 -0
- junifer/{api → cli}/tests/test_cli.py +8 -8
- junifer/{api/tests/test_api_utils.py → cli/tests/test_cli_utils.py} +5 -4
- junifer/{api → cli}/tests/test_parser.py +2 -2
- junifer/{api → cli}/utils.py +6 -16
- junifer/configs/juseless/__init__.py +2 -2
- junifer/configs/juseless/__init__.pyi +3 -0
- junifer/configs/juseless/datagrabbers/__init__.py +2 -12
- junifer/configs/juseless/datagrabbers/__init__.pyi +13 -0
- junifer/configs/juseless/datagrabbers/ixi_vbm.py +2 -2
- junifer/configs/juseless/datagrabbers/py.typed +0 -0
- junifer/configs/juseless/datagrabbers/tests/test_ucla.py +2 -2
- junifer/configs/juseless/datagrabbers/ucla.py +4 -4
- junifer/configs/juseless/py.typed +0 -0
- junifer/conftest.py +25 -0
- junifer/data/__init__.py +2 -42
- junifer/data/__init__.pyi +29 -0
- junifer/data/_dispatch.py +248 -0
- junifer/data/coordinates/__init__.py +9 -0
- junifer/data/coordinates/__init__.pyi +5 -0
- junifer/data/coordinates/_ants_coordinates_warper.py +104 -0
- junifer/data/coordinates/_coordinates.py +385 -0
- junifer/data/coordinates/_fsl_coordinates_warper.py +81 -0
- junifer/data/{tests → coordinates/tests}/test_coordinates.py +26 -33
- junifer/data/masks/__init__.py +9 -0
- junifer/data/masks/__init__.pyi +6 -0
- junifer/data/masks/_ants_mask_warper.py +177 -0
- junifer/data/masks/_fsl_mask_warper.py +106 -0
- junifer/data/masks/_masks.py +802 -0
- junifer/data/{tests → masks/tests}/test_masks.py +67 -63
- junifer/data/parcellations/__init__.py +9 -0
- junifer/data/parcellations/__init__.pyi +6 -0
- junifer/data/parcellations/_ants_parcellation_warper.py +166 -0
- junifer/data/parcellations/_fsl_parcellation_warper.py +89 -0
- junifer/data/parcellations/_parcellations.py +1388 -0
- junifer/data/{tests → parcellations/tests}/test_parcellations.py +165 -295
- junifer/data/pipeline_data_registry_base.py +76 -0
- junifer/data/py.typed +0 -0
- junifer/data/template_spaces.py +44 -79
- junifer/data/tests/test_data_utils.py +1 -2
- junifer/data/tests/test_template_spaces.py +8 -4
- junifer/data/utils.py +109 -4
- junifer/datagrabber/__init__.py +2 -26
- junifer/datagrabber/__init__.pyi +27 -0
- junifer/datagrabber/aomic/__init__.py +2 -4
- junifer/datagrabber/aomic/__init__.pyi +5 -0
- junifer/datagrabber/aomic/id1000.py +81 -52
- junifer/datagrabber/aomic/piop1.py +83 -55
- junifer/datagrabber/aomic/piop2.py +85 -56
- junifer/datagrabber/aomic/py.typed +0 -0
- junifer/datagrabber/aomic/tests/test_id1000.py +19 -12
- junifer/datagrabber/aomic/tests/test_piop1.py +52 -18
- junifer/datagrabber/aomic/tests/test_piop2.py +50 -17
- junifer/datagrabber/base.py +22 -18
- junifer/datagrabber/datalad_base.py +71 -34
- junifer/datagrabber/dmcc13_benchmark.py +31 -18
- junifer/datagrabber/hcp1200/__init__.py +2 -3
- junifer/datagrabber/hcp1200/__init__.pyi +4 -0
- junifer/datagrabber/hcp1200/datalad_hcp1200.py +3 -3
- junifer/datagrabber/hcp1200/hcp1200.py +26 -15
- junifer/datagrabber/hcp1200/py.typed +0 -0
- junifer/datagrabber/hcp1200/tests/test_hcp1200.py +8 -2
- junifer/datagrabber/multiple.py +14 -9
- junifer/datagrabber/pattern.py +132 -96
- junifer/datagrabber/pattern_validation_mixin.py +206 -94
- junifer/datagrabber/py.typed +0 -0
- junifer/datagrabber/tests/test_datalad_base.py +27 -12
- junifer/datagrabber/tests/test_dmcc13_benchmark.py +28 -11
- junifer/datagrabber/tests/test_multiple.py +48 -2
- junifer/datagrabber/tests/test_pattern_datalad.py +1 -1
- junifer/datagrabber/tests/test_pattern_validation_mixin.py +6 -6
- junifer/datareader/__init__.py +2 -2
- junifer/datareader/__init__.pyi +3 -0
- junifer/datareader/default.py +6 -6
- junifer/datareader/py.typed +0 -0
- junifer/external/nilearn/__init__.py +2 -3
- junifer/external/nilearn/__init__.pyi +4 -0
- junifer/external/nilearn/junifer_connectivity_measure.py +25 -17
- junifer/external/nilearn/junifer_nifti_spheres_masker.py +4 -4
- junifer/external/nilearn/py.typed +0 -0
- junifer/external/nilearn/tests/test_junifer_connectivity_measure.py +17 -16
- junifer/external/nilearn/tests/test_junifer_nifti_spheres_masker.py +2 -3
- junifer/markers/__init__.py +2 -38
- junifer/markers/__init__.pyi +37 -0
- junifer/markers/base.py +11 -14
- junifer/markers/brainprint.py +12 -14
- junifer/markers/complexity/__init__.py +2 -18
- junifer/markers/complexity/__init__.pyi +17 -0
- junifer/markers/complexity/complexity_base.py +9 -11
- junifer/markers/complexity/hurst_exponent.py +7 -7
- junifer/markers/complexity/multiscale_entropy_auc.py +7 -7
- junifer/markers/complexity/perm_entropy.py +7 -7
- junifer/markers/complexity/py.typed +0 -0
- junifer/markers/complexity/range_entropy.py +7 -7
- junifer/markers/complexity/range_entropy_auc.py +7 -7
- junifer/markers/complexity/sample_entropy.py +7 -7
- junifer/markers/complexity/tests/test_complexity_base.py +1 -1
- junifer/markers/complexity/tests/test_hurst_exponent.py +5 -5
- junifer/markers/complexity/tests/test_multiscale_entropy_auc.py +5 -5
- junifer/markers/complexity/tests/test_perm_entropy.py +5 -5
- junifer/markers/complexity/tests/test_range_entropy.py +5 -5
- junifer/markers/complexity/tests/test_range_entropy_auc.py +5 -5
- junifer/markers/complexity/tests/test_sample_entropy.py +5 -5
- junifer/markers/complexity/tests/test_weighted_perm_entropy.py +5 -5
- junifer/markers/complexity/weighted_perm_entropy.py +7 -7
- junifer/markers/ets_rss.py +12 -11
- junifer/markers/falff/__init__.py +2 -3
- junifer/markers/falff/__init__.pyi +4 -0
- junifer/markers/falff/_afni_falff.py +38 -45
- junifer/markers/falff/_junifer_falff.py +16 -19
- junifer/markers/falff/falff_base.py +7 -11
- junifer/markers/falff/falff_parcels.py +9 -9
- junifer/markers/falff/falff_spheres.py +8 -8
- junifer/markers/falff/py.typed +0 -0
- junifer/markers/falff/tests/test_falff_spheres.py +3 -1
- junifer/markers/functional_connectivity/__init__.py +2 -12
- junifer/markers/functional_connectivity/__init__.pyi +13 -0
- junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +9 -8
- junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +8 -8
- junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +7 -7
- junifer/markers/functional_connectivity/functional_connectivity_base.py +13 -12
- junifer/markers/functional_connectivity/functional_connectivity_parcels.py +8 -8
- junifer/markers/functional_connectivity/functional_connectivity_spheres.py +7 -7
- junifer/markers/functional_connectivity/py.typed +0 -0
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +1 -2
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +1 -2
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +6 -6
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +5 -5
- junifer/markers/parcel_aggregation.py +22 -17
- junifer/markers/py.typed +0 -0
- junifer/markers/reho/__init__.py +2 -3
- junifer/markers/reho/__init__.pyi +4 -0
- junifer/markers/reho/_afni_reho.py +29 -35
- junifer/markers/reho/_junifer_reho.py +13 -14
- junifer/markers/reho/py.typed +0 -0
- junifer/markers/reho/reho_base.py +7 -11
- junifer/markers/reho/reho_parcels.py +10 -10
- junifer/markers/reho/reho_spheres.py +9 -9
- junifer/markers/sphere_aggregation.py +22 -17
- junifer/markers/temporal_snr/__init__.py +2 -3
- junifer/markers/temporal_snr/__init__.pyi +4 -0
- junifer/markers/temporal_snr/py.typed +0 -0
- junifer/markers/temporal_snr/temporal_snr_base.py +11 -10
- junifer/markers/temporal_snr/temporal_snr_parcels.py +8 -8
- junifer/markers/temporal_snr/temporal_snr_spheres.py +7 -7
- junifer/markers/tests/test_ets_rss.py +3 -3
- junifer/markers/tests/test_parcel_aggregation.py +24 -24
- junifer/markers/tests/test_sphere_aggregation.py +6 -6
- junifer/markers/utils.py +3 -3
- junifer/onthefly/__init__.py +2 -1
- junifer/onthefly/_brainprint.py +138 -0
- junifer/onthefly/read_transform.py +5 -8
- junifer/pipeline/__init__.py +2 -10
- junifer/pipeline/__init__.pyi +13 -0
- junifer/{markers/collection.py → pipeline/marker_collection.py} +8 -14
- junifer/pipeline/pipeline_component_registry.py +294 -0
- junifer/pipeline/pipeline_step_mixin.py +15 -11
- junifer/pipeline/py.typed +0 -0
- junifer/{markers/tests/test_collection.py → pipeline/tests/test_marker_collection.py} +2 -3
- junifer/pipeline/tests/test_pipeline_component_registry.py +200 -0
- junifer/pipeline/tests/test_pipeline_step_mixin.py +36 -37
- junifer/pipeline/tests/test_update_meta_mixin.py +4 -4
- junifer/pipeline/tests/test_workdir_manager.py +43 -0
- junifer/pipeline/update_meta_mixin.py +21 -17
- junifer/pipeline/utils.py +6 -6
- junifer/pipeline/workdir_manager.py +19 -5
- junifer/preprocess/__init__.py +2 -10
- junifer/preprocess/__init__.pyi +11 -0
- junifer/preprocess/base.py +10 -10
- junifer/preprocess/confounds/__init__.py +2 -2
- junifer/preprocess/confounds/__init__.pyi +3 -0
- junifer/preprocess/confounds/fmriprep_confound_remover.py +243 -64
- junifer/preprocess/confounds/py.typed +0 -0
- junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py +121 -14
- junifer/preprocess/py.typed +0 -0
- junifer/preprocess/smoothing/__init__.py +2 -2
- junifer/preprocess/smoothing/__init__.pyi +3 -0
- junifer/preprocess/smoothing/_afni_smoothing.py +40 -40
- junifer/preprocess/smoothing/_fsl_smoothing.py +22 -32
- junifer/preprocess/smoothing/_nilearn_smoothing.py +35 -14
- junifer/preprocess/smoothing/py.typed +0 -0
- junifer/preprocess/smoothing/smoothing.py +11 -13
- junifer/preprocess/warping/__init__.py +2 -2
- junifer/preprocess/warping/__init__.pyi +3 -0
- junifer/preprocess/warping/_ants_warper.py +136 -32
- junifer/preprocess/warping/_fsl_warper.py +73 -22
- junifer/preprocess/warping/py.typed +0 -0
- junifer/preprocess/warping/space_warper.py +39 -11
- junifer/preprocess/warping/tests/test_space_warper.py +5 -9
- junifer/py.typed +0 -0
- junifer/stats.py +5 -5
- junifer/storage/__init__.py +2 -10
- junifer/storage/__init__.pyi +11 -0
- junifer/storage/base.py +47 -13
- junifer/storage/hdf5.py +95 -33
- junifer/storage/pandas_base.py +12 -11
- junifer/storage/py.typed +0 -0
- junifer/storage/sqlite.py +11 -11
- junifer/storage/tests/test_hdf5.py +86 -4
- junifer/storage/tests/test_sqlite.py +2 -2
- junifer/storage/tests/test_storage_base.py +5 -2
- junifer/storage/tests/test_utils.py +33 -7
- junifer/storage/utils.py +95 -9
- junifer/testing/__init__.py +2 -3
- junifer/testing/__init__.pyi +4 -0
- junifer/testing/datagrabbers.py +10 -11
- junifer/testing/py.typed +0 -0
- junifer/testing/registry.py +4 -7
- junifer/testing/tests/test_testing_registry.py +9 -17
- junifer/tests/test_stats.py +2 -2
- junifer/typing/__init__.py +9 -0
- junifer/typing/__init__.pyi +31 -0
- junifer/typing/_typing.py +68 -0
- junifer/utils/__init__.py +2 -12
- junifer/utils/__init__.pyi +18 -0
- junifer/utils/_config.py +110 -0
- junifer/utils/_yaml.py +16 -0
- junifer/utils/helpers.py +6 -6
- junifer/utils/logging.py +117 -8
- junifer/utils/py.typed +0 -0
- junifer/{pipeline → utils}/singleton.py +19 -14
- junifer/utils/tests/test_config.py +59 -0
- {junifer-0.0.5.dev242.dist-info → junifer-0.0.6.dist-info}/METADATA +43 -38
- junifer-0.0.6.dist-info/RECORD +350 -0
- {junifer-0.0.5.dev242.dist-info → junifer-0.0.6.dist-info}/WHEEL +1 -1
- junifer-0.0.6.dist-info/entry_points.txt +2 -0
- junifer/api/parser.py +0 -118
- junifer/data/coordinates.py +0 -408
- junifer/data/masks.py +0 -670
- junifer/data/parcellations.py +0 -1828
- junifer/pipeline/registry.py +0 -177
- junifer/pipeline/tests/test_registry.py +0 -150
- junifer-0.0.5.dev242.dist-info/RECORD +0 -275
- junifer-0.0.5.dev242.dist-info/entry_points.txt +0 -2
- /junifer/{api → cli}/tests/data/gmd_mean.yaml +0 -0
- /junifer/{api → cli}/tests/data/gmd_mean_htcondor.yaml +0 -0
- /junifer/{api → cli}/tests/data/partly_cloudy_agg_mean_tian.yml +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/AutobiographicalMemory_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/CogAC_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/CogAR_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/DMNBuckner_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/Dosenbach2010_MNI_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/Empathy_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/Motor_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/MultiTask_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/PhysioStress_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/Power2011_MNI_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/Power2013_MNI_VOIs.tsv +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/Rew_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/Somatosensory_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/ToM_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/VigAtt_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/WM_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/eMDN_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/eSAD_VOIs.txt +0 -0
- /junifer/data/{VOIs → coordinates/VOIs}/meta/extDMN_VOIs.txt +0 -0
- {junifer-0.0.5.dev242.dist-info → junifer-0.0.6.dist-info/licenses}/AUTHORS.rst +0 -0
- {junifer-0.0.5.dev242.dist-info → junifer-0.0.6.dist-info/licenses}/LICENSE.md +0 -0
- {junifer-0.0.5.dev242.dist-info → junifer-0.0.6.dist-info}/top_level.txt +0 -0
@@ -4,7 +4,7 @@
|
|
4
4
|
# License: AGPL
|
5
5
|
|
6
6
|
|
7
|
-
from typing import Any,
|
7
|
+
from typing import Any, Optional, Union
|
8
8
|
|
9
9
|
import numpy as np
|
10
10
|
|
@@ -24,8 +24,8 @@ class ReHoParcels(ReHoBase):
|
|
24
24
|
Parameters
|
25
25
|
----------
|
26
26
|
parcellation : str or list of str
|
27
|
-
The name(s) of the parcellation(s)
|
28
|
-
:func:`.
|
27
|
+
The name(s) of the parcellation(s) to use.
|
28
|
+
See :func:`.list_data` for options.
|
29
29
|
using : {"junifer", "afni"}
|
30
30
|
Implementation to use for computing ReHo:
|
31
31
|
|
@@ -92,12 +92,12 @@ class ReHoParcels(ReHoBase):
|
|
92
92
|
|
93
93
|
def __init__(
|
94
94
|
self,
|
95
|
-
parcellation: Union[str,
|
95
|
+
parcellation: Union[str, list[str]],
|
96
96
|
using: str,
|
97
|
-
reho_params: Optional[
|
97
|
+
reho_params: Optional[dict] = None,
|
98
98
|
agg_method: str = "mean",
|
99
|
-
agg_method_params: Optional[
|
100
|
-
masks: Union[str,
|
99
|
+
agg_method_params: Optional[dict] = None,
|
100
|
+
masks: Union[str, dict, list[Union[dict, str]], None] = None,
|
101
101
|
name: Optional[str] = None,
|
102
102
|
) -> None:
|
103
103
|
# Superclass init first to validate `using` parameter
|
@@ -110,9 +110,9 @@ class ReHoParcels(ReHoBase):
|
|
110
110
|
|
111
111
|
def compute(
|
112
112
|
self,
|
113
|
-
input:
|
114
|
-
extra_input: Optional[
|
115
|
-
) ->
|
113
|
+
input: dict[str, Any],
|
114
|
+
extra_input: Optional[dict[str, Any]] = None,
|
115
|
+
) -> dict[str, Any]:
|
116
116
|
"""Compute.
|
117
117
|
|
118
118
|
Parameters
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# License: AGPL
|
5
5
|
|
6
6
|
|
7
|
-
from typing import Any,
|
7
|
+
from typing import Any, Optional, Union
|
8
8
|
|
9
9
|
import numpy as np
|
10
10
|
|
@@ -24,8 +24,8 @@ class ReHoSpheres(ReHoBase):
|
|
24
24
|
Parameters
|
25
25
|
----------
|
26
26
|
coords : str
|
27
|
-
The name of the coordinates list to use.
|
28
|
-
:func:`.
|
27
|
+
The name of the coordinates list to use.
|
28
|
+
See :func:`.list_data` for options.
|
29
29
|
using : {"junifer", "afni"}
|
30
30
|
Implementation to use for computing ReHo:
|
31
31
|
|
@@ -107,10 +107,10 @@ class ReHoSpheres(ReHoBase):
|
|
107
107
|
using: str,
|
108
108
|
radius: Optional[float] = None,
|
109
109
|
allow_overlap: bool = False,
|
110
|
-
reho_params: Optional[
|
110
|
+
reho_params: Optional[dict] = None,
|
111
111
|
agg_method: str = "mean",
|
112
|
-
agg_method_params: Optional[
|
113
|
-
masks: Union[str,
|
112
|
+
agg_method_params: Optional[dict] = None,
|
113
|
+
masks: Union[str, dict, list[Union[dict, str]], None] = None,
|
114
114
|
name: Optional[str] = None,
|
115
115
|
) -> None:
|
116
116
|
# Superclass init first to validate `using` parameter
|
@@ -125,9 +125,9 @@ class ReHoSpheres(ReHoBase):
|
|
125
125
|
|
126
126
|
def compute(
|
127
127
|
self,
|
128
|
-
input:
|
129
|
-
extra_input: Optional[
|
130
|
-
) ->
|
128
|
+
input: dict[str, Any],
|
129
|
+
extra_input: Optional[dict[str, Any]] = None,
|
130
|
+
) -> dict[str, Any]:
|
131
131
|
"""Compute.
|
132
132
|
|
133
133
|
Parameters
|
@@ -4,12 +4,13 @@
|
|
4
4
|
# Synchon Mandal <s.mandal@fz-juelich.de>
|
5
5
|
# License: AGPL
|
6
6
|
|
7
|
-
from typing import Any, ClassVar,
|
7
|
+
from typing import Any, ClassVar, Optional, Union
|
8
8
|
|
9
9
|
from ..api.decorators import register_marker
|
10
|
-
from ..data import
|
10
|
+
from ..data import get_data
|
11
11
|
from ..external.nilearn import JuniferNiftiSpheresMasker
|
12
12
|
from ..stats import get_aggfunc_by_name
|
13
|
+
from ..typing import Dependencies, MarkerInOutMappings
|
13
14
|
from ..utils import logger, raise_error, warn_with_log
|
14
15
|
from .base import BaseMarker
|
15
16
|
|
@@ -24,8 +25,8 @@ class SphereAggregation(BaseMarker):
|
|
24
25
|
Parameters
|
25
26
|
----------
|
26
27
|
coords : str
|
27
|
-
The name of the coordinates list to use.
|
28
|
-
:func:`.
|
28
|
+
The name of the coordinates list to use.
|
29
|
+
See :func:`.list_data` for options.
|
29
30
|
radius : float, optional
|
30
31
|
The radius of the sphere in millimeters. If None, the signal will be
|
31
32
|
extracted from a single voxel. See
|
@@ -66,9 +67,9 @@ class SphereAggregation(BaseMarker):
|
|
66
67
|
|
67
68
|
"""
|
68
69
|
|
69
|
-
_DEPENDENCIES: ClassVar[
|
70
|
+
_DEPENDENCIES: ClassVar[Dependencies] = {"nilearn", "numpy"}
|
70
71
|
|
71
|
-
_MARKER_INOUT_MAPPINGS: ClassVar[
|
72
|
+
_MARKER_INOUT_MAPPINGS: ClassVar[MarkerInOutMappings] = {
|
72
73
|
"T1w": {
|
73
74
|
"aggregation": "vector",
|
74
75
|
},
|
@@ -104,11 +105,11 @@ class SphereAggregation(BaseMarker):
|
|
104
105
|
radius: Optional[float] = None,
|
105
106
|
allow_overlap: bool = False,
|
106
107
|
method: str = "mean",
|
107
|
-
method_params: Optional[
|
108
|
+
method_params: Optional[dict[str, Any]] = None,
|
108
109
|
time_method: Optional[str] = None,
|
109
|
-
time_method_params: Optional[
|
110
|
-
masks: Union[str,
|
111
|
-
on: Union[
|
110
|
+
time_method_params: Optional[dict[str, Any]] = None,
|
111
|
+
masks: Union[str, dict, list[Union[dict, str]], None] = None,
|
112
|
+
on: Union[list[str], str, None] = None,
|
112
113
|
name: Optional[str] = None,
|
113
114
|
) -> None:
|
114
115
|
self.coords = coords
|
@@ -135,9 +136,9 @@ class SphereAggregation(BaseMarker):
|
|
135
136
|
|
136
137
|
def compute(
|
137
138
|
self,
|
138
|
-
input:
|
139
|
-
extra_input: Optional[
|
140
|
-
) ->
|
139
|
+
input: dict[str, Any],
|
140
|
+
extra_input: Optional[dict] = None,
|
141
|
+
) -> dict:
|
141
142
|
"""Compute.
|
142
143
|
|
143
144
|
Parameters
|
@@ -177,8 +178,9 @@ class SphereAggregation(BaseMarker):
|
|
177
178
|
)
|
178
179
|
|
179
180
|
# Get seeds and labels tailored to target image
|
180
|
-
coords, labels =
|
181
|
-
|
181
|
+
coords, labels = get_data(
|
182
|
+
kind="coordinates",
|
183
|
+
names=self.coords,
|
182
184
|
target_data=input,
|
183
185
|
extra_input=extra_input,
|
184
186
|
)
|
@@ -188,8 +190,11 @@ class SphereAggregation(BaseMarker):
|
|
188
190
|
if self.masks is not None:
|
189
191
|
logger.debug(f"Masking with {self.masks}")
|
190
192
|
# Get tailored mask
|
191
|
-
mask_img =
|
192
|
-
|
193
|
+
mask_img = get_data(
|
194
|
+
kind="mask",
|
195
|
+
names=self.masks,
|
196
|
+
target_data=input,
|
197
|
+
extra_input=extra_input,
|
193
198
|
)
|
194
199
|
|
195
200
|
# Initialize masker
|
@@ -3,8 +3,7 @@
|
|
3
3
|
# Authors: Leonard Sasse <l.sasse@fz-juelich.de>
|
4
4
|
# License: AGPL
|
5
5
|
|
6
|
-
|
7
|
-
from .temporal_snr_spheres import TemporalSNRSpheres
|
6
|
+
import lazy_loader as lazy
|
8
7
|
|
9
8
|
|
10
|
-
__all__ =
|
9
|
+
__getattr__, __dir__, __all__ = lazy.attach_stub(__name__, __file__)
|
File without changes
|
@@ -5,10 +5,11 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
from abc import abstractmethod
|
8
|
-
from typing import Any, ClassVar,
|
8
|
+
from typing import Any, ClassVar, Optional, Union
|
9
9
|
|
10
10
|
from nilearn import image as nimg
|
11
11
|
|
12
|
+
from ...typing import Dependencies, MarkerInOutMappings
|
12
13
|
from ...utils import raise_error
|
13
14
|
from ..base import BaseMarker
|
14
15
|
|
@@ -37,9 +38,9 @@ class TemporalSNRBase(BaseMarker):
|
|
37
38
|
|
38
39
|
"""
|
39
40
|
|
40
|
-
_DEPENDENCIES: ClassVar[
|
41
|
+
_DEPENDENCIES: ClassVar[Dependencies] = {"nilearn"}
|
41
42
|
|
42
|
-
_MARKER_INOUT_MAPPINGS: ClassVar[
|
43
|
+
_MARKER_INOUT_MAPPINGS: ClassVar[MarkerInOutMappings] = {
|
43
44
|
"BOLD": {
|
44
45
|
"tsnr": "vector",
|
45
46
|
},
|
@@ -48,8 +49,8 @@ class TemporalSNRBase(BaseMarker):
|
|
48
49
|
def __init__(
|
49
50
|
self,
|
50
51
|
agg_method: str = "mean",
|
51
|
-
agg_method_params: Optional[
|
52
|
-
masks: Union[str,
|
52
|
+
agg_method_params: Optional[dict] = None,
|
53
|
+
masks: Union[str, dict, list[Union[dict, str]], None] = None,
|
53
54
|
name: Optional[str] = None,
|
54
55
|
) -> None:
|
55
56
|
self.agg_method = agg_method
|
@@ -59,8 +60,8 @@ class TemporalSNRBase(BaseMarker):
|
|
59
60
|
|
60
61
|
@abstractmethod
|
61
62
|
def aggregate(
|
62
|
-
self, input:
|
63
|
-
) ->
|
63
|
+
self, input: dict[str, Any], extra_input: Optional[dict] = None
|
64
|
+
) -> dict[str, Any]:
|
64
65
|
"""Perform aggregation."""
|
65
66
|
raise_error(
|
66
67
|
msg="Concrete classes need to implement aggregate().",
|
@@ -69,9 +70,9 @@ class TemporalSNRBase(BaseMarker):
|
|
69
70
|
|
70
71
|
def compute(
|
71
72
|
self,
|
72
|
-
input:
|
73
|
-
extra_input: Optional[
|
74
|
-
) ->
|
73
|
+
input: dict[str, Any],
|
74
|
+
extra_input: Optional[dict] = None,
|
75
|
+
) -> dict:
|
75
76
|
"""Compute.
|
76
77
|
|
77
78
|
Parameters
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Authors: Leonard Sasse <l.sasse@fz-juelich.de>
|
4
4
|
# License: AGPL
|
5
5
|
|
6
|
-
from typing import Any,
|
6
|
+
from typing import Any, Optional, Union
|
7
7
|
|
8
8
|
from ...api.decorators import register_marker
|
9
9
|
from ..parcel_aggregation import ParcelAggregation
|
@@ -20,8 +20,8 @@ class TemporalSNRParcels(TemporalSNRBase):
|
|
20
20
|
Parameters
|
21
21
|
----------
|
22
22
|
parcellation : str or list of str
|
23
|
-
The name(s) of the parcellation(s)
|
24
|
-
:func:`.
|
23
|
+
The name(s) of the parcellation(s) to use.
|
24
|
+
See :func:`.list_data` for options.
|
25
25
|
agg_method : str, optional
|
26
26
|
The method to perform aggregation using. Check valid options in
|
27
27
|
:func:`.get_aggfunc_by_name` (default "mean").
|
@@ -40,10 +40,10 @@ class TemporalSNRParcels(TemporalSNRBase):
|
|
40
40
|
|
41
41
|
def __init__(
|
42
42
|
self,
|
43
|
-
parcellation: Union[str,
|
43
|
+
parcellation: Union[str, list[str]],
|
44
44
|
agg_method: str = "mean",
|
45
|
-
agg_method_params: Optional[
|
46
|
-
masks: Union[str,
|
45
|
+
agg_method_params: Optional[dict] = None,
|
46
|
+
masks: Union[str, dict, list[Union[dict, str]], None] = None,
|
47
47
|
name: Optional[str] = None,
|
48
48
|
) -> None:
|
49
49
|
self.parcellation = parcellation
|
@@ -55,8 +55,8 @@ class TemporalSNRParcels(TemporalSNRBase):
|
|
55
55
|
)
|
56
56
|
|
57
57
|
def aggregate(
|
58
|
-
self, input:
|
59
|
-
) ->
|
58
|
+
self, input: dict[str, Any], extra_input: Optional[dict] = None
|
59
|
+
) -> dict:
|
60
60
|
"""Perform parcel aggregation.
|
61
61
|
|
62
62
|
Parameters
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Authors: Leonard Sasse <l.sasse@fz-juelich.de>
|
4
4
|
# License: AGPL
|
5
5
|
|
6
|
-
from typing import Any,
|
6
|
+
from typing import Any, Optional, Union
|
7
7
|
|
8
8
|
from ...api.decorators import register_marker
|
9
9
|
from ..sphere_aggregation import SphereAggregation
|
@@ -21,8 +21,8 @@ class TemporalSNRSpheres(TemporalSNRBase):
|
|
21
21
|
Parameters
|
22
22
|
----------
|
23
23
|
coords : str
|
24
|
-
The name of the coordinates list to use.
|
25
|
-
:func:`.
|
24
|
+
The name of the coordinates list to use.
|
25
|
+
See :func:`.list_data` for options.
|
26
26
|
radius : float, optional
|
27
27
|
The radius of the sphere in mm. If None, the signal will be extracted
|
28
28
|
from a single voxel. See :class:`nilearn.maskers.NiftiSpheresMasker`
|
@@ -53,8 +53,8 @@ class TemporalSNRSpheres(TemporalSNRBase):
|
|
53
53
|
radius: Optional[float] = None,
|
54
54
|
allow_overlap: bool = False,
|
55
55
|
agg_method: str = "mean",
|
56
|
-
agg_method_params: Optional[
|
57
|
-
masks: Union[str,
|
56
|
+
agg_method_params: Optional[dict] = None,
|
57
|
+
masks: Union[str, dict, list[Union[dict, str]], None] = None,
|
58
58
|
name: Optional[str] = None,
|
59
59
|
) -> None:
|
60
60
|
self.coords = coords
|
@@ -70,8 +70,8 @@ class TemporalSNRSpheres(TemporalSNRBase):
|
|
70
70
|
)
|
71
71
|
|
72
72
|
def aggregate(
|
73
|
-
self, input:
|
74
|
-
) ->
|
73
|
+
self, input: dict[str, Any], extra_input: Optional[dict] = None
|
74
|
+
) -> dict:
|
75
75
|
"""Perform sphere aggregation.
|
76
76
|
|
77
77
|
Parameters
|
@@ -10,7 +10,7 @@ from pathlib import Path
|
|
10
10
|
|
11
11
|
from nilearn.maskers import NiftiLabelsMasker
|
12
12
|
|
13
|
-
from junifer.data import
|
13
|
+
from junifer.data import ParcellationRegistry
|
14
14
|
from junifer.datareader import DefaultDataReader
|
15
15
|
from junifer.markers.ets_rss import RSSETSMarker
|
16
16
|
from junifer.storage import SQLiteFeatureStorage
|
@@ -32,8 +32,8 @@ def test_compute() -> None:
|
|
32
32
|
|
33
33
|
# Compare with nilearn
|
34
34
|
# Load testing parcellation
|
35
|
-
test_parcellation, _ =
|
36
|
-
|
35
|
+
test_parcellation, _ = ParcellationRegistry().get(
|
36
|
+
parcellations=[PARCELLATION],
|
37
37
|
target_data=element_data["BOLD"],
|
38
38
|
)
|
39
39
|
# Extract timeseries
|
@@ -16,7 +16,7 @@ from nilearn.masking import compute_brain_mask
|
|
16
16
|
from numpy.testing import assert_array_almost_equal, assert_array_equal
|
17
17
|
from scipy.stats import trim_mean
|
18
18
|
|
19
|
-
from junifer.data import
|
19
|
+
from junifer.data import MaskRegistry, ParcellationRegistry
|
20
20
|
from junifer.datareader import DefaultDataReader
|
21
21
|
from junifer.markers.parcel_aggregation import ParcelAggregation
|
22
22
|
from junifer.storage import SQLiteFeatureStorage
|
@@ -98,8 +98,8 @@ def test_ParcelAggregation_3D() -> None:
|
|
98
98
|
|
99
99
|
# Compare with nilearn
|
100
100
|
# Load testing parcellation
|
101
|
-
testing_parcellation, _ =
|
102
|
-
|
101
|
+
testing_parcellation, _ = ParcellationRegistry().get(
|
102
|
+
parcellations=["TianxS1x3TxMNInonlinear2009cAsym"],
|
103
103
|
target_data=element_data["BOLD"],
|
104
104
|
)
|
105
105
|
# Binarize parcellation
|
@@ -206,8 +206,8 @@ def test_ParcelAggregation_4D():
|
|
206
206
|
|
207
207
|
# Compare with nilearn
|
208
208
|
# Load testing parcellation
|
209
|
-
testing_parcellation, _ =
|
210
|
-
|
209
|
+
testing_parcellation, _ = ParcellationRegistry().get(
|
210
|
+
parcellations=["TianxS1x3TxMNInonlinear2009cAsym"],
|
211
211
|
target_data=element_data["BOLD"],
|
212
212
|
)
|
213
213
|
# Extract data
|
@@ -295,12 +295,12 @@ def test_ParcelAggregation_3D_mask() -> None:
|
|
295
295
|
|
296
296
|
# Compare with nilearn
|
297
297
|
# Load testing parcellation
|
298
|
-
testing_parcellation, _ =
|
299
|
-
|
298
|
+
testing_parcellation, _ = ParcellationRegistry().get(
|
299
|
+
parcellations=["TianxS1x3TxMNInonlinear2009cAsym"],
|
300
300
|
target_data=element_data["BOLD"],
|
301
301
|
)
|
302
302
|
# Load mask
|
303
|
-
mask_img =
|
303
|
+
mask_img = MaskRegistry().get(
|
304
304
|
"compute_brain_mask", target_data=element_data["BOLD"]
|
305
305
|
)
|
306
306
|
# Extract data
|
@@ -328,8 +328,8 @@ def test_ParcelAggregation_3D_mask_computed() -> None:
|
|
328
328
|
|
329
329
|
# Compare with nilearn
|
330
330
|
# Load testing parcellation
|
331
|
-
testing_parcellation, _ =
|
332
|
-
|
331
|
+
testing_parcellation, _ = ParcellationRegistry().get(
|
332
|
+
parcellations=["TianxS1x3TxMNInonlinear2009cAsym"],
|
333
333
|
target_data=element_data["BOLD"],
|
334
334
|
)
|
335
335
|
# Get a mask
|
@@ -396,8 +396,8 @@ def test_ParcelAggregation_3D_multiple_non_overlapping(tmp_path: Path) -> None:
|
|
396
396
|
]
|
397
397
|
|
398
398
|
# Load testing parcellation
|
399
|
-
testing_parcellation, labels =
|
400
|
-
|
399
|
+
testing_parcellation, labels = ParcellationRegistry().get(
|
400
|
+
parcellations=["TianxS1x3TxMNInonlinear2009cAsym"],
|
401
401
|
target_data=element_data["BOLD"],
|
402
402
|
)
|
403
403
|
|
@@ -424,14 +424,14 @@ def test_ParcelAggregation_3D_multiple_non_overlapping(tmp_path: Path) -> None:
|
|
424
424
|
nib.save(parcellation1_img, parcellation1_path)
|
425
425
|
nib.save(parcellation2_img, parcellation2_path)
|
426
426
|
|
427
|
-
|
427
|
+
ParcellationRegistry().register(
|
428
428
|
name="TianxS1x3TxMNInonlinear2009cAsym_low",
|
429
429
|
parcellation_path=parcellation1_path,
|
430
430
|
parcels_labels=labels1,
|
431
431
|
space="MNI152NLin2009cAsym",
|
432
432
|
overwrite=True,
|
433
433
|
)
|
434
|
-
|
434
|
+
ParcellationRegistry().register(
|
435
435
|
name="TianxS1x3TxMNInonlinear2009cAsym_high",
|
436
436
|
parcellation_path=parcellation2_path,
|
437
437
|
parcels_labels=labels2,
|
@@ -498,8 +498,8 @@ def test_ParcelAggregation_3D_multiple_overlapping(tmp_path: Path) -> None:
|
|
498
498
|
]
|
499
499
|
|
500
500
|
# Load testing parcellation
|
501
|
-
testing_parcellation, labels =
|
502
|
-
|
501
|
+
testing_parcellation, labels = ParcellationRegistry().get(
|
502
|
+
parcellations=["TianxS1x3TxMNInonlinear2009cAsym"],
|
503
503
|
target_data=element_data["BOLD"],
|
504
504
|
)
|
505
505
|
|
@@ -528,14 +528,14 @@ def test_ParcelAggregation_3D_multiple_overlapping(tmp_path: Path) -> None:
|
|
528
528
|
nib.save(parcellation1_img, parcellation1_path)
|
529
529
|
nib.save(parcellation2_img, parcellation2_path)
|
530
530
|
|
531
|
-
|
531
|
+
ParcellationRegistry().register(
|
532
532
|
name="TianxS1x3TxMNInonlinear2009cAsym_low",
|
533
533
|
parcellation_path=parcellation1_path,
|
534
534
|
parcels_labels=labels1,
|
535
535
|
space="MNI152NLin2009cAsym",
|
536
536
|
overwrite=True,
|
537
537
|
)
|
538
|
-
|
538
|
+
ParcellationRegistry().register(
|
539
539
|
name="TianxS1x3TxMNInonlinear2009cAsym_high",
|
540
540
|
parcellation_path=parcellation2_path,
|
541
541
|
parcels_labels=labels2,
|
@@ -609,8 +609,8 @@ def test_ParcelAggregation_3D_multiple_duplicated_labels(
|
|
609
609
|
]
|
610
610
|
|
611
611
|
# Load testing parcellation
|
612
|
-
testing_parcellation, labels =
|
613
|
-
|
612
|
+
testing_parcellation, labels = ParcellationRegistry().get(
|
613
|
+
parcellations=["TianxS1x3TxMNInonlinear2009cAsym"],
|
614
614
|
target_data=element_data["BOLD"],
|
615
615
|
)
|
616
616
|
|
@@ -637,14 +637,14 @@ def test_ParcelAggregation_3D_multiple_duplicated_labels(
|
|
637
637
|
nib.save(parcellation1_img, parcellation1_path)
|
638
638
|
nib.save(parcellation2_img, parcellation2_path)
|
639
639
|
|
640
|
-
|
640
|
+
ParcellationRegistry().register(
|
641
641
|
name="TianxS1x3TxMNInonlinear2009cAsym_low",
|
642
642
|
parcellation_path=parcellation1_path,
|
643
643
|
parcels_labels=labels1,
|
644
644
|
space="MNI152NLin2009cAsym",
|
645
645
|
overwrite=True,
|
646
646
|
)
|
647
|
-
|
647
|
+
ParcellationRegistry().register(
|
648
648
|
name="TianxS1x3TxMNInonlinear2009cAsym_high",
|
649
649
|
parcellation_path=parcellation2_path,
|
650
650
|
parcels_labels=labels2,
|
@@ -719,8 +719,8 @@ def test_ParcelAggregation_4D_agg_time():
|
|
719
719
|
|
720
720
|
# Compare with nilearn
|
721
721
|
# Loading testing parcellation
|
722
|
-
testing_parcellation, _ =
|
723
|
-
|
722
|
+
testing_parcellation, _ = ParcellationRegistry().get(
|
723
|
+
parcellations=["TianxS1x3TxMNInonlinear2009cAsym"],
|
724
724
|
target_data=element_data["BOLD"],
|
725
725
|
)
|
726
726
|
# Extract data
|
@@ -10,7 +10,7 @@ import pytest
|
|
10
10
|
from nilearn.maskers import NiftiSpheresMasker
|
11
11
|
from numpy.testing import assert_array_equal
|
12
12
|
|
13
|
-
from junifer.data import
|
13
|
+
from junifer.data import CoordinatesRegistry, MaskRegistry
|
14
14
|
from junifer.datareader import DefaultDataReader
|
15
15
|
from junifer.markers.sphere_aggregation import SphereAggregation
|
16
16
|
from junifer.storage import SQLiteFeatureStorage
|
@@ -100,7 +100,7 @@ def test_SphereAggregation_3D() -> None:
|
|
100
100
|
|
101
101
|
# Compare with nilearn
|
102
102
|
# Load testing coordinates
|
103
|
-
testing_coords, _ =
|
103
|
+
testing_coords, _ = CoordinatesRegistry().get(
|
104
104
|
coords=COORDS, target_data=element_data["VBM_GM"]
|
105
105
|
)
|
106
106
|
# Extract data
|
@@ -132,7 +132,7 @@ def test_SphereAggregation_4D() -> None:
|
|
132
132
|
|
133
133
|
# Compare with nilearn
|
134
134
|
# Load testing coordinates
|
135
|
-
testing_coords, _ =
|
135
|
+
testing_coords, _ = CoordinatesRegistry().get(
|
136
136
|
coords=COORDS, target_data=element_data["BOLD"]
|
137
137
|
)
|
138
138
|
# Extract data
|
@@ -210,11 +210,11 @@ def test_SphereAggregation_3D_mask() -> None:
|
|
210
210
|
|
211
211
|
# Compare with nilearn
|
212
212
|
# Load testing coordinates
|
213
|
-
testing_coords, _ =
|
213
|
+
testing_coords, _ = CoordinatesRegistry().get(
|
214
214
|
coords=COORDS, target_data=element_data["VBM_GM"]
|
215
215
|
)
|
216
216
|
# Load mask
|
217
|
-
mask_img =
|
217
|
+
mask_img = MaskRegistry().get(
|
218
218
|
"compute_brain_mask", target_data=element_data["VBM_GM"]
|
219
219
|
)
|
220
220
|
# Extract data
|
@@ -253,7 +253,7 @@ def test_SphereAggregation_4D_agg_time() -> None:
|
|
253
253
|
|
254
254
|
# Compare with nilearn
|
255
255
|
# Load testing coordinates
|
256
|
-
testing_coords, _ =
|
256
|
+
testing_coords, _ = CoordinatesRegistry().get(
|
257
257
|
coords=COORDS, target_data=element_data["BOLD"]
|
258
258
|
)
|
259
259
|
# Extract data
|
junifer/markers/utils.py
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
# Amir Omidvarnia <a.omidvarnia@fz-juelich.de>
|
9
9
|
# License: AGPL
|
10
10
|
|
11
|
-
from typing import Callable,
|
11
|
+
from typing import Callable, Optional, Union
|
12
12
|
|
13
13
|
import numpy as np
|
14
14
|
import pandas as pd
|
@@ -19,8 +19,8 @@ from ..utils import raise_error
|
|
19
19
|
|
20
20
|
def _ets(
|
21
21
|
bold_ts: np.ndarray,
|
22
|
-
roi_names: Union[None,
|
23
|
-
) ->
|
22
|
+
roi_names: Union[None, list[str]] = None,
|
23
|
+
) -> tuple[np.ndarray, Optional[list[str]]]:
|
24
24
|
"""Compute the edge-wise time series based on BOLD time series.
|
25
25
|
|
26
26
|
Take a timeseries of brain areas, and calculate timeseries for each
|