junifer 0.0.6.dev227__py3-none-any.whl → 0.0.6.dev252__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.
Files changed (131) hide show
  1. junifer/_version.py +2 -2
  2. junifer/api/decorators.py +1 -2
  3. junifer/api/functions.py +18 -18
  4. junifer/api/queue_context/gnu_parallel_local_adapter.py +4 -4
  5. junifer/api/queue_context/htcondor_adapter.py +4 -4
  6. junifer/api/queue_context/tests/test_gnu_parallel_local_adapter.py +3 -3
  7. junifer/api/queue_context/tests/test_htcondor_adapter.py +3 -3
  8. junifer/api/tests/test_functions.py +32 -32
  9. junifer/cli/cli.py +3 -3
  10. junifer/cli/parser.py +4 -4
  11. junifer/cli/tests/test_cli.py +5 -5
  12. junifer/cli/utils.py +5 -6
  13. junifer/configs/juseless/datagrabbers/ixi_vbm.py +2 -2
  14. junifer/configs/juseless/datagrabbers/tests/test_ucla.py +2 -2
  15. junifer/configs/juseless/datagrabbers/ucla.py +4 -4
  16. junifer/data/_dispatch.py +11 -14
  17. junifer/data/coordinates/_ants_coordinates_warper.py +6 -8
  18. junifer/data/coordinates/_coordinates.py +34 -21
  19. junifer/data/coordinates/_fsl_coordinates_warper.py +6 -8
  20. junifer/data/masks/_ants_mask_warper.py +18 -11
  21. junifer/data/masks/_fsl_mask_warper.py +6 -8
  22. junifer/data/masks/_masks.py +27 -34
  23. junifer/data/masks/tests/test_masks.py +4 -4
  24. junifer/data/parcellations/_ants_parcellation_warper.py +18 -11
  25. junifer/data/parcellations/_fsl_parcellation_warper.py +6 -8
  26. junifer/data/parcellations/_parcellations.py +39 -43
  27. junifer/data/parcellations/tests/test_parcellations.py +1 -2
  28. junifer/data/pipeline_data_registry_base.py +3 -2
  29. junifer/data/template_spaces.py +3 -3
  30. junifer/data/tests/test_data_utils.py +1 -2
  31. junifer/data/utils.py +69 -4
  32. junifer/datagrabber/aomic/id1000.py +24 -11
  33. junifer/datagrabber/aomic/piop1.py +27 -14
  34. junifer/datagrabber/aomic/piop2.py +27 -14
  35. junifer/datagrabber/aomic/tests/test_id1000.py +3 -3
  36. junifer/datagrabber/aomic/tests/test_piop1.py +4 -4
  37. junifer/datagrabber/aomic/tests/test_piop2.py +4 -4
  38. junifer/datagrabber/base.py +18 -12
  39. junifer/datagrabber/datalad_base.py +18 -11
  40. junifer/datagrabber/dmcc13_benchmark.py +31 -18
  41. junifer/datagrabber/hcp1200/datalad_hcp1200.py +3 -3
  42. junifer/datagrabber/hcp1200/hcp1200.py +26 -15
  43. junifer/datagrabber/hcp1200/tests/test_hcp1200.py +2 -1
  44. junifer/datagrabber/multiple.py +7 -7
  45. junifer/datagrabber/pattern.py +75 -45
  46. junifer/datagrabber/pattern_validation_mixin.py +204 -94
  47. junifer/datagrabber/tests/test_datalad_base.py +7 -8
  48. junifer/datagrabber/tests/test_dmcc13_benchmark.py +28 -11
  49. junifer/datagrabber/tests/test_pattern_validation_mixin.py +6 -6
  50. junifer/datareader/default.py +6 -6
  51. junifer/external/nilearn/junifer_connectivity_measure.py +2 -2
  52. junifer/external/nilearn/junifer_nifti_spheres_masker.py +4 -4
  53. junifer/external/nilearn/tests/test_junifer_connectivity_measure.py +15 -15
  54. junifer/external/nilearn/tests/test_junifer_nifti_spheres_masker.py +2 -3
  55. junifer/markers/base.py +8 -8
  56. junifer/markers/brainprint.py +7 -9
  57. junifer/markers/complexity/complexity_base.py +6 -8
  58. junifer/markers/complexity/hurst_exponent.py +5 -5
  59. junifer/markers/complexity/multiscale_entropy_auc.py +5 -5
  60. junifer/markers/complexity/perm_entropy.py +5 -5
  61. junifer/markers/complexity/range_entropy.py +5 -5
  62. junifer/markers/complexity/range_entropy_auc.py +5 -5
  63. junifer/markers/complexity/sample_entropy.py +5 -5
  64. junifer/markers/complexity/weighted_perm_entropy.py +5 -5
  65. junifer/markers/ets_rss.py +7 -7
  66. junifer/markers/falff/_afni_falff.py +1 -2
  67. junifer/markers/falff/_junifer_falff.py +1 -2
  68. junifer/markers/falff/falff_base.py +2 -4
  69. junifer/markers/falff/falff_parcels.py +7 -7
  70. junifer/markers/falff/falff_spheres.py +6 -6
  71. junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +6 -6
  72. junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +7 -7
  73. junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +6 -6
  74. junifer/markers/functional_connectivity/functional_connectivity_base.py +10 -10
  75. junifer/markers/functional_connectivity/functional_connectivity_parcels.py +7 -7
  76. junifer/markers/functional_connectivity/functional_connectivity_spheres.py +6 -6
  77. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +1 -2
  78. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +1 -2
  79. junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +3 -3
  80. junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +3 -3
  81. junifer/markers/parcel_aggregation.py +8 -8
  82. junifer/markers/reho/_afni_reho.py +1 -2
  83. junifer/markers/reho/_junifer_reho.py +1 -2
  84. junifer/markers/reho/reho_base.py +2 -4
  85. junifer/markers/reho/reho_parcels.py +8 -8
  86. junifer/markers/reho/reho_spheres.py +7 -7
  87. junifer/markers/sphere_aggregation.py +8 -8
  88. junifer/markers/temporal_snr/temporal_snr_base.py +8 -8
  89. junifer/markers/temporal_snr/temporal_snr_parcels.py +6 -6
  90. junifer/markers/temporal_snr/temporal_snr_spheres.py +5 -5
  91. junifer/markers/utils.py +3 -3
  92. junifer/onthefly/_brainprint.py +2 -2
  93. junifer/onthefly/read_transform.py +3 -3
  94. junifer/pipeline/marker_collection.py +4 -4
  95. junifer/pipeline/pipeline_component_registry.py +5 -4
  96. junifer/pipeline/pipeline_step_mixin.py +15 -11
  97. junifer/pipeline/tests/test_pipeline_component_registry.py +2 -3
  98. junifer/pipeline/tests/test_pipeline_step_mixin.py +19 -19
  99. junifer/pipeline/tests/test_update_meta_mixin.py +4 -4
  100. junifer/pipeline/update_meta_mixin.py +21 -17
  101. junifer/pipeline/utils.py +5 -5
  102. junifer/preprocess/base.py +10 -10
  103. junifer/preprocess/confounds/fmriprep_confound_remover.py +11 -14
  104. junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py +1 -2
  105. junifer/preprocess/smoothing/smoothing.py +7 -7
  106. junifer/preprocess/warping/_ants_warper.py +26 -6
  107. junifer/preprocess/warping/_fsl_warper.py +22 -7
  108. junifer/preprocess/warping/space_warper.py +37 -10
  109. junifer/preprocess/warping/tests/test_space_warper.py +3 -4
  110. junifer/stats.py +4 -4
  111. junifer/storage/base.py +14 -13
  112. junifer/storage/hdf5.py +21 -20
  113. junifer/storage/pandas_base.py +12 -11
  114. junifer/storage/sqlite.py +11 -11
  115. junifer/storage/tests/test_hdf5.py +1 -2
  116. junifer/storage/tests/test_sqlite.py +2 -2
  117. junifer/storage/tests/test_utils.py +8 -7
  118. junifer/storage/utils.py +7 -7
  119. junifer/testing/datagrabbers.py +9 -10
  120. junifer/tests/test_stats.py +2 -2
  121. junifer/typing/_typing.py +6 -9
  122. junifer/utils/helpers.py +2 -3
  123. junifer/utils/logging.py +5 -5
  124. junifer/utils/singleton.py +3 -3
  125. {junifer-0.0.6.dev227.dist-info → junifer-0.0.6.dev252.dist-info}/METADATA +2 -2
  126. {junifer-0.0.6.dev227.dist-info → junifer-0.0.6.dev252.dist-info}/RECORD +131 -131
  127. {junifer-0.0.6.dev227.dist-info → junifer-0.0.6.dev252.dist-info}/WHEEL +1 -1
  128. {junifer-0.0.6.dev227.dist-info → junifer-0.0.6.dev252.dist-info}/AUTHORS.rst +0 -0
  129. {junifer-0.0.6.dev227.dist-info → junifer-0.0.6.dev252.dist-info}/LICENSE.md +0 -0
  130. {junifer-0.0.6.dev227.dist-info → junifer-0.0.6.dev252.dist-info}/entry_points.txt +0 -0
  131. {junifer-0.0.6.dev227.dist-info → junifer-0.0.6.dev252.dist-info}/top_level.txt +0 -0
