Skip to content

Commit c729280

Browse files
authored
Merge pull request #265 from nipreps/maint/update-nitransforms-pin
MAINT: Update nitransforms pin
2 parents fd64c14 + 51cc6f4 commit c729280

File tree

9 files changed

+14
-11
lines changed

9 files changed

+14
-11
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dependencies = [
2424
"dipy>=1.5.0",
2525
"joblib",
2626
"nipype>=1.5.1,<2.0",
27-
"nitransforms>=22.0.0,<24",
27+
"nitransforms>=25.0.0",
2828
"nireports",
2929
"numpy>=1.21.3",
3030
"nest-asyncio>=1.5.1",

scripts/compute_nufo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def main() -> None:
164164
_, brain_mask = median_otsu(dwi_data, vol_idx=[0])
165165

166166
dwi_data_masked = dwi_data.copy()
167-
dwi_data_masked[~brain_mask, :] = 0
167+
dwi_data_masked[~brain_mask.astype(bool), :] = 0
168168

169169
# Create a CSD model
170170
response, ratio = auto_response_ssst(

scripts/optimize_registration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ async def train_coro(
125125

126126
index = i * len(REFERENCES) + j
127127
moving_path = tmp_folder / f"test-{index:04d}.nii.gz"
128-
(~xfm).apply(refnii, reference=refnii).to_filename(moving_path)
128+
nt.resampling.apply(~xfm, refnii, reference=refnii).to_filename(moving_path)
129129

130130
_kwargs = {"output_transform_prefix": f"conversion-{index:04d}", **align_kwargs}
131131

src/nifreeze/data/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import nibabel as nb
3636
import numpy as np
3737
from nitransforms.linear import LinearTransformsMapping
38+
from nitransforms.resampling import apply
3839
from typing_extensions import Self, TypeVarTuple, Unpack
3940

4041
Ts = TypeVarTuple("Ts")
@@ -285,7 +286,7 @@ def to_nifti(
285286
datamoving = nb.Nifti1Image(frame[0], self.affine, self.datahdr)
286287
# resample at index
287288
resampled[..., i] = np.asanyarray(
288-
xform.apply(datamoving, order=order).dataobj,
289+
apply(xform, datamoving, order=order).dataobj,
289290
dtype=self.dataobj.dtype,
290291
)
291292

src/nifreeze/data/pet.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import numpy as np
3636
from nibabel.spatialimages import SpatialImage
3737
from nitransforms.linear import Affine
38+
from nitransforms.resampling import apply
3839
from typing_extensions import Self
3940

4041
from nifreeze.data.base import BaseDataset, _cmp, _data_repr
@@ -137,7 +138,7 @@ def set_transform(self, index: int, affine: np.ndarray, order: int = 3) -> None:
137138

138139
# resample and update orientation at index
139140
self.dataobj[..., index] = np.asanyarray(
140-
xform.apply(dmoving, order=order).dataobj,
141+
apply(xform, dmoving, order=order).dataobj,
141142
dtype=self.dataobj.dtype,
142143
)
143144

src/nifreeze/data/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ def apply_affines(nii, em_affines, output_filename=None):
2828

2929
for ii, bvecnii in enumerate(nb.four_to_three(nii)):
3030
xfms = nt.linear.Affine(em_affines[ii])
31-
transformed_nii[..., ii] = np.asanyarray((~xfms).apply(bvecnii, reference=nii).dataobj)
31+
transformed_nii[..., ii] = np.asanyarray(
32+
nt.resampling.apply(~xfms, bvecnii, reference=nii).dataobj
33+
)
3234

3335
nii_t_img = nii.__class__(transformed_nii, nii.affine, nii.header)
3436

src/nifreeze/model/_dipy.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
from __future__ import annotations
2626

27-
from typing import Any
28-
2927
import numpy as np
3028
from dipy.core.gradients import GradientTable
3129
from dipy.reconst.base import ReconstModel
@@ -153,7 +151,7 @@ def fit(
153151
self,
154152
data: np.ndarray,
155153
gtab: GradientTable | np.ndarray,
156-
mask: np.ndarray[bool, Any] | None = None,
154+
mask: np.ndarray | None = None,
157155
random_state: int = 0,
158156
) -> GPFit:
159157
"""Fit method of the DTI model class

src/nifreeze/registration/ants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import numpy as np
3636
from nipype.interfaces.ants.registration import Registration
3737
from nitransforms.linear import Affine
38+
from nitransforms.resampling import apply
3839

3940
PARAMETERS_SINGLE_VALUE = {
4041
"collapse_output_transforms",
@@ -494,7 +495,7 @@ def _run_registration(
494495
),
495496
)
496497
# debugging: generate aligned file for testing
497-
xform.apply(moving_path, reference=fixed_path).to_filename(
498+
apply(xform, moving_path, reference=fixed_path).to_filename(
498499
dirname / f"dbg_{vol_idx:05d}.nii.gz"
499500
)
500501

test/test_registration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_ANTs_config_b0(datadir, tmp_path, dataset, r_x, r_y, r_z, t_x, t_y, t_z
5858
T = from_matvec(euler2mat(x=r_x, y=r_y, z=r_z), (t_x, t_y, t_z))
5959
xfm = nt.linear.Affine(T, reference=b0nii)
6060

61-
(~xfm).apply(b0nii, reference=b0nii).to_filename(moving)
61+
nt.resampling.apply(~xfm, b0nii, reference=b0nii).to_filename(moving)
6262

6363
registration = Registration(
6464
terminal_output="file",

0 commit comments

Comments
 (0)