Skip to content

Commit 921caf9

Browse files
committed
FIX: Incomplete transition to an HMC-free path
1 parent 3991846 commit 921caf9

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

fmriprep/interfaces/resampling.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def resample_image(
539539
classes = [xfm.__class__.__name__ for xfm in transforms]
540540
raise ValueError(f"HMC transforms must come last. Found sequence: {classes}")
541541
transform_list: list = transforms.transforms
542-
hmc = None
542+
hmc = []
543543

544544
# Retrieve the RAS coordinates of the target space
545545
coordinates = nt.base.SpatialReference.factory(target).ndcoords.astype('f4').T
@@ -548,15 +548,12 @@ def resample_image(
548548
vox2ras = source.affine
549549
ras2vox = np.linalg.inv(vox2ras)
550550
# Transform RAS2RAS head motion transforms to VOX2VOX
551-
if hmc is not None:
552-
hmc_xfms = [ras2vox @ xfm.matrix @ vox2ras for xfm in transforms[-1]]
553-
else:
554-
hmc_xfms = None
551+
hmc_xfms = [ras2vox @ xfm.matrix @ vox2ras for xfm in hmc]
555552

556-
# Remove the head-motion transforms and add a mapping from boldref
553+
# After removing the head-motion transforms, add a mapping from boldref
557554
# world space to voxels. This new transform maps from world coordinates
558555
# in the target space to voxel coordinates in the source space.
559-
ref2vox = nt.TransformChain(transforms[:-1] + [nt.Affine(ras2vox)])
556+
ref2vox = nt.TransformChain(transform_list + [nt.Affine(ras2vox)])
560557
mapped_coordinates = ref2vox.map(coordinates)
561558

562559
# Some identities to reduce special casing downstream

0 commit comments

Comments
 (0)