@@ -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, Dict, List, Optional, Tuple, Union
15
+ from typing import TYPE_CHECKING, Any, Optional, Union
16
16
 
17
17
  import httpx
18
18
  import nibabel as nib
@@ -23,7 +23,7 @@ from nilearn import datasets, image
23
23
  from ...utils import logger, raise_error, warn_with_log
24
24
  from ...utils.singleton import Singleton
25
25
  from ..pipeline_data_registry_base import BasePipelineDataRegistry
26
- from ..utils import closest_resolution
26
+ from ..utils import closest_resolution, get_native_warper
27
27
  from ._ants_parcellation_warper import ANTsParcellationWarper
28
28
  from ._fsl_parcellation_warper import FSLParcellationWarper
29
29
 
@@ -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: List[str],
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
- ) -> Tuple[Optional["Nifti1Image"], List[str], Path, str]:
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, List[str]],
371
- target_data: Dict[str, Any],
372
- extra_input: Optional[Dict[str, Any]] = None,
373
- ) -> Tuple["Nifti1Image", List[str]]:
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
@@ -394,16 +394,12 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
394
394
 
395
395
  Raises
396
396
  ------
397
- RuntimeError
398
- If warp / transformation file extension is not ".mat" or ".h5".
399
397
  ValueError
400
398
  If ``extra_input`` is None when ``target_data``'s space is native.
