Skip to content
Snippets Groups Projects
Commit 2be63aaf authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Bugfix to TensorImage.__init__. Bugfix to Image.name

initialisation. Image.name property turned into a regular (writeable)
attribute.
parent 3d835d9c
No related branches found
No related tags found
No related merge requests found
...@@ -295,8 +295,8 @@ class Image(Nifti1, notifier.Notifier): ...@@ -295,8 +295,8 @@ class Image(Nifti1, notifier.Notifier):
In addition to the attributes added by the :meth:`Nifti1.__init__` method, In addition to the attributes added by the :meth:`Nifti1.__init__` method,
the following read-only properties are present on an ``Image`` instance as the following attributes/properties are present on an ``Image`` instance
properties (https://docs.python.org/2/library/functions.html#property): as properties (https://docs.python.org/2/library/functions.html#property):
============== ====================================================== ============== ======================================================
...@@ -408,23 +408,26 @@ class Image(Nifti1, notifier.Notifier): ...@@ -408,23 +408,26 @@ class Image(Nifti1, notifier.Notifier):
else: else:
nibImage = image nibImage = image
# Figure out the name of this image. If it has # Figure out the name of this image, if
# not beenbeen explicitly passed in, and this # it has not beenbeen explicitly passed in
# image was loaded from disk, use the file name. if name is None:
if name is None and isinstance(image, six.string_types):
name = removeExt(op.basename(image))
# Or the image was created from a numpy array # If this image was loaded
elif isinstance(image, np.ndarray): # from disk, use the file name.
name = 'Numpy array' if isinstance(image, six.string_types):
name = removeExt(op.basename(image))
# Or image from a nibabel image # Or the image was created from a numpy array
else: elif isinstance(image, np.ndarray):
name = 'Nibabel image' name = 'Numpy array'
# Or image from a nibabel image
else:
name = 'Nibabel image'
Nifti1.__init__(self, nibImage.get_header()) Nifti1.__init__(self, nibImage.get_header())
self.__name = name self.name = name
self.__dataSource = dataSource self.__dataSource = dataSource
self.__nibImage = nibImage self.__nibImage = nibImage
self.__saveState = dataSource is not None self.__saveState = dataSource is not None
...@@ -458,12 +461,6 @@ class Image(Nifti1, notifier.Notifier): ...@@ -458,12 +461,6 @@ class Image(Nifti1, notifier.Notifier):
"""See the :meth:`__str__` method.""" """See the :meth:`__str__` method."""
return self.__str__() return self.__str__()
@property
def name(self):
"""Returns the name of this ``Image``. """
return self.__name
@property @property
def dataSource(self): def dataSource(self):
......
...@@ -125,16 +125,15 @@ class TensorImage(fslimage.Nifti1): ...@@ -125,16 +125,15 @@ class TensorImage(fslimage.Nifti1):
else: else:
paths = path paths = path
fslimage.Nifti1.__init__(self, paths['l1'],
loadData=False,
calcRange=False)
self.__v1 = fslimage.Image(paths['v1']) self.__v1 = fslimage.Image(paths['v1'])
self.__v2 = fslimage.Image(paths['v2']) self.__v2 = fslimage.Image(paths['v2'])
self.__v3 = fslimage.Image(paths['v3']) self.__v3 = fslimage.Image(paths['v3'])
self.__l1 = fslimage.Image(paths['l1']) self.__l1 = fslimage.Image(paths['l1'])
self.__l2 = fslimage.Image(paths['l2']) 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'])) l1dir = op.abspath(op.dirname(paths['l1']))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment