From 2be63aaf277bcaa1c8116ae0be500cdceb4c19da Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Sun, 5 Jun 2016 14:47:54 +0100 Subject: [PATCH] Bugfix to TensorImage.__init__. Bugfix to Image.name initialisation. Image.name property turned into a regular (writeable) attribute. --- fsl/data/image.py | 37 +++++++++++++++++-------------------- fsl/data/tensorimage.py | 7 +++---- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/fsl/data/image.py b/fsl/data/image.py index 846e8abb7..2560cffdb 100644 --- a/fsl/data/image.py +++ b/fsl/data/image.py @@ -295,8 +295,8 @@ class Image(Nifti1, notifier.Notifier): In addition to the attributes added by the :meth:`Nifti1.__init__` method, - the following read-only properties are present on an ``Image`` instance as - properties (https://docs.python.org/2/library/functions.html#property): + the following attributes/properties are present on an ``Image`` instance + as properties (https://docs.python.org/2/library/functions.html#property): ============== ====================================================== @@ -408,23 +408,26 @@ class Image(Nifti1, notifier.Notifier): else: nibImage = image - # Figure out the name of this image. If it has - # not beenbeen explicitly passed in, and this - # image was loaded from disk, use the file name. - if name is None and isinstance(image, six.string_types): - name = removeExt(op.basename(image)) + # Figure out the name of this image, if + # it has not beenbeen explicitly passed in + if name is None: - # Or the image was created from a numpy array - elif isinstance(image, np.ndarray): - name = 'Numpy array' + # If this image was loaded + # from disk, use the file name. + if isinstance(image, six.string_types): + name = removeExt(op.basename(image)) - # Or image from a nibabel image - else: - name = 'Nibabel image' + # Or the image was created from a numpy array + elif isinstance(image, np.ndarray): + name = 'Numpy array' + + # Or image from a nibabel image + else: + name = 'Nibabel image' Nifti1.__init__(self, nibImage.get_header()) - self.__name = name + self.name = name self.__dataSource = dataSource self.__nibImage = nibImage self.__saveState = dataSource is not None @@ -458,12 +461,6 @@ class Image(Nifti1, notifier.Notifier): """See the :meth:`__str__` method.""" return self.__str__() - - @property - def name(self): - """Returns the name of this ``Image``. """ - return self.__name - @property def dataSource(self): diff --git a/fsl/data/tensorimage.py b/fsl/data/tensorimage.py index 2587cc189..0cee5380c 100644 --- a/fsl/data/tensorimage.py +++ b/fsl/data/tensorimage.py @@ -125,16 +125,15 @@ class TensorImage(fslimage.Nifti1): else: paths = path - fslimage.Nifti1.__init__(self, paths['l1'], - loadData=False, - calcRange=False) self.__v1 = fslimage.Image(paths['v1']) self.__v2 = fslimage.Image(paths['v2']) self.__v3 = fslimage.Image(paths['v3']) self.__l1 = fslimage.Image(paths['l1']) self.__l2 = fslimage.Image(paths['l2']) - self.__l3 = fslimage.Image(paths['l3']) + self.__l3 = fslimage.Image(paths['l3']) + + fslimage.Nifti1.__init__(self, self.__l1.header) l1dir = op.abspath(op.dirname(paths['l1'])) -- GitLab