401
399
 
402
400
  """
403
401
  # Check pre-requirements for space manipulation
404
402
  target_space = target_data["space"]
405
- # Set target standard space to target space
406
- target_std_space = target_space
407
403
  # Extra data type requirement check if target space is native
408
404
  if target_space == "native":
409
405
  # Check for extra inputs
@@ -413,8 +409,16 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
413
409
  "data types in particular for transformation to "
414
410
  f"{target_data['space']} space for further computation."
415
411
  )
412
+ # Get native space warper spec
413
+ warper_spec = get_native_warper(
414
+ target_data=target_data,
415
+ other_data=extra_input,
416
+ )
416
417
  # Set target standard space to warp file space source
417
- target_std_space = extra_input["Warp"]["src"]
418
+ target_std_space = warper_spec["src"]
419
+ else:
420
+ # Set target standard space to target space
421
+ target_std_space = target_space
418
422
 
419
423
  # Get the min of the voxels sizes and use it as the resolution
420
424
  target_img = target_data["data"]
@@ -428,12 +432,14 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
428
432
  all_parcellations = []
429
433
  all_labels = []
430
434
  for name in parcellations:
435
+ # Load parcellation
431
436
  img, labels, _, space = self.load(
432
437
  name=name,
433
438
  resolution=resolution,
434
439
  )
435
440
 
436
- # Convert parcellation spaces if required
441
+ # Convert parcellation spaces if required;
442
+ # cannot be "native" due to earlier check
437
443
  if space != target_std_space:
438
444
  raw_img = ANTsParcellationWarper().warp(
439
445
  parcellation_name=name,
@@ -441,7 +447,7 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
441
447
  src=space,
442
448
  dst=target_std_space,
443
449
  target_data=target_data,
444
- extra_input=None,
450
+ warp_data=None,
445
451
  )
446
452
  # Remove extra dimension added by ANTs
447
453
  img = image.math_img("np.squeeze(img)", img=raw_img)
@@ -471,32 +477,22 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
471
477
 
472
478
  # Warp parcellation if target space is native
473
479
  if target_space == "native":
474
- # extra_input check done earlier
475
- # Check for warp file type to use correct tool
476
- warp_file_ext = extra_input["Warp"]["path"].suffix
477
- if warp_file_ext == ".mat":
480
+ # extra_input check done earlier and warper_spec exists
481
+ if warper_spec["warper"] == "fsl":
478
482
  resampled_parcellation_img = FSLParcellationWarper().warp(
479
483
  parcellation_name="native",
480
484
  parcellation_img=resampled_parcellation_img,
481
485
  target_data=target_data,
482
- extra_input=extra_input,
486
+ warp_data=warper_spec,
483
487
  )
484
- elif warp_file_ext == ".h5":
488
+ elif warper_spec["warper"] == "ants":
485
489
  resampled_parcellation_img = ANTsParcellationWarper().warp(
486
490
  parcellation_name="native",
487
491
  parcellation_img=resampled_parcellation_img,
488
492
  src="",
489
- dst="T1w",
493
+ dst="native",
490
494
  target_data=target_data,
491
- extra_input=extra_input,
492
- )
493
- else:
494
- raise_error(
495
- msg=(
496
- "Unknown warp / transformation file extension: "
497
- f"{warp_file_ext}"
498
- ),
499
- klass=RuntimeError,
495
+ warp_data=warper_spec,
500
496
  )
501
497
 
502
498
  return resampled_parcellation_img, labels
@@ -507,7 +503,7 @@ def _retrieve_parcellation(
507
503
  parcellations_dir: Union[str, Path, None] = None,
508
504
  resolution: Optional[float] = None,
509
505
  **kwargs,
510
- ) -> Tuple[Path, List[str]]:
506
+ ) -> tuple[Path, list[str]]:
511
507
  """Retrieve a brain parcellation object from nilearn or online source.
