From 482a1290d0cf649814d0307b2f8127c493cfff44 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Sun, 27 May 2018 14:43:03 +0100
Subject: [PATCH] RF: Image.ndims renamed to Image.ndim. New Image.data
 property - easy way to get image data as numpy array.

---
 fsl/data/image.py        | 23 +++++++++++++++++++++--
 fsl/data/melodicimage.py |  2 +-
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/fsl/data/image.py b/fsl/data/image.py
index c03618d85..174e1746b 100644
--- a/fsl/data/image.py
+++ b/fsl/data/image.py
@@ -490,8 +490,7 @@ class Nifti(notifier.Notifier, meta.Meta):
         return fileslice.canonical_slicers(sliceobj, self.__origShape)
 
 
-    @property
-    def ndims(self):
+    def ndim(self):
         """Returns the number of dimensions in this image. This number may not
         match the number of dimensions specified in the NIFTI header, as
         trailing dimensions of length 1 are ignored. But it is guaranteed to be
@@ -500,6 +499,15 @@ class Nifti(notifier.Notifier, meta.Meta):
         return len(self.__shape)
 
 
+    @property
+    @deprecation.deprecated(deprecated_in='1.9.0',
+                            removed_in='2.0.0',
+                            details='Use ndim instead')
+    def ndims(self):
+        """Deprecated - use :mod::meth:``ndim`` instead. """
+        return self.ndim()
+
+
     @deprecation.deprecated(deprecated_in='1.1.0',
                             removed_in='2.0.0',
                             details='Use ndims instead')
@@ -1006,6 +1014,17 @@ class Image(Nifti):
         return self.__nibImage
 
 
+    @property
+    def data(self):
+        """Returns the image data as a ``numpy`` array.
+
+        .. warning:: Calling this method will cause the entire image to be
+                     loaded into memory.
+        """
+        self.__imageWrapper.loadData()
+        return self[:]
+
+
     @property
     def saveState(self):
         """Returns ``True`` if this ``Image`` has been saved to disk, ``False``
diff --git a/fsl/data/melodicimage.py b/fsl/data/melodicimage.py
index 4d7f05809..ad8922f85 100644
--- a/fsl/data/melodicimage.py
+++ b/fsl/data/melodicimage.py
@@ -77,7 +77,7 @@ class MelodicImage(fslimage.Image):
             dataImage = fslimage.Image(dataFile,
                                        loadData=False,
                                        calcRange=False)
-            if dataImage.ndims >= 4:
+            if dataImage.ndim >= 4:
                 self.__tr = dataImage.pixdim[3]
 
 
-- 
GitLab