diff --git a/fsl/utils/image/__init__.py b/fsl/utils/image/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8e22533648b6ff1c4125b31e0375b594f937164b 100644 --- a/fsl/utils/image/__init__.py +++ b/fsl/utils/image/__init__.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# +# __init__.py - The fsl.utils.image package +# +# Author: Paul McCarthy <pauldmccarthy@gmail.com> +# +"""The :mod:`fsl.utils.image` oackage contains algorithms and utilities for +manipulating and working with :class:`.Image` objects. + +The following modules are available: + +.. autosumary:: + :nosignature + + .image.resample +""" diff --git a/fsl/utils/image/resample.py b/fsl/utils/image/resample.py index 0b4c4c00ce893639ed5d8b24d88f5e6bc5bdda88..cc49a621dca6a5759421e8353578fbb7038eca8e 100644 --- a/fsl/utils/image/resample.py +++ b/fsl/utils/image/resample.py @@ -32,10 +32,10 @@ def resampleToPixdims(image, newPixdims, **kwargs): :arg image: :class:`.Image` to resample :arg pixdims: New voxel dimensions to resample ``image`` to. """ - oldShape = image.shape - oldPixdims = image.pixdim - fac = [o / float(n) for o, n in zip(oldPixdims, newPixdims)] - newShape = [p * f for p, f in zip(oldShape, fac)] + newPixdims = np.array(newPixdims) + oldShape = np.array(image.shape) + oldPixdims = np.array(image.pixdim) + newShape = oldShape * (oldPixdims / newPixdims) return resample(image, newShape, **kwargs)