512
508
 
513
509
  Only returns one parcellation per call. Call function multiple times for
@@ -651,7 +647,7 @@ def _retrieve_schaefer(
651
647
  resolution: Optional[float] = None,
652
648
  n_rois: Optional[int] = None,
653
649
  yeo_networks: int = 7,
654
- ) -> Tuple[Path, List[str]]:
650
+ ) -> tuple[Path, list[str]]:
655
651
  """Retrieve Schaefer parcellation.
656
652
 
657
653
  Parameters
@@ -753,7 +749,7 @@ def _retrieve_tian(
753
749
  scale: Optional[int] = None,
754
750
  space: str = "MNI152NLin6Asym",
755
751
  magneticfield: str = "3T",
756
- ) -> Tuple[Path, List[str]]:
752
+ ) -> tuple[Path, list[str]]:
757
753
  """Retrieve Tian parcellation.
758
754
 
759
755
  Parameters
@@ -927,7 +923,7 @@ def _retrieve_suit(
927
923
  parcellations_dir: Path,
928
924
  resolution: Optional[float],
929
925
  space: str = "MNI152NLin6Asym",
930
- ) -> Tuple[Path, List[str]]:
926
+ ) -> tuple[Path, list[str]]:
931
927
  """Retrieve SUIT parcellation.
932
928
 
933
929
  Parameters
@@ -1053,7 +1049,7 @@ def _retrieve_aicha(
1053
1049
  parcellations_dir: Path,
1054
1050
  resolution: Optional[float] = None,
1055
1051
  version: int = 2,
1056
- ) -> Tuple[Path, List[str]]:
1052
+ ) -> tuple[Path, list[str]]:
1057
1053
  """Retrieve AICHA parcellation.
1058
1054
 
1059
1055
  Parameters
@@ -1209,7 +1205,7 @@ def _retrieve_shen( # noqa: C901
1209
1205
  resolution: Optional[float] = None,
1210
1206
  year: int = 2015,
1211
1207
  n_rois: int = 268,
1212
- ) -> Tuple[Path, List[str]]:
1208
+ ) -> tuple[Path, list[str]]:
1213
1209
  """Retrieve Shen parcellation.
1214
1210
 
1215
1211
  Parameters
@@ -1414,7 +1410,7 @@ def _retrieve_yan(
1414
1410
  n_rois: Optional[int] = None,
1415
1411
  yeo_networks: Optional[int] = None,
1416
1412
  kong_networks: Optional[int] = None,
1417
- ) -> Tuple[Path, List[str]]:
1413
+ ) -> tuple[Path, list[str]]:
1418
1414
  """Retrieve Yan parcellation.
1419
1415
 
1420
1416
  Parameters
