From cdcc9bb0c01297fc247f708d4849c5cd47221341 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Fri, 15 Aug 2025 16:09:26 +0200 Subject: [PATCH] fix: remove "densification" of B-Spline transforms in ``apply()`` For some reason, ``apply()`` always converted B-Spline displacements into a displacements dense-field. --- nitransforms/resampling.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/nitransforms/resampling.py b/nitransforms/resampling.py index 8cb2059..df23749 100644 --- a/nitransforms/resampling.py +++ b/nitransforms/resampling.py @@ -259,22 +259,14 @@ def apply( targets = None ref_ndcoords = _ref.ndcoords - if hasattr(transform, "to_field") and callable(transform.to_field): - targets = ImageGrid(spatialimage).index( - _as_homogeneous( - transform.to_field(reference=reference).map(ref_ndcoords), - dim=_ref.ndim, - ) - ) - else: - # Targets' shape is (Nt, 3, Nv) with Nv = Num. voxels, Nt = Num. timepoints. - targets = ( - ImageGrid(spatialimage).index( - _as_homogeneous(transform.map(ref_ndcoords), dim=_ref.ndim) - ) - if targets is None - else targets + # Targets' shape is (Nt, 3, Nv) with Nv = Num. voxels, Nt = Num. timepoints. + targets = ( + ImageGrid(spatialimage).index( + _as_homogeneous(transform.map(ref_ndcoords), dim=_ref.ndim) ) + if targets is None + else targets + ) if targets.ndim == 2: targets = targets.T[np.newaxis, ...]