junifer 0.0.6.dev248__py3-none-any.whl → 0.0.6.dev258__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/_version.py +2 -2
- junifer/api/decorators.py +1 -2
- junifer/api/functions.py +18 -18
- junifer/api/queue_context/gnu_parallel_local_adapter.py +4 -4
- junifer/api/queue_context/htcondor_adapter.py +4 -4
- 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 +32 -32
- junifer/cli/cli.py +3 -3
- junifer/cli/parser.py +4 -4
- junifer/cli/tests/test_cli.py +5 -5
- junifer/cli/utils.py +5 -6
- junifer/configs/juseless/datagrabbers/ixi_vbm.py +2 -2
- junifer/configs/juseless/datagrabbers/tests/test_ucla.py +2 -2
- junifer/configs/juseless/datagrabbers/ucla.py +4 -4
- junifer/data/_dispatch.py +11 -14
- junifer/data/coordinates/_ants_coordinates_warper.py +16 -6
- junifer/data/coordinates/_coordinates.py +7 -7
- junifer/data/coordinates/_fsl_coordinates_warper.py +3 -3
- junifer/data/masks/_ants_mask_warper.py +3 -3
- junifer/data/masks/_fsl_mask_warper.py +3 -3
- junifer/data/masks/_masks.py +6 -9
- junifer/data/masks/tests/test_masks.py +4 -4
- junifer/data/parcellations/_ants_parcellation_warper.py +3 -3
- junifer/data/parcellations/_fsl_parcellation_warper.py +3 -3
- junifer/data/parcellations/_parcellations.py +19 -19
- junifer/data/parcellations/tests/test_parcellations.py +1 -2
- junifer/data/pipeline_data_registry_base.py +3 -2
- junifer/data/template_spaces.py +3 -3
- junifer/data/tests/test_data_utils.py +1 -2
- junifer/data/utils.py +4 -3
- junifer/datagrabber/aomic/id1000.py +2 -2
- junifer/datagrabber/aomic/piop1.py +5 -5
- junifer/datagrabber/aomic/piop2.py +5 -5
- junifer/datagrabber/aomic/tests/test_id1000.py +3 -3
- junifer/datagrabber/aomic/tests/test_piop1.py +4 -4
- junifer/datagrabber/aomic/tests/test_piop2.py +4 -4
- junifer/datagrabber/base.py +12 -11
- junifer/datagrabber/datalad_base.py +3 -3
- junifer/datagrabber/dmcc13_benchmark.py +8 -8
- junifer/datagrabber/hcp1200/datalad_hcp1200.py +3 -3
- junifer/datagrabber/hcp1200/hcp1200.py +8 -8
- junifer/datagrabber/hcp1200/tests/test_hcp1200.py +2 -1
- junifer/datagrabber/multiple.py +7 -7
- junifer/datagrabber/pattern.py +10 -10
- junifer/datagrabber/pattern_validation_mixin.py +10 -10
- junifer/datagrabber/tests/test_datalad_base.py +7 -8
- junifer/datagrabber/tests/test_dmcc13_benchmark.py +2 -2
- junifer/datagrabber/tests/test_pattern_validation_mixin.py +6 -6
- junifer/datareader/default.py +6 -6
- junifer/external/nilearn/junifer_connectivity_measure.py +2 -2
- junifer/external/nilearn/junifer_nifti_spheres_masker.py +4 -4
- junifer/external/nilearn/tests/test_junifer_connectivity_measure.py +15 -15
- junifer/external/nilearn/tests/test_junifer_nifti_spheres_masker.py +2 -3
- junifer/markers/base.py +8 -8
- junifer/markers/brainprint.py +7 -9
- junifer/markers/complexity/complexity_base.py +6 -8
- junifer/markers/complexity/hurst_exponent.py +5 -5
- junifer/markers/complexity/multiscale_entropy_auc.py +5 -5
- junifer/markers/complexity/perm_entropy.py +5 -5
- junifer/markers/complexity/range_entropy.py +5 -5
- junifer/markers/complexity/range_entropy_auc.py +5 -5
- junifer/markers/complexity/sample_entropy.py +5 -5
- junifer/markers/complexity/weighted_perm_entropy.py +5 -5
- junifer/markers/ets_rss.py +7 -7
- junifer/markers/falff/_afni_falff.py +1 -2
- junifer/markers/falff/_junifer_falff.py +1 -2
- junifer/markers/falff/falff_base.py +2 -4
- junifer/markers/falff/falff_parcels.py +7 -7
- junifer/markers/falff/falff_spheres.py +6 -6
- junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +6 -6
- junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +7 -7
- junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +6 -6
- junifer/markers/functional_connectivity/functional_connectivity_base.py +10 -10
- junifer/markers/functional_connectivity/functional_connectivity_parcels.py +7 -7
- junifer/markers/functional_connectivity/functional_connectivity_spheres.py +6 -6
- 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 +3 -3
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +3 -3
- junifer/markers/parcel_aggregation.py +8 -8
- junifer/markers/reho/_afni_reho.py +1 -2
- junifer/markers/reho/_junifer_reho.py +1 -2
- junifer/markers/reho/reho_base.py +2 -4
- junifer/markers/reho/reho_parcels.py +8 -8
- junifer/markers/reho/reho_spheres.py +7 -7
- junifer/markers/sphere_aggregation.py +8 -8
- junifer/markers/temporal_snr/temporal_snr_base.py +8 -8
- junifer/markers/temporal_snr/temporal_snr_parcels.py +6 -6
- junifer/markers/temporal_snr/temporal_snr_spheres.py +5 -5
- junifer/markers/utils.py +3 -3
- junifer/onthefly/_brainprint.py +2 -2
- junifer/onthefly/read_transform.py +3 -3
- junifer/pipeline/marker_collection.py +4 -4
- junifer/pipeline/pipeline_component_registry.py +5 -4
- junifer/pipeline/pipeline_step_mixin.py +7 -7
- junifer/pipeline/tests/test_pipeline_component_registry.py +2 -3
- junifer/pipeline/tests/test_pipeline_step_mixin.py +19 -19
- junifer/pipeline/tests/test_update_meta_mixin.py +4 -4
- junifer/pipeline/update_meta_mixin.py +2 -2
- junifer/pipeline/utils.py +5 -5
- junifer/preprocess/base.py +10 -10
- junifer/preprocess/confounds/fmriprep_confound_remover.py +11 -14
- junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py +1 -2
- junifer/preprocess/smoothing/smoothing.py +7 -7
- junifer/preprocess/warping/_ants_warper.py +3 -4
- junifer/preprocess/warping/_fsl_warper.py +3 -4
- junifer/preprocess/warping/space_warper.py +6 -6
- junifer/preprocess/warping/tests/test_space_warper.py +3 -4
- junifer/stats.py +4 -4
- junifer/storage/base.py +14 -13
- junifer/storage/hdf5.py +21 -20
- junifer/storage/pandas_base.py +12 -11
- junifer/storage/sqlite.py +11 -11
- junifer/storage/tests/test_hdf5.py +1 -2
- junifer/storage/tests/test_sqlite.py +2 -2
- junifer/storage/tests/test_utils.py +8 -7
- junifer/storage/utils.py +7 -7
- junifer/testing/datagrabbers.py +9 -10
- junifer/tests/test_stats.py +2 -2
- junifer/typing/_typing.py +6 -9
- junifer/utils/helpers.py +2 -3
- junifer/utils/logging.py +5 -5
- junifer/utils/singleton.py +3 -3
- {junifer-0.0.6.dev248.dist-info → junifer-0.0.6.dev258.dist-info}/METADATA +2 -2
- {junifer-0.0.6.dev248.dist-info → junifer-0.0.6.dev258.dist-info}/RECORD +131 -131
- {junifer-0.0.6.dev248.dist-info → junifer-0.0.6.dev258.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.6.dev248.dist-info → junifer-0.0.6.dev258.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.6.dev248.dist-info → junifer-0.0.6.dev258.dist-info}/WHEEL +0 -0
- {junifer-0.0.6.dev248.dist-info → junifer-0.0.6.dev258.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.6.dev248.dist-info → junifer-0.0.6.dev258.dist-info}/top_level.txt +0 -0
junifer/data/_dispatch.py
CHANGED
@@ -8,10 +8,7 @@ from typing import (
|
|
8
8
|
TYPE_CHECKING,
|
9
9
|
Any,
|
10
10
|
Callable,
|
11
|
-
Dict,
|
12
|
-
List,
|
13
11
|
Optional,
|
14
|
-
Tuple,
|
15
12
|
Union,
|
16
13
|
)
|
17
14
|
|
@@ -40,15 +37,15 @@ def get_data(
|
|
40
37
|
kind: str,
|
41
38
|
names: Union[
|
42
39
|
str, # coordinates, parcellation, mask
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
list[str], # parcellation, mask
|
41
|
+
dict, # mask
|
42
|
+
list[dict], # mask
|
46
43
|
],
|
47
|
-
target_data:
|
48
|
-
extra_input: Optional[
|
44
|
+
target_data: dict[str, Any],
|
45
|
+
extra_input: Optional[dict[str, Any]] = None,
|
49
46
|
) -> Union[
|
50
|
-
|
51
|
-
|
47
|
+
tuple[ArrayLike, list[str]], # coordinates
|
48
|
+
tuple["Nifti1Image", list[str]], # parcellation
|
52
49
|
"Nifti1Image", # mask
|
53
50
|
]:
|
54
51
|
"""Get tailored ``kind`` for ``target_data``.
|
@@ -102,7 +99,7 @@ def get_data(
|
|
102
99
|
raise_error(f"Unknown data kind: {kind}")
|
103
100
|
|
104
101
|
|
105
|
-
def list_data(kind: str) ->
|
102
|
+
def list_data(kind: str) -> list[str]:
|
106
103
|
"""List available data for ``kind``.
|
107
104
|
|
108
105
|
Parameters
|
@@ -137,9 +134,9 @@ def load_data(
|
|
137
134
|
name: str,
|
138
135
|
**kwargs,
|
139
136
|
) -> Union[
|
140
|
-
|
141
|
-
|
142
|
-
|
137
|
+
tuple[ArrayLike, list[str], str], # coordinates
|
138
|
+
tuple[Optional["Nifti1Image"], list[str], Path, str], # parcellation
|
139
|
+
tuple[
|
143
140
|
Optional[Union["Nifti1Image", Callable]], Optional[Path], str
|
144
141
|
], # mask
|
145
142
|
]:
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Authors: Synchon Mandal <s.mandal@fz-juelich.de>
|
4
4
|
# License: AGPL
|
5
5
|
|
6
|
-
from typing import Any
|
6
|
+
from typing import Any
|
7
7
|
|
8
8
|
import numpy as np
|
9
9
|
from numpy.typing import ArrayLike
|
@@ -25,8 +25,8 @@ class ANTsCoordinatesWarper:
|
|
25
25
|
def warp(
|
26
26
|
self,
|
27
27
|
seeds: ArrayLike,
|
28
|
-
target_data:
|
29
|
-
warp_data:
|
28
|
+
target_data: dict[str, Any],
|
29
|
+
warp_data: dict[str, Any],
|
30
30
|
) -> ArrayLike:
|
31
31
|
"""Warp ``seeds`` to correct space.
|
32
32
|
|
@@ -55,19 +55,24 @@ class ANTsCoordinatesWarper:
|
|
55
55
|
|
56
56
|
# Save existing coordinates to a tempfile
|
57
57
|
pretransform_coordinates_path = (
|
58
|
-
element_tempdir / "pretransform_coordinates.
|
58
|
+
element_tempdir / "pretransform_coordinates.csv"
|
59
59
|
)
|
60
|
+
# Convert LPS to RAS
|
61
|
+
seeds[:, 0] *= -1
|
62
|
+
seeds[:, 1] *= -1
|
60
63
|
np.savetxt(
|
61
64
|
pretransform_coordinates_path,
|
62
65
|
seeds,
|
63
66
|
delimiter=",",
|
64
67
|
# Add header while saving to make ANTs work
|
65
68
|
header="x,y,z",
|
69
|
+
# Remove comment tag for header
|
70
|
+
comments="",
|
66
71
|
)
|
67
72
|
|
68
73
|
# Create a tempfile for transformed coordinates output
|
69
74
|
transformed_coords_path = (
|
70
|
-
element_tempdir / "coordinates_transformed.
|
75
|
+
element_tempdir / "coordinates_transformed.csv"
|
71
76
|
)
|
72
77
|
# Set antsApplyTransformsToPoints command
|
73
78
|
apply_transforms_to_points_cmd = [
|
@@ -86,9 +91,14 @@ class ANTsCoordinatesWarper:
|
|
86
91
|
)
|
87
92
|
|
88
93
|
# Load coordinates
|
89
|
-
|
94
|
+
transformed_seeds = np.loadtxt(
|
90
95
|
# Skip header when reading
|
91
96
|
transformed_coords_path,
|
92
97
|
delimiter=",",
|
93
98
|
skiprows=1,
|
94
99
|
)
|
100
|
+
# Convert RAS to LPS
|
101
|
+
transformed_seeds[:, 0] *= -1
|
102
|
+
transformed_seeds[:, 1] *= -1
|
103
|
+
|
104
|
+
return transformed_seeds
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# License: AGPL
|
6
6
|
|
7
7
|
from pathlib import Path
|
8
|
-
from typing import Any,
|
8
|
+
from typing import Any, Optional
|
9
9
|
|
10
10
|
import numpy as np
|
11
11
|
import pandas as pd
|
@@ -135,7 +135,7 @@ class CoordinatesRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
135
135
|
self,
|
136
136
|
name: str,
|
137
137
|
coordinates: ArrayLike,
|
138
|
-
voi_names:
|
138
|
+
voi_names: list[str],
|
139
139
|
space: str,
|
140
140
|
overwrite: Optional[bool] = False,
|
141
141
|
) -> None:
|
@@ -236,7 +236,7 @@ class CoordinatesRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
236
236
|
# Update registry
|
237
237
|
_ = self._registry.pop(name)
|
238
238
|
|
239
|
-
def load(self, name: str) ->
|
239
|
+
def load(self, name: str) -> tuple[ArrayLike, list[str], str]:
|
240
240
|
"""Load coordinates.
|
241
241
|
|
242
242
|
Parameters
|
@@ -285,9 +285,9 @@ class CoordinatesRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
285
285
|
def get(
|
286
286
|
self,
|
287
287
|
coords: str,
|
288
|
-
target_data:
|
289
|
-
extra_input: Optional[
|
290
|
-
) ->
|
288
|
+
target_data: dict[str, Any],
|
289
|
+
extra_input: Optional[dict[str, Any]] = None,
|
290
|
+
) -> tuple[ArrayLike, list[str]]:
|
291
291
|
"""Get coordinates, tailored for the target data.
|
292
292
|
|
293
293
|
Parameters
|
@@ -362,7 +362,7 @@ class CoordinatesRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
362
362
|
seeds = ANTsCoordinatesWarper().warp(
|
363
363
|
seeds=seeds,
|
364
364
|
target_data=target_data,
|
365
|
-
warp_data=
|
365
|
+
warp_data=inverse_warper_spec,
|
366
366
|
)
|
367
367
|
|
368
368
|
return seeds, labels
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Authors: Synchon Mandal <s.mandal@fz-juelich.de>
|
4
4
|
# License: AGPL
|
5
5
|
|
6
|
-
from typing import Any
|
6
|
+
from typing import Any
|
7
7
|
|
8
8
|
import numpy as np
|
9
9
|
from numpy.typing import ArrayLike
|
@@ -25,8 +25,8 @@ class FSLCoordinatesWarper:
|
|
25
25
|
def warp(
|
26
26
|
self,
|
27
27
|
seeds: ArrayLike,
|
28
|
-
target_data:
|
29
|
-
warp_data:
|
28
|
+
target_data: dict[str, Any],
|
29
|
+
warp_data: dict[str, Any],
|
30
30
|
) -> ArrayLike:
|
31
31
|
"""Warp ``seeds`` to correct space.
|
32
32
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# License: AGPL
|
5
5
|
|
6
6
|
import uuid
|
7
|
-
from typing import TYPE_CHECKING, Any,
|
7
|
+
from typing import TYPE_CHECKING, Any, Optional
|
8
8
|
|
9
9
|
import nibabel as nib
|
10
10
|
|
@@ -33,8 +33,8 @@ class ANTsMaskWarper:
|
|
33
33
|
mask_img: "Nifti1Image",
|
34
34
|
src: str,
|
35
35
|
dst: str,
|
36
|
-
target_data:
|
37
|
-
warp_data: Optional[
|
36
|
+
target_data: dict[str, Any],
|
37
|
+
warp_data: Optional[dict[str, Any]],
|
38
38
|
) -> "Nifti1Image":
|
39
39
|
"""Warp ``mask_img`` to correct space.
|
40
40
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# License: AGPL
|
5
5
|
|
6
6
|
import uuid
|
7
|
-
from typing import TYPE_CHECKING, Any
|
7
|
+
from typing import TYPE_CHECKING, Any
|
8
8
|
|
9
9
|
import nibabel as nib
|
10
10
|
|
@@ -30,8 +30,8 @@ class FSLMaskWarper:
|
|
30
30
|
self,
|
31
31
|
mask_name: str,
|
32
32
|
mask_img: "Nifti1Image",
|
33
|
-
target_data:
|
34
|
-
warp_data:
|
33
|
+
target_data: dict[str, Any],
|
34
|
+
warp_data: dict[str, Any],
|
35
35
|
) -> "Nifti1Image":
|
36
36
|
"""Warp ``mask_img`` to correct space.
|
37
37
|
|
junifer/data/masks/_masks.py
CHANGED
@@ -9,10 +9,7 @@ from typing import (
|
|
9
9
|
TYPE_CHECKING,
|
10
10
|
Any,
|
11
11
|
Callable,
|
12
|
-
Dict,
|
13
|
-
List,
|
14
12
|
Optional,
|
15
|
-
Tuple,
|
16
13
|
Union,
|
17
14
|
)
|
18
15
|
|
@@ -46,8 +43,8 @@ _masks_path = Path(__file__).parent
|
|
46
43
|
|
47
44
|
|
48
45
|
def compute_brain_mask(
|
49
|
-
target_data:
|
50
|
-
extra_input: Optional[
|
46
|
+
target_data: dict[str, Any],
|
47
|
+
extra_input: Optional[dict[str, Any]] = None,
|
51
48
|
mask_type: str = "brain",
|
52
49
|
threshold: float = 0.5,
|
53
50
|
) -> "Nifti1Image":
|
@@ -266,7 +263,7 @@ class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
266
263
|
name: str,
|
267
264
|
resolution: Optional[float] = None,
|
268
265
|
path_only: bool = False,
|
269
|
-
) ->
|
266
|
+
) -> tuple[Optional[Union["Nifti1Image", Callable]], Optional[Path], str]:
|
270
267
|
"""Load mask.
|
271
268
|
|
272
269
|
Parameters
|
@@ -332,9 +329,9 @@ class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
332
329
|
|
333
330
|
def get( # noqa: C901
|
334
331
|
self,
|
335
|
-
masks: Union[str,
|
336
|
-
target_data:
|
337
|
-
extra_input: Optional[
|
332
|
+
masks: Union[str, dict, list[Union[dict, str]]],
|
333
|
+
target_data: dict[str, Any],
|
334
|
+
extra_input: Optional[dict[str, Any]] = None,
|
338
335
|
) -> "Nifti1Image":
|
339
336
|
"""Get mask, tailored for the target image.
|
340
337
|
|
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
import socket
|
9
9
|
from pathlib import Path
|
10
|
-
from typing import Callable,
|
10
|
+
from typing import Callable, Optional, Union
|
11
11
|
|
12
12
|
import nibabel as nib
|
13
13
|
import numpy as np
|
@@ -254,7 +254,7 @@ def test_load_incorrect() -> None:
|
|
254
254
|
def test_vickery_patil(
|
255
255
|
name: str,
|
256
256
|
resolution: Optional[float],
|
257
|
-
pixdim:
|
257
|
+
pixdim: list[float],
|
258
258
|
fname: str,
|
259
259
|
) -> None:
|
260
260
|
"""Test Vickery-Patil mask.
|
@@ -396,7 +396,7 @@ def test_get_errors() -> None:
|
|
396
396
|
def test_nilearn_compute_masks(
|
397
397
|
mask_name: str,
|
398
398
|
function: Callable,
|
399
|
-
params: Union[
|
399
|
+
params: Union[dict, None],
|
400
400
|
resample: bool,
|
401
401
|
) -> None:
|
402
402
|
"""Test using nilearn compute mask functions.
|
@@ -479,7 +479,7 @@ def test_get_inherit() -> None:
|
|
479
479
|
],
|
480
480
|
)
|
481
481
|
def test_get_multiple(
|
482
|
-
masks: Union[str,
|
482
|
+
masks: Union[str, dict, list[Union[dict, str]]], params: dict
|
483
483
|
) -> None:
|
484
484
|
"""Test getting multiple masks.
|
485
485
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# License: AGPL
|
5
5
|
|
6
6
|
import uuid
|
7
|
-
from typing import TYPE_CHECKING, Any,
|
7
|
+
from typing import TYPE_CHECKING, Any, Optional
|
8
8
|
|
9
9
|
import nibabel as nib
|
10
10
|
|
@@ -33,8 +33,8 @@ class ANTsParcellationWarper:
|
|
33
33
|
parcellation_img: "Nifti1Image",
|
34
34
|
src: str,
|
35
35
|
dst: str,
|
36
|
-
target_data:
|
37
|
-
warp_data: Optional[
|
36
|
+
target_data: dict[str, Any],
|
37
|
+
warp_data: Optional[dict[str, Any]],
|
38
38
|
) -> "Nifti1Image":
|
39
39
|
"""Warp ``parcellation_img`` to correct space.
|
40
40
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# License: AGPL
|
5
5
|
|
6
6
|
import uuid
|
7
|
-
from typing import TYPE_CHECKING, Any
|
7
|
+
from typing import TYPE_CHECKING, Any
|
8
8
|
|
9
9
|
import nibabel as nib
|
10
10
|
|
@@ -30,8 +30,8 @@ class FSLParcellationWarper:
|
|
30
30
|
self,
|
31
31
|
parcellation_name: str,
|
32
32
|
parcellation_img: "Nifti1Image",
|
33
|
-
target_data:
|
34
|
-
warp_data:
|
33
|
+
target_data: dict[str, Any],
|
34
|
+
warp_data: dict[str, Any],
|
35
35
|
) -> "Nifti1Image":
|
36
36
|
"""Warp ``parcellation_img`` to correct space.
|
37
37
|
|
@@ -12,7 +12,7 @@ import tempfile
|
|
12
12
|
import zipfile
|
13
13
|
from itertools import product
|
14
14
|
from pathlib import Path
|
15
|
-
from typing import TYPE_CHECKING, Any,
|
15
|
+
from typing import TYPE_CHECKING, Any, Optional, Union
|
16
16
|
|
17
17
|
import httpx
|
18
18
|
import nibabel as nib
|
@@ -190,7 +190,7 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
190
190
|
self,
|
191
191
|
name: str,
|
192
192
|
parcellation_path: Union[str, Path],
|
193
|
-
parcels_labels:
|
193
|
+
parcels_labels: list[str],
|
194
194
|
space: str,
|
195
195
|
overwrite: bool = False,
|
196
196
|
) -> None:
|
@@ -272,7 +272,7 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
272
272
|
parcellations_dir: Union[str, Path, None] = None,
|
273
273
|
resolution: Optional[float] = None,
|
274
274
|
path_only: bool = False,
|
275
|
-
) ->
|
275
|
+
) -> tuple[Optional["Nifti1Image"], list[str], Path, str]:
|
276
276
|
"""Load parcellation and labels.
|
277
277
|
|
278
278
|
If it is a built-in parcellation and the file is not present in the
|
@@ -367,10 +367,10 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
367
367
|
|
368
368
|
def get(
|
369
369
|
self,
|
370
|
-
parcellations: Union[str,
|
371
|
-
target_data:
|
372
|
-
extra_input: Optional[
|
373
|
-
) ->
|
370
|
+
parcellations: Union[str, list[str]],
|
371
|
+
target_data: dict[str, Any],
|
372
|
+
extra_input: Optional[dict[str, Any]] = None,
|
373
|
+
) -> tuple["Nifti1Image", list[str]]:
|
374
374
|
"""Get parcellation, tailored for the target image.
|
375
375
|
|
376
376
|
Parameters
|
@@ -503,7 +503,7 @@ def _retrieve_parcellation(
|
|
503
503
|
parcellations_dir: Union[str, Path, None] = None,
|
504
504
|
resolution: Optional[float] = None,
|
505
505
|
**kwargs,
|
506
|
-
) ->
|
506
|
+
) -> tuple[Path, list[str]]:
|
507
507
|
"""Retrieve a brain parcellation object from nilearn or online source.
|
508
508
|
|
509
509
|
Only returns one parcellation per call. Call function multiple times for
|
@@ -647,7 +647,7 @@ def _retrieve_schaefer(
|
|
647
647
|
resolution: Optional[float] = None,
|
648
648
|
n_rois: Optional[int] = None,
|
649
649
|
yeo_networks: int = 7,
|
650
|
-
) ->
|
650
|
+
) -> tuple[Path, list[str]]:
|
651
651
|
"""Retrieve Schaefer parcellation.
|
652
652
|
|
653
653
|
Parameters
|
@@ -749,7 +749,7 @@ def _retrieve_tian(
|
|
749
749
|
scale: Optional[int] = None,
|
750
750
|
space: str = "MNI152NLin6Asym",
|
751
751
|
magneticfield: str = "3T",
|
752
|
-
) ->
|
752
|
+
) -> tuple[Path, list[str]]:
|
753
753
|
"""Retrieve Tian parcellation.
|
754
754
|
|
755
755
|
Parameters
|
@@ -923,7 +923,7 @@ def _retrieve_suit(
|
|
923
923
|
parcellations_dir: Path,
|
924
924
|
resolution: Optional[float],
|
925
925
|
space: str = "MNI152NLin6Asym",
|
926
|
-
) ->
|
926
|
+
) -> tuple[Path, list[str]]:
|
927
927
|
"""Retrieve SUIT parcellation.
|
928
928
|
|
929
929
|
Parameters
|
@@ -1049,7 +1049,7 @@ def _retrieve_aicha(
|
|
1049
1049
|
parcellations_dir: Path,
|
1050
1050
|
resolution: Optional[float] = None,
|
1051
1051
|
version: int = 2,
|
1052
|
-
) ->
|
1052
|
+
) -> tuple[Path, list[str]]:
|
1053
1053
|
"""Retrieve AICHA parcellation.
|
1054
1054
|
|
1055
1055
|
Parameters
|
@@ -1205,7 +1205,7 @@ def _retrieve_shen( # noqa: C901
|
|
1205
1205
|
resolution: Optional[float] = None,
|
1206
1206
|
year: int = 2015,
|
1207
1207
|
n_rois: int = 268,
|
1208
|
-
) ->
|
1208
|
+
) -> tuple[Path, list[str]]:
|
1209
1209
|
"""Retrieve Shen parcellation.
|
1210
1210
|
|
1211
1211
|
Parameters
|
@@ -1410,7 +1410,7 @@ def _retrieve_yan(
|
|
1410
1410
|
n_rois: Optional[int] = None,
|
1411
1411
|
yeo_networks: Optional[int] = None,
|
1412
1412
|
kong_networks: Optional[int] = None,
|
1413
|
-
) ->
|
1413
|
+
) -> tuple[Path, list[str]]:
|
1414
1414
|
"""Retrieve Yan parcellation.
|
1415
1415
|
|
1416
1416
|
Parameters
|
@@ -1607,7 +1607,7 @@ def _retrieve_brainnetome(
|
|
1607
1607
|
parcellations_dir: Path,
|
1608
1608
|
resolution: Optional[float] = None,
|
1609
1609
|
threshold: Optional[int] = None,
|
1610
|
-
) ->
|
1610
|
+
) -> tuple[Path, list[str]]:
|
1611
1611
|
"""Retrieve Brainnetome parcellation.
|
1612
1612
|
|
1613
1613
|
Parameters
|
@@ -1720,10 +1720,10 @@ def _retrieve_brainnetome(
|
|
1720
1720
|
|
1721
1721
|
|
1722
1722
|
def merge_parcellations(
|
1723
|
-
parcellations_list:
|
1724
|
-
parcellations_names:
|
1725
|
-
labels_lists:
|
1726
|
-
) ->
|
1723
|
+
parcellations_list: list["Nifti1Image"],
|
1724
|
+
parcellations_names: list[str],
|
1725
|
+
labels_lists: list[list[str]],
|
1726
|
+
) -> tuple["Nifti1Image", list[str]]:
|
1727
1727
|
"""Merge all parcellations from a list into one parcellation.
|
1728
1728
|
|
1729
1729
|
Parameters
|
@@ -6,7 +6,6 @@
|
|
6
6
|
# License: AGPL
|
7
7
|
|
8
8
|
from pathlib import Path
|
9
|
-
from typing import List
|
10
9
|
|
11
10
|
import nibabel as nib
|
12
11
|
import numpy as np
|
@@ -171,7 +170,7 @@ def test_parcellation_wrong_labels_values(tmp_path: Path) -> None:
|
|
171
170
|
def test_register(
|
172
171
|
name: str,
|
173
172
|
parcellation_path: str,
|
174
|
-
parcels_labels:
|
173
|
+
parcels_labels: list[str],
|
175
174
|
space: str,
|
176
175
|
overwrite: bool,
|
177
176
|
) -> None:
|
@@ -4,7 +4,8 @@
|
|
4
4
|
# License: AGPL
|
5
5
|
|
6
6
|
from abc import ABC, abstractmethod
|
7
|
-
from
|
7
|
+
from collections.abc import Mapping
|
8
|
+
from typing import Any
|
8
9
|
|
9
10
|
from ..utils import raise_error
|
10
11
|
from ..utils.singleton import ABCSingleton
|
@@ -38,7 +39,7 @@ class BasePipelineDataRegistry(ABC, metaclass=ABCSingleton):
|
|
38
39
|
return self._registry
|
39
40
|
|
40
41
|
@property
|
41
|
-
def list(self) ->
|
42
|
+
def list(self) -> list[str]:
|
42
43
|
"""List available pipeline data keys."""
|
43
44
|
return sorted(self._registry.keys())
|
44
45
|
|
junifer/data/template_spaces.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# License: AGPL
|
5
5
|
|
6
6
|
from pathlib import Path
|
7
|
-
from typing import Any,
|
7
|
+
from typing import Any, Optional, Union
|
8
8
|
|
9
9
|
import datalad.api as dl
|
10
10
|
import nibabel as nib
|
@@ -122,8 +122,8 @@ def get_xfm(
|
|
122
122
|
|
123
123
|
def get_template(
|
124
124
|
space: str,
|
125
|
-
target_data:
|
126
|
-
extra_input: Optional[
|
125
|
+
target_data: dict[str, Any],
|
126
|
+
extra_input: Optional[dict[str, Any]] = None,
|
127
127
|
template_type: str = "T1w",
|
128
128
|
) -> nib.Nifti1Image:
|
129
129
|
"""Get template for the space, tailored for the target image.
|
@@ -3,7 +3,6 @@
|
|
3
3
|
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
|
4
4
|
# License: AGPL
|
5
5
|
|
6
|
-
from typing import List
|
7
6
|
|
8
7
|
import numpy as np
|
9
8
|
import pytest
|
@@ -24,7 +23,7 @@ from junifer.data.utils import closest_resolution
|
|
24
23
|
],
|
25
24
|
)
|
26
25
|
def test_closest_resolution(
|
27
|
-
resolution: float, valid_resolutions:
|
26
|
+
resolution: float, valid_resolutions: list[float], expected: float
|
28
27
|
):
|
29
28
|
"""Test closest_resolution.
|
30
29
|
|
junifer/data/utils.py
CHANGED
@@ -4,7 +4,8 @@
|
|
4
4
|
# Synchon Mandal <s.mandal@fz-juelich.de>
|
5
5
|
# License: AGPL
|
6
6
|
|
7
|
-
from
|
7
|
+
from collections.abc import MutableMapping
|
8
|
+
from typing import Optional, Union
|
8
9
|
|
9
10
|
import numpy as np
|
10
11
|
|
@@ -16,7 +17,7 @@ __all__ = ["closest_resolution", "get_native_warper"]
|
|
16
17
|
|
17
18
|
def closest_resolution(
|
18
19
|
resolution: Optional[Union[float, int]],
|
19
|
-
valid_resolution: Union[
|
20
|
+
valid_resolution: Union[list[float], list[int], np.ndarray],
|
20
21
|
) -> Union[float, int]:
|
21
22
|
"""Find the closest resolution.
|
22
23
|
|
@@ -55,7 +56,7 @@ def get_native_warper(
|
|
55
56
|
target_data: MutableMapping,
|
56
57
|
other_data: MutableMapping,
|
57
58
|
inverse: bool = False,
|
58
|
-
) ->
|
59
|
+
) -> dict:
|
59
60
|
"""Get correct warping specification for native space.
|
60
61
|
|
61
62
|
Parameters
|
@@ -8,7 +8,7 @@
|
|
8
8
|
# License: AGPL
|
9
9
|
|
10
10
|
from pathlib import Path
|
11
|
-
from typing import
|
11
|
+
from typing import Union
|
12
12
|
|
13
13
|
from ...api.decorators import register_datagrabber
|
14
14
|
from ..pattern_datalad import PatternDataladDataGrabber
|
@@ -39,7 +39,7 @@ class DataladAOMICID1000(PatternDataladDataGrabber):
|
|
39
39
|
def __init__(
|
40
40
|
self,
|
41
41
|
datadir: Union[str, Path, None] = None,
|
42
|
-
types: Union[str,
|
42
|
+
types: Union[str, list[str], None] = None,
|
43
43
|
native_t1w: bool = False,
|
44
44
|
) -> None:
|
45
45
|
# The patterns
|
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
from itertools import product
|
11
11
|
from pathlib import Path
|
12
|
-
from typing import
|
12
|
+
from typing import Union
|
13
13
|
|
14
14
|
from ...api.decorators import register_datagrabber
|
15
15
|
from ...utils import raise_error
|
@@ -50,8 +50,8 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber):
|
|
50
50
|
def __init__(
|
51
51
|
self,
|
52
52
|
datadir: Union[str, Path, None] = None,
|
53
|
-
types: Union[str,
|
54
|
-
tasks: Union[str,
|
53
|
+
types: Union[str, list[str], None] = None,
|
54
|
+
tasks: Union[str, list[str], None] = None,
|
55
55
|
native_t1w: bool = False,
|
56
56
|
) -> None:
|
57
57
|
# Declare all tasks
|
@@ -247,7 +247,7 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber):
|
|
247
247
|
confounds_format="fmriprep",
|
248
248
|
)
|
249
249
|
|
250
|
-
def get_item(self, subject: str, task: str) ->
|
250
|
+
def get_item(self, subject: str, task: str) -> dict:
|
251
251
|
"""Index one element in the dataset.
|
252
252
|
|
253
253
|
Parameters
|
@@ -279,7 +279,7 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber):
|
|
279
279
|
|
280
280
|
return super().get_item(subject=subject, task=new_task)
|
281
281
|
|
282
|
-
def get_elements(self) ->
|
282
|
+
def get_elements(self) -> list:
|
283
283
|
"""Implement fetching list of subjects in the dataset.
|
284
284
|
|
285
285
|
Returns
|
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
from itertools import product
|
11
11
|
from pathlib import Path
|
12
|
-
from typing import
|
12
|
+
from typing import Union
|
13
13
|
|
14
14
|
from ...api.decorators import register_datagrabber
|
15
15
|
from ...utils import raise_error
|
@@ -50,8 +50,8 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
|
|
50
50
|
def __init__(
|
51
51
|
self,
|
52
52
|
datadir: Union[str, Path, None] = None,
|
53
|
-
types: Union[str,
|
54
|
-
tasks: Union[str,
|
53
|
+
types: Union[str, list[str], None] = None,
|
54
|
+
tasks: Union[str, list[str], None] = None,
|
55
55
|
native_t1w: bool = False,
|
56
56
|
) -> None:
|
57
57
|
# Declare all tasks
|
@@ -245,7 +245,7 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
|
|
245
245
|
confounds_format="fmriprep",
|
246
246
|
)
|
247
247
|
|
248
|
-
def get_elements(self) ->
|
248
|
+
def get_elements(self) -> list:
|
249
249
|
"""Implement fetching list of elements in the dataset.
|
250
250
|
|
251
251
|
Returns
|
@@ -261,7 +261,7 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
|
|
261
261
|
elems.append((subject, task))
|
262
262
|
return elems
|
263
263
|
|
264
|
-
def get_item(self, subject: str, task: str) ->
|
264
|
+
def get_item(self, subject: str, task: str) -> dict:
|
265
265
|
"""Index one element in the dataset.
|
266
266
|
|
267
267
|
Parameters
|