@@ -1611,7 +1607,7 @@ def _retrieve_brainnetome(
1611
1607
  parcellations_dir: Path,
1612
1608
  resolution: Optional[float] = None,
1613
1609
  threshold: Optional[int] = None,
1614
- ) -> Tuple[Path, List[str]]:
1610
+ ) -> tuple[Path, list[str]]:
1615
1611
  """Retrieve Brainnetome parcellation.
1616
1612
 
1617
1613
  Parameters
@@ -1724,10 +1720,10 @@ def _retrieve_brainnetome(
1724
1720
 
1725
1721
 
1726
1722
  def merge_parcellations(
1727
- parcellations_list: List["Nifti1Image"],
1728
- parcellations_names: List[str],
1729
- labels_lists: List[List[str]],
1730
- ) -> Tuple["Nifti1Image", List[str]]:
1723
+ parcellations_list: list["Nifti1Image"],
1724
+ parcellations_names: list[str],
1725
+ labels_lists: list[list[str]],
1726
+ ) -> tuple["Nifti1Image", list[str]]:
1731
1727
  """Merge all parcellations from a list into one parcellation.
1732
1728
 
1733
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: List[str],
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 typing import Any, List, Mapping
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) -> List[str]:
42
+ def list(self) -> list[str]:
42
43
  """List available pipeline data keys."""
43
44
  return sorted(self._registry.keys())
44
45
 
@@ -4,7 +4,7 @@
4
4
  # License: AGPL
5
5
 
6
6
  from pathlib import Path
7
- from typing import Any, Dict, Optional, Union
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: Dict[str, Any],
126
- extra_input: Optional[Dict[str, Any]] = None,
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: List[float], expected: float
26
+ resolution: float, valid_resolutions: list[float], expected: float
28
27
  ):
29
28
  """Test closest_resolution.
30
29
 
junifer/data/utils.py CHANGED
@@ -4,19 +4,20 @@
4
4
  # Synchon Mandal <s.mandal@fz-juelich.de>
5
5
  # License: AGPL
6
6
 
7
- from typing import List, Optional, Union
7
+ from collections.abc import MutableMapping
8
+ from typing import Optional, Union
8
9
 
9
10
  import numpy as np
10
11
 
11
- from ..utils.logging import logger
12
+ from ..utils import logger, raise_error
12
13
 
13
14
 
14
- __all__ = ["closest_resolution"]
15
+ __all__ = ["closest_resolution", "get_native_warper"]
15
16
 
16
17
 
17
18
  def closest_resolution(
18
19
  resolution: Optional[Union[float, int]],
19
- valid_resolution: Union[List[float], List[int], np.ndarray],
20
+ valid_resolution: Union[list[float], list[int], np.ndarray],
20
21
  ) -> Union[float, int]:
21
22
  """Find the closest resolution.
22
23
 
@@ -49,3 +50,67 @@ def closest_resolution(
49
50
  closest = np.min(valid_resolution)
50
51
 
51
52
  return closest
53
+
54
+
55
+ def get_native_warper(
56
+ target_data: MutableMapping,
57
+ other_data: MutableMapping,
58
+ inverse: bool = False,
59
+ ) -> dict:
60
+ """Get correct warping specification for native space.
61
+
62
+ Parameters
63
+ ----------
64
+ target_data : dict
65
+ The target data from the pipeline data object.
66
+ other_data : dict
67
+ The other data in the pipeline data object.
68
+ inverse : bool, optional
69
+ Whether to get the inverse warping specification (default False).
70
+
71
+ Returns
72
+ -------
73
+ dict
74
+ The correct warping specification.
75
+
76
+ Raises
77
+ ------
78
+ RuntimeError
79
+ If no warper or multiple possible warpers are found.
80
+
81
+ """
82
+ # Get possible warpers
83
+ possible_warpers = []
84
+ for entry in other_data["Warp"]:
85
+ if not inverse:
86
+ if (
87
+ entry["src"] == target_data["prewarp_space"]
88
+ and entry["dst"] == "native"
89
+ ):
90
+ possible_warpers.append(entry)
91
+ else:
92
+ if (
93
+ entry["dst"] == target_data["prewarp_space"]
94
+ and entry["src"] == "native"
95
+ ):
96
+ possible_warpers.append(entry)
97
+
98
+ # Check for no warper
99
+ if not possible_warpers:
100
+ raise_error(
101
+ klass=RuntimeError,
102
+ msg="Could not find correct warping specification",
103
+ )
104
+
105
+ # Check for multiple possible warpers
106
+ if len(possible_warpers) > 1:
107
+ raise_error(
108
+ klass=RuntimeError,
109
+ msg=(
110
+ "Cannot proceed as multiple warping specification found, "
111
+ "adjust either the DataGrabber or the working space: "
112
+ f"{possible_warpers}"
113
+ ),
114
+ )
115
+
116
+ return possible_warpers[0]
@@ -8,7 +8,7 @@
8
8
  # License: AGPL
9
9
 
10
10
  from pathlib import Path
11
- from typing import List, Union
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, List[str], None] = None,
42
+ types: Union[str, list[str], None] = None,
43
43
  native_t1w: bool = False,
