junifer 0.0.6.dev371__py3-none-any.whl → 0.0.6.dev379__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 +2 -2
- junifer/data/masks/_ants_mask_warper.py +22 -1
- junifer/data/masks/_fsl_mask_warper.py +22 -1
- junifer/data/masks/_masks.py +27 -4
- {junifer-0.0.6.dev371.dist-info → junifer-0.0.6.dev379.dist-info}/METADATA +1 -1
- {junifer-0.0.6.dev371.dist-info → junifer-0.0.6.dev379.dist-info}/RECORD +11 -11
- {junifer-0.0.6.dev371.dist-info → junifer-0.0.6.dev379.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.6.dev371.dist-info → junifer-0.0.6.dev379.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.6.dev371.dist-info → junifer-0.0.6.dev379.dist-info}/WHEEL +0 -0
- {junifer-0.0.6.dev371.dist-info → junifer-0.0.6.dev379.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.6.dev371.dist-info → junifer-0.0.6.dev379.dist-info}/top_level.txt +0 -0
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.
|
16
|
-
__version_tuple__ = version_tuple = (0, 0, 6, '
|
15
|
+
__version__ = version = '0.0.6.dev379'
|
16
|
+
__version_tuple__ = version_tuple = (0, 0, 6, 'dev379')
|
@@ -7,6 +7,7 @@ import uuid
|
|
7
7
|
from typing import TYPE_CHECKING, Any, Optional
|
8
8
|
|
9
9
|
import nibabel as nib
|
10
|
+
import numpy as np
|
10
11
|
|
11
12
|
from ...pipeline import WorkDirManager
|
12
13
|
from ...utils import logger, raise_error, run_ext_cmd
|
@@ -20,6 +21,26 @@ if TYPE_CHECKING:
|
|
20
21
|
__all__ = ["ANTsMaskWarper"]
|
21
22
|
|
22
23
|
|
24
|
+
def _get_interpolation_method(img: "Nifti1Image") -> str:
|
25
|
+
"""Get correct interpolation method for `img`.
|
26
|
+
|
27
|
+
Parameters
|
28
|
+
----------
|
29
|
+
img : nibabel.nifti1.Nifti1Image
|
30
|
+
The image.
|
31
|
+
|
32
|
+
Returns
|
33
|
+
-------
|
34
|
+
str
|
35
|
+
The interpolation method.
|
36
|
+
|
37
|
+
"""
|
38
|
+
if np.array_equal(np.unique(img.get_fdata()), [0, 1]):
|
39
|
+
return "'GenericLabel[NearestNeighbor]'"
|
40
|
+
else:
|
41
|
+
return "LanczosWindowedSinc"
|
42
|
+
|
43
|
+
|
23
44
|
class ANTsMaskWarper:
|
24
45
|
"""Class for mask space warping via ANTs.
|
25
46
|
|
@@ -143,7 +164,7 @@ class ANTsMaskWarper:
|
|
143
164
|
"antsApplyTransforms",
|
144
165
|
"-d 3",
|
145
166
|
"-e 3",
|
146
|
-
"-n
|
167
|
+
f"-n {_get_interpolation_method(mask_img)}",
|
147
168
|
f"-i {prewarp_mask_path.resolve()}",
|
148
169
|
f"-r {template_space_img_path.resolve()}",
|
149
170
|
f"-t {xfm_file_path.resolve()}",
|
@@ -7,6 +7,7 @@ import uuid
|
|
7
7
|
from typing import TYPE_CHECKING, Any
|
8
8
|
|
9
9
|
import nibabel as nib
|
10
|
+
import numpy as np
|
10
11
|
|
11
12
|
from ...pipeline import WorkDirManager
|
12
13
|
from ...utils import logger, run_ext_cmd
|
@@ -19,6 +20,26 @@ if TYPE_CHECKING:
|
|
19
20
|
__all__ = ["FSLMaskWarper"]
|
20
21
|
|
21
22
|
|
23
|
+
def _get_interpolation_method(img: "Nifti1Image") -> str:
|
24
|
+
"""Get correct interpolation method for `img`.
|
25
|
+
|
26
|
+
Parameters
|
27
|
+
----------
|
28
|
+
img : nibabel.nifti1.Nifti1Image
|
29
|
+
The image.
|
30
|
+
|
31
|
+
Returns
|
32
|
+
-------
|
33
|
+
str
|
34
|
+
The interpolation method.
|
35
|
+
|
36
|
+
"""
|
37
|
+
if np.array_equal(np.unique(img.get_fdata()), [0, 1]):
|
38
|
+
return "nn"
|
39
|
+
else:
|
40
|
+
return "spline"
|
41
|
+
|
42
|
+
|
22
43
|
class FSLMaskWarper:
|
23
44
|
"""Class for mask space warping via FSL FLIRT.
|
24
45
|
|
@@ -71,7 +92,7 @@ class FSLMaskWarper:
|
|
71
92
|
# Set applywarp command
|
72
93
|
applywarp_cmd = [
|
73
94
|
"applywarp",
|
74
|
-
"--interp=
|
95
|
+
f"--interp={_get_interpolation_method(mask_img)}",
|
75
96
|
f"-i {prewarp_mask_path.resolve()}",
|
76
97
|
# use resampled reference
|
77
98
|
f"-r {target_data['reference']['path'].resolve()}",
|
junifer/data/masks/_masks.py
CHANGED
@@ -184,14 +184,14 @@ def compute_brain_mask(
|
|
184
184
|
if target_data["space"] == "native" and template_space != "native":
|
185
185
|
if warp_data["warper"] == "fsl":
|
186
186
|
resampled_template = FSLMaskWarper().warp(
|
187
|
-
mask_name=
|
187
|
+
mask_name=mask_name,
|
188
188
|
mask_img=template,
|
189
189
|
target_data=target_data,
|
190
190
|
warp_data=warp_data,
|
191
191
|
)
|
192
192
|
elif warp_data["warper"] == "ants":
|
193
193
|
resampled_template = ANTsMaskWarper().warp(
|
194
|
-
mask_name=
|
194
|
+
mask_name=mask_name,
|
195
195
|
# use template here
|
196
196
|
mask_img=template,
|
197
197
|
src=target_std_space,
|
@@ -199,11 +199,12 @@ def compute_brain_mask(
|
|
199
199
|
target_data=target_data,
|
200
200
|
warp_data=warp_data,
|
201
201
|
)
|
202
|
-
# Resample template to target image
|
203
202
|
else:
|
204
203
|
# Resample template to target image
|
205
204
|
resampled_template = nimg.resample_to_img(
|
206
|
-
source_img=template,
|
205
|
+
source_img=template,
|
206
|
+
target_img=target_data["data"],
|
207
|
+
interpolation=_get_interpolation_method(template),
|
207
208
|
)
|
208
209
|
|
209
210
|
# Threshold resampled template and get mask
|
@@ -561,6 +562,7 @@ class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
561
562
|
mask_img = nimg.resample_to_img(
|
562
563
|
source_img=mask_img,
|
563
564
|
target_img=target_data["data"],
|
565
|
+
interpolation=_get_interpolation_method(mask_img),
|
564
566
|
)
|
565
567
|
# Starting with new mask
|
566
568
|
else:
|
@@ -632,6 +634,7 @@ class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
632
634
|
mask_img = nimg.resample_to_img(
|
633
635
|
source_img=mask_img,
|
634
636
|
target_img=target_img,
|
637
|
+
interpolation=_get_interpolation_method(mask_img),
|
635
638
|
)
|
636
639
|
else:
|
637
640
|
# Warp mask if target space is native as
|
@@ -761,3 +764,23 @@ def _load_ukb_mask(name: str) -> Path:
|
|
761
764
|
mask_fname = _masks_path / "ukb" / mask_fname
|
762
765
|
|
763
766
|
return mask_fname
|
767
|
+
|
768
|
+
|
769
|
+
def _get_interpolation_method(img: "Nifti1Image") -> str:
|
770
|
+
"""Get correct interpolation method for `img`.
|
771
|
+
|
772
|
+
Parameters
|
773
|
+
----------
|
774
|
+
img : nibabel.nifti1.Nifti1Image
|
775
|
+
The image.
|
776
|
+
|
777
|
+
Returns
|
778
|
+
-------
|
779
|
+
str
|
780
|
+
The interpolation method.
|
781
|
+
|
782
|
+
"""
|
783
|
+
if np.array_equal(np.unique(img.get_fdata()), [0, 1]):
|
784
|
+
return "nearest"
|
785
|
+
else:
|
786
|
+
return "continuous"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: junifer
|
3
|
-
Version: 0.0.6.
|
3
|
+
Version: 0.0.6.dev379
|
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=
|
3
|
+
junifer/_version.py,sha256=HhdN9ExDOk5GQptlKq1vXbTLsjl26fTtCOnfJ-HdlBE,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
|
@@ -104,9 +104,9 @@ junifer/data/coordinates/VOIs/meta/extDMN_VOIs.txt,sha256=Ogx1QvqZcnXDM3ncF2ha78
|
|
104
104
|
junifer/data/coordinates/tests/test_coordinates.py,sha256=_c2P4oaDGpsmui5gJBe_jN6HLGiKxONkYPR69sRBUlU,4219
|
105
105
|
junifer/data/masks/__init__.py,sha256=eEEhHglyVEx1LrqwXjq3cOmjf4sTsgBstRx5-k7zIQU,180
|
106
106
|
junifer/data/masks/__init__.pyi,sha256=lcgr8gmWDPibC4RxnWBXb8DDpIkO73Aax09u6VXiJJI,114
|
107
|
-
junifer/data/masks/_ants_mask_warper.py,sha256=
|
108
|
-
junifer/data/masks/_fsl_mask_warper.py,sha256=
|
109
|
-
junifer/data/masks/_masks.py,sha256=
|
107
|
+
junifer/data/masks/_ants_mask_warper.py,sha256=JLK2Jh2AOAiv_NoUGhRoTBEhRFXPRXTDPmQGH9vBSok,5805
|
108
|
+
junifer/data/masks/_fsl_mask_warper.py,sha256=YZOMlRgQ7_4shnXNc_05tmwDk5xHI-1wqle-RdNsJ34,2857
|
109
|
+
junifer/data/masks/_masks.py,sha256=K-A1cr9TAeVzFPGgn4FUmwIo6LBP0xQb1Q4NW6WTWVo,28166
|
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
|
@@ -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.
|
345
|
-
junifer-0.0.6.
|
346
|
-
junifer-0.0.6.
|
347
|
-
junifer-0.0.6.
|
348
|
-
junifer-0.0.6.
|
349
|
-
junifer-0.0.6.
|
350
|
-
junifer-0.0.6.
|
344
|
+
junifer-0.0.6.dev379.dist-info/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
|
345
|
+
junifer-0.0.6.dev379.dist-info/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
|
346
|
+
junifer-0.0.6.dev379.dist-info/METADATA,sha256=uDj1UT_o42FUimuI7VbBLM_eNYP_S8OcMFnWeR_AWbY,8429
|
347
|
+
junifer-0.0.6.dev379.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
348
|
+
junifer-0.0.6.dev379.dist-info/entry_points.txt,sha256=6O8ru0BP-SP7YMUZiizFNoaZ2HvJpadO2G7nKk4PwjI,48
|
349
|
+
junifer-0.0.6.dev379.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
|
350
|
+
junifer-0.0.6.dev379.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|