From 7b6144d2c47847d94c839cda1f55e9c5d2534839 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Wed, 15 Jun 2016 12:21:58 +0100 Subject: [PATCH] Little bugfixes to Notifier and Image classes. --- fsl/data/image.py | 5 +++-- fsl/utils/notifier.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fsl/data/image.py b/fsl/data/image.py index 802172675..36d02ad0e 100644 --- a/fsl/data/image.py +++ b/fsl/data/image.py @@ -384,6 +384,7 @@ class Image(Nifti1, notifier.Notifier): nibImage = None dataSource = None + fileobj = None # The image parameter may be the name of an image file if isinstance(image, six.string_types): @@ -413,13 +414,12 @@ class Image(Nifti1, notifier.Notifier): fmap['image'].fileobj = fobj nibImage = nib.Nifti1Image.from_file_map(fmap) - self.__fileobj = fobj + fileobj = fobj # Otherwise we let nibabel # manage the file reference(s) else: nibImage = nib.load(image) - self.__fileobj = None dataSource = image @@ -460,6 +460,7 @@ class Image(Nifti1, notifier.Notifier): self.name = name self.__dataSource = dataSource + self.__fileobj = fileobj self.__nibImage = nibImage self.__saveState = dataSource is not None self.__suppressDataRange = False diff --git a/fsl/utils/notifier.py b/fsl/utils/notifier.py index 79ae85443..c1a12e45d 100644 --- a/fsl/utils/notifier.py +++ b/fsl/utils/notifier.py @@ -94,7 +94,7 @@ class Notifier(object): if listeners is None: return - callback, _ = listeners.pop(name, None) + callback, _ = listeners.pop(name, (None, None)) # Silently absorb invalid names - the # notify function may have removed gc'd -- GitLab