junifer 0.0.4.dev477__py3-none-any.whl → 0.0.4.dev493__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
junifer/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.0.4.dev477'
16
- __version_tuple__ = version_tuple = (0, 0, 4, 'dev477')
15
+ __version__ = version = '0.0.4.dev493'
16
+ __version_tuple__ = version_tuple = (0, 0, 4, 'dev493')
@@ -35,6 +35,7 @@ def test_get_dependency_information_short() -> None:
35
35
  assert list(dependency_information.keys()) == [
36
36
  "click",
37
37
  "numpy",
38
+ "scipy",
38
39
  "datalad",
39
40
  "pandas",
40
41
  "nibabel",
@@ -51,6 +52,7 @@ def test_get_dependency_information_long() -> None:
51
52
  for key in [
52
53
  "click",
53
54
  "numpy",
55
+ "scipy",
54
56
  "datalad",
55
57
  "pandas",
56
58
  "nibabel",
junifer/data/masks.py CHANGED
@@ -280,12 +280,16 @@ def get_mask( # noqa: C901
280
280
  f"because the item ({inherited_mask_item}) does not exist."
281
281
  )
282
282
  mask_img = extra_input[inherited_mask_item]["data"]
283
+ mask_space = target_data["space"]
283
284
  # Starting with new mask
284
285
  else:
285
286
  # Load mask
286
287
  mask_object, _, mask_space = load_mask(
287
288
  mask_name, path_only=False, resolution=resolution
288
289
  )
290
+ # Replace mask space with target space if mask's space is inherit
291
+ if mask_space == "inherit":
292
+ mask_space = target_data["space"]
289
293
  # If mask is callable like from nilearn
290
294
  if callable(mask_object):
291
295
  if mask_params is None:
@@ -306,20 +310,22 @@ def get_mask( # noqa: C901
306
310
  interpolation="nearest",
307
311
  copy=True,
308
312
  )
309
- all_spaces.append(mask_space)
313
+ all_spaces.append(mask_space)
310
314
  all_masks.append(mask_img)
311
315
 
312
316
  # Multiple masks, need intersection / union
313
317
  if len(all_masks) > 1:
314
- # Filter out "inherit" and make a set for spaces
315
- filtered_spaces = set(filter(lambda x: x != "inherit", all_spaces))
318
+ # Make a set of unique spaces
319
+ unique_spaces = set(all_spaces)
316
320
  # Intersect / union of masks only if all masks are in the same space
317
- if len(filtered_spaces) == 1:
321
+ if len(unique_spaces) == 1:
318
322
  mask_img = intersect_masks(all_masks, **intersect_params)
323
+ # Store the mask space for further checks
324
+ mask_space = next(iter(unique_spaces))
319
325
  else:
320
326
  raise_error(
321
327
  msg=(
322
- f"Masks are in different spaces: {filtered_spaces}, "
328
+ f"Masks are in different spaces: {unique_spaces}, "
323
329
  "unable to merge."
324
330
  ),
325
331
  klass=RuntimeError,
@@ -333,9 +339,10 @@ def get_mask( # noqa: C901
333
339
  "when there is only one mask."
334
340
  )
335
341
  mask_img = all_masks[0]
342
+ mask_space = all_spaces[0]
336
343
 
337
- # Warp mask if target data is native
338
- if target_data["space"] == "native":
344
+ # Warp mask if target data is native and mask space is not native
345
+ if target_data["space"] == "native" and target_data["space"] != mask_space:
339
346
  # Check for extra inputs
340
347
  if extra_input is None:
341
348
  raise_error(
@@ -392,7 +392,9 @@ def test_get_mask_inherit() -> None:
392
392
 
393
393
  # Now get the mask using the inherit functionality, passing the
394
394
  # computed mask as extra data
395
- extra_input = {"BOLD_MASK": {"data": gm_mask}}
395
+ extra_input = {
396
+ "BOLD_MASK": {"data": gm_mask, "space": input["BOLD"]["space"]}
397
+ }
396
398
  input["BOLD"]["mask_item"] = "BOLD_MASK"
397
399
  mask2 = get_mask(
398
400
  masks="inherit", target_data=input["BOLD"], extra_input=extra_input
@@ -405,11 +407,9 @@ def test_get_mask_inherit() -> None:
405
407
  @pytest.mark.parametrize(
406
408
  "masks,params",
407
409
  [
408
- (["GM_prob0.2", "compute_brain_mask"], {}),
409
- (
410
- ["GM_prob0.2", "compute_brain_mask"],
411
- {"threshold": 0.2},
412
- ),
410
+ (["GM_prob0.2", "GM_prob0.2_cortex"], {}),
411
+ (["compute_brain_mask", "compute_background_mask"], {}),
412
+ (["compute_brain_mask", "compute_epi_mask"], {}),
413
413
  ],
414
414
  )
415
415
  def test_get_mask_multiple(
@@ -574,7 +574,10 @@ class fMRIPrepConfoundRemover(BasePreprocessor):
574
574
  # this allows to use "inherit" down the pipeline
575
575
  if extra_input is not None:
576
576
  logger.debug("Setting mask_item")
577
- extra_input["BOLD_mask"] = {"data": mask_img}
577
+ extra_input["BOLD_mask"] = {
578
+ "data": mask_img,
579
+ "space": input["space"],
580
+ }
578
581
  input["mask_item"] = "BOLD_mask"
579
582
 
580
583
  logger.info("Cleaning image")
junifer/stats.py CHANGED
@@ -7,7 +7,7 @@
7
7
  from typing import Any, Callable, Dict, List, Optional
8
8
 
9
9
  import numpy as np
10
- from scipy.stats import trim_mean
10
+ from scipy.stats import mode, trim_mean
11
11
  from scipy.stats.mstats import winsorize
12
12
 
13
13
  from .utils import logger, raise_error
@@ -24,10 +24,11 @@ def get_aggfunc_by_name(
24
24
  Name to identify the function. Currently supported names and
25
25
  corresponding functions are:
26
26
 
27
- * ``winsorized_mean`` -> :func:`scipy.stats.mstats.winsorize`
28
27
  * ``mean`` -> :func:`numpy.mean`
29
- * ``std`` -> :func:`numpy.std`
28
+ * ``winsorized_mean`` -> :func:`scipy.stats.mstats.winsorize`
30
29
  * ``trim_mean`` -> :func:`scipy.stats.trim_mean`
30
+ * ``mode`` -> :func:`scipy.stats.mode`
31
+ * ``std`` -> :func:`numpy.std`
31
32
  * ``count`` -> :func:`.count`
32
33
  * ``select`` -> :func:`.select`
33
34
 
@@ -40,6 +41,7 @@ def get_aggfunc_by_name(
40
41
  -------
41
42
  function
42
43
  Respective function with ``func_params`` parameter set.
44
+
43
45
  """
44
46
  from functools import partial # local import to avoid sphinx error
45
47
 
@@ -51,6 +53,7 @@ def get_aggfunc_by_name(
51
53
  "trim_mean",
52
54
  "count",
53
55
  "select",
56
+ "mode",
54
57
  }
55
58
  if func_params is None:
56
59
  func_params = {}
@@ -93,6 +96,8 @@ def get_aggfunc_by_name(
93
96
  elif pick is not None and drop is not None:
94
97
  raise_error("Either pick or drop must be specified, not both.")
95
98
  func = partial(select, **func_params)
99
+ elif name == "mode":
100
+ func = partial(mode, **func_params)
96
101
  else:
97
102
  raise_error(
98
103
  f"Function {name} unknown. Please provide any of "
@@ -115,6 +120,7 @@ def count(data: np.ndarray, axis: int = 0) -> np.ndarray:
115
120
  -------
116
121
  numpy.ndarray
117
122
  Number of elements along the given axis.
123
+
118
124
  """
119
125
  ax_size = data.shape[axis]
120
126
  if axis < 0:
@@ -137,7 +143,7 @@ def winsorized_mean(
137
143
  The axis to calculate winsorized mean on (default None).
138
144
  **win_params : dict
139
145
  Dictionary containing the keyword arguments for the winsorize function.
140
- E.g. ``{'limits': [0.1, 0.1]}``.
146
+ E.g., ``{'limits': [0.1, 0.1]}``.
141
147
 
142
148
  Returns
143
149
  -------
@@ -149,6 +155,7 @@ def winsorized_mean(
149
155
  --------
150
156
  scipy.stats.mstats.winsorize :
151
157
  The winsorize function used in this function.
158
+
152
159
  """
153
160
  win_dat = winsorize(data, axis=axis, **win_params)
154
161
  win_mean = win_dat.mean(axis=axis)
@@ -180,6 +187,13 @@ def select(
180
187
  numpy.ndarray
181
188
  Subset of the inputted data with the select settings
182
189
  applied as specified in ``select_params``.
190
+
191
+ Raises
192
+ ------
193
+ ValueError
194
+ If both ``pick`` and ``drop`` are None or
195
+ if both ``pick`` and ``drop`` are not None.
196
+
183
197
  """
184
198
 
185
199
  if pick is None and drop is None:
@@ -21,6 +21,8 @@ from junifer.stats import count, get_aggfunc_by_name, select, winsorized_mean
21
21
  ("count", None),
22
22
  ("trim_mean", None),
23
23
  ("trim_mean", {"proportiontocut": 0.1}),
24
+ ("mode", None),
25
+ ("mode", {"keepdims": True}),
24
26
  ],
25
27
  )
26
28
  def test_get_aggfunc_by_name(name: str, params: Optional[Dict]) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: junifer
3
- Version: 0.0.4.dev477
3
+ Version: 0.0.4.dev493
4
4
  Summary: JUelich NeuroImaging FEature extractoR
5
5
  Author-email: Fede Raimondo <f.raimondo@fz-juelich.de>, Synchon Mandal <s.mandal@fz-juelich.de>
6
6
  Maintainer-email: Fede Raimondo <f.raimondo@fz-juelich.de>, Synchon Mandal <s.mandal@fz-juelich.de>
@@ -28,6 +28,7 @@ License-File: LICENSE.md
28
28
  License-File: AUTHORS.rst
29
29
  Requires-Dist: click <8.2,>=8.1.3
30
30
  Requires-Dist: numpy <1.27,>=1.24
31
+ Requires-Dist: scipy <=1.11.4,>=1.9.0
31
32
  Requires-Dist: datalad <0.20,>=0.15.4
32
33
  Requires-Dist: pandas <2.2,>=1.4.0
33
34
  Requires-Dist: nibabel <5.11,>=3.2.0
@@ -1,6 +1,6 @@
1
1
  junifer/__init__.py,sha256=x1UR2jUcrUdm2HNl-3Qvyi4UUrU6ms5qm2qcmNY7zZk,391
2
- junifer/_version.py,sha256=M4X3STs52HWvFyMwLZ_m-ldav_VVRF4lDp3N_LiwSn8,428
3
- junifer/stats.py,sha256=KUX4jJcLWnlE34coet8EkdFypFd-td4Vtpx5LvlomVs,5879
2
+ junifer/_version.py,sha256=s3b4obIT6-Dm0gw7Hf_6VelPhsN39hihLhhrnI_A6sU,428
3
+ junifer/stats.py,sha256=sU5IZ2qFZWbzgSutQS_z42miIVItpSGmQYBn6KkD5fA,6162
4
4
  junifer/api/__init__.py,sha256=YILu9M7SC0Ri4CVd90fELH2OnK_gvCYAXCoqBNCFE8E,257
5
5
  junifer/api/cli.py,sha256=xScav2mF-Jr8JjVFt8kaHuLpX5l_jVTaQGPgQL3VNvA,12881
6
6
  junifer/api/decorators.py,sha256=8bnwHPAe7VgzKxl--M_e0umdAlTVSzaJQHEJZ5kof5k,2580
@@ -21,7 +21,7 @@ junifer/api/res/fsl/flirt,sha256=tSjiUco8ui8AbHD7mTzChEwbR0Rf_4iJTgzYTPF_WuQ,42
21
21
  junifer/api/res/fsl/img2imgcoord,sha256=Zmaw3oJYrEltcXiPyEubXry9ppAq3SND52tdDWGgeZk,49
22
22
  junifer/api/res/fsl/run_fsl_docker.sh,sha256=mRLtZo0OgDwleoee2MG6rYI37HVuGNk9zOADwcl97RA,1122
23
23
  junifer/api/res/fsl/std2imgcoord,sha256=-X5wRH6XMl0yqnTACJX6MFhO8DFOEWg42MHRxGvimXg,49
24
- junifer/api/tests/test_api_utils.py,sha256=_ykEECJN0qTEBcJ2YSvOAQrRN-xmEilRLPyirC5cO_o,2285
24
+ junifer/api/tests/test_api_utils.py,sha256=dexkg5U8JSo3wEU6EUIWnPNuVzHxRMXH1o2sBchMEu0,2319
25
25
  junifer/api/tests/test_cli.py,sha256=qKWkAf-A1DeDwCtrOaCrQ5bmuUYcLWeRbGk2K95OMHQ,5717
26
26
  junifer/api/tests/test_functions.py,sha256=0XHxCC7-jfVqV7m-R-eGiEwZPjEoBzdS0zperVIyNow,24659
27
27
  junifer/api/tests/test_parser.py,sha256=eUz2JPVb0_cxvoeI1O_C5PMNs5v_lDzGsN6fV1VW5Eg,6109
@@ -42,7 +42,7 @@ junifer/configs/juseless/datagrabbers/tests/test_ucla.py,sha256=e-jdvcZ9B0mka6_5
42
42
  junifer/configs/juseless/datagrabbers/tests/test_ukb_vbm.py,sha256=b9hjc1mgO--PSRC3id2EzzfE2yWNsuZ2UI47a6sfGZU,1025
43
43
  junifer/data/__init__.py,sha256=oUjOs8_M6fitNb44izxpXf3su1e4pG_vCdjwVYkjZjQ,550
44
44
  junifer/data/coordinates.py,sha256=rwjPb6hYlCpxqM73UNatl7bLtXEF9o8nIEwXz1iwERE,11317
45
- junifer/data/masks.py,sha256=chWSl-vyv5Nsd9GuQzydXPOY3AdhApOJq_42NSKpykQ,16952
45
+ junifer/data/masks.py,sha256=gsA8_1l011uq2E0hRZvQvfk3_ER8HFsmWd3h6o5qPxE,17311
46
46
  junifer/data/parcellations.py,sha256=wL8lkAYYvg7NDt160EA8N_xFjK8ZtDwoXYJQHNHwbDU,55805
47
47
  junifer/data/utils.py,sha256=K9quLIoWRmm2QFM8Rdy_5bYsWb_XhL0l5Uq_1Sie0kA,1274
48
48
  junifer/data/VOIs/meta/CogAC_VOIs.txt,sha256=Sr5_E712OLdeQRyUcDNM0wLBvZIyO6gc9Q7KkyJHX1A,398
@@ -68,7 +68,7 @@ junifer/data/masks/vickery-patil/CAT12_IXI555_MNI152_TMP_GS_GMprob0.2_clean_3mm.
68
68
  junifer/data/masks/vickery-patil/GMprob0.2_cortex_3mm_NA_rm.nii.gz,sha256=jfMe_4H9XEnArYms5bSQbqS2V1_HbLHTfI5amQa_Pes,8700
69
69
  junifer/data/tests/test_coordinates.py,sha256=BNkz9qFbnwAI0oVlIm_XrT-z4Vsia_rMtMVaoFXT6mU,4328
70
70
  junifer/data/tests/test_data_utils.py,sha256=Vy7x8zaHws5hmn92PKSv3H38hU2kamOpyaH6nG_NNpw,1086
71
- junifer/data/tests/test_masks.py,sha256=njo6yEzrBYDsojm6_7xGV3B8FvjmjK3zX3WBBYAs7aA,14496
71
+ junifer/data/tests/test_masks.py,sha256=Q_iMNktcxweRzoe5esFTpYgjt1pwPqIJk1Gqk0pb5GE,14570
72
72
  junifer/data/tests/test_parcellations.py,sha256=3Tk0bU4xT9TJfdrDWcUMq6ns-IPJUpZzkiR-PEbmM6M,36212
73
73
  junifer/datagrabber/__init__.py,sha256=pZHJIY8nAlbVngsyRScE6a6GKbytiwjJB7SdJNqIbl4,680
74
74
  junifer/datagrabber/base.py,sha256=clErdDX5jz8LTjwPTQPCv3jfELCJ2vObg7ks8imAx8Y,6224
@@ -192,7 +192,7 @@ junifer/preprocess/__init__.py,sha256=-3exohZnw-gJ-MjVM63WcXzBW1mbSetEVozcDfs5et
192
192
  junifer/preprocess/base.py,sha256=syiNqI8pUjoGyShZSjs_RTsd5VHhwoqzIfPfFstr4f4,6230
193
193
  junifer/preprocess/bold_warper.py,sha256=Sia8mCdluYNrFkYsRx0vP-z_RNF7x-dwHcEDkmpvnHo,3277
194
194
  junifer/preprocess/confounds/__init__.py,sha256=EDlcD9jy8O9xluJr6XOnFXtjGCDVqwg6sDIRDMbM8ZU,235
195
- junifer/preprocess/confounds/fmriprep_confound_remover.py,sha256=C6P00Ge5j5vxu7HSz4OXFML2aQAQseGXM45fXl-vTbs,21820
195
+ junifer/preprocess/confounds/fmriprep_confound_remover.py,sha256=23UJ6miqX0iE3dUMsZ1hzWoJDnMLl6WMlT-k9GFmAAU,21904
196
196
  junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py,sha256=OKACXAHytNrOAFZ5I2UcyfcYz5s2qeu31MZ9K71rWGc,22167
197
197
  junifer/preprocess/fsl/__init__.py,sha256=DerGFQ-dIuX5PT9a_BH6QkIXkJZVymjYy-woXF7tYGc,111
198
198
  junifer/preprocess/fsl/apply_warper.py,sha256=QTls4z2oF0qVqZ_S1yc-uYNUE9MeJZR4Lesv98SnJrc,7915
@@ -220,16 +220,16 @@ junifer/testing/tests/test_partlycloudytesting_datagrabber.py,sha256=1VY71RhGtLD
220
220
  junifer/testing/tests/test_spmauditory_datagrabber.py,sha256=1G1emk-Ze59HiNLaYsyIz5O1YGW9darcqlzvhE-J_Mc,919
221
221
  junifer/testing/tests/test_testing_registry.py,sha256=oerticBaPRaRZm3yANzInLac0Mqph3Y0aZPQFayu7xA,827
222
222
  junifer/tests/test_main.py,sha256=GMff7jlisGM9_FsiUwWDte43j-KQJGFRYZpwRRqTkd8,373
223
- junifer/tests/test_stats.py,sha256=u3bLjbshzc5fV207tLM79rR5vHDvNhdN7ZoYI1UTI04,4093
223
+ junifer/tests/test_stats.py,sha256=3vPMgYYpWxk8ECDFOMm3-dFBlh4XxjL83SwRBSBAHok,4155
224
224
  junifer/utils/__init__.py,sha256=ZDPU9ezSKawAJhb-3T67jDf-16QEyF6e7ONyu-lnBtQ,277
225
225
  junifer/utils/fs.py,sha256=Jd9AoV2fIF7pT7KhXsn8T1O1fJ1_SFZgaFuOBAM7DG8,460
226
226
  junifer/utils/logging.py,sha256=4kH8j9X_J2bMdnBJMldVF95C5sURa5UAsLmSgRaD9Ig,9117
227
227
  junifer/utils/tests/test_fs.py,sha256=WQS7cKlKEZ742CIuiOYYpueeAhY9PqlastfDVpVVtvE,923
228
228
  junifer/utils/tests/test_logging.py,sha256=l8oo-AiBV7H6_IzlsNcj__cLeZBUvgIGoaMszD9VaJg,7754
229
- junifer-0.0.4.dev477.dist-info/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
230
- junifer-0.0.4.dev477.dist-info/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
231
- junifer-0.0.4.dev477.dist-info/METADATA,sha256=rRpLolV-SBGOl-4ktutkDrIhIpWnB9fjsFS55rS66QM,7707
232
- junifer-0.0.4.dev477.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
233
- junifer-0.0.4.dev477.dist-info/entry_points.txt,sha256=DxFvKq0pOqRunAK0FxwJcoDfV1-dZvsFDpD5HRqSDhw,48
234
- junifer-0.0.4.dev477.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
235
- junifer-0.0.4.dev477.dist-info/RECORD,,
229
+ junifer-0.0.4.dev493.dist-info/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
230
+ junifer-0.0.4.dev493.dist-info/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
231
+ junifer-0.0.4.dev493.dist-info/METADATA,sha256=_3K04VVuQxUyuIslgoc7stjFrg9UP2yAychS_LN6gtY,7745
232
+ junifer-0.0.4.dev493.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
233
+ junifer-0.0.4.dev493.dist-info/entry_points.txt,sha256=DxFvKq0pOqRunAK0FxwJcoDfV1-dZvsFDpD5HRqSDhw,48
234
+ junifer-0.0.4.dev493.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
235
+ junifer-0.0.4.dev493.dist-info/RECORD,,