junifer 0.0.5__py3-none-any.whl → 0.0.5.dev11__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 +0 -17
- junifer/_version.py +2 -2
- junifer/api/__init__.py +1 -4
- junifer/api/cli.py +1 -91
- junifer/api/decorators.py +0 -9
- junifer/api/functions.py +10 -56
- junifer/api/parser.py +0 -3
- junifer/api/queue_context/__init__.py +1 -4
- junifer/api/res/afni/run_afni_docker.sh +1 -1
- junifer/api/res/ants/run_ants_docker.sh +1 -1
- junifer/api/res/fsl/run_fsl_docker.sh +1 -1
- junifer/api/tests/test_api_utils.py +2 -4
- junifer/api/tests/test_cli.py +0 -83
- junifer/api/tests/test_functions.py +2 -27
- junifer/configs/__init__.py +1 -1
- junifer/configs/juseless/__init__.py +1 -4
- junifer/configs/juseless/datagrabbers/__init__.py +1 -10
- junifer/configs/juseless/datagrabbers/aomic_id1000_vbm.py +0 -3
- junifer/configs/juseless/datagrabbers/camcan_vbm.py +0 -3
- junifer/configs/juseless/datagrabbers/ixi_vbm.py +0 -3
- junifer/configs/juseless/datagrabbers/tests/test_ucla.py +3 -1
- junifer/configs/juseless/datagrabbers/ucla.py +9 -12
- junifer/configs/juseless/datagrabbers/ukb_vbm.py +0 -3
- junifer/data/__init__.py +1 -21
- junifer/data/coordinates.py +19 -10
- junifer/data/masks.py +87 -58
- junifer/data/parcellations.py +3 -14
- junifer/data/template_spaces.py +1 -4
- junifer/data/tests/test_masks.py +37 -26
- junifer/data/utils.py +0 -3
- junifer/datagrabber/__init__.py +1 -18
- junifer/datagrabber/aomic/__init__.py +0 -3
- junifer/datagrabber/aomic/id1000.py +37 -70
- junifer/datagrabber/aomic/piop1.py +36 -69
- junifer/datagrabber/aomic/piop2.py +38 -71
- junifer/datagrabber/aomic/tests/test_id1000.py +99 -44
- junifer/datagrabber/aomic/tests/test_piop1.py +108 -65
- junifer/datagrabber/aomic/tests/test_piop2.py +102 -45
- junifer/datagrabber/base.py +6 -13
- junifer/datagrabber/datalad_base.py +1 -13
- junifer/datagrabber/dmcc13_benchmark.py +53 -36
- junifer/datagrabber/hcp1200/__init__.py +0 -3
- junifer/datagrabber/hcp1200/datalad_hcp1200.py +0 -3
- junifer/datagrabber/hcp1200/hcp1200.py +1 -4
- junifer/datagrabber/multiple.py +6 -45
- junifer/datagrabber/pattern.py +62 -170
- junifer/datagrabber/pattern_datalad.py +12 -25
- junifer/datagrabber/tests/test_datagrabber_utils.py +218 -0
- junifer/datagrabber/tests/test_datalad_base.py +4 -4
- junifer/datagrabber/tests/test_dmcc13_benchmark.py +19 -46
- junifer/datagrabber/tests/test_multiple.py +84 -161
- junifer/datagrabber/tests/test_pattern.py +0 -45
- junifer/datagrabber/tests/test_pattern_datalad.py +4 -4
- junifer/datagrabber/utils.py +230 -0
- junifer/datareader/__init__.py +1 -4
- junifer/datareader/default.py +43 -95
- junifer/external/__init__.py +1 -1
- junifer/external/nilearn/__init__.py +1 -5
- junifer/external/nilearn/junifer_nifti_spheres_masker.py +9 -23
- junifer/external/nilearn/tests/test_junifer_nifti_spheres_masker.py +1 -76
- junifer/markers/__init__.py +1 -23
- junifer/markers/base.py +28 -68
- junifer/markers/collection.py +2 -10
- junifer/markers/complexity/__init__.py +0 -10
- junifer/markers/complexity/complexity_base.py +43 -26
- junifer/markers/complexity/hurst_exponent.py +0 -3
- junifer/markers/complexity/multiscale_entropy_auc.py +0 -3
- junifer/markers/complexity/perm_entropy.py +0 -3
- junifer/markers/complexity/range_entropy.py +0 -3
- junifer/markers/complexity/range_entropy_auc.py +0 -3
- junifer/markers/complexity/sample_entropy.py +0 -3
- junifer/markers/complexity/tests/test_hurst_exponent.py +3 -11
- junifer/markers/complexity/tests/test_multiscale_entropy_auc.py +3 -11
- junifer/markers/complexity/tests/test_perm_entropy.py +3 -11
- junifer/markers/complexity/tests/test_range_entropy.py +3 -11
- junifer/markers/complexity/tests/test_range_entropy_auc.py +3 -11
- junifer/markers/complexity/tests/test_sample_entropy.py +3 -11
- junifer/markers/complexity/tests/test_weighted_perm_entropy.py +3 -11
- junifer/markers/complexity/weighted_perm_entropy.py +0 -3
- junifer/markers/ets_rss.py +42 -27
- junifer/markers/falff/__init__.py +0 -3
- junifer/markers/falff/_afni_falff.py +2 -5
- junifer/markers/falff/_junifer_falff.py +0 -3
- junifer/markers/falff/falff_base.py +46 -20
- junifer/markers/falff/falff_parcels.py +27 -56
- junifer/markers/falff/falff_spheres.py +29 -60
- junifer/markers/falff/tests/test_falff_parcels.py +23 -39
- junifer/markers/falff/tests/test_falff_spheres.py +23 -39
- junifer/markers/functional_connectivity/__init__.py +0 -9
- junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +60 -63
- junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +32 -45
- junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +36 -49
- junifer/markers/functional_connectivity/functional_connectivity_base.py +70 -71
- junifer/markers/functional_connectivity/functional_connectivity_parcels.py +25 -34
- junifer/markers/functional_connectivity/functional_connectivity_spheres.py +30 -40
- junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py +7 -11
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +7 -27
- junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +12 -28
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +11 -35
- junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +62 -36
- junifer/markers/parcel_aggregation.py +61 -47
- junifer/markers/reho/__init__.py +0 -3
- junifer/markers/reho/_afni_reho.py +2 -5
- junifer/markers/reho/_junifer_reho.py +1 -4
- junifer/markers/reho/reho_base.py +27 -8
- junifer/markers/reho/reho_parcels.py +17 -28
- junifer/markers/reho/reho_spheres.py +18 -27
- junifer/markers/reho/tests/test_reho_parcels.py +3 -8
- junifer/markers/reho/tests/test_reho_spheres.py +3 -8
- junifer/markers/sphere_aggregation.py +59 -43
- junifer/markers/temporal_snr/__init__.py +0 -3
- junifer/markers/temporal_snr/temporal_snr_base.py +32 -23
- junifer/markers/temporal_snr/temporal_snr_parcels.py +6 -9
- junifer/markers/temporal_snr/temporal_snr_spheres.py +6 -9
- junifer/markers/temporal_snr/tests/test_temporal_snr_parcels.py +3 -6
- junifer/markers/temporal_snr/tests/test_temporal_snr_spheres.py +3 -6
- junifer/markers/tests/test_collection.py +8 -9
- junifer/markers/tests/test_ets_rss.py +9 -15
- junifer/markers/tests/test_markers_base.py +18 -17
- junifer/markers/tests/test_parcel_aggregation.py +32 -93
- junifer/markers/tests/test_sphere_aggregation.py +19 -72
- junifer/onthefly/__init__.py +1 -4
- junifer/onthefly/read_transform.py +0 -3
- junifer/pipeline/__init__.py +1 -9
- junifer/pipeline/pipeline_step_mixin.py +4 -21
- junifer/pipeline/registry.py +0 -3
- junifer/pipeline/singleton.py +0 -3
- junifer/pipeline/tests/test_registry.py +1 -1
- junifer/pipeline/update_meta_mixin.py +0 -3
- junifer/pipeline/utils.py +1 -67
- junifer/pipeline/workdir_manager.py +0 -3
- junifer/preprocess/__init__.py +2 -10
- junifer/preprocess/ants/__init__.py +4 -0
- junifer/preprocess/ants/ants_apply_transforms_warper.py +185 -0
- junifer/preprocess/ants/tests/test_ants_apply_transforms_warper.py +56 -0
- junifer/preprocess/base.py +3 -6
- junifer/preprocess/bold_warper.py +265 -0
- junifer/preprocess/confounds/__init__.py +0 -3
- junifer/preprocess/confounds/fmriprep_confound_remover.py +60 -47
- junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py +113 -72
- junifer/preprocess/fsl/__init__.py +4 -0
- junifer/preprocess/fsl/apply_warper.py +179 -0
- junifer/preprocess/fsl/tests/test_apply_warper.py +45 -0
- junifer/preprocess/tests/test_bold_warper.py +159 -0
- junifer/preprocess/warping/__init__.py +0 -3
- junifer/preprocess/warping/_ants_warper.py +0 -3
- junifer/preprocess/warping/_fsl_warper.py +0 -3
- junifer/stats.py +1 -4
- junifer/storage/__init__.py +1 -9
- junifer/storage/base.py +1 -40
- junifer/storage/hdf5.py +9 -71
- junifer/storage/pandas_base.py +0 -3
- junifer/storage/sqlite.py +0 -3
- junifer/storage/tests/test_hdf5.py +10 -82
- junifer/storage/utils.py +0 -9
- junifer/testing/__init__.py +1 -4
- junifer/testing/datagrabbers.py +6 -13
- junifer/testing/tests/test_partlycloudytesting_datagrabber.py +7 -7
- junifer/testing/utils.py +0 -3
- junifer/utils/__init__.py +2 -13
- junifer/utils/fs.py +0 -3
- junifer/utils/helpers.py +1 -32
- junifer/utils/logging.py +4 -33
- junifer/utils/tests/test_logging.py +0 -8
- {junifer-0.0.5.dist-info → junifer-0.0.5.dev11.dist-info}/METADATA +16 -17
- junifer-0.0.5.dev11.dist-info/RECORD +259 -0
- {junifer-0.0.5.dist-info → junifer-0.0.5.dev11.dist-info}/WHEEL +1 -1
- junifer/api/res/freesurfer/mri_binarize +0 -3
- junifer/api/res/freesurfer/mri_mc +0 -3
- junifer/api/res/freesurfer/mri_pretess +0 -3
- junifer/api/res/freesurfer/mris_convert +0 -3
- junifer/api/res/freesurfer/run_freesurfer_docker.sh +0 -61
- junifer/data/masks/ukb/UKB_15K_GM_template.nii.gz +0 -0
- junifer/datagrabber/pattern_validation_mixin.py +0 -388
- junifer/datagrabber/tests/test_pattern_validation_mixin.py +0 -249
- junifer/external/BrainPrint/brainprint/__init__.py +0 -4
- junifer/external/BrainPrint/brainprint/_version.py +0 -3
- junifer/external/BrainPrint/brainprint/asymmetry.py +0 -91
- junifer/external/BrainPrint/brainprint/brainprint.py +0 -441
- junifer/external/BrainPrint/brainprint/surfaces.py +0 -258
- junifer/external/BrainPrint/brainprint/utils/__init__.py +0 -1
- junifer/external/BrainPrint/brainprint/utils/_config.py +0 -112
- junifer/external/BrainPrint/brainprint/utils/utils.py +0 -188
- junifer/external/nilearn/junifer_connectivity_measure.py +0 -483
- junifer/external/nilearn/tests/test_junifer_connectivity_measure.py +0 -1089
- junifer/markers/brainprint.py +0 -459
- junifer/markers/tests/test_brainprint.py +0 -58
- junifer/preprocess/smoothing/__init__.py +0 -9
- junifer/preprocess/smoothing/_afni_smoothing.py +0 -119
- junifer/preprocess/smoothing/_fsl_smoothing.py +0 -116
- junifer/preprocess/smoothing/_nilearn_smoothing.py +0 -69
- junifer/preprocess/smoothing/smoothing.py +0 -174
- junifer/preprocess/smoothing/tests/test_smoothing.py +0 -94
- junifer-0.0.5.dist-info/RECORD +0 -275
- {junifer-0.0.5.dist-info → junifer-0.0.5.dev11.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.5.dist-info → junifer-0.0.5.dev11.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.5.dist-info → junifer-0.0.5.dev11.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.5.dist-info → junifer-0.0.5.dev11.dist-info}/top_level.txt +0 -0
junifer/data/__init__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Provide imports for data sub-package."""
|
2
2
|
|
3
3
|
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
|
4
4
|
# Synchon Mandal <s.mandal@fz-juelich.de>
|
@@ -28,23 +28,3 @@ from .masks import (
|
|
28
28
|
from .template_spaces import get_template, get_xfm
|
29
29
|
|
30
30
|
from . import utils
|
31
|
-
|
32
|
-
|
33
|
-
__all__ = [
|
34
|
-
"list_coordinates",
|
35
|
-
"load_coordinates",
|
36
|
-
"register_coordinates",
|
37
|
-
"get_coordinates",
|
38
|
-
"list_parcellations",
|
39
|
-
"load_parcellation",
|
40
|
-
"register_parcellation",
|
41
|
-
"merge_parcellations",
|
42
|
-
"get_parcellation",
|
43
|
-
"list_masks",
|
44
|
-
"load_mask",
|
45
|
-
"register_mask",
|
46
|
-
"get_mask",
|
47
|
-
"get_template",
|
48
|
-
"get_xfm",
|
49
|
-
"utils",
|
50
|
-
]
|
junifer/data/coordinates.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Provide functions for list of coordinates."""
|
2
2
|
|
3
3
|
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
|
4
4
|
# Synchon Mandal <s.mandal@fz-juelich.de>
|
@@ -13,15 +13,7 @@ import pandas as pd
|
|
13
13
|
from numpy.typing import ArrayLike
|
14
14
|
|
15
15
|
from ..pipeline import WorkDirManager
|
16
|
-
from ..utils import logger, raise_error, run_ext_cmd
|
17
|
-
|
18
|
-
|
19
|
-
__all__ = [
|
20
|
-
"register_coordinates",
|
21
|
-
"list_coordinates",
|
22
|
-
"get_coordinates",
|
23
|
-
"load_coordinates",
|
24
|
-
]
|
16
|
+
from ..utils import logger, raise_error, run_ext_cmd, warn_with_log
|
25
17
|
|
26
18
|
|
27
19
|
# Path to the VOIs
|
@@ -385,6 +377,11 @@ def load_coordinates(name: str) -> Tuple[ArrayLike, List[str], str]:
|
|
385
377
|
ValueError
|
386
378
|
If ``name`` is invalid.
|
387
379
|
|
380
|
+
Warns
|
381
|
+
-----
|
382
|
+
DeprecationWarning
|
383
|
+
If ``Power`` is provided as the ``name``.
|
384
|
+
|
388
385
|
"""
|
389
386
|
# Check for valid coordinates name
|
390
387
|
if name not in _available_coordinates:
|
@@ -392,6 +389,18 @@ def load_coordinates(name: str) -> Tuple[ArrayLike, List[str], str]:
|
|
392
389
|
f"Coordinates {name} not found. "
|
393
390
|
f"Valid options are: {list_coordinates()}"
|
394
391
|
)
|
392
|
+
|
393
|
+
# Put up deprecation notice
|
394
|
+
if name == "Power":
|
395
|
+
warn_with_log(
|
396
|
+
msg=(
|
397
|
+
"`Power` has been replaced with `Power2011` and will be "
|
398
|
+
"removed in the next release. For now, it's available for "
|
399
|
+
"backward compatibility."
|
400
|
+
),
|
401
|
+
category=DeprecationWarning,
|
402
|
+
)
|
403
|
+
|
395
404
|
# Load coordinates
|
396
405
|
t_coord = _available_coordinates[name]
|
397
406
|
if isinstance(t_coord.get("path"), Path):
|
junifer/data/masks.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Provide functions for masks."""
|
2
2
|
|
3
3
|
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
|
4
4
|
# Synchon Mandal <s.mandal@fz-juelich.de>
|
@@ -19,6 +19,7 @@ from typing import (
|
|
19
19
|
|
20
20
|
import nibabel as nib
|
21
21
|
import numpy as np
|
22
|
+
from nilearn.datasets import fetch_icbm152_brain_gm_mask
|
22
23
|
from nilearn.image import get_data, new_img_like, resample_to_img
|
23
24
|
from nilearn.masking import (
|
24
25
|
compute_background_mask,
|
@@ -27,7 +28,7 @@ from nilearn.masking import (
|
|
27
28
|
)
|
28
29
|
|
29
30
|
from ..pipeline import WorkDirManager
|
30
|
-
from ..utils import logger, raise_error, run_ext_cmd
|
31
|
+
from ..utils import logger, raise_error, run_ext_cmd, warn_with_log
|
31
32
|
from .template_spaces import get_template, get_xfm
|
32
33
|
from .utils import closest_resolution
|
33
34
|
|
@@ -35,16 +36,6 @@ from .utils import closest_resolution
|
|
35
36
|
if TYPE_CHECKING:
|
36
37
|
from nibabel import Nifti1Image
|
37
38
|
|
38
|
-
|
39
|
-
__all__ = [
|
40
|
-
"compute_brain_mask",
|
41
|
-
"register_mask",
|
42
|
-
"list_masks",
|
43
|
-
"get_mask",
|
44
|
-
"load_mask",
|
45
|
-
]
|
46
|
-
|
47
|
-
|
48
39
|
# Path to the masks
|
49
40
|
_masks_path = Path(__file__).parent / "masks"
|
50
41
|
|
@@ -130,6 +121,46 @@ def compute_brain_mask(
|
|
130
121
|
return new_img_like(target_img, mask) # type: ignore
|
131
122
|
|
132
123
|
|
124
|
+
def _fetch_icbm152_brain_gm_mask(
|
125
|
+
target_img: "Nifti1Image",
|
126
|
+
**kwargs,
|
127
|
+
) -> "Nifti1Image":
|
128
|
+
"""Fetch ICBM152 brain mask and resample.
|
129
|
+
|
130
|
+
Parameters
|
131
|
+
----------
|
132
|
+
target_img : nibabel.Nifti1Image
|
133
|
+
The image to which the mask will be resampled.
|
134
|
+
**kwargs : dict
|
135
|
+
Keyword arguments to be passed to
|
136
|
+
:func:`nilearn.datasets.fetch_icbm152_brain_gm_mask`.
|
137
|
+
|
138
|
+
Returns
|
139
|
+
-------
|
140
|
+
nibabel.Nifti1Image
|
141
|
+
The resampled mask.
|
142
|
+
|
143
|
+
Warns
|
144
|
+
-----
|
145
|
+
DeprecationWarning
|
146
|
+
If this function is used.
|
147
|
+
|
148
|
+
"""
|
149
|
+
warn_with_log(
|
150
|
+
msg=(
|
151
|
+
"It is recommended to use ``compute_brain_mask`` with "
|
152
|
+
"``mask_type='gm'``. This function will be removed in the next "
|
153
|
+
"release. For now, it's available for backward compatibility."
|
154
|
+
),
|
155
|
+
category=DeprecationWarning,
|
156
|
+
)
|
157
|
+
mask = fetch_icbm152_brain_gm_mask(**kwargs)
|
158
|
+
mask = resample_to_img(
|
159
|
+
mask, target_img, interpolation="nearest", copy=True
|
160
|
+
)
|
161
|
+
return mask
|
162
|
+
|
163
|
+
|
133
164
|
# A dictionary containing all supported masks and their respective file or
|
134
165
|
# data.
|
135
166
|
|
@@ -163,9 +194,10 @@ _available_masks: Dict[str, Dict[str, Any]] = {
|
|
163
194
|
"func": compute_epi_mask,
|
164
195
|
"space": "inherit",
|
165
196
|
},
|
166
|
-
"
|
167
|
-
"family": "
|
168
|
-
"
|
197
|
+
"fetch_icbm152_brain_gm_mask": {
|
198
|
+
"family": "Callable",
|
199
|
+
"func": _fetch_icbm152_brain_gm_mask,
|
200
|
+
"space": "MNI152NLin2009aAsym",
|
169
201
|
},
|
170
202
|
}
|
171
203
|
|
@@ -260,12 +292,14 @@ def get_mask( # noqa: C901
|
|
260
292
|
Raises
|
261
293
|
------
|
262
294
|
RuntimeError
|
263
|
-
If warp / transformation file extension is not ".mat" or ".h5"
|
295
|
+
If warp / transformation file extension is not ".mat" or ".h5" or
|
296
|
+
if fetch_icbm152_brain_gm_mask is used and requires warping to
|
297
|
+
other template space.
|
264
298
|
ValueError
|
265
299
|
If extra key is provided in addition to mask name in ``masks`` or
|
266
300
|
if no mask is provided or
|
267
|
-
if ``masks = "inherit"``
|
268
|
-
not
|
301
|
+
if ``masks = "inherit"`` but ``extra_input`` is None or ``mask_item``
|
302
|
+
is None or ``mask_items``'s value is not in ``extra_input`` or
|
269
303
|
if callable parameters are passed to non-callable mask or
|
270
304
|
if parameters are passed to :func:`nilearn.masking.intersect_masks`
|
271
305
|
when there is only one mask or
|
@@ -324,8 +358,8 @@ def get_mask( # noqa: C901
|
|
324
358
|
if len(true_masks) == 0:
|
325
359
|
raise_error("No mask was passed. At least one mask is required.")
|
326
360
|
|
327
|
-
# Get the
|
328
|
-
inherited_mask_item = target_data.get("
|
361
|
+
# Get the data type for the input data type's mask
|
362
|
+
inherited_mask_item = target_data.get("mask_item", None)
|
329
363
|
|
330
364
|
# Create component-scoped tempdir
|
331
365
|
tempdir = WorkDirManager().get_tempdir(prefix="masks")
|
@@ -344,18 +378,45 @@ def get_mask( # noqa: C901
|
|
344
378
|
mask_name = t_mask
|
345
379
|
mask_params = None
|
346
380
|
|
347
|
-
# If mask is being inherited from
|
348
|
-
# check that it's accessible
|
381
|
+
# If mask is being inherited from previous steps like preprocessing
|
349
382
|
if mask_name == "inherit":
|
383
|
+
# Requires extra input to be passed
|
384
|
+
if extra_input is None:
|
385
|
+
raise_error(
|
386
|
+
"Cannot inherit mask from another data item "
|
387
|
+
"because no extra data was passed."
|
388
|
+
)
|
389
|
+
# Missing inherited mask item
|
350
390
|
if inherited_mask_item is None:
|
351
391
|
raise_error(
|
352
|
-
"Cannot inherit mask from
|
353
|
-
"
|
354
|
-
"
|
392
|
+
"Cannot inherit mask from another data item "
|
393
|
+
"because no mask item was specified "
|
394
|
+
"(missing `mask_item` key in the data object)."
|
355
395
|
)
|
356
|
-
|
396
|
+
# Missing inherited mask item in extra input
|
397
|
+
if inherited_mask_item not in extra_input:
|
398
|
+
raise_error(
|
399
|
+
"Cannot inherit mask from another data item "
|
400
|
+
f"because the item ({inherited_mask_item}) does not exist."
|
401
|
+
)
|
402
|
+
mask_img = extra_input[inherited_mask_item]["data"]
|
357
403
|
# Starting with new mask
|
358
404
|
else:
|
405
|
+
# Restrict fetch_icbm152_brain_gm_mask if target std space doesn't
|
406
|
+
# match
|
407
|
+
if (
|
408
|
+
mask_name == "fetch_icbm152_brain_gm_mask"
|
409
|
+
and target_std_space != "MNI152NLin2009aAsym"
|
410
|
+
):
|
411
|
+
raise_error(
|
412
|
+
(
|
413
|
+
"``fetch_icbm152_brain_gm_mask`` is deprecated and "
|
414
|
+
"space transformation to any other template space is "
|
415
|
+
"prohibited as it will lead to unforeseen errors. "
|
416
|
+
"``compute_brain_mask`` is a better alternative."
|
417
|
+
),
|
418
|
+
klass=RuntimeError,
|
419
|
+
)
|
359
420
|
# Load mask
|
360
421
|
mask_object, _, mask_space = load_mask(
|
361
422
|
mask_name, path_only=False, resolution=resolution
|
@@ -571,8 +632,6 @@ def load_mask(
|
|
571
632
|
elif t_family == "Callable":
|
572
633
|
mask_img = mask_definition["func"]
|
573
634
|
mask_fname = None
|
574
|
-
elif t_family == "UKB":
|
575
|
-
mask_fname = _load_ukb_mask(name)
|
576
635
|
else:
|
577
636
|
raise_error(f"I don't know about the {t_family} mask family.")
|
578
637
|
|
@@ -638,33 +697,3 @@ def _load_vickery_patil_mask(
|
|
638
697
|
mask_fname = _masks_path / "vickery-patil" / mask_fname
|
639
698
|
|
640
699
|
return mask_fname
|
641
|
-
|
642
|
-
|
643
|
-
def _load_ukb_mask(name: str) -> Path:
|
644
|
-
"""Load UKB mask.
|
645
|
-
|
646
|
-
Parameters
|
647
|
-
----------
|
648
|
-
name : {"UKB_15K_GM"}
|
649
|
-
The name of the mask.
|
650
|
-
|
651
|
-
Returns
|
652
|
-
-------
|
653
|
-
pathlib.Path
|
654
|
-
File path to the mask image.
|
655
|
-
|
656
|
-
Raises
|
657
|
-
------
|
658
|
-
ValueError
|
659
|
-
If ``name`` is invalid.
|
660
|
-
|
661
|
-
"""
|
662
|
-
if name == "UKB_15K_GM":
|
663
|
-
mask_fname = "UKB_15K_GM_template.nii.gz"
|
664
|
-
else:
|
665
|
-
raise_error(f"Cannot find a UKB mask called {name}")
|
666
|
-
|
667
|
-
# Set path for masks
|
668
|
-
mask_fname = _masks_path / "ukb" / mask_fname
|
669
|
-
|
670
|
-
return mask_fname
|
junifer/data/parcellations.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Provide functions for parcellation."""
|
2
2
|
|
3
3
|
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
|
4
4
|
# Vera Komeyer <v.komeyer@fz-juelich.de>
|
@@ -30,15 +30,6 @@ if TYPE_CHECKING:
|
|
30
30
|
from nibabel import Nifti1Image
|
31
31
|
|
32
32
|
|
33
|
-
__all__ = [
|
34
|
-
"register_parcellation",
|
35
|
-
"list_parcellations",
|
36
|
-
"get_parcellation",
|
37
|
-
"load_parcellation",
|
38
|
-
"merge_parcellations",
|
39
|
-
]
|
40
|
-
|
41
|
-
|
42
33
|
# A dictionary containing all supported parcellations and their respective
|
43
34
|
# valid parameters.
|
44
35
|
|
@@ -335,9 +326,7 @@ def get_parcellation(
|
|
335
326
|
# Call antsApplyTransforms
|
336
327
|
run_ext_cmd(name="antsApplyTransforms", cmd=apply_transforms_cmd)
|
337
328
|
|
338
|
-
|
339
|
-
# Remove extra dimension added by ANTs
|
340
|
-
img = image.math_img("np.squeeze(img)", img=raw_img)
|
329
|
+
img = nib.load(warped_parcellation_path)
|
341
330
|
|
342
331
|
# Resample parcellation to target image
|
343
332
|
img_to_merge = image.resample_to_img(
|
@@ -898,7 +887,7 @@ def _retrieve_tian(
|
|
898
887
|
)
|
899
888
|
with open(parcellation_lname, "w") as filehandle:
|
900
889
|
for listitem in labels:
|
901
|
-
filehandle.write(
|
890
|
+
filehandle.write("%s\n" % listitem)
|
902
891
|
logger.info(
|
903
892
|
"Currently there are no labels provided for the 7T Tian "
|
904
893
|
"parcellation. A simple numbering scheme for distinction was "
|
junifer/data/template_spaces.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Provide functions for template spaces."""
|
2
2
|
|
3
3
|
# Authors: Synchon Mandal <s.mandal@fz-juelich.de>
|
4
4
|
# License: AGPL
|
@@ -15,9 +15,6 @@ from ..utils import logger, raise_error
|
|
15
15
|
from .utils import closest_resolution
|
16
16
|
|
17
17
|
|
18
|
-
__all__ = ["get_xfm", "get_template"]
|
19
|
-
|
20
|
-
|
21
18
|
def get_xfm(
|
22
19
|
src: str, dst: str, xfms_dir: Union[str, Path, None] = None
|
23
20
|
) -> Path: # pragma: no cover
|
junifer/data/tests/test_masks.py
CHANGED
@@ -22,7 +22,6 @@ from numpy.testing import assert_array_almost_equal, assert_array_equal
|
|
22
22
|
|
23
23
|
from junifer.data.masks import (
|
24
24
|
_available_masks,
|
25
|
-
_load_ukb_mask,
|
26
25
|
_load_vickery_patil_mask,
|
27
26
|
compute_brain_mask,
|
28
27
|
get_mask,
|
@@ -213,7 +212,6 @@ def test_register_mask(
|
|
213
212
|
[
|
214
213
|
"GM_prob0.2",
|
215
214
|
"GM_prob0.2_cortex",
|
216
|
-
"UKB_15K_GM",
|
217
215
|
],
|
218
216
|
)
|
219
217
|
def test_list_masks_correct(mask_name: str) -> None:
|
@@ -293,21 +291,6 @@ def test_vickery_patil_error() -> None:
|
|
293
291
|
_load_vickery_patil_mask(name="wrong", resolution=2.0)
|
294
292
|
|
295
293
|
|
296
|
-
def test_ukb() -> None:
|
297
|
-
"""Test UKB mask."""
|
298
|
-
mask, mask_fname, space = load_mask("UKB_15K_GM", resolution=2.0)
|
299
|
-
assert_array_almost_equal(mask.header["pixdim"][1:4], 2.0) # type: ignore
|
300
|
-
assert space == "MNI152NLin6Asym"
|
301
|
-
assert mask_fname is not None
|
302
|
-
assert mask_fname.name == "UKB_15K_GM_template.nii.gz"
|
303
|
-
|
304
|
-
|
305
|
-
def test_ukb_error() -> None:
|
306
|
-
"""Test error for UKB mask."""
|
307
|
-
with pytest.raises(ValueError, match=r"find a UKB mask "):
|
308
|
-
_load_ukb_mask(name="wrong")
|
309
|
-
|
310
|
-
|
311
294
|
def test_get_mask() -> None:
|
312
295
|
"""Test the get_mask function."""
|
313
296
|
with OasisVBMTestingDataGrabber() as dg:
|
@@ -367,7 +350,7 @@ def test_get_mask_errors() -> None:
|
|
367
350
|
with pytest.raises(ValueError, match=r"callable params"):
|
368
351
|
get_mask(masks={"GM_prob0.2": {"param": 1}}, target_data=vbm_gm)
|
369
352
|
|
370
|
-
# Pass only
|
353
|
+
# Pass only parametesr to the intersection function
|
371
354
|
with pytest.raises(
|
372
355
|
ValueError, match=r" At least one mask is required."
|
373
356
|
):
|
@@ -382,10 +365,35 @@ def test_get_mask_errors() -> None:
|
|
382
365
|
target_data=vbm_gm,
|
383
366
|
)
|
384
367
|
|
385
|
-
# Test "inherited" masks
|
386
|
-
|
368
|
+
# Test "inherited" masks errors
|
369
|
+
|
370
|
+
# 1) No extra_data parameter
|
371
|
+
with pytest.raises(ValueError, match=r"no extra data was passed"):
|
387
372
|
get_mask(masks="inherit", target_data=vbm_gm)
|
388
373
|
|
374
|
+
extra_input = {"VBM_MASK": {}}
|
375
|
+
|
376
|
+
# 2) No mask_item key in target_data
|
377
|
+
with pytest.raises(ValueError, match=r"no mask item was specified"):
|
378
|
+
get_mask(
|
379
|
+
masks="inherit", target_data=vbm_gm, extra_input=extra_input
|
380
|
+
)
|
381
|
+
|
382
|
+
# 3) mask_item not in extra data
|
383
|
+
with pytest.raises(ValueError, match=r"does not exist"):
|
384
|
+
vbm_gm["mask_item"] = "wrong"
|
385
|
+
get_mask(
|
386
|
+
masks="inherit", target_data=vbm_gm, extra_input=extra_input
|
387
|
+
)
|
388
|
+
|
389
|
+
# Block fetch_icbm152_brain_gm_mask space transformation
|
390
|
+
with pytest.raises(RuntimeError, match="prohibited"):
|
391
|
+
get_mask(
|
392
|
+
masks="fetch_icbm152_brain_gm_mask",
|
393
|
+
target_data=vbm_gm,
|
394
|
+
extra_input=extra_input,
|
395
|
+
)
|
396
|
+
|
389
397
|
|
390
398
|
@pytest.mark.parametrize(
|
391
399
|
"mask_name,function,params,resample",
|
@@ -457,15 +465,18 @@ def test_get_mask_inherit() -> None:
|
|
457
465
|
)
|
458
466
|
|
459
467
|
# Now get the mask using the inherit functionality, passing the
|
460
|
-
# computed mask as
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
468
|
+
# computed mask as extra data
|
469
|
+
extra_input = {
|
470
|
+
"BOLD_MASK": {
|
471
|
+
"data": gm_mask,
|
472
|
+
"space": element_data["BOLD"]["space"],
|
473
|
+
}
|
465
474
|
}
|
475
|
+
element_data["BOLD"]["mask_item"] = "BOLD_MASK"
|
466
476
|
mask2 = get_mask(
|
467
477
|
masks="inherit",
|
468
|
-
target_data=
|
478
|
+
target_data=element_data["BOLD"],
|
479
|
+
extra_input=extra_input,
|
469
480
|
)
|
470
481
|
|
471
482
|
# Both masks should be equal
|
junifer/data/utils.py
CHANGED
junifer/datagrabber/__init__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Provide imports for datagrabber sub-package."""
|
2
2
|
|
3
3
|
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
|
4
4
|
# Leonard Sasse <l.sasse@fz-juelich.de>
|
@@ -16,20 +16,3 @@ from .aomic import DataladAOMICID1000, DataladAOMICPIOP1, DataladAOMICPIOP2
|
|
16
16
|
from .hcp1200 import HCP1200, DataladHCP1200
|
17
17
|
from .multiple import MultipleDataGrabber
|
18
18
|
from .dmcc13_benchmark import DMCC13Benchmark
|
19
|
-
|
20
|
-
from .pattern_validation_mixin import PatternValidationMixin
|
21
|
-
|
22
|
-
__all__ = [
|
23
|
-
"BaseDataGrabber",
|
24
|
-
"DataladDataGrabber",
|
25
|
-
"PatternDataGrabber",
|
26
|
-
"PatternDataladDataGrabber",
|
27
|
-
"DataladAOMICID1000",
|
28
|
-
"DataladAOMICPIOP1",
|
29
|
-
"DataladAOMICPIOP2",
|
30
|
-
"HCP1200",
|
31
|
-
"DataladHCP1200",
|
32
|
-
"MultipleDataGrabber",
|
33
|
-
"DMCC13Benchmark",
|
34
|
-
"PatternValidationMixin",
|
35
|
-
]
|
@@ -14,9 +14,6 @@ from ...api.decorators import register_datagrabber
|
|
14
14
|
from ..pattern_datalad import PatternDataladDataGrabber
|
15
15
|
|
16
16
|
|
17
|
-
__all__ = ["DataladAOMICID1000"]
|
18
|
-
|
19
|
-
|
20
17
|
@register_datagrabber
|
21
18
|
class DataladAOMICID1000(PatternDataladDataGrabber):
|
22
19
|
"""Concrete implementation for datalad-based data fetching of AOMIC ID1000.
|
@@ -27,8 +24,8 @@ class DataladAOMICID1000(PatternDataladDataGrabber):
|
|
27
24
|
The directory where the datalad dataset will be cloned. If None,
|
28
25
|
the datalad dataset will be cloned into a temporary directory
|
29
26
|
(default None).
|
30
|
-
types: {"BOLD", "
|
31
|
-
"
|
27
|
+
types: {"BOLD", "BOLD_confounds", "T1w", "VBM_CSF", "VBM_GM", \
|
28
|
+
"VBM_WM", "DWI"} or a list of the options, optional
|
32
29
|
AOMIC data types. If None, all available data types are selected.
|
33
30
|
(default None).
|
34
31
|
native_t1w : bool, optional
|
@@ -51,23 +48,24 @@ class DataladAOMICID1000(PatternDataladDataGrabber):
|
|
51
48
|
"space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz"
|
52
49
|
),
|
53
50
|
"space": "MNI152NLin2009cAsym",
|
54
|
-
"
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
"
|
70
|
-
|
51
|
+
"mask_item": "BOLD_mask",
|
52
|
+
},
|
53
|
+
"BOLD_confounds": {
|
54
|
+
"pattern": (
|
55
|
+
"derivatives/fmriprep/{subject}/func/"
|
56
|
+
"{subject}_task-moviewatching_"
|
57
|
+
"desc-confounds_regressors.tsv"
|
58
|
+
),
|
59
|
+
"format": "fmriprep",
|
60
|
+
},
|
61
|
+
"BOLD_mask": {
|
62
|
+
"pattern": (
|
63
|
+
"derivatives/fmriprep/{subject}/func/"
|
64
|
+
"{subject}_task-moviewatching_"
|
65
|
+
"space-MNI152NLin2009cAsym_"
|
66
|
+
"desc-brain_mask.nii.gz"
|
67
|
+
),
|
68
|
+
"space": "MNI152NLin2009cAsym",
|
71
69
|
},
|
72
70
|
"T1w": {
|
73
71
|
"pattern": (
|
@@ -76,14 +74,15 @@ class DataladAOMICID1000(PatternDataladDataGrabber):
|
|
76
74
|
"desc-preproc_T1w.nii.gz"
|
77
75
|
),
|
78
76
|
"space": "MNI152NLin2009cAsym",
|
79
|
-
"
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
"
|
86
|
-
|
77
|
+
"mask_item": "T1w_mask",
|
78
|
+
},
|
79
|
+
"T1w_mask": {
|
80
|
+
"pattern": (
|
81
|
+
"derivatives/fmriprep/{subject}/anat/"
|
82
|
+
"{subject}_space-MNI152NLin2009cAsym_"
|
83
|
+
"desc-brain_mask.nii.gz"
|
84
|
+
),
|
85
|
+
"space": "MNI152NLin2009cAsym",
|
87
86
|
},
|
88
87
|
"VBM_CSF": {
|
89
88
|
"pattern": (
|
@@ -115,39 +114,6 @@ class DataladAOMICID1000(PatternDataladDataGrabber):
|
|
115
114
|
"{subject}_desc-preproc_dwi.nii.gz"
|
116
115
|
),
|
117
116
|
},
|
118
|
-
"FreeSurfer": {
|
119
|
-
"pattern": "derivatives/freesurfer/[!f]{subject}/mri/T1.mg[z]",
|
120
|
-
"aseg": {
|
121
|
-
"pattern": (
|
122
|
-
"derivatives/freesurfer/[!f]{subject}/mri/aseg.mg[z]"
|
123
|
-
)
|
124
|
-
},
|
125
|
-
"norm": {
|
126
|
-
"pattern": (
|
127
|
-
"derivatives/freesurfer/[!f]{subject}/mri/norm.mg[z]"
|
128
|
-
)
|
129
|
-
},
|
130
|
-
"lh_white": {
|
131
|
-
"pattern": (
|
132
|
-
"derivatives/freesurfer/[!f]{subject}/surf/lh.whit[e]"
|
133
|
-
)
|
134
|
-
},
|
135
|
-
"rh_white": {
|
136
|
-
"pattern": (
|
137
|
-
"derivatives/freesurfer/[!f]{subject}/surf/rh.whit[e]"
|
138
|
-
)
|
139
|
-
},
|
140
|
-
"lh_pial": {
|
141
|
-
"pattern": (
|
142
|
-
"derivatives/freesurfer/[!f]{subject}/surf/lh.pia[l]"
|
143
|
-
)
|
144
|
-
},
|
145
|
-
"rh_pial": {
|
146
|
-
"pattern": (
|
147
|
-
"derivatives/freesurfer/[!f]{subject}/surf/rh.pia[l]"
|
148
|
-
)
|
149
|
-
},
|
150
|
-
},
|
151
117
|
}
|
152
118
|
# Use native T1w assets
|
153
119
|
self.native_t1w = False
|
@@ -161,13 +127,14 @@ class DataladAOMICID1000(PatternDataladDataGrabber):
|
|
161
127
|
"{subject}_desc-preproc_T1w.nii.gz"
|
162
128
|
),
|
163
129
|
"space": "native",
|
164
|
-
"
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
"
|
170
|
-
|
130
|
+
"mask_item": "T1w_mask",
|
131
|
+
},
|
132
|
+
"T1w_mask": {
|
133
|
+
"pattern": (
|
134
|
+
"derivatives/fmriprep/{subject}/anat/"
|
135
|
+
"{subject}_desc-brain_mask.nii.gz"
|
136
|
+
),
|
137
|
+
"space": "native",
|
171
138
|
},
|
172
139
|
"Warp": {
|
173
140
|
"pattern": (
|