junifer 0.0.6.dev358__py3-none-any.whl → 0.0.6.dev366__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.6.dev358'
16
- __version_tuple__ = version_tuple = (0, 0, 6, 'dev358')
15
+ __version__ = version = '0.0.6.dev366'
16
+ __version_tuple__ = version_tuple = (0, 0, 6, 'dev366')
@@ -14,8 +14,8 @@ from typing import (
14
14
  )
15
15
 
16
16
  import nibabel as nib
17
+ import nilearn.image as nimg
17
18
  import numpy as np
18
- from nilearn.image import get_data, new_img_like, resample_to_img
19
19
  from nilearn.masking import (
20
20
  compute_background_mask,
21
21
  compute_epi_mask,
@@ -168,14 +168,14 @@ def compute_brain_mask(
168
168
  )
169
169
  # Resample template to target image
170
170
  else:
171
- resampled_template = resample_to_img(
171
+ resampled_template = nimg.resample_to_img(
172
172
  source_img=template, target_img=target_data["data"]
173
173
  )
174
174
 
175
175
  # Threshold resampled template and get mask
176
- mask = (get_data(resampled_template) >= threshold).astype("int8")
176
+ mask = (nimg.get_data(resampled_template) >= threshold).astype("int8")
177
177
 
178
- return new_img_like(target_data["data"], mask) # type: ignore
178
+ return nimg.new_img_like(target_data["data"], mask) # type: ignore
179
179
 
180
180
 
181
181
  class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
@@ -523,7 +523,7 @@ class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
523
523
  )
524
524
  logger.debug("Resampling inherited mask to target image.")
525
525
  # Resample inherited mask to target image
526
- mask_img = resample_to_img(
526
+ mask_img = nimg.resample_to_img(
527
527
  source_img=mask_img,
528
528
  target_img=target_data["data"],
529
529
  )
@@ -568,34 +568,41 @@ class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
568
568
  "mask."
569
569
  )
570
570
 
571
+ # Set here to simplify things later
572
+ mask_img: nib.nifti1.Nifti1Image = mask_object
573
+
571
574
  # Resample and warp mask to standard space
572
575
  if mask_space != target_std_space:
573
576
  logger.debug(
574
577
  f"Warping {t_mask} to {target_std_space} space "
575
- "using ants."
578
+ "using ANTs."
576
579
  )
577
580
  mask_img = ANTsMaskWarper().warp(
578
581
  mask_name=mask_name,
579
- mask_img=mask_object,
582
+ mask_img=mask_img,
580
583
  src=mask_space,
581
584
  dst=target_std_space,
582
585
  target_data=target_data,
583
586
  warp_data=warper_spec,
584
587
  )
588
+ # Remove extra dimension added by ANTs
589
+ mask_img = nimg.math_img(
590
+ "np.squeeze(img)", img=mask_img
591
+ )
585
592
 
586
- else:
587
- # Resample mask to target image; no further warping
593
+ if target_space != "native":
594
+ # No warping is going to happen, just resampling,
595
+ # because we are in the correct space
588
596
  logger.debug(f"Resampling {t_mask} to target image.")
589
- if target_space != "native":
590
- mask_img = resample_to_img(
591
- source_img=mask_object,
592
- target_img=target_data["data"],
593
- )
594
- # Set mask_img in case no warping happens before this
595
- else:
596
- mask_img = mask_object
597
- # Resample and warp mask if target data is native
598
- if target_space == "native":
597
+ mask_img = nimg.resample_to_img(
598
+ source_img=mask_img,
599
+ target_img=target_img,
600
+ )
601
+ else:
602
+ # Warp mask if target space is native as
603
+ # either the image is in the right non-native space or
604
+ # it's warped from one non-native space to another
605
+ # non-native space
599
606
  logger.debug(
600
607
  "Warping mask to native space using "
601
608
  f"{warper_spec['warper']}."
@@ -16,9 +16,10 @@ from typing import TYPE_CHECKING, Any, Optional, Union
16
16
 
17
17
  import httpx
18
18
  import nibabel as nib
19
+ import nilearn.image as nimg
19
20
  import numpy as np
20
21
  import pandas as pd
21
- from nilearn import datasets, image
22
+ from nilearn import datasets
22
23
 
23
24
  from ...utils import logger, raise_error, warn_with_log
24
25
  from ...utils.singleton import Singleton
@@ -470,28 +471,23 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
470
471
  warp_data=None,
471
472
  )
472
473
  # Remove extra dimension added by ANTs
473
- img = image.math_img("np.squeeze(img)", img=raw_img)
474
- # Set correct affine as resolution won't be correct
475
- img = image.resample_img(
476
- img=img,
477
- target_affine=target_img.affine,
474
+ img = nimg.math_img("np.squeeze(img)", img=raw_img)
475
+
476
+ if target_space != "native":
477
+ # No warping is going to happen, just resampling, because
478
+ # we are in the correct space
479
+ logger.debug(f"Resampling {name} to target image.")
480
+ # Resample parcellation to target image
481
+ img = nimg.resample_to_img(
482
+ source_img=img,
483
+ target_img=target_img,
478
484
  interpolation="nearest",
485
+ copy=True,
479
486
  )
480
487
  else:
481
- if target_space != "native":
482
- # No warping is going to happen, just resampling, because
483
- # we are in the correct space
484
- logger.debug(f"Resampling {name} to target image.")
485
- # Resample parcellation to target image
486
- img = image.resample_to_img(
487
- source_img=img,
488
- target_img=target_img,
489
- interpolation="nearest",
490
- copy=True,
491
- )
492
-
493
- # Warp parcellation if target space is native
494
- if target_space == "native":
488
+ # Warp parcellation if target space is native as either
489
+ # the image is in the right non-native space or it's
490
+ # warped from one non-native space to another non-native space
495
491
  logger.debug(
496
492
  "Warping parcellation to native space using "
497
493
  f"{warper_spec['warper']}."
@@ -1807,7 +1803,7 @@ def merge_parcellations(
1807
1803
  "The parcellations have different resolutions!"
1808
1804
  "Resampling all parcellations to the first one in the list."
1809
1805
  )
1810
- t_parc = image.resample_to_img(
1806
+ t_parc = nimg.resample_to_img(
1811
1807
  t_parc, ref_parc, interpolation="nearest", copy=True
1812
1808
  )
1813
1809
 
@@ -1833,6 +1829,6 @@ def merge_parcellations(
1833
1829
  "parcellation that was first in the list."
1834
1830
  )
1835
1831
 
1836
- parcellation_img_res = image.new_img_like(parcellations_list[0], parc_data)
1832
+ parcellation_img_res = nimg.new_img_like(parcellations_list[0], parc_data)
1837
1833
 
1838
1834
  return parcellation_img_res, labels
@@ -86,10 +86,6 @@ def test_ReHoParcels(caplog: pytest.LogCaptureFixture, tmp_path: Path) -> None:
86
86
  @pytest.mark.skipif(
87
87
  _check_afni() is False, reason="requires AFNI to be in PATH"
88
88
  )
89
- @pytest.mark.xfail(
90
- reason="junifer ReHo needs to use the correct mask",
91
- raises=AssertionError,
92
- )
93
89
  def test_ReHoParcels_comparison(tmp_path: Path) -> None:
94
90
  """Test ReHoParcels implementation comparison.
95
91
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: junifer
3
- Version: 0.0.6.dev358
3
+ Version: 0.0.6.dev366
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>
@@ -1,6 +1,6 @@
1
1
  junifer/__init__.py,sha256=2McgH1yNue6Z1V26-uN_mfMjbTcx4CLhym-DMBl5xA4,266
2
2
  junifer/__init__.pyi,sha256=SsTvgq2Dod6UqJN96GH1lCphH6hJQQurEJHGNhHjGUI,508
3
- junifer/_version.py,sha256=FgjmOt5uZU0g8aIkualgel30oxeUJfjpBfbQcVNHwH8,428
3
+ junifer/_version.py,sha256=t-3cRoRiLKJo00UFpf7tn_vToC9PLS2rVeH50rEhEGs,428
4
4
  junifer/conftest.py,sha256=PWYkkRDU8ly2lYwv7VBKMHje4et6HX7Yey3Md_I2KbA,613
5
5
  junifer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  junifer/stats.py,sha256=e9aaagMGtgpRfW3Wdpz9ocpnYld1IWylCDcjFUgX9Mk,6225
@@ -106,7 +106,7 @@ junifer/data/masks/__init__.py,sha256=eEEhHglyVEx1LrqwXjq3cOmjf4sTsgBstRx5-k7zIQ
106
106
  junifer/data/masks/__init__.pyi,sha256=lcgr8gmWDPibC4RxnWBXb8DDpIkO73Aax09u6VXiJJI,114
107
107
  junifer/data/masks/_ants_mask_warper.py,sha256=Mwgc2_ZMf28vS_-fviRvZnHyT7JoQ1cQLozo7nUZSyM,5350
108
108
  junifer/data/masks/_fsl_mask_warper.py,sha256=VApp-ofGBKePNmCdgTg1HoEA66lMQiAPT0ihkhB2ezY,2415
109
- junifer/data/masks/_masks.py,sha256=8w-J-ZBKuik99gk9tYHntbmanpx_Mbu9oUujzxO7y1w,25874
109
+ junifer/data/masks/_masks.py,sha256=ZJ5kmZQCL854k0gwXQhsWnWVI2hzdDnz2O6kIe2Ih2A,26194
110
110
  junifer/data/masks/tests/test_masks.py,sha256=W0bzRB5Bp-iGO44VtEmaf7BuT-joe_2tQI0lma5NQHA,16090
111
111
  junifer/data/masks/ukb/UKB_15K_GM_template.nii.gz,sha256=jcX1pDOrDsoph8cPMNFVKH5gZYio5G4rJNpOFXm9wJI,946636
112
112
  junifer/data/masks/vickery-patil/CAT12_IXI555_MNI152_TMP_GS_GMprob0.2_clean.nii.gz,sha256=j6EY8EtRnUuRxeKgD65Q6B0GPEPIALKDJEIje1TfnAU,88270
@@ -116,7 +116,7 @@ junifer/data/parcellations/__init__.py,sha256=6-Ysil3NyZ69V6rWx4RO15_d-iDKizfbHu
116
116
  junifer/data/parcellations/__init__.pyi,sha256=lhBHTbMDizzqUqVHrx2eyfPFodrTBgMFeTgxfESSkQ8,140
117
117
  junifer/data/parcellations/_ants_parcellation_warper.py,sha256=YUCJC0_wutGw7j_n9JRU3LCwm9Ttg5PIlJUgqejfRhs,5806
118
118
  junifer/data/parcellations/_fsl_parcellation_warper.py,sha256=JfJ022flg5OR48P4OAALVHHQgTVxdMBXT-fAqBl3nUM,2679
119
- junifer/data/parcellations/_parcellations.py,sha256=9azcYRBjwGuwZvKdFJj34BWPcCblxe2Ps8obbyl58k8,67179
119
+ junifer/data/parcellations/_parcellations.py,sha256=JUUglL0ZM_UKL5jTG1q-3x6Fd3CUO6Hl4YAGAUsGtmI,67019
120
120
  junifer/data/parcellations/tests/test_parcellations.py,sha256=ESQI-KWsepmgKB2BWWWUxjkpjOWeIZhhlKxNuTsRPJg,39268
121
121
  junifer/data/tests/test_data_utils.py,sha256=136iGPjGecCxyqgUwU8VZMHoE6imcYJ0WNC32PDGK4g,1063
122
122
  junifer/data/tests/test_template_spaces.py,sha256=ZEicEcLqOJ-NpuBZ5SYh4yZ0xZRkhYHnYXiC_YSxjrY,3219
@@ -239,7 +239,7 @@ junifer/markers/reho/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
239
239
  junifer/markers/reho/reho_base.py,sha256=Q88TbhIM4rQWdeQPLwwxwZ9DrR8l09orD1rdTkSYDtc,4077
240
240
  junifer/markers/reho/reho_parcels.py,sha256=UE1ia3uqbmTcZMc_FI625xVPLxBYvwpfrcvhekopbkI,6392
241
241
  junifer/markers/reho/reho_spheres.py,sha256=FCC2qncC85Kd82hg-MOu4T7NAKEkXHUaCcwC9taau9Y,6996
242
- junifer/markers/reho/tests/test_reho_parcels.py,sha256=dek2TMxMZ04o5s_06ZudZihDer55dAIFUhFexWQAH18,4181
242
+ junifer/markers/reho/tests/test_reho_parcels.py,sha256=bRtDi91qRcRYaRqqQjuSU6NuNz-KwLVCoTYo-e5VmsI,4075
243
243
  junifer/markers/reho/tests/test_reho_spheres.py,sha256=VyyQ3hhD6ArFc1BmigmAdePACB1EMQlo1mDr2QKvT2I,3989
244
244
  junifer/markers/temporal_snr/__init__.py,sha256=86hNMyaSfWlWOXZ6m9reSDtMIgUaByOXjcxCvo7LmDw,235
245
245
  junifer/markers/temporal_snr/__init__.pyi,sha256=20FhG9ZkAHQfmJ0r5p6fRMxhK8xrFQeFr0cgTrqu3ik,162
@@ -341,10 +341,10 @@ junifer/utils/tests/test_config.py,sha256=7ltIXuwb_W4Mv_1dxQWyiyM10XgUAfsWKV6D_i
341
341
  junifer/utils/tests/test_fs.py,sha256=WQS7cKlKEZ742CIuiOYYpueeAhY9PqlastfDVpVVtvE,923
342
342
  junifer/utils/tests/test_helpers.py,sha256=k5qqfxK8dFyuewTJyR1Qn6-nFaYNuVr0ysc18bfPjyU,929
343
343
  junifer/utils/tests/test_logging.py,sha256=duO4ou365hxwa_kwihFtKPLaL6LC5XHiyhOijrrngbA,8009
344
- junifer-0.0.6.dev358.dist-info/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
345
- junifer-0.0.6.dev358.dist-info/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
346
- junifer-0.0.6.dev358.dist-info/METADATA,sha256=aw963eFey-7fsO__-qenMulbVlYGZ6vnMJl7sDRhjDY,8429
347
- junifer-0.0.6.dev358.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
348
- junifer-0.0.6.dev358.dist-info/entry_points.txt,sha256=6O8ru0BP-SP7YMUZiizFNoaZ2HvJpadO2G7nKk4PwjI,48
349
- junifer-0.0.6.dev358.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
350
- junifer-0.0.6.dev358.dist-info/RECORD,,
344
+ junifer-0.0.6.dev366.dist-info/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
345
+ junifer-0.0.6.dev366.dist-info/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
346
+ junifer-0.0.6.dev366.dist-info/METADATA,sha256=1bnN5jpKnbFsIC94NMUL1xwIOpl-LhdAYQmDFrKNa3g,8429
347
+ junifer-0.0.6.dev366.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
348
+ junifer-0.0.6.dev366.dist-info/entry_points.txt,sha256=6O8ru0BP-SP7YMUZiizFNoaZ2HvJpadO2G7nKk4PwjI,48
349
+ junifer-0.0.6.dev366.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
350
+ junifer-0.0.6.dev366.dist-info/RECORD,,