File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -539,7 +539,7 @@ def resample_image(
539
539
classes = [xfm .__class__ .__name__ for xfm in transforms ]
540
540
raise ValueError (f"HMC transforms must come last. Found sequence: { classes } " )
541
541
transform_list : list = transforms .transforms
542
- hmc = None
542
+ hmc = []
543
543
544
544
# Retrieve the RAS coordinates of the target space
545
545
coordinates = nt .base .SpatialReference .factory (target ).ndcoords .astype ('f4' ).T
@@ -548,15 +548,12 @@ def resample_image(
548
548
vox2ras = source .affine
549
549
ras2vox = np .linalg .inv (vox2ras )
550
550
# 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 ]
555
552
556
- # Remove the head-motion transforms and add a mapping from boldref
553
+ # After removing the head-motion transforms, add a mapping from boldref
557
554
# world space to voxels. This new transform maps from world coordinates
558
555
# 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 )])
560
557
mapped_coordinates = ref2vox .map (coordinates )
561
558
562
559
# Some identities to reduce special casing downstream
You can’t perform that action at this time.
0 commit comments