44
44
  ) -> None:
45
45
  # The patterns
@@ -169,15 +169,28 @@ class DataladAOMICID1000(PatternDataladDataGrabber):
169
169
  "space": "native",
170
170
  },
171
171
  },
172
- "Warp": {
173
- "pattern": (
174
- "derivatives/fmriprep/{subject}/anat/"
175
- "{subject}_from-MNI152NLin2009cAsym_to-T1w_"
176
- "mode-image_xfm.h5"
177
- ),
178
- "src": "MNI152NLin2009cAsym",
179
- "dst": "native",
180
- },
172
+ "Warp": [
173
+ {
174
+ "pattern": (
175
+ "derivatives/fmriprep/{subject}/anat/"
176
+ "{subject}_from-MNI152NLin2009cAsym_to-T1w_"
177
+ "mode-image_xfm.h5"
178
+ ),
179
+ "src": "MNI152NLin2009cAsym",
180
+ "dst": "native",
181
+ "warper": "ants",
182
+ },
183
+ {
184
+ "pattern": (
185
+ "derivatives/fmriprep/{subject}/anat/"
186
+ "{subject}_from-T1w_to-MNI152NLin2009cAsym_"
187
+ "mode-image_xfm.h5"
188
+ ),
189
+ "src": "native",
190
+ "dst": "MNI152NLin2009cAsym",
191
+ "warper": "ants",
192
+ },
193
+ ],
181
194
  }
182
195
  )
183
196
  # Set default types
@@ -9,7 +9,7 @@
9
9
 
10
10
  from itertools import product
11
11
  from pathlib import Path
12
- from typing import Dict, List, Union
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, List[str], None] = None,
54
- tasks: Union[str, List[str], None] = None,
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
@@ -204,15 +204,28 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber):
204
204
  "space": "native",
205
205
  },
206
206
  },
207
- "Warp": {
208
- "pattern": (
209
- "derivatives/fmriprep/{subject}/anat/"
210
- "{subject}_from-MNI152NLin2009cAsym_to-T1w_"
211
- "mode-image_xfm.h5"
212
- ),
213
- "src": "MNI152NLin2009cAsym",
214
- "dst": "native",
215
- },
207
+ "Warp": [
208
+ {
209
+ "pattern": (
210
+ "derivatives/fmriprep/{subject}/anat/"
211
+ "{subject}_from-MNI152NLin2009cAsym_to-T1w_"
212
+ "mode-image_xfm.h5"
213
+ ),
214
+ "src": "MNI152NLin2009cAsym",
215
+ "dst": "native",
216
+ "warper": "ants",
217
+ },
218
+ {
219
+ "pattern": (
220
+ "derivatives/fmriprep/{subject}/anat/"
221
+ "{subject}_from-T1w_to-MNI152NLin2009cAsym_"
222
+ "mode-image_xfm.h5"
223
+ ),
224
+ "src": "native",
225
+ "dst": "MNI152NLin2009cAsym",
226
+ "warper": "ants",
227
+ },
228
+ ],
216
229
  }
217
230
  )
218
231
  # Set default types
@@ -234,7 +247,7 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber):
234
247
  confounds_format="fmriprep",
235
248
  )
236
249
 
237
- def get_item(self, subject: str, task: str) -> Dict:
250
+ def get_item(self, subject: str, task: str) -> dict:
238
251
  """Index one element in the dataset.
239
252
 
240
253
  Parameters
@@ -266,7 +279,7 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber):
266
279
 
267
280
  return super().get_item(subject=subject, task=new_task)
268
281
 
269
- def get_elements(self) -> List:
282
+ def get_elements(self) -> list:
270
283
  """Implement fetching list of subjects in the dataset.
271
284
 
272
285
  Returns
@@ -9,7 +9,7 @@
9
9
 
10
10
  from itertools import product
11
11
  from pathlib import Path
