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
@@ -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
|
@@ -33,12 +33,12 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
|
|
33
33
|
"FreeSurfer"} or list of the options, optional
|
34
34
|
AOMIC data types. If None, all available data types are selected.
|
35
35
|
(default None).
|
36
|
-
tasks : {"restingstate", "stopsignal", "workingmemory"} or \
|
36
|
+
tasks : {"restingstate", "stopsignal", "workingmemory", "emomatching"} or \
|
37
37
|
list of the options, optional
|
38
38
|
AOMIC PIOP2 task sessions. If None, all available task sessions are
|
39
39
|
selected (default None).
|
40
|
-
|
41
|
-
|
40
|
+
space : {"native", "MNI152NLin2009cAsym"}, optional
|
41
|
+
The space to use for the data (default "MNI152NLin2009cAsym").
|
42
42
|
|
43
43
|
Raises
|
44
44
|
------
|
@@ -50,15 +50,21 @@ 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,
|
55
|
-
|
53
|
+
types: Union[str, list[str], None] = None,
|
54
|
+
tasks: Union[str, list[str], None] = None,
|
55
|
+
space: str = "MNI152NLin2009cAsym",
|
56
56
|
) -> None:
|
57
|
+
valid_spaces = ["native", "MNI152NLin2009cAsym"]
|
58
|
+
if space not in ["native", "MNI152NLin2009cAsym"]:
|
59
|
+
raise_error(
|
60
|
+
f"Invalid space {space}. Must be one of {valid_spaces}"
|
61
|
+
)
|
57
62
|
# Declare all tasks
|
58
63
|
all_tasks = [
|
59
64
|
"restingstate",
|
60
65
|
"stopsignal",
|
61
66
|
"workingmemory",
|
67
|
+
"emomatching",
|
62
68
|
]
|
63
69
|
# Set default tasks
|
64
70
|
if tasks is None:
|
@@ -75,22 +81,32 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
|
|
75
81
|
" dataset!"
|
76
82
|
)
|
77
83
|
self.tasks = tasks
|
84
|
+
# Descriptor for space in `anat`
|
85
|
+
sp_anat_desc = (
|
86
|
+
"" if space == "native" else "space-MNI152NLin2009cAsym_"
|
87
|
+
)
|
88
|
+
# Descriptor for space in `func`
|
89
|
+
sp_func_desc = (
|
90
|
+
"space-T1w_" if space == "native" else "space-MNI152NLin2009cAsym_"
|
91
|
+
)
|
78
92
|
# The patterns
|
79
93
|
patterns = {
|
80
94
|
"BOLD": {
|
81
95
|
"pattern": (
|
82
96
|
"derivatives/fmriprep/{subject}/func/"
|
83
97
|
"{subject}_task-{task}_"
|
84
|
-
"
|
98
|
+
f"{sp_func_desc}"
|
99
|
+
"desc-preproc_bold.nii.gz"
|
85
100
|
),
|
86
|
-
"space":
|
101
|
+
"space": space,
|
87
102
|
"mask": {
|
88
103
|
"pattern": (
|
89
104
|
"derivatives/fmriprep/{subject}/func/"
|
90
105
|
"{subject}_task-{task}_"
|
91
|
-
"
|
106
|
+
f"{sp_func_desc}"
|
107
|
+
"desc-brain_mask.nii.gz"
|
92
108
|
),
|
93
|
-
"space":
|
109
|
+
"space": space,
|
94
110
|
},
|
95
111
|
"confounds": {
|
96
112
|
"pattern": (
|
@@ -100,46 +116,59 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
|
|
100
116
|
),
|
101
117
|
"format": "fmriprep",
|
102
118
|
},
|
119
|
+
"reference": {
|
120
|
+
"pattern": (
|
121
|
+
"derivatives/fmriprep/{subject}/func/"
|
122
|
+
"{subject}_task-{task}_"
|
123
|
+
f"{sp_func_desc}"
|
124
|
+
"boldref.nii.gz"
|
125
|
+
),
|
126
|
+
},
|
103
127
|
},
|
104
128
|
"T1w": {
|
105
129
|
"pattern": (
|
106
130
|
"derivatives/fmriprep/{subject}/anat/"
|
107
|
-
"{subject}
|
131
|
+
"{subject}_"
|
132
|
+
f"{sp_anat_desc}"
|
108
133
|
"desc-preproc_T1w.nii.gz"
|
109
134
|
),
|
110
|
-
"space":
|
135
|
+
"space": space,
|
111
136
|
"mask": {
|
112
137
|
"pattern": (
|
113
138
|
"derivatives/fmriprep/{subject}/anat/"
|
114
|
-
"{subject}
|
139
|
+
"{subject}_"
|
140
|
+
f"{sp_anat_desc}"
|
115
141
|
"desc-brain_mask.nii.gz"
|
116
142
|
),
|
117
|
-
"space":
|
143
|
+
"space": space,
|
118
144
|
},
|
119
145
|
},
|
120
146
|
"VBM_CSF": {
|
121
147
|
"pattern": (
|
122
148
|
"derivatives/fmriprep/{subject}/anat/"
|
123
|
-
"{subject}
|
124
|
-
"
|
149
|
+
"{subject}_"
|
150
|
+
f"{sp_anat_desc}"
|
151
|
+
"label-CSF_probseg.nii.gz"
|
125
152
|
),
|
126
|
-
"space":
|
153
|
+
"space": space,
|
127
154
|
},
|
128
155
|
"VBM_GM": {
|
129
156
|
"pattern": (
|
130
157
|
"derivatives/fmriprep/{subject}/anat/"
|
131
|
-
"{subject}
|
132
|
-
"
|
158
|
+
"{subject}_"
|
159
|
+
f"{sp_anat_desc}"
|
160
|
+
"label-GM_probseg.nii.gz"
|
133
161
|
),
|
134
|
-
"space":
|
162
|
+
"space": space,
|
135
163
|
},
|
136
164
|
"VBM_WM": {
|
137
165
|
"pattern": (
|
138
166
|
"derivatives/fmriprep/{subject}/anat/"
|
139
|
-
"{subject}
|
140
|
-
"
|
167
|
+
"{subject}_"
|
168
|
+
f"{sp_anat_desc}"
|
169
|
+
"label-WM_probseg.nii.gz"
|
141
170
|
),
|
142
|
-
"space":
|
171
|
+
"space": space,
|
143
172
|
},
|
144
173
|
"DWI": {
|
145
174
|
"pattern": (
|
@@ -180,38 +209,38 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
|
|
180
209
|
)
|
181
210
|
},
|
182
211
|
},
|
212
|
+
"Warp": [
|
213
|
+
{
|
214
|
+
"pattern": (
|
215
|
+
"derivatives/fmriprep/{subject}/anat/"
|
216
|
+
"{subject}_from-MNI152NLin2009cAsym_to-T1w_"
|
217
|
+
"mode-image_xfm.h5"
|
218
|
+
),
|
219
|
+
"src": "MNI152NLin2009cAsym",
|
220
|
+
"dst": "native",
|
221
|
+
"warper": "ants",
|
222
|
+
},
|
223
|
+
{
|
224
|
+
"pattern": (
|
225
|
+
"derivatives/fmriprep/{subject}/anat/"
|
226
|
+
"{subject}_from-T1w_to-MNI152NLin2009cAsym_"
|
227
|
+
"mode-image_xfm.h5"
|
228
|
+
),
|
229
|
+
"src": "native",
|
230
|
+
"dst": "MNI152NLin2009cAsym",
|
231
|
+
"warper": "ants",
|
232
|
+
},
|
233
|
+
],
|
183
234
|
}
|
235
|
+
|
236
|
+
if space == "native":
|
237
|
+
patterns["BOLD"]["prewarp_space"] = "MNI152NLin2009cAsym"
|
238
|
+
else:
|
239
|
+
patterns["BOLD"]["prewarp_space"] = "native"
|
240
|
+
|
184
241
|
# Use native T1w assets
|
185
|
-
self.
|
186
|
-
|
187
|
-
self.native_t1w = True
|
188
|
-
patterns.update(
|
189
|
-
{
|
190
|
-
"T1w": {
|
191
|
-
"pattern": (
|
192
|
-
"derivatives/fmriprep/{subject}/anat/"
|
193
|
-
"{subject}_desc-preproc_T1w.nii.gz"
|
194
|
-
),
|
195
|
-
"space": "native",
|
196
|
-
"mask": {
|
197
|
-
"pattern": (
|
198
|
-
"derivatives/fmriprep/{subject}/anat/"
|
199
|
-
"{subject}_desc-brain_mask.nii.gz"
|
200
|
-
),
|
201
|
-
"space": "native",
|
202
|
-
},
|
203
|
-
},
|
204
|
-
"Warp": {
|
205
|
-
"pattern": (
|
206
|
-
"derivatives/fmriprep/{subject}/anat/"
|
207
|
-
"{subject}_from-MNI152NLin2009cAsym_to-T1w_"
|
208
|
-
"mode-image_xfm.h5"
|
209
|
-
),
|
210
|
-
"src": "MNI152NLin2009cAsym",
|
211
|
-
"dst": "native",
|
212
|
-
},
|
213
|
-
}
|
214
|
-
)
|
242
|
+
self.space = space
|
243
|
+
|
215
244
|
# Set default types
|
216
245
|
if types is None:
|
217
246
|
types = list(patterns.keys())
|
@@ -231,7 +260,7 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
|
|
231
260
|
confounds_format="fmriprep",
|
232
261
|
)
|
233
262
|
|
234
|
-
def get_elements(self) ->
|
263
|
+
def get_elements(self) -> list:
|
235
264
|
"""Implement fetching list of elements in the dataset.
|
236
265
|
|
237
266
|
Returns
|
@@ -247,7 +276,7 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
|
|
247
276
|
elems.append((subject, task))
|
248
277
|
return elems
|
249
278
|
|
250
|
-
def get_item(self, subject: str, task: str) ->
|
279
|
+
def get_item(self, subject: str, task: str) -> dict:
|
251
280
|
"""Index one element in the dataset.
|
252
281
|
|
253
282
|
Parameters
|
File without changes
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# Synchon Mandal <s.mandal@fz-juelich.de>
|
8
8
|
# License: AGPL
|
9
9
|
|
10
|
-
from typing import
|
10
|
+
from typing import Optional, Union
|
11
11
|
|
12
12
|
import pytest
|
13
13
|
|
@@ -18,20 +18,25 @@ URI = "https://gin.g-node.org/juaml/datalad-example-aomic1000"
|
|
18
18
|
|
19
19
|
|
20
20
|
@pytest.mark.parametrize(
|
21
|
-
"type_, nested_types",
|
21
|
+
"type_, nested_types, space",
|
22
22
|
[
|
23
|
-
("BOLD", ["confounds", "mask"]),
|
24
|
-
("
|
25
|
-
("
|
26
|
-
("
|
27
|
-
("
|
28
|
-
("
|
29
|
-
("
|
23
|
+
("BOLD", ["confounds", "mask", "reference"], "MNI152NLin2009cAsym"),
|
24
|
+
("BOLD", ["confounds", "mask", "reference"], "native"),
|
25
|
+
("T1w", ["mask"], "MNI152NLin2009cAsym"),
|
26
|
+
("T1w", ["mask"], "native"),
|
27
|
+
("VBM_CSF", None, "MNI152NLin2009cAsym"),
|
28
|
+
("VBM_CSF", None, "native"),
|
29
|
+
("VBM_GM", None, "MNI152NLin2009cAsym"),
|
30
|
+
("VBM_GM", None, "native"),
|
31
|
+
("VBM_WM", None, "MNI152NLin2009cAsym"),
|
32
|
+
("DWI", None, "MNI152NLin2009cAsym"),
|
33
|
+
("FreeSurfer", None, "MNI152NLin2009cAsym"),
|
30
34
|
],
|
31
35
|
)
|
32
36
|
def test_DataladAOMICID1000(
|
33
37
|
type_: str,
|
34
|
-
nested_types: Optional[
|
38
|
+
nested_types: Optional[list[str]],
|
39
|
+
space: str,
|
35
40
|
) -> None:
|
36
41
|
"""Test DataladAOMICID1000 DataGrabber.
|
37
42
|
|
@@ -41,9 +46,11 @@ def test_DataladAOMICID1000(
|
|
41
46
|
The parametrized type.
|
42
47
|
nested_types : list of str or None
|
43
48
|
The parametrized nested types.
|
49
|
+
space: str
|
50
|
+
The parametrized space.
|
44
51
|
|
45
52
|
"""
|
46
|
-
dg = DataladAOMICID1000(types=type_)
|
53
|
+
dg = DataladAOMICID1000(types=type_, space=space)
|
47
54
|
# Set URI to Gin
|
48
55
|
dg.uri = URI
|
49
56
|
|
@@ -87,7 +94,7 @@ def test_DataladAOMICID1000(
|
|
87
94
|
],
|
88
95
|
)
|
89
96
|
def test_DataladAOMICID1000_partial_data_access(
|
90
|
-
types: Union[str,
|
97
|
+
types: Union[str, list[str]],
|
91
98
|
) -> None:
|
92
99
|
"""Test DataladAOMICID1000 DataGrabber partial data access.
|
93
100
|
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# Synchon Mandal <s.mandal@fz-juelich.de>
|
8
8
|
# License: AGPL
|
9
9
|
|
10
|
-
from typing import
|
10
|
+
from typing import Optional, Union
|
11
11
|
|
12
12
|
import pytest
|
13
13
|
|
@@ -18,30 +18,62 @@ URI = "https://gin.g-node.org/juaml/datalad-example-aomicpiop1"
|
|
18
18
|
|
19
19
|
|
20
20
|
@pytest.mark.parametrize(
|
21
|
-
"type_, nested_types, tasks",
|
21
|
+
"type_, nested_types, tasks, space",
|
22
22
|
[
|
23
|
-
("BOLD", ["confounds", "mask"], None),
|
24
|
-
("BOLD", ["confounds", "mask"], ["anticipation"]),
|
25
|
-
("BOLD", ["confounds", "mask"], ["emomatching", "faces"]),
|
26
|
-
("BOLD", ["confounds", "mask"], ["restingstate"]),
|
27
|
-
("BOLD", ["confounds", "mask"], ["workingmemory", "gstroop"]),
|
28
23
|
(
|
29
24
|
"BOLD",
|
30
|
-
["confounds", "mask"],
|
25
|
+
["confounds", "mask", "reference"],
|
26
|
+
None,
|
27
|
+
"MNI152NLin2009cAsym",
|
28
|
+
),
|
29
|
+
("BOLD", ["confounds", "mask", "reference"], None, "native"),
|
30
|
+
(
|
31
|
+
"BOLD",
|
32
|
+
["confounds", "mask", "reference"],
|
33
|
+
["anticipation"],
|
34
|
+
"MNI152NLin2009cAsym",
|
35
|
+
),
|
36
|
+
(
|
37
|
+
"BOLD",
|
38
|
+
["confounds", "mask", "reference"],
|
39
|
+
["emomatching", "faces"],
|
40
|
+
"MNI152NLin2009cAsym",
|
41
|
+
),
|
42
|
+
(
|
43
|
+
"BOLD",
|
44
|
+
["confounds", "mask", "reference"],
|
45
|
+
["restingstate"],
|
46
|
+
"MNI152NLin2009cAsym",
|
47
|
+
),
|
48
|
+
(
|
49
|
+
"BOLD",
|
50
|
+
["confounds", "mask", "reference"],
|
51
|
+
["workingmemory", "gstroop"],
|
52
|
+
"MNI152NLin2009cAsym",
|
53
|
+
),
|
54
|
+
(
|
55
|
+
"BOLD",
|
56
|
+
["confounds", "mask", "reference"],
|
31
57
|
["anticipation", "faces", "restingstate"],
|
58
|
+
"MNI152NLin2009cAsym",
|
32
59
|
),
|
33
|
-
("T1w", ["mask"], None),
|
34
|
-
("
|
35
|
-
("
|
36
|
-
("
|
37
|
-
("
|
38
|
-
("
|
60
|
+
("T1w", ["mask"], None, "MNI152NLin2009cAsym"),
|
61
|
+
("T1w", ["mask"], None, "native"),
|
62
|
+
("VBM_CSF", None, None, "MNI152NLin2009cAsym"),
|
63
|
+
("VBM_CSF", None, None, "native"),
|
64
|
+
("VBM_GM", None, None, "MNI152NLin2009cAsym"),
|
65
|
+
("VBM_GM", None, None, "native"),
|
66
|
+
("VBM_WM", None, None, "MNI152NLin2009cAsym"),
|
67
|
+
("VBM_WM", None, None, "native"),
|
68
|
+
("DWI", None, None, "MNI152NLin2009cAsym"),
|
69
|
+
("FreeSurfer", None, None, "MNI152NLin2009cAsym"),
|
39
70
|
],
|
40
71
|
)
|
41
72
|
def test_DataladAOMICPIOP1(
|
42
73
|
type_: str,
|
43
|
-
nested_types: Optional[
|
44
|
-
tasks: Optional[
|
74
|
+
nested_types: Optional[list[str]],
|
75
|
+
tasks: Optional[list[str]],
|
76
|
+
space: str,
|
45
77
|
) -> None:
|
46
78
|
"""Test DataladAOMICPIOP1 DataGrabber.
|
47
79
|
|
@@ -53,9 +85,11 @@ def test_DataladAOMICPIOP1(
|
|
53
85
|
The parametrized nested types.
|
54
86
|
tasks : list of str or None
|
55
87
|
The parametrized task values.
|
88
|
+
space: str
|
89
|
+
The parametrized space.
|
56
90
|
|
57
91
|
"""
|
58
|
-
dg = DataladAOMICPIOP1(types=type_, tasks=tasks)
|
92
|
+
dg = DataladAOMICPIOP1(types=type_, tasks=tasks, space=space)
|
59
93
|
# Set URI to Gin
|
60
94
|
dg.uri = URI
|
61
95
|
|
@@ -117,7 +151,7 @@ def test_DataladAOMICPIOP1(
|
|
117
151
|
],
|
118
152
|
)
|
119
153
|
def test_DataladAOMICPIOP1_partial_data_access(
|
120
|
-
types: Union[str,
|
154
|
+
types: Union[str, list[str]],
|
121
155
|
) -> None:
|
122
156
|
"""Test DataladAOMICPIOP1 DataGrabber partial data access.
|
123
157
|
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# Synchon Mandal <s.mandal@fz-juelich.de>
|
8
8
|
# License: AGPL
|
9
9
|
|
10
|
-
from typing import
|
10
|
+
from typing import Optional, Union
|
11
11
|
|
12
12
|
import pytest
|
13
13
|
|
@@ -18,25 +18,56 @@ URI = "https://gin.g-node.org/juaml/datalad-example-aomicpiop2"
|
|
18
18
|
|
19
19
|
|
20
20
|
@pytest.mark.parametrize(
|
21
|
-
"type_, nested_types, tasks",
|
21
|
+
"type_, nested_types, tasks, space",
|
22
22
|
[
|
23
|
-
(
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
("
|
30
|
-
(
|
31
|
-
|
32
|
-
|
33
|
-
|
23
|
+
(
|
24
|
+
"BOLD",
|
25
|
+
["confounds", "mask", "reference"],
|
26
|
+
None,
|
27
|
+
"MNI152NLin2009cAsym",
|
28
|
+
),
|
29
|
+
("BOLD", ["confounds", "mask", "reference"], None, "native"),
|
30
|
+
(
|
31
|
+
"BOLD",
|
32
|
+
["confounds", "mask", "reference"],
|
33
|
+
["restingstate"],
|
34
|
+
"MNI152NLin2009cAsym",
|
35
|
+
),
|
36
|
+
(
|
37
|
+
"BOLD",
|
38
|
+
["confounds", "mask", "reference"],
|
39
|
+
["restingstate", "stopsignal"],
|
40
|
+
"MNI152NLin2009cAsym",
|
41
|
+
),
|
42
|
+
(
|
43
|
+
"BOLD",
|
44
|
+
["confounds", "mask", "reference"],
|
45
|
+
["workingmemory", "stopsignal"],
|
46
|
+
"MNI152NLin2009cAsym",
|
47
|
+
),
|
48
|
+
(
|
49
|
+
"BOLD",
|
50
|
+
["confounds", "mask", "reference"],
|
51
|
+
["workingmemory"],
|
52
|
+
"MNI152NLin2009cAsym",
|
53
|
+
),
|
54
|
+
("T1w", ["mask"], None, "MNI152NLin2009cAsym"),
|
55
|
+
("T1w", ["mask"], None, "native"),
|
56
|
+
("VBM_CSF", None, None, "MNI152NLin2009cAsym"),
|
57
|
+
("VBM_CSF", None, None, "native"),
|
58
|
+
("VBM_GM", None, None, "MNI152NLin2009cAsym"),
|
59
|
+
("VBM_GM", None, None, "native"),
|
60
|
+
("VBM_WM", None, None, "MNI152NLin2009cAsym"),
|
61
|
+
("VBM_WM", None, None, "native"),
|
62
|
+
("DWI", None, None, "MNI152NLin2009cAsym"),
|
63
|
+
("FreeSurfer", None, None, "MNI152NLin2009cAsym"),
|
34
64
|
],
|
35
65
|
)
|
36
66
|
def test_DataladAOMICPIOP2(
|
37
67
|
type_: str,
|
38
|
-
nested_types: Optional[
|
39
|
-
tasks: Optional[
|
68
|
+
nested_types: Optional[list[str]],
|
69
|
+
tasks: Optional[list[str]],
|
70
|
+
space: str,
|
40
71
|
) -> None:
|
41
72
|
"""Test DataladAOMICPIOP2 DataGrabber.
|
42
73
|
|
@@ -48,9 +79,11 @@ def test_DataladAOMICPIOP2(
|
|
48
79
|
The parametrized nested types.
|
49
80
|
tasks : list of str or None
|
50
81
|
The parametrized task values.
|
82
|
+
space: str
|
83
|
+
The parametrized space.
|
51
84
|
|
52
85
|
"""
|
53
|
-
dg = DataladAOMICPIOP2(types=type_, tasks=tasks)
|
86
|
+
dg = DataladAOMICPIOP2(types=type_, tasks=tasks, space=space)
|
54
87
|
# Set URI to Gin
|
55
88
|
dg.uri = URI
|
56
89
|
|
@@ -97,7 +130,7 @@ def test_DataladAOMICPIOP2(
|
|
97
130
|
],
|
98
131
|
)
|
99
132
|
def test_DataladAOMICPIOP2_partial_data_access(
|
100
|
-
types: Union[str,
|
133
|
+
types: Union[str, list[str]],
|
101
134
|
) -> None:
|
102
135
|
"""Test DataladAOMICPIOP2 DataGrabber partial data access.
|
103
136
|
|
junifer/datagrabber/base.py
CHANGED
@@ -6,10 +6,12 @@
|
|
6
6
|
# License: AGPL
|
7
7
|
|
8
8
|
from abc import ABC, abstractmethod
|
9
|
+
from collections.abc import Iterator
|
9
10
|
from pathlib import Path
|
10
|
-
from typing import
|
11
|
+
from typing import Union
|
11
12
|
|
12
13
|
from ..pipeline import UpdateMetaMixin
|
14
|
+
from ..typing import Element, Elements
|
13
15
|
from ..utils import logger, raise_error
|
14
16
|
|
15
17
|
|
@@ -36,7 +38,7 @@ class BaseDataGrabber(ABC, UpdateMetaMixin):
|
|
36
38
|
|
37
39
|
"""
|
38
40
|
|
39
|
-
def __init__(self, types:
|
41
|
+
def __init__(self, types: list[str], datadir: Union[str, Path]) -> None:
|
40
42
|
# Validate types
|
41
43
|
if not isinstance(types, list):
|
42
44
|
raise_error(msg="`types` must be a list", klass=TypeError)
|
@@ -66,9 +68,7 @@ class BaseDataGrabber(ABC, UpdateMetaMixin):
|
|
66
68
|
"""
|
67
69
|
yield from self.get_elements()
|
68
70
|
|
69
|
-
def __getitem__(
|
70
|
-
self, element: Union[str, Tuple[str, ...]]
|
71
|
-
) -> Dict[str, Dict]:
|
71
|
+
def __getitem__(self, element: Element) -> dict[str, dict]:
|
72
72
|
"""Enable indexing support.
|
73
73
|
|
74
74
|
Parameters
|
@@ -89,14 +89,19 @@ class BaseDataGrabber(ABC, UpdateMetaMixin):
|
|
89
89
|
element = (element,)
|
90
90
|
# Zip through element keys and actual values to construct element
|
91
91
|
# access dictionary
|
92
|
-
named_element:
|
92
|
+
named_element: dict = dict(zip(self.get_element_keys(), element))
|
93
93
|
logger.debug(f"Named element: {named_element}")
|
94
94
|
# Fetch element
|
95
95
|
out = self.get_item(**named_element)
|
96
96
|
# Update metadata
|
97
97
|
for _, t_val in out.items():
|
98
98
|
self.update_meta(t_val, "datagrabber")
|
99
|
-
|
99
|
+
# Conditional for list dtype vals like Warp
|
100
|
+
if isinstance(t_val, list):
|
101
|
+
for entry in t_val:
|
102
|
+
entry["meta"]["element"] = named_element
|
103
|
+
else:
|
104
|
+
t_val["meta"]["element"] = named_element
|
100
105
|
|
101
106
|
return out
|
102
107
|
|
@@ -108,7 +113,7 @@ class BaseDataGrabber(ABC, UpdateMetaMixin):
|
|
108
113
|
"""Context exit."""
|
109
114
|
return None
|
110
115
|
|
111
|
-
def get_types(self) ->
|
116
|
+
def get_types(self) -> list[str]:
|
112
117
|
"""Get types.
|
113
118
|
|
114
119
|
Returns
|
@@ -131,13 +136,13 @@ class BaseDataGrabber(ABC, UpdateMetaMixin):
|
|
131
136
|
"""
|
132
137
|
return self._datadir
|
133
138
|
|
134
|
-
def filter(self, selection:
|
139
|
+
def filter(self, selection: Elements) -> Iterator:
|
135
140
|
"""Filter elements to be grabbed.
|
136
141
|
|
137
142
|
Parameters
|
138
143
|
----------
|
139
|
-
selection : list
|
140
|
-
The list of partial element
|
144
|
+
selection : list
|
145
|
+
The list of partial or complete element selectors to filter using.
|
141
146
|
|
142
147
|
Yields
|
143
148
|
------
|
@@ -146,7 +151,7 @@ class BaseDataGrabber(ABC, UpdateMetaMixin):
|
|
146
151
|
|
147
152
|
"""
|
148
153
|
|
149
|
-
def filter_func(element:
|
154
|
+
def filter_func(element: Element) -> bool:
|
150
155
|
"""Filter element based on selection.
|
151
156
|
|
152
157
|
Parameters
|
@@ -177,7 +182,7 @@ class BaseDataGrabber(ABC, UpdateMetaMixin):
|
|
177
182
|
yield from filter(filter_func, self.get_elements())
|
178
183
|
|
179
184
|
@abstractmethod
|
180
|
-
def get_element_keys(self) ->
|
185
|
+
def get_element_keys(self) -> list[str]:
|
181
186
|
"""Get element keys.
|
182
187
|
|
183
188
|
For each item in the ``element`` tuple passed to ``__getitem__()``,
|
@@ -195,15 +200,14 @@ class BaseDataGrabber(ABC, UpdateMetaMixin):
|
|
195
200
|
) # pragma: no cover
|
196
201
|
|
197
202
|
@abstractmethod
|
198
|
-
def get_elements(self) ->
|
203
|
+
def get_elements(self) -> Elements:
|
199
204
|
"""Get elements.
|
200
205
|
|
201
206
|
Returns
|
202
207
|
-------
|
203
208
|
list
|
204
|
-
List of elements that can be grabbed. The elements can be strings
|
205
|
-
|
206
|
-
DataGrabber.
|
209
|
+
List of elements that can be grabbed. The elements can be strings
|
210
|
+
or tuples of strings to index the DataGrabber.
|
207
211
|
|
208
212
|
"""
|
209
213
|
raise_error(
|
@@ -212,7 +216,7 @@ class BaseDataGrabber(ABC, UpdateMetaMixin):
|
|
212
216
|
) # pragma: no cover
|
213
217
|
|
214
218
|
@abstractmethod
|
215
|
-
def get_item(self, **element:
|
219
|
+
def get_item(self, **element: dict) -> dict[str, dict]:
|
216
220
|
"""Get the specified item from the dataset.
|
217
221
|
|
218
222
|
Parameters
|