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.
Files changed (198) hide show
  1. junifer/__init__.py +0 -17
  2. junifer/_version.py +2 -2
  3. junifer/api/__init__.py +1 -4
  4. junifer/api/cli.py +1 -91
  5. junifer/api/decorators.py +0 -9
  6. junifer/api/functions.py +10 -56
  7. junifer/api/parser.py +0 -3
  8. junifer/api/queue_context/__init__.py +1 -4
  9. junifer/api/res/afni/run_afni_docker.sh +1 -1
  10. junifer/api/res/ants/run_ants_docker.sh +1 -1
  11. junifer/api/res/fsl/run_fsl_docker.sh +1 -1
  12. junifer/api/tests/test_api_utils.py +2 -4
  13. junifer/api/tests/test_cli.py +0 -83
  14. junifer/api/tests/test_functions.py +2 -27
  15. junifer/configs/__init__.py +1 -1
  16. junifer/configs/juseless/__init__.py +1 -4
  17. junifer/configs/juseless/datagrabbers/__init__.py +1 -10
  18. junifer/configs/juseless/datagrabbers/aomic_id1000_vbm.py +0 -3
  19. junifer/configs/juseless/datagrabbers/camcan_vbm.py +0 -3
  20. junifer/configs/juseless/datagrabbers/ixi_vbm.py +0 -3
  21. junifer/configs/juseless/datagrabbers/tests/test_ucla.py +3 -1
  22. junifer/configs/juseless/datagrabbers/ucla.py +9 -12
  23. junifer/configs/juseless/datagrabbers/ukb_vbm.py +0 -3
  24. junifer/data/__init__.py +1 -21
  25. junifer/data/coordinates.py +19 -10
  26. junifer/data/masks.py +87 -58
  27. junifer/data/parcellations.py +3 -14
  28. junifer/data/template_spaces.py +1 -4
  29. junifer/data/tests/test_masks.py +37 -26
  30. junifer/data/utils.py +0 -3
  31. junifer/datagrabber/__init__.py +1 -18
  32. junifer/datagrabber/aomic/__init__.py +0 -3
  33. junifer/datagrabber/aomic/id1000.py +37 -70
  34. junifer/datagrabber/aomic/piop1.py +36 -69
  35. junifer/datagrabber/aomic/piop2.py +38 -71
  36. junifer/datagrabber/aomic/tests/test_id1000.py +99 -44
  37. junifer/datagrabber/aomic/tests/test_piop1.py +108 -65
  38. junifer/datagrabber/aomic/tests/test_piop2.py +102 -45
  39. junifer/datagrabber/base.py +6 -13
  40. junifer/datagrabber/datalad_base.py +1 -13
  41. junifer/datagrabber/dmcc13_benchmark.py +53 -36
  42. junifer/datagrabber/hcp1200/__init__.py +0 -3
  43. junifer/datagrabber/hcp1200/datalad_hcp1200.py +0 -3
  44. junifer/datagrabber/hcp1200/hcp1200.py +1 -4
  45. junifer/datagrabber/multiple.py +6 -45
  46. junifer/datagrabber/pattern.py +62 -170
  47. junifer/datagrabber/pattern_datalad.py +12 -25
  48. junifer/datagrabber/tests/test_datagrabber_utils.py +218 -0
  49. junifer/datagrabber/tests/test_datalad_base.py +4 -4
  50. junifer/datagrabber/tests/test_dmcc13_benchmark.py +19 -46
  51. junifer/datagrabber/tests/test_multiple.py +84 -161
  52. junifer/datagrabber/tests/test_pattern.py +0 -45
  53. junifer/datagrabber/tests/test_pattern_datalad.py +4 -4
  54. junifer/datagrabber/utils.py +230 -0
  55. junifer/datareader/__init__.py +1 -4
  56. junifer/datareader/default.py +43 -95
  57. junifer/external/__init__.py +1 -1
  58. junifer/external/nilearn/__init__.py +1 -5
  59. junifer/external/nilearn/junifer_nifti_spheres_masker.py +9 -23
  60. junifer/external/nilearn/tests/test_junifer_nifti_spheres_masker.py +1 -76
  61. junifer/markers/__init__.py +1 -23
  62. junifer/markers/base.py +28 -68
  63. junifer/markers/collection.py +2 -10
  64. junifer/markers/complexity/__init__.py +0 -10
  65. junifer/markers/complexity/complexity_base.py +43 -26
  66. junifer/markers/complexity/hurst_exponent.py +0 -3
  67. junifer/markers/complexity/multiscale_entropy_auc.py +0 -3
  68. junifer/markers/complexity/perm_entropy.py +0 -3
  69. junifer/markers/complexity/range_entropy.py +0 -3
  70. junifer/markers/complexity/range_entropy_auc.py +0 -3
  71. junifer/markers/complexity/sample_entropy.py +0 -3
  72. junifer/markers/complexity/tests/test_hurst_exponent.py +3 -11
  73. junifer/markers/complexity/tests/test_multiscale_entropy_auc.py +3 -11
  74. junifer/markers/complexity/tests/test_perm_entropy.py +3 -11
  75. junifer/markers/complexity/tests/test_range_entropy.py +3 -11
  76. junifer/markers/complexity/tests/test_range_entropy_auc.py +3 -11
  77. junifer/markers/complexity/tests/test_sample_entropy.py +3 -11
  78. junifer/markers/complexity/tests/test_weighted_perm_entropy.py +3 -11
  79. junifer/markers/complexity/weighted_perm_entropy.py +0 -3
  80. junifer/markers/ets_rss.py +42 -27
  81. junifer/markers/falff/__init__.py +0 -3
  82. junifer/markers/falff/_afni_falff.py +2 -5
  83. junifer/markers/falff/_junifer_falff.py +0 -3
  84. junifer/markers/falff/falff_base.py +46 -20
  85. junifer/markers/falff/falff_parcels.py +27 -56
  86. junifer/markers/falff/falff_spheres.py +29 -60
  87. junifer/markers/falff/tests/test_falff_parcels.py +23 -39
  88. junifer/markers/falff/tests/test_falff_spheres.py +23 -39
  89. junifer/markers/functional_connectivity/__init__.py +0 -9
  90. junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +60 -63
  91. junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +32 -45
  92. junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +36 -49
  93. junifer/markers/functional_connectivity/functional_connectivity_base.py +70 -71
  94. junifer/markers/functional_connectivity/functional_connectivity_parcels.py +25 -34
  95. junifer/markers/functional_connectivity/functional_connectivity_spheres.py +30 -40
  96. junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py +7 -11
  97. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +7 -27
  98. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +12 -28
  99. junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +11 -35
  100. junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +62 -36
  101. junifer/markers/parcel_aggregation.py +61 -47
  102. junifer/markers/reho/__init__.py +0 -3
  103. junifer/markers/reho/_afni_reho.py +2 -5
  104. junifer/markers/reho/_junifer_reho.py +1 -4
  105. junifer/markers/reho/reho_base.py +27 -8
  106. junifer/markers/reho/reho_parcels.py +17 -28
  107. junifer/markers/reho/reho_spheres.py +18 -27
  108. junifer/markers/reho/tests/test_reho_parcels.py +3 -8
  109. junifer/markers/reho/tests/test_reho_spheres.py +3 -8
  110. junifer/markers/sphere_aggregation.py +59 -43
  111. junifer/markers/temporal_snr/__init__.py +0 -3
  112. junifer/markers/temporal_snr/temporal_snr_base.py +32 -23
  113. junifer/markers/temporal_snr/temporal_snr_parcels.py +6 -9
  114. junifer/markers/temporal_snr/temporal_snr_spheres.py +6 -9
  115. junifer/markers/temporal_snr/tests/test_temporal_snr_parcels.py +3 -6
  116. junifer/markers/temporal_snr/tests/test_temporal_snr_spheres.py +3 -6
  117. junifer/markers/tests/test_collection.py +8 -9
  118. junifer/markers/tests/test_ets_rss.py +9 -15
  119. junifer/markers/tests/test_markers_base.py +18 -17
  120. junifer/markers/tests/test_parcel_aggregation.py +32 -93
  121. junifer/markers/tests/test_sphere_aggregation.py +19 -72
  122. junifer/onthefly/__init__.py +1 -4
  123. junifer/onthefly/read_transform.py +0 -3
  124. junifer/pipeline/__init__.py +1 -9
  125. junifer/pipeline/pipeline_step_mixin.py +4 -21
  126. junifer/pipeline/registry.py +0 -3
  127. junifer/pipeline/singleton.py +0 -3
  128. junifer/pipeline/tests/test_registry.py +1 -1
  129. junifer/pipeline/update_meta_mixin.py +0 -3
  130. junifer/pipeline/utils.py +1 -67
  131. junifer/pipeline/workdir_manager.py +0 -3
  132. junifer/preprocess/__init__.py +2 -10
  133. junifer/preprocess/ants/__init__.py +4 -0
  134. junifer/preprocess/ants/ants_apply_transforms_warper.py +185 -0
  135. junifer/preprocess/ants/tests/test_ants_apply_transforms_warper.py +56 -0
  136. junifer/preprocess/base.py +3 -6
  137. junifer/preprocess/bold_warper.py +265 -0
  138. junifer/preprocess/confounds/__init__.py +0 -3
  139. junifer/preprocess/confounds/fmriprep_confound_remover.py +60 -47
  140. junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py +113 -72
  141. junifer/preprocess/fsl/__init__.py +4 -0
  142. junifer/preprocess/fsl/apply_warper.py +179 -0
  143. junifer/preprocess/fsl/tests/test_apply_warper.py +45 -0
  144. junifer/preprocess/tests/test_bold_warper.py +159 -0
  145. junifer/preprocess/warping/__init__.py +0 -3
  146. junifer/preprocess/warping/_ants_warper.py +0 -3
  147. junifer/preprocess/warping/_fsl_warper.py +0 -3
  148. junifer/stats.py +1 -4
  149. junifer/storage/__init__.py +1 -9
  150. junifer/storage/base.py +1 -40
  151. junifer/storage/hdf5.py +9 -71
  152. junifer/storage/pandas_base.py +0 -3
  153. junifer/storage/sqlite.py +0 -3
  154. junifer/storage/tests/test_hdf5.py +10 -82
  155. junifer/storage/utils.py +0 -9
  156. junifer/testing/__init__.py +1 -4
  157. junifer/testing/datagrabbers.py +6 -13
  158. junifer/testing/tests/test_partlycloudytesting_datagrabber.py +7 -7
  159. junifer/testing/utils.py +0 -3
  160. junifer/utils/__init__.py +2 -13
  161. junifer/utils/fs.py +0 -3
  162. junifer/utils/helpers.py +1 -32
  163. junifer/utils/logging.py +4 -33
  164. junifer/utils/tests/test_logging.py +0 -8
  165. {junifer-0.0.5.dist-info → junifer-0.0.5.dev11.dist-info}/METADATA +16 -17
  166. junifer-0.0.5.dev11.dist-info/RECORD +259 -0
  167. {junifer-0.0.5.dist-info → junifer-0.0.5.dev11.dist-info}/WHEEL +1 -1
  168. junifer/api/res/freesurfer/mri_binarize +0 -3
  169. junifer/api/res/freesurfer/mri_mc +0 -3
  170. junifer/api/res/freesurfer/mri_pretess +0 -3
  171. junifer/api/res/freesurfer/mris_convert +0 -3
  172. junifer/api/res/freesurfer/run_freesurfer_docker.sh +0 -61
  173. junifer/data/masks/ukb/UKB_15K_GM_template.nii.gz +0 -0
  174. junifer/datagrabber/pattern_validation_mixin.py +0 -388
  175. junifer/datagrabber/tests/test_pattern_validation_mixin.py +0 -249
  176. junifer/external/BrainPrint/brainprint/__init__.py +0 -4
  177. junifer/external/BrainPrint/brainprint/_version.py +0 -3
  178. junifer/external/BrainPrint/brainprint/asymmetry.py +0 -91
  179. junifer/external/BrainPrint/brainprint/brainprint.py +0 -441
  180. junifer/external/BrainPrint/brainprint/surfaces.py +0 -258
  181. junifer/external/BrainPrint/brainprint/utils/__init__.py +0 -1
  182. junifer/external/BrainPrint/brainprint/utils/_config.py +0 -112
  183. junifer/external/BrainPrint/brainprint/utils/utils.py +0 -188
  184. junifer/external/nilearn/junifer_connectivity_measure.py +0 -483
  185. junifer/external/nilearn/tests/test_junifer_connectivity_measure.py +0 -1089
  186. junifer/markers/brainprint.py +0 -459
  187. junifer/markers/tests/test_brainprint.py +0 -58
  188. junifer/preprocess/smoothing/__init__.py +0 -9
  189. junifer/preprocess/smoothing/_afni_smoothing.py +0 -119
  190. junifer/preprocess/smoothing/_fsl_smoothing.py +0 -116
  191. junifer/preprocess/smoothing/_nilearn_smoothing.py +0 -69
  192. junifer/preprocess/smoothing/smoothing.py +0 -174
  193. junifer/preprocess/smoothing/tests/test_smoothing.py +0 -94
  194. junifer-0.0.5.dist-info/RECORD +0 -275
  195. {junifer-0.0.5.dist-info → junifer-0.0.5.dev11.dist-info}/AUTHORS.rst +0 -0
  196. {junifer-0.0.5.dist-info → junifer-0.0.5.dev11.dist-info}/LICENSE.md +0 -0
  197. {junifer-0.0.5.dist-info → junifer-0.0.5.dev11.dist-info}/entry_points.txt +0 -0
  198. {junifer-0.0.5.dist-info → junifer-0.0.5.dev11.dist-info}/top_level.txt +0 -0
