Commit 482a1290 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF: Image.ndims renamed to Image.ndim. New property - easy way to

get image data as numpy array.
parent 0ee48df0
......@@ -490,8 +490,7 @@ class Nifti(notifier.Notifier, meta.Meta):
return fileslice.canonical_slicers(sliceobj, self.__origShape)
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)
details='Use ndim instead')
def ndims(self):
"""Deprecated - use :mod::meth:``ndim`` instead. """
return self.ndim()
details='Use ndims instead')
......@@ -1006,6 +1014,17 @@ class Image(Nifti):
return self.__nibImage
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.
return self[:]
def saveState(self):
"""Returns ``True`` if this ``Image`` has been saved to disk, ``False``
......@@ -77,7 +77,7 @@ class MelodicImage(fslimage.Image):
dataImage = fslimage.Image(dataFile,
if dataImage.ndims >= 4:
if dataImage.ndim >= 4:
self.__tr = dataImage.pixdim[3]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment