Skip to content

Commit

Permalink
FIX: Incomplete transition to an HMC-free path
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Nov 14, 2023
1 parent 3991846 commit 921caf9
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions fmriprep/interfaces/resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ def resample_image(
classes = [xfm.__class__.__name__ for xfm in transforms]
raise ValueError(f"HMC transforms must come last. Found sequence: {classes}")
transform_list: list = transforms.transforms
hmc = None
hmc = []

Check warning on line 542 in fmriprep/interfaces/resampling.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/interfaces/resampling.py#L542

Added line #L542 was not covered by tests

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

Check warning on line 551 in fmriprep/interfaces/resampling.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/interfaces/resampling.py#L551

Added line #L551 was not covered by tests

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

Check warning on line 556 in fmriprep/interfaces/resampling.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/interfaces/resampling.py#L556

Added line #L556 was not covered by tests
mapped_coordinates = ref2vox.map(coordinates)

# Some identities to reduce special casing downstream
Expand Down

0 comments on commit 921caf9

Please sign in to comment.