junifer 0.0.6.dev311__py3-none-any.whl → 0.0.6.dev317__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/preprocess/confounds/fmriprep_confound_remover.py +35 -2
- junifer/preprocess/smoothing/_afni_smoothing.py +37 -35
- junifer/preprocess/smoothing/_fsl_smoothing.py +19 -26
- junifer/preprocess/smoothing/_nilearn_smoothing.py +33 -12
- junifer/preprocess/smoothing/smoothing.py +2 -5
- junifer/preprocess/warping/_ants_warper.py +111 -25
- junifer/preprocess/warping/_fsl_warper.py +51 -13
- {junifer-0.0.6.dev311.dist-info → junifer-0.0.6.dev317.dist-info}/METADATA +1 -1
- {junifer-0.0.6.dev311.dist-info → junifer-0.0.6.dev317.dist-info}/RECORD +15 -15
- {junifer-0.0.6.dev311.dist-info → junifer-0.0.6.dev317.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.6.dev311.dist-info → junifer-0.0.6.dev317.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.6.dev311.dist-info → junifer-0.0.6.dev317.dist-info}/WHEEL +0 -0
- {junifer-0.0.6.dev311.dist-info → junifer-0.0.6.dev317.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.6.dev311.dist-info → junifer-0.0.6.dev317.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.dev317'
|
16
|
+
__version_tuple__ = version_tuple = (0, 0, 6, 'dev317')
|
@@ -12,6 +12,7 @@ from typing import (
|
|
12
12
|
Union,
|
13
13
|
)
|
14
14
|
|
15
|
+
import nibabel as nib
|
15
16
|
import numpy as np
|
16
17
|
import pandas as pd
|
17
18
|
from nilearn import image as nimg
|
@@ -19,6 +20,7 @@ from nilearn._utils.niimg_conversions import check_niimg_4d
|
|
19
20
|
|
20
21
|
from ...api.decorators import register_preprocessor
|
21
22
|
from ...data import get_data
|
23
|
+
from ...pipeline import WorkDirManager
|
22
24
|
from ...typing import Dependencies
|
23
25
|
from ...utils import logger, raise_error
|
24
26
|
from ..base import BasePreprocessor
|
@@ -539,9 +541,17 @@ class fMRIPrepConfoundRemover(BasePreprocessor):
|
|
539
541
|
logger.info(
|
540
542
|
f"Read t_r from NIfTI header: {t_r}",
|
541
543
|
)
|
544
|
+
|
545
|
+
# Create element-specific tempdir for storing generated data
|
546
|
+
# and / or mask
|
547
|
+
element_tempdir = WorkDirManager().get_element_tempdir(
|
548
|
+
prefix="fmriprep_confound_remover"
|
549
|
+
)
|
550
|
+
|
542
551
|
# Set mask data
|
543
552
|
mask_img = None
|
544
553
|
if self.masks is not None:
|
554
|
+
# Generate mask
|
545
555
|
logger.debug(f"Masking with {self.masks}")
|
546
556
|
mask_img = get_data(
|
547
557
|
kind="mask",
|
@@ -549,13 +559,21 @@ class fMRIPrepConfoundRemover(BasePreprocessor):
|
|
549
559
|
target_data=input,
|
550
560
|
extra_input=extra_input,
|
551
561
|
)
|
552
|
-
#
|
562
|
+
# Save generated mask for use later
|
563
|
+
generated_mask_img_path = element_tempdir / "generated_mask.nii.gz"
|
564
|
+
nib.save(mask_img, generated_mask_img_path)
|
565
|
+
|
566
|
+
# Save BOLD mask and link it to the BOLD data type dict;
|
553
567
|
# this allows to use "inherit" down the pipeline
|
554
568
|
logger.debug("Setting `BOLD.mask`")
|
555
569
|
input.update(
|
556
570
|
{
|
557
571
|
"mask": {
|
572
|
+
# Update path to sync with "data"
|
573
|
+
"path": generated_mask_img_path,
|
574
|
+
# Update data
|
558
575
|
"data": mask_img,
|
576
|
+
# Should be in the same space as target data
|
559
577
|
"space": input["space"],
|
560
578
|
}
|
561
579
|
}
|
@@ -566,7 +584,9 @@ class fMRIPrepConfoundRemover(BasePreprocessor):
|
|
566
584
|
logger.debug(f"\tstandardize: {self.standardize}")
|
567
585
|
logger.debug(f"\tlow_pass: {self.low_pass}")
|
568
586
|
logger.debug(f"\thigh_pass: {self.high_pass}")
|
569
|
-
|
587
|
+
|
588
|
+
# Deconfound data
|
589
|
+
cleaned_img = nimg.clean_img(
|
570
590
|
imgs=bold_img,
|
571
591
|
detrend=self.detrend,
|
572
592
|
standardize=self.standardize,
|
@@ -576,5 +596,18 @@ class fMRIPrepConfoundRemover(BasePreprocessor):
|
|
576
596
|
t_r=t_r,
|
577
597
|
mask_img=mask_img,
|
578
598
|
)
|
599
|
+
# Save deconfounded data
|
600
|
+
deconfounded_img_path = element_tempdir / "deconfounded_data.nii.gz"
|
601
|
+
nib.save(cleaned_img, deconfounded_img_path)
|
602
|
+
|
603
|
+
logger.debug("Updating `BOLD`")
|
604
|
+
input.update(
|
605
|
+
{
|
606
|
+
# Update path to sync with "data"
|
607
|
+
"path": deconfounded_img_path,
|
608
|
+
# Update data
|
609
|
+
"data": cleaned_img,
|
610
|
+
}
|
611
|
+
)
|
579
612
|
|
580
613
|
return input, None
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# License: AGPL
|
5
5
|
|
6
6
|
from typing import (
|
7
|
-
|
7
|
+
Any,
|
8
8
|
ClassVar,
|
9
9
|
Union,
|
10
10
|
)
|
@@ -16,10 +16,6 @@ from ...typing import Dependencies, ExternalDependencies
|
|
16
16
|
from ...utils import logger, run_ext_cmd
|
17
17
|
|
18
18
|
|
19
|
-
if TYPE_CHECKING:
|
20
|
-
from nibabel.nifti1 import Nifti1Image
|
21
|
-
|
22
|
-
|
23
19
|
__all__ = ["AFNISmoothing"]
|
24
20
|
|
25
21
|
|
@@ -41,23 +37,23 @@ class AFNISmoothing:
|
|
41
37
|
|
42
38
|
def preprocess(
|
43
39
|
self,
|
44
|
-
|
40
|
+
input: dict[str, Any],
|
45
41
|
fwhm: Union[int, float],
|
46
|
-
) ->
|
42
|
+
) -> dict[str, Any]:
|
47
43
|
"""Preprocess using AFNI.
|
48
44
|
|
49
45
|
Parameters
|
50
46
|
----------
|
51
|
-
|
52
|
-
|
47
|
+
input : dict
|
48
|
+
A single input from the Junifer Data object in which to preprocess.
|
53
49
|
fwhm : int or float
|
54
50
|
Smooth until the value. AFNI estimates the smoothing and then
|
55
51
|
applies smoothing to reach ``fwhm``.
|
56
52
|
|
57
53
|
Returns
|
58
54
|
-------
|
59
|
-
|
60
|
-
The
|
55
|
+
dict
|
56
|
+
The ``input`` dictionary with updated values.
|
61
57
|
|
62
58
|
Notes
|
63
59
|
-----
|
@@ -71,18 +67,18 @@ class AFNISmoothing:
|
|
71
67
|
"""
|
72
68
|
logger.info("Smoothing using AFNI")
|
73
69
|
|
74
|
-
# Create
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
70
|
+
# Create element-scoped tempdir so that the output is
|
71
|
+
# available later as nibabel stores file path reference for
|
72
|
+
# loading on computation
|
73
|
+
element_tempdir = WorkDirManager().get_element_tempdir(
|
74
|
+
prefix="afni_smoothing"
|
75
|
+
)
|
80
76
|
|
81
77
|
# Set 3dBlurToFWHM command
|
82
|
-
blur_out_path_prefix =
|
78
|
+
blur_out_path_prefix = element_tempdir / "blur"
|
83
79
|
blur_cmd = [
|
84
80
|
"3dBlurToFWHM",
|
85
|
-
f"-input {
|
81
|
+
f"-input {input['path'].resolve()}",
|
86
82
|
f"-prefix {blur_out_path_prefix.resolve()}",
|
87
83
|
"-automask",
|
88
84
|
f"-FWHM {fwhm}",
|
@@ -90,28 +86,34 @@ class AFNISmoothing:
|
|
90
86
|
# Call 3dBlurToFWHM
|
91
87
|
run_ext_cmd(name="3dBlurToFWHM", cmd=blur_cmd)
|
92
88
|
|
93
|
-
#
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
89
|
+
# Read header to get output suffix
|
90
|
+
header = input["data"].header
|
91
|
+
sform_code = header.get_sform(coded=True)[1]
|
92
|
+
if sform_code == 4:
|
93
|
+
output_suffix = "tlrc"
|
94
|
+
else:
|
95
|
+
output_suffix = "orig"
|
96
|
+
|
99
97
|
# Convert afni to nifti
|
100
|
-
|
101
|
-
element_tempdir / "
|
98
|
+
blur_nifti_out_path = (
|
99
|
+
element_tempdir / "smoothed_data.nii" # needs to be .nii
|
102
100
|
)
|
103
101
|
convert_cmd = [
|
104
102
|
"3dAFNItoNIFTI",
|
105
|
-
f"-prefix {
|
106
|
-
f"{blur_out_path_prefix}+
|
103
|
+
f"-prefix {blur_nifti_out_path.resolve()}",
|
104
|
+
f"{blur_out_path_prefix}+{output_suffix}.BRIK",
|
107
105
|
]
|
108
106
|
# Call 3dAFNItoNIFTI
|
109
107
|
run_ext_cmd(name="3dAFNItoNIFTI", cmd=convert_cmd)
|
110
108
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
109
|
+
logger.debug("Updating smoothed data")
|
110
|
+
input.update(
|
111
|
+
{
|
112
|
+
# Update path to sync with "data"
|
113
|
+
"path": blur_nifti_out_path,
|
114
|
+
# Load nifti
|
115
|
+
"data": nib.load(blur_nifti_out_path),
|
116
|
+
}
|
117
|
+
)
|
116
118
|
|
117
|
-
return
|
119
|
+
return input
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# License: AGPL
|
5
5
|
|
6
6
|
from typing import (
|
7
|
-
|
7
|
+
Any,
|
8
8
|
ClassVar,
|
9
9
|
)
|
10
10
|
|
@@ -15,10 +15,6 @@ from ...typing import Dependencies, ExternalDependencies
|
|
15
15
|
from ...utils import logger, run_ext_cmd
|
16
16
|
|
17
17
|
|
18
|
-
if TYPE_CHECKING:
|
19
|
-
from nibabel.nifti1 import Nifti1Image
|
20
|
-
|
21
|
-
|
22
18
|
__all__ = ["FSLSmoothing"]
|
23
19
|
|
24
20
|
|
@@ -40,16 +36,16 @@ class FSLSmoothing:
|
|
40
36
|
|
41
37
|
def preprocess(
|
42
38
|
self,
|
43
|
-
|
39
|
+
input: dict[str, Any],
|
44
40
|
brightness_threshold: float,
|
45
41
|
fwhm: float,
|
46
|
-
) ->
|
42
|
+
) -> dict[str, Any]:
|
47
43
|
"""Preprocess using FSL.
|
48
44
|
|
49
45
|
Parameters
|
50
46
|
----------
|
51
|
-
|
52
|
-
|
47
|
+
input : dict
|
48
|
+
A single input from the Junifer Data object in which to preprocess.
|
53
49
|
brightness_threshold : float
|
54
50
|
Threshold to discriminate between noise and the underlying image.
|
55
51
|
The value should be set greater than the noise level and less than
|
@@ -59,8 +55,8 @@ class FSLSmoothing:
|
|
59
55
|
|
60
56
|
Returns
|
61
57
|
-------
|
62
|
-
|
63
|
-
The
|
58
|
+
dict
|
59
|
+
The ``input`` dictionary with updated values.
|
64
60
|
|
65
61
|
Notes
|
66
62
|
-----
|
@@ -76,24 +72,17 @@ class FSLSmoothing:
|
|
76
72
|
"""
|
77
73
|
logger.info("Smoothing using FSL")
|
78
74
|
|
79
|
-
# Create component-scoped tempdir
|
80
|
-
tempdir = WorkDirManager().get_tempdir(prefix="fsl_smoothing")
|
81
|
-
|
82
|
-
# Save target data to a component-scoped tempfile
|
83
|
-
nifti_in_file_path = tempdir / "input.nii.gz"
|
84
|
-
nib.save(data, nifti_in_file_path)
|
85
|
-
|
86
75
|
# Create element-scoped tempdir so that the output is
|
87
76
|
# available later as nibabel stores file path reference for
|
88
77
|
# loading on computation
|
89
78
|
element_tempdir = WorkDirManager().get_element_tempdir(
|
90
79
|
prefix="fsl_susan"
|
91
80
|
)
|
92
|
-
susan_out_path = element_tempdir / "
|
81
|
+
susan_out_path = element_tempdir / "smoothed_data.nii.gz"
|
93
82
|
# Set susan command
|
94
83
|
susan_cmd = [
|
95
84
|
"susan",
|
96
|
-
f"{
|
85
|
+
f"{input['path'].resolve()}",
|
97
86
|
f"{brightness_threshold}",
|
98
87
|
f"{fwhm}",
|
99
88
|
"3", # dimension
|
@@ -104,10 +93,14 @@ class FSLSmoothing:
|
|
104
93
|
# Call susan
|
105
94
|
run_ext_cmd(name="susan", cmd=susan_cmd)
|
106
95
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
96
|
+
logger.debug("Updating smoothed data")
|
97
|
+
input.update(
|
98
|
+
{
|
99
|
+
# Update path to sync with "data"
|
100
|
+
"path": susan_out_path,
|
101
|
+
# Load nifti
|
102
|
+
"data": nib.load(susan_out_path),
|
103
|
+
}
|
104
|
+
)
|
112
105
|
|
113
|
-
return
|
106
|
+
return input
|
@@ -4,23 +4,21 @@
|
|
4
4
|
# License: AGPL
|
5
5
|
|
6
6
|
from typing import (
|
7
|
-
|
7
|
+
Any,
|
8
8
|
ClassVar,
|
9
9
|
Literal,
|
10
10
|
Union,
|
11
11
|
)
|
12
12
|
|
13
|
+
import nibabel as nib
|
13
14
|
from nilearn import image as nimg
|
14
15
|
from numpy.typing import ArrayLike
|
15
16
|
|
17
|
+
from ...pipeline import WorkDirManager
|
16
18
|
from ...typing import Dependencies
|
17
19
|
from ...utils import logger
|
18
20
|
|
19
21
|
|
20
|
-
if TYPE_CHECKING:
|
21
|
-
from nibabel.nifti1 import Nifti1Image
|
22
|
-
|
23
|
-
|
24
22
|
__all__ = ["NilearnSmoothing"]
|
25
23
|
|
26
24
|
|
@@ -35,15 +33,15 @@ class NilearnSmoothing:
|
|
35
33
|
|
36
34
|
def preprocess(
|
37
35
|
self,
|
38
|
-
|
36
|
+
input: dict[str, Any],
|
39
37
|
fwhm: Union[int, float, ArrayLike, Literal["fast"], None],
|
40
|
-
) ->
|
38
|
+
) -> dict[str, Any]:
|
41
39
|
"""Preprocess using nilearn.
|
42
40
|
|
43
41
|
Parameters
|
44
42
|
----------
|
45
|
-
|
46
|
-
|
43
|
+
input : dict
|
44
|
+
A single input from the Junifer Data object in which to preprocess.
|
47
45
|
fwhm : scalar, ``numpy.ndarray``, tuple or list of scalar, "fast" or \
|
48
46
|
None
|
49
47
|
Smoothing strength, as a full-width at half maximum, in
|
@@ -61,9 +59,32 @@ class NilearnSmoothing:
|
|
61
59
|
|
62
60
|
Returns
|
63
61
|
-------
|
64
|
-
|
65
|
-
The
|
62
|
+
dict
|
63
|
+
The ``input`` dictionary with updated values.
|
66
64
|
|
67
65
|
"""
|
68
66
|
logger.info("Smoothing using nilearn")
|
69
|
-
|
67
|
+
|
68
|
+
# Create element-scoped tempdir so that the output is
|
69
|
+
# available later as nibabel stores file path reference for
|
70
|
+
# loading on computation
|
71
|
+
element_tempdir = WorkDirManager().get_element_tempdir(
|
72
|
+
prefix="nilearn_smoothing"
|
73
|
+
)
|
74
|
+
|
75
|
+
smoothed_img = nimg.smooth_img(imgs=input["data"], fwhm=fwhm)
|
76
|
+
|
77
|
+
# Save smoothed output
|
78
|
+
smoothed_img_path = element_tempdir / "smoothed_data.nii.gz"
|
79
|
+
nib.save(smoothed_img, smoothed_img_path)
|
80
|
+
|
81
|
+
logger.debug("Updating smoothed data")
|
82
|
+
input.update(
|
83
|
+
{
|
84
|
+
# Update path to sync with "data"
|
85
|
+
"path": smoothed_img_path,
|
86
|
+
"data": smoothed_img,
|
87
|
+
}
|
88
|
+
)
|
89
|
+
|
90
|
+
return input
|
@@ -164,12 +164,9 @@ class Smoothing(BasePreprocessor):
|
|
164
164
|
elif self.using == "fsl":
|
165
165
|
preprocessor = FSLSmoothing()
|
166
166
|
# Smooth
|
167
|
-
|
168
|
-
|
167
|
+
input = preprocessor.preprocess(
|
168
|
+
input=input,
|
169
169
|
**self.smoothing_params,
|
170
170
|
)
|
171
171
|
|
172
|
-
# Modify target data
|
173
|
-
input["data"] = output
|
174
|
-
|
175
172
|
return input, None
|
@@ -58,9 +58,7 @@ class ANTsWarper:
|
|
58
58
|
Returns
|
59
59
|
-------
|
60
60
|
dict
|
61
|
-
The ``input`` dictionary with
|
62
|
-
values and new ``reference`` key whose value points to the
|
63
|
-
reference file used for warping.
|
61
|
+
The ``input`` dictionary with updated values.
|
64
62
|
|
65
63
|
Raises
|
66
64
|
------
|
@@ -110,7 +108,7 @@ class ANTsWarper:
|
|
110
108
|
run_ext_cmd(name="ResampleImage", cmd=resample_image_cmd)
|
111
109
|
|
112
110
|
# Create a tempfile for warped output
|
113
|
-
apply_transforms_out_path = element_tempdir / "
|
111
|
+
apply_transforms_out_path = element_tempdir / "warped_data.nii.gz"
|
114
112
|
# Set antsApplyTransforms command
|
115
113
|
apply_transforms_cmd = [
|
116
114
|
"antsApplyTransforms",
|
@@ -126,14 +124,59 @@ class ANTsWarper:
|
|
126
124
|
# Call antsApplyTransforms
|
127
125
|
run_ext_cmd(name="antsApplyTransforms", cmd=apply_transforms_cmd)
|
128
126
|
|
129
|
-
|
130
|
-
input
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
127
|
+
logger.debug("Updating warped data")
|
128
|
+
input.update(
|
129
|
+
{
|
130
|
+
# Update path to sync with "data"
|
131
|
+
"path": apply_transforms_out_path,
|
132
|
+
# Load nifti
|
133
|
+
"data": nib.load(apply_transforms_out_path),
|
134
|
+
# Use reference input's space as warped input's space
|
135
|
+
"space": extra_input["T1w"]["space"],
|
136
|
+
# Save resampled reference path
|
137
|
+
"reference": {"path": resample_image_out_path},
|
138
|
+
# Keep pre-warp space for further operations
|
139
|
+
"prewarp_space": input["space"],
|
140
|
+
}
|
141
|
+
)
|
142
|
+
|
143
|
+
# Check for data type's mask and warp if found
|
144
|
+
if input.get("mask") is not None:
|
145
|
+
# Create a tempfile for warped mask output
|
146
|
+
apply_transforms_mask_out_path = (
|
147
|
+
element_tempdir / "warped_mask.nii.gz"
|
148
|
+
)
|
149
|
+
# Set antsApplyTransforms command
|
150
|
+
apply_transforms_mask_cmd = [
|
151
|
+
"antsApplyTransforms",
|
152
|
+
"-d 3",
|
153
|
+
"-e 3",
|
154
|
+
"-n 'GenericLabel[NearestNeighbor]'",
|
155
|
+
f"-i {input['mask']['path'].resolve()}",
|
156
|
+
# use resampled reference
|
157
|
+
f"-r {input['reference']['path'].resolve()}",
|
158
|
+
f"-t {warp_file_path.resolve()}",
|
159
|
+
f"-o {apply_transforms_mask_out_path.resolve()}",
|
160
|
+
]
|
161
|
+
# Call antsApplyTransforms
|
162
|
+
run_ext_cmd(
|
163
|
+
name="antsApplyTransforms", cmd=apply_transforms_mask_cmd
|
164
|
+
)
|
165
|
+
|
166
|
+
logger.debug("Updating warped mask data")
|
167
|
+
input.update(
|
168
|
+
{
|
169
|
+
"mask": {
|
170
|
+
# Update path to sync with "data"
|
171
|
+
"path": apply_transforms_mask_out_path,
|
172
|
+
# Load nifti
|
173
|
+
"data": nib.load(apply_transforms_mask_out_path),
|
174
|
+
# Use reference input's space as warped input
|
175
|
+
# mask's space
|
176
|
+
"space": extra_input["T1w"]["space"],
|
177
|
+
}
|
178
|
+
}
|
179
|
+
)
|
137
180
|
|
138
181
|
# Template space warping
|
139
182
|
else:
|
@@ -149,16 +192,15 @@ class ANTsWarper:
|
|
149
192
|
target_data=input,
|
150
193
|
extra_input=None,
|
151
194
|
)
|
152
|
-
|
153
|
-
# Create component-scoped tempdir
|
154
|
-
tempdir = WorkDirManager().get_tempdir(prefix="ants_warper")
|
155
195
|
# Save template
|
156
|
-
template_space_img_path =
|
196
|
+
template_space_img_path = (
|
197
|
+
element_tempdir / f"{reference}_T1w.nii.gz"
|
198
|
+
)
|
157
199
|
nib.save(template_space_img, template_space_img_path)
|
158
200
|
|
159
201
|
# Create a tempfile for warped output
|
160
202
|
warped_output_path = element_tempdir / (
|
161
|
-
f"
|
203
|
+
f"warped_data_from_{input['space']}_to_{reference}.nii.gz"
|
162
204
|
)
|
163
205
|
|
164
206
|
# Set antsApplyTransforms command
|
@@ -175,14 +217,58 @@ class ANTsWarper:
|
|
175
217
|
# Call antsApplyTransforms
|
176
218
|
run_ext_cmd(name="antsApplyTransforms", cmd=apply_transforms_cmd)
|
177
219
|
|
178
|
-
|
179
|
-
|
220
|
+
logger.debug("Updating warped data")
|
221
|
+
input.update(
|
222
|
+
{
|
223
|
+
# Update path to sync with "data"
|
224
|
+
"path": warped_output_path,
|
225
|
+
# Load nifti
|
226
|
+
"data": nib.load(warped_output_path),
|
227
|
+
# Update warped input's space
|
228
|
+
"space": reference,
|
229
|
+
# Save reference path
|
230
|
+
"reference": {"path": template_space_img_path},
|
231
|
+
# Keep pre-warp space for further operations
|
232
|
+
"prewarp_space": input["space"],
|
233
|
+
}
|
234
|
+
)
|
235
|
+
|
236
|
+
# Check for data type's mask and warp if found
|
237
|
+
if input.get("mask") is not None:
|
238
|
+
# Create a tempfile for warped mask output
|
239
|
+
apply_transforms_mask_out_path = element_tempdir / (
|
240
|
+
f"warped_mask_from_{input['space']}_to_"
|
241
|
+
f"{reference}.nii.gz"
|
242
|
+
)
|
243
|
+
# Set antsApplyTransforms command
|
244
|
+
apply_transforms_mask_cmd = [
|
245
|
+
"antsApplyTransforms",
|
246
|
+
"-d 3",
|
247
|
+
"-e 3",
|
248
|
+
"-n 'GenericLabel[NearestNeighbor]'",
|
249
|
+
f"-i {input['mask']['path'].resolve()}",
|
250
|
+
# use resampled reference
|
251
|
+
f"-r {input['reference']['path'].resolve()}",
|
252
|
+
f"-t {xfm_file_path.resolve()}",
|
253
|
+
f"-o {apply_transforms_mask_out_path.resolve()}",
|
254
|
+
]
|
255
|
+
# Call antsApplyTransforms
|
256
|
+
run_ext_cmd(
|
257
|
+
name="antsApplyTransforms", cmd=apply_transforms_mask_cmd
|
258
|
+
)
|
180
259
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
260
|
+
logger.debug("Updating warped mask data")
|
261
|
+
input.update(
|
262
|
+
{
|
263
|
+
"mask": {
|
264
|
+
# Update path to sync with "data"
|
265
|
+
"path": apply_transforms_mask_out_path,
|
266
|
+
# Load nifti
|
267
|
+
"data": nib.load(apply_transforms_mask_out_path),
|
268
|
+
# Update warped input mask's space
|
269
|
+
"space": reference,
|
270
|
+
}
|
271
|
+
}
|
272
|
+
)
|
187
273
|
|
188
274
|
return input
|
@@ -54,9 +54,7 @@ class FSLWarper:
|
|
54
54
|
Returns
|
55
55
|
-------
|
56
56
|
dict
|
57
|
-
The ``input`` dictionary with
|
58
|
-
values and new ``reference`` key whose value points to the
|
59
|
-
reference file used for warping.
|
57
|
+
The ``input`` dictionary with updated values.
|
60
58
|
|
61
59
|
Raises
|
62
60
|
------
|
@@ -100,26 +98,66 @@ class FSLWarper:
|
|
100
98
|
run_ext_cmd(name="flirt", cmd=flirt_cmd)
|
101
99
|
|
102
100
|
# Create a tempfile for warped output
|
103
|
-
applywarp_out_path = element_tempdir / "
|
101
|
+
applywarp_out_path = element_tempdir / "warped_data.nii.gz"
|
104
102
|
# Set applywarp command
|
105
103
|
applywarp_cmd = [
|
106
104
|
"applywarp",
|
107
105
|
"--interp=spline",
|
108
106
|
f"-i {input['path'].resolve()}",
|
109
|
-
|
107
|
+
# use resampled reference
|
108
|
+
f"-r {flirt_out_path.resolve()}",
|
110
109
|
f"-w {warp_file_path.resolve()}",
|
111
110
|
f"-o {applywarp_out_path.resolve()}",
|
112
111
|
]
|
113
112
|
# Call applywarp
|
114
113
|
run_ext_cmd(name="applywarp", cmd=applywarp_cmd)
|
115
114
|
|
116
|
-
|
117
|
-
input
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
115
|
+
logger.debug("Updating warped data")
|
116
|
+
input.update(
|
117
|
+
{
|
118
|
+
# Update path to sync with "data"
|
119
|
+
"path": applywarp_out_path,
|
120
|
+
# Load nifti
|
121
|
+
"data": nib.load(applywarp_out_path),
|
122
|
+
# Use reference input's space as warped input's space
|
123
|
+
"space": extra_input["T1w"]["space"],
|
124
|
+
# Save resampled reference path
|
125
|
+
"reference": {"path": flirt_out_path},
|
126
|
+
# Keep pre-warp space for further operations
|
127
|
+
"prewarp_space": input["space"],
|
128
|
+
}
|
129
|
+
)
|
130
|
+
|
131
|
+
# Check for data type's mask and warp if found
|
132
|
+
if input.get("mask") is not None:
|
133
|
+
# Create a tempfile for warped mask output
|
134
|
+
applywarp_mask_out_path = element_tempdir / "warped_mask.nii.gz"
|
135
|
+
# Set applywarp command
|
136
|
+
applywarp_mask_cmd = [
|
137
|
+
"applywarp",
|
138
|
+
"--interp=nn",
|
139
|
+
f"-i {input['mask']['path'].resolve()}",
|
140
|
+
# use resampled reference
|
141
|
+
f"-r {input['reference']['path'].resolve()}",
|
142
|
+
f"-w {warp_file_path.resolve()}",
|
143
|
+
f"-o {applywarp_mask_out_path.resolve()}",
|
144
|
+
]
|
145
|
+
# Call applywarp
|
146
|
+
run_ext_cmd(name="applywarp", cmd=applywarp_mask_cmd)
|
147
|
+
|
148
|
+
logger.debug("Updating warped mask data")
|
149
|
+
input.update(
|
150
|
+
{
|
151
|
+
"mask": {
|
152
|
+
# Update path to sync with "data"
|
153
|
+
"path": applywarp_mask_out_path,
|
154
|
+
# Load nifti
|
155
|
+
"data": nib.load(applywarp_mask_out_path),
|
156
|
+
# Use reference input's space as warped input mask's
|
157
|
+
# space
|
158
|
+
"space": extra_input["T1w"]["space"],
|
159
|
+
}
|
160
|
+
}
|
161
|
+
)
|
124
162
|
|
125
163
|
return input
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: junifer
|
3
|
-
Version: 0.0.6.
|
3
|
+
Version: 0.0.6.dev317
|
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=ysdlII3ZUlFBiHIzSCvasFtc1CMEpYMsiJEwLoFxjKQ,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
|
@@ -280,22 +280,22 @@ junifer/preprocess/base.py,sha256=hARO4Yq9sQ8m2tATeuBmPMbI4BSnwNxLf2prF8Iq_Tk,66
|
|
280
280
|
junifer/preprocess/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
281
281
|
junifer/preprocess/confounds/__init__.py,sha256=L3CquKcndFb2b8yVo-XLi-zsNCe8MMKUN41UOVdooWc,270
|
282
282
|
junifer/preprocess/confounds/__init__.pyi,sha256=iC70cqcWNMX4JM42RcUgKb9YX8ciK8oVERdWWjo-13c,102
|
283
|
-
junifer/preprocess/confounds/fmriprep_confound_remover.py,sha256=
|
283
|
+
junifer/preprocess/confounds/fmriprep_confound_remover.py,sha256=Vw0ymmA8QppKY3GHdP8J9K6KyYUSbLGbBnwT-VpwXLw,21527
|
284
284
|
junifer/preprocess/confounds/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
285
285
|
junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py,sha256=yZxCud9l8bW36Rsk63Fi1qWUpM9L4Wtd2-zZW-DjvZA,19949
|
286
286
|
junifer/preprocess/smoothing/__init__.py,sha256=7aTwvAG522kA76QQwqxwY5zV_6asyPaaH2uSMTaKQls,216
|
287
287
|
junifer/preprocess/smoothing/__init__.pyi,sha256=5sjw61Eyon9gE_SWoktND9raw6IkgqcT2rtGNhVV9EA,58
|
288
|
-
junifer/preprocess/smoothing/_afni_smoothing.py,sha256=
|
289
|
-
junifer/preprocess/smoothing/_fsl_smoothing.py,sha256=
|
290
|
-
junifer/preprocess/smoothing/_nilearn_smoothing.py,sha256=
|
288
|
+
junifer/preprocess/smoothing/_afni_smoothing.py,sha256=4mdZk9YkA02wZ8rS6sbLnXL_7SIX7M0NwHPLckJgCmI,3325
|
289
|
+
junifer/preprocess/smoothing/_fsl_smoothing.py,sha256=vIj1sUjysujjPErZH2T5G1GrcaZyAkuvzERBgx4SmDU,2856
|
290
|
+
junifer/preprocess/smoothing/_nilearn_smoothing.py,sha256=bWljIiKX0dfIQmRo33Z-6WrCz05nMVAAroYaBsj2B1Q,2685
|
291
291
|
junifer/preprocess/smoothing/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
292
|
-
junifer/preprocess/smoothing/smoothing.py,sha256=
|
292
|
+
junifer/preprocess/smoothing/smoothing.py,sha256=wdOnPi8XkEqzOQdUNJ0yOm_uWi3H4DnTQhOL8z7dZDs,5281
|
293
293
|
junifer/preprocess/smoothing/tests/test_smoothing.py,sha256=t1j3zEvJk5XLO4fzcb-wQyBMH-xuvR1k6WYm8zriwik,2390
|
294
294
|
junifer/preprocess/tests/test_preprocess_base.py,sha256=-0rpe8QjqYES36H6MHuDs3cv_6upHBdVHnFMgQsmEX4,2571
|
295
295
|
junifer/preprocess/warping/__init__.py,sha256=rzUUP7-6H_nygQ7a7TBZ4_RY7p0ELacosYsWQbSdVZk,214
|
296
296
|
junifer/preprocess/warping/__init__.pyi,sha256=Drbqp8N3uprvXcKSxqdfj90fesz9XYVLgivhPnKAYcc,65
|
297
|
-
junifer/preprocess/warping/_ants_warper.py,sha256=
|
298
|
-
junifer/preprocess/warping/_fsl_warper.py,sha256=
|
297
|
+
junifer/preprocess/warping/_ants_warper.py,sha256=Qk6piCuGPlfgGbH3zMVC5UHCoQ7iddYuc2vgsrqncGg,10163
|
298
|
+
junifer/preprocess/warping/_fsl_warper.py,sha256=dH1xd3jTRPREzgdh98Dz_4o2gwdrOgc0h5wbARSSB98,5226
|
299
299
|
junifer/preprocess/warping/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
300
300
|
junifer/preprocess/warping/space_warper.py,sha256=mf7SDu574R3TXNt82fqGl_hcEYx7SjXwz2TcmWObHQA,7706
|
301
301
|
junifer/preprocess/warping/tests/test_space_warper.py,sha256=amFHtt-q7L7v9uL4cOvrmHEbUOGDhmoMHkLnKJ0dF7A,5543
|
@@ -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.dev317.dist-info/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
|
345
|
+
junifer-0.0.6.dev317.dist-info/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
|
346
|
+
junifer-0.0.6.dev317.dist-info/METADATA,sha256=aQiIDdr_Ov-v0da-VOALNQiJe1FIGM-Xz32tTTqlW00,8429
|
347
|
+
junifer-0.0.6.dev317.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
348
|
+
junifer-0.0.6.dev317.dist-info/entry_points.txt,sha256=6O8ru0BP-SP7YMUZiizFNoaZ2HvJpadO2G7nKk4PwjI,48
|
349
|
+
junifer-0.0.6.dev317.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
|
350
|
+
junifer-0.0.6.dev317.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|