From 3848f29492fbfd4fccd06f2dbb42e82b158c1650 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Fri, 15 Feb 2019 16:45:03 -0500 Subject: [PATCH] FIX: GenerateSamplingReference with correct zooms --- niworkflows/interfaces/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/niworkflows/interfaces/utils.py b/niworkflows/interfaces/utils.py index 231ed3ad76a..47cdd5793af 100644 --- a/niworkflows/interfaces/utils.py +++ b/niworkflows/interfaces/utils.py @@ -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,