Skip to content

Commit

Permalink
Merge pull request #312 from effigies/fix/generate_reference_image
Browse files Browse the repository at this point in the history
FIX: GenerateSamplingReference with correct zooms
  • Loading branch information
effigies authored Feb 16, 2019
2 parents 9d7b80e + 3848f29 commit 3869e86
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion niworkflows/interfaces/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,13 @@ def _gen_reference(fixed_image, moving_image, fov_mask=None, out_file=None,
suffix='_reference',
newpath=os.getcwd())

new_zooms = nli.load_img(moving_image).header.get_zooms()[:3]
# Moving images may not be RAS/LPS (more generally, transverse-longitudinal-axial)
reoriented_moving_img = nb.as_closest_canonical(nb.load(moving_image))
new_zooms = reoriented_moving_img.header.get_zooms()[:3]

# Avoid small differences in reported resolution to cause changes to
# FOV. See https://github.com/poldracklab/fmriprep/issues/512
# A positive diagonal affine is RAS, hence the need to reorient above.
new_affine = np.diag(np.round(new_zooms, 3))

resampled = nli.resample_img(fixed_image,
Expand Down

0 comments on commit 3869e86

Please sign in to comment.