@@ -1,116 +0,0 @@
1
- """Provide class for smoothing via FSL."""
2
-
3
- # Authors: Synchon Mandal <s.mandal@fz-juelich.de>
4
- # License: AGPL
5
-
6
- from typing import (
7
- TYPE_CHECKING,
8
- ClassVar,
9
- Dict,
10
- List,
11
- Set,
12
- Union,
13
- )
14
-
15
- import nibabel as nib
16
-
17
- from ...pipeline import WorkDirManager
18
- from ...utils import logger, run_ext_cmd
19
-
20
-
21
- if TYPE_CHECKING:
22
- from nibabel import Nifti1Image
23
-
24
-
25
- __all__ = ["FSLSmoothing"]
26
-
27
-
28
- class FSLSmoothing:
29
- """Class for smoothing via FSL.
30
-
31
- This class uses FSL's susan.
32
-
33
- """
34
-
35
- _EXT_DEPENDENCIES: ClassVar[List[Dict[str, Union[str, List[str]]]]] = [
36
- {
37
- "name": "fsl",
38
- "commands": ["susan"],
39
- },
40
- ]
41
-
42
- _DEPENDENCIES: ClassVar[Set[str]] = {"nibabel"}
43
-
44
- def preprocess(
45
- self,
46
- data: "Nifti1Image",
47
- brightness_threshold: float,
48
- fwhm: float,
49
- ) -> "Nifti1Image":
50
- """Preprocess using FSL.
51
-
52
- Parameters
53
- ----------
54
- data : Niimg-like object
55
- Image(s) to preprocess.
56
- brightness_threshold : float
57
- Threshold to discriminate between noise and the underlying image.
58
- The value should be set greater than the noise level and less than
59
- the contrast of the underlying image.
60
- fwhm : float
61
- Spatial extent of smoothing.
62
-
63
- Returns
64
- -------
65
- Niimg-like object
66
- The preprocessed image(s).
67
-
68
- Notes
69
- -----
70
- For more information on ``SUSAN``, check [1]_
71
-
72
- References
73
- ----------
74
- .. [1] Smith, S.M. and Brady, J.M. (1997).
75
- SUSAN - a new approach to low level image processing.
76
- International Journal of Computer Vision, Volume 23(1),
77
- Pages 45-78.
78
-
79
- """
80
- logger.info("Smoothing using FSL")
81
-
82
- # Create component-scoped tempdir
83
- tempdir = WorkDirManager().get_tempdir(prefix="fsl_smoothing")
84
-
85
- # Save target data to a component-scoped tempfile
86
- nifti_in_file_path = tempdir / "input.nii.gz"
87
- nib.save(data, nifti_in_file_path)
88
-
89
- # Create element-scoped tempdir so that the output is
90
- # available later as nibabel stores file path reference for
91
- # loading on computation
92
- element_tempdir = WorkDirManager().get_element_tempdir(
93
- prefix="fsl_susan"
94
- )
95
- susan_out_path = element_tempdir / "output.nii.gz"
96
- # Set susan command
97
- susan_cmd = [
98
- "susan",
99
- f"{nifti_in_file_path.resolve()}",
100
- f"{brightness_threshold}",
101
- f"{fwhm}",
102
- "3", # dimension
103
- "1", # use median when no neighbourhood is found
104
- "0", # use input image to find USAN
105
- f"{susan_out_path.resolve()}",
106
- ]
107
- # Call susan
108
- run_ext_cmd(name="susan", cmd=susan_cmd)
109
-
110
- # Load nifti
111
- output_data = nib.load(susan_out_path)
112
-
113
- # Delete tempdir
114
- WorkDirManager().delete_tempdir(tempdir)
115
-
116
- return output_data # type: ignore
@@ -1,69 +0,0 @@
1
- """Provide class for smoothing via nilearn."""
2
-
3
- # Authors: Synchon Mandal <s.mandal@fz-juelich.de>
4
- # License: AGPL
5
-
6
- from typing import (
7
- TYPE_CHECKING,
8
- ClassVar,
9
- Literal,
10
- Set,
11
- Union,
12
- )
13
-
14
- from nilearn import image as nimg
15
- from numpy.typing import ArrayLike
16
-
17
- from ...utils import logger
18
-
19
-
20
- if TYPE_CHECKING:
21
- from nibabel import Nifti1Image
22
-
23
-
24
- __all__ = ["NilearnSmoothing"]
25
-
26
-
27
- class NilearnSmoothing:
28
- """Class for smoothing via nilearn.
29
-
30
- This class uses :func:`nilearn.image.smooth_img` to smooth image(s).
31
-
32
- """
33
-
34
- _DEPENDENCIES: ClassVar[Set[str]] = {"nilearn"}
35
-
36
- def preprocess(
37
- self,
38
- data: "Nifti1Image",
39
- fwhm: Union[int, float, ArrayLike, Literal["fast"], None],
40
- ) -> "Nifti1Image":
41
- """Preprocess using nilearn.
42
-
43
- Parameters
44
- ----------
45
- data : Niimg-like object
46
- Image(s) to preprocess.
47
- fwhm : scalar, ``numpy.ndarray``, tuple or list of scalar, "fast" or \
48
- None
49
- Smoothing strength, as a full-width at half maximum, in
50
- millimeters:
51
-
52
- * If nonzero scalar, width is identical in all 3 directions.
53
- * If ``numpy.ndarray``, tuple, or list, it must have 3 elements,
54
- giving the FWHM along each axis. If any of the elements is 0 or
55
- None, smoothing is not performed along that axis.
56
- * If ``"fast"``, a fast smoothing will be performed with a filter
57
- ``[0.2, 1, 0.2]`` in each direction and a normalisation to
58
- preserve the local average value.
59
- * If None, no filtering is performed (useful when just removal of
60
- non-finite values is needed).
61
-
62
- Returns
63
- -------
64
- Niimg-like object
65
- The preprocessed image(s).
66
-
67
- """
68
- logger.info("Smoothing using nilearn")
69
- return nimg.smooth_img(imgs=data, fwhm=fwhm) # type: ignore
@@ -1,174 +0,0 @@
1
- """Provide class for smoothing."""
2
-
3
- # Authors: Synchon Mandal <s.mandal@fz-juelich.de>
4
- # License: AGPL
5
-
6
- from typing import Any, ClassVar, Dict, List, Optional, Tuple, Type, Union
7
-
8
- from ...api.decorators import register_preprocessor
9
- from ...utils import logger, raise_error
10
- from ..base import BasePreprocessor
11
- from ._afni_smoothing import AFNISmoothing
12
- from ._fsl_smoothing import FSLSmoothing
13
- from ._nilearn_smoothing import NilearnSmoothing
14
-
15
-
16
- __all__ = ["Smoothing"]
17
-
18
-
19
- @register_preprocessor
20
- class Smoothing(BasePreprocessor):
21
- """Class for smoothing.
22
-
23
- Parameters
24
- ----------
25
- using : {"nilearn", "afni", "fsl"}
26
- Implementation to use for smoothing:
27
-
28
- * "nilearn" : Use :func:`nilearn.image.smooth_img`
29
- * "afni" : Use AFNI's ``3dBlurToFWHM``
30
- * "fsl" : Use FSL SUSAN's ``susan``
31
-
32
- on : {"T1w", "T2w", "BOLD"} or list of the options
33
- The data type to apply smoothing to.
34
- smoothing_params : dict, optional
35
- Extra parameters for smoothing as a dictionary (default None).
36
- If ``using="nilearn"``, then the valid keys are:
37
-
38
- * ``fmhw`` : scalar, ``numpy.ndarray``, tuple or list of scalar, \
39
- "fast" or None
40
- Smoothing strength, as a full-width at half maximum, in
41
- millimeters:
42
-
43
- - If nonzero scalar, width is identical in all 3 directions.
44
- - If ``numpy.ndarray``, tuple, or list, it must have 3 elements,
45
- giving the FWHM along each axis. If any of the elements is 0 or
46
- None, smoothing is not performed along that axis.
47
- - If ``"fast"``, a fast smoothing will be performed with a filter
48
- ``[0.2, 1, 0.2]`` in each direction and a normalisation to
49
- preserve the local average value.
50
- - If None, no filtering is performed (useful when just removal of
51
- non-finite values is needed).
52
-
53
- else if ``using="afni"``, then the valid keys are:
54
-
55
- * ``fwhm`` : int or float
56
- Smooth until the value. AFNI estimates the smoothing and then
57
- applies smoothing to reach ``fwhm``.
58
-
59
- else if ``using="fsl"``, then the valid keys are:
60
-
61
- * ``brightness_threshold`` : float
62
- Threshold to discriminate between noise and the underlying image.
63
- The value should be set greater than the noise level and less than
64
- the contrast of the underlying image.
65
- * ``fwhm`` : float
66
- Spatial extent of smoothing.
67
-
68
- """
69
-
70
- _CONDITIONAL_DEPENDENCIES: ClassVar[List[Dict[str, Union[str, Type]]]] = [
71
- {
72
- "using": "nilearn",
73
- "depends_on": NilearnSmoothing,
74
- },
75
- {
76
- "using": "afni",
77
- "depends_on": AFNISmoothing,
78
- },
79
- {
80
- "using": "fsl",
81
- "depends_on": FSLSmoothing,
82
- },
83
- ]
84
-
85
- def __init__(
86
- self,
87
- using: str,
88
- on: Union[List[str], str],
89
- smoothing_params: Optional[Dict] = None,
90
- ) -> None:
91
- """Initialize the class."""
92
- # Validate `using` parameter
93
- valid_using = [dep["using"] for dep in self._CONDITIONAL_DEPENDENCIES]
94
- if using not in valid_using:
95
- raise_error(
96
- f"Invalid value for `using`, should be one of: {valid_using}"
97
- )
98
- self.using = using
99
- self.smoothing_params = (
100
- smoothing_params if smoothing_params is not None else {}
101
- )
102
- super().__init__(on=on)
103
-
104
- def get_valid_inputs(self) -> List[str]:
105
- """Get valid data types for input.
106
-
107
- Returns
108
- -------
109
- list of str
110
- The list of data types that can be used as input for this
111
- preprocessor.
112
-
113
- """
114
- return ["T1w", "T2w", "BOLD"]
115
-
116
- def get_output_type(self, input_type: str) -> str:
117
- """Get output type.
118
-
119
- Parameters
120
- ----------
121
- input_type : str
122
- The data type input to the preprocessor.
123
-
124
- Returns
125
- -------
126
- str
127
- The data type output by the preprocessor.
128
-
129
- """
130
- # Does not add any new keys
131
- return input_type
132
-
133
- def preprocess(
134
- self,
135
- input: Dict[str, Any],
136
- extra_input: Optional[Dict[str, Any]] = None,
137
- ) -> Tuple[Dict[str, Any], Optional[Dict[str, Dict[str, Any]]]]:
138
- """Preprocess.
139
-
140
- Parameters
141
- ----------
142
- input : dict
143
- The input from the Junifer Data object.
144
- extra_input : dict, optional
145
- The other fields in the Junifer Data object.
146
-
147
- Returns
148
- -------
149
- dict
150
- The computed result as dictionary.
151
- None
152
- Extra "helper" data types as dictionary to add to the Junifer Data
153
- object.
154
-
155
- """
156
- logger.debug("Smoothing")
157
-
158
- # Conditional preprocessor
159
- if self.using == "nilearn":
160
- preprocessor = NilearnSmoothing()
161
- elif self.using == "afni":
162
- preprocessor = AFNISmoothing()
163
- elif self.using == "fsl":
164
- preprocessor = FSLSmoothing()
165
- # Smooth
166
- output = preprocessor.preprocess( # type: ignore
167
- data=input["data"],
168
- **self.smoothing_params,
169
- )
170
-
171
- # Modify target data
172
- input["data"] = output
173
-
174
- return input, None
@@ -1,94 +0,0 @@
1
- """Provide tests for Smoothing."""
2
-
3
- # Authors: Synchon Mandal <s.mandal@fz-juelich.de>
4
- # License: AGPL
5
-
6
-
7
- import pytest
8
-
9
- from junifer.datareader import DefaultDataReader
10
- from junifer.pipeline.utils import _check_afni, _check_fsl
11
- from junifer.preprocess import Smoothing
12
- from junifer.testing.datagrabbers import SPMAuditoryTestingDataGrabber
13
-
14
-
15
- @pytest.mark.parametrize(
16
- "data_type",
17
- ["T1w", "BOLD"],
18
- )
19
- def test_Smoothing_nilearn(data_type: str) -> None:
20
- """Test Smoothing using nilearn.
21
-
22
- Parameters
23
- ----------
24
- data_type : str
25
- The parametrized data type.
26
-
27
- """
28
- with SPMAuditoryTestingDataGrabber() as dg:
29
- # Read data
30
- element_data = DefaultDataReader().fit_transform(dg["sub001"])
31
- # Preprocess data
32
- output = Smoothing(
33
- using="nilearn",
34
- on=data_type,
35
- smoothing_params={"fwhm": "fast"},
36
- ).fit_transform(element_data)
37
-
38
- assert isinstance(output, dict)
39
-
40
-
41
- @pytest.mark.parametrize(
42
- "data_type",
43
- ["T1w", "BOLD"],
44
- )
45
- @pytest.mark.skipif(
46
- _check_afni() is False, reason="requires AFNI to be in PATH"
47
- )
48
- def test_Smoothing_afni(data_type: str) -> None:
49
- """Test Smoothing using AFNI.
50
-
51
- Parameters
52
- ----------
53
- data_type : str
54
- The parametrized data type.
55
-
56
- """
57
- with SPMAuditoryTestingDataGrabber() as dg:
58
- # Read data
59
- element_data = DefaultDataReader().fit_transform(dg["sub001"])
60
- # Preprocess data
61
- output = Smoothing(
62
- using="afni",
63
- on=data_type,
64
- smoothing_params={"fwhm": 3},
65
- ).fit_transform(element_data)
66
-
67
- assert isinstance(output, dict)
68
-
69
-
70
- @pytest.mark.parametrize(
71
- "data_type",
72
- ["T1w", "BOLD"],
73
- )
74
- @pytest.mark.skipif(_check_fsl() is False, reason="requires FSL to be in PATH")
75
- def test_Smoothing_fsl(data_type: str) -> None:
76
- """Test Smoothing using FSL.
77
-
78
- Parameters
79
- ----------
80
- data_type : str
81
- The parametrized data type.
82
-
83
- """
84
- with SPMAuditoryTestingDataGrabber() as dg:
85
- # Read data
86
- element_data = DefaultDataReader().fit_transform(dg["sub001"])
87
- # Preprocess data
88
- output = Smoothing(
89
- using="fsl",
90
- on=data_type,
91
- smoothing_params={"brightness_threshold": 10.0, "fwhm": 3.0},
92
- ).fit_transform(element_data)
93
-
94
- assert isinstance(output, dict)