12
- from typing import Dict, List, Union
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, List[str], None] = None,
54
- tasks: Union[str, List[str], None] = None,
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
@@ -202,15 +202,28 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
202
202
  "space": "native",
203
203
  },
204
204
  },
205
- "Warp": {
206
- "pattern": (
207
- "derivatives/fmriprep/{subject}/anat/"
208
- "{subject}_from-MNI152NLin2009cAsym_to-T1w_"
209
- "mode-image_xfm.h5"
210
- ),
211
- "src": "MNI152NLin2009cAsym",
212
- "dst": "native",
213
- },
205
+ "Warp": [
206
+ {
207
+ "pattern": (
208
+ "derivatives/fmriprep/{subject}/anat/"
209
+ "{subject}_from-MNI152NLin2009cAsym_to-T1w_"
210
+ "mode-image_xfm.h5"
211
+ ),
212
+ "src": "MNI152NLin2009cAsym",
213
+ "dst": "native",
214
+ "warper": "ants",
215
+ },
216
+ {
217
+ "pattern": (
218
+ "derivatives/fmriprep/{subject}/anat/"
219
+ "{subject}_from-T1w_to-MNI152NLin2009cAsym_"
220
+ "mode-image_xfm.h5"
221
+ ),
222
+ "src": "native",
223
+ "dst": "MNI152NLin2009cAsym",
224
+ "warper": "ants",
225
+ },
226
+ ],
214
227
  }
215
228
  )
216
229
  # Set default types
@@ -232,7 +245,7 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
232
245
  confounds_format="fmriprep",
233
246
  )
234
247
 
235
- def get_elements(self) -> List:
248
+ def get_elements(self) -> list:
236
249
  """Implement fetching list of elements in the dataset.
237
250
 
238
251
  Returns
@@ -248,7 +261,7 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
248
261
  elems.append((subject, task))
249
262
  return elems
250
263
 
251
- def get_item(self, subject: str, task: str) -> Dict:
264
+ def get_item(self, subject: str, task: str) -> dict:
252
265
  """Index one element in the dataset.
253
266
 
254
267
  Parameters
@@ -7,7 +7,7 @@
7
7
  # Synchon Mandal <s.mandal@fz-juelich.de>
8
8
  # License: AGPL
9
9
 
10
- from typing import List, Optional, Union
10
+ from typing import Optional, Union
11
11
 
12
12
  import pytest
13
13
 
@@ -31,7 +31,7 @@ URI = "https://gin.g-node.org/juaml/datalad-example-aomic1000"
31
31
  )
32
32
  def test_DataladAOMICID1000(
33
33
  type_: str,
34
- nested_types: Optional[List[str]],
34
+ nested_types: Optional[list[str]],
35
35
  ) -> None:
36
36
  """Test DataladAOMICID1000 DataGrabber.
37
37
 
@@ -87,7 +87,7 @@ def test_DataladAOMICID1000(
87
87
  ],
88
88
  )
89
89
  def test_DataladAOMICID1000_partial_data_access(
90
- types: Union[str, List[str]],
90
+ types: Union[str, list[str]],
91
91
  ) -> None:
92
92
  """Test DataladAOMICID1000 DataGrabber partial data access.
93
93
 
@@ -7,7 +7,7 @@
7
7
  # Synchon Mandal <s.mandal@fz-juelich.de>
8
8
  # License: AGPL
9
9
 
10
- from typing import List, Optional, Union
10
+ from typing import Optional, Union
11
11
 
12
12
  import pytest
13
13
 
@@ -40,8 +40,8 @@ URI = "https://gin.g-node.org/juaml/datalad-example-aomicpiop1"
40
40
  )
41
41
  def test_DataladAOMICPIOP1(
42
42
  type_: str,
43
- nested_types: Optional[List[str]],
44
- tasks: Optional[List[str]],
43
+ nested_types: Optional[list[str]],
44
+ tasks: Optional[list[str]],
45
45
  ) -> None:
46
46
  """Test DataladAOMICPIOP1 DataGrabber.
47
47
 
@@ -117,7 +117,7 @@ def test_DataladAOMICPIOP1(
117
117
  ],
118
118
  )
119
119
  def test_DataladAOMICPIOP1_partial_data_access(
120
- types: Union[str, List[str]],
120
+ types: Union[str, list[str]],
121
121
  ) -> None:
122
122
  """Test DataladAOMICPIOP1 DataGrabber partial data access.
123
123