From 4e0acb873c9442a5b2e526df003eb2b0a7d8c7ea Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Fri, 3 May 2019 13:40:38 +0100
Subject: [PATCH] RF: Minor refactor

---
 fsl/utils/image/__init__.py | 16 ++++++++++++++++
 fsl/utils/image/resample.py |  8 ++++----
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/fsl/utils/image/__init__.py b/fsl/utils/image/__init__.py
index e69de29bb..8e2253364 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 0b4c4c00c..cc49a621d 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)
 
 
-- 
GitLab