diff --git a/fsl/data/image.py b/fsl/data/image.py index 802172675138312252bd74ecd67f5cd23b855d7d..36d02ad0ec4ca0e59d3b2286bd1c45d48b498477 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 79ae85443b1b39a799ac925bd7756c012a69d66d..c1a12e45d837ce09029ff60d43699c86d03ced04 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