From cd79e13ea177e021480420de6720788a8bb68c19 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Wed, 3 Jul 2019 07:23:01 +0100
Subject: [PATCH] RF: Newly created images are only considered "saved" if they
 were created from a file name. Bitmap.asImage passes dataSource through to
 Image.__init__

---
 fsl/data/bitmap.py | 4 +++-
 fsl/data/image.py  | 5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/fsl/data/bitmap.py b/fsl/data/bitmap.py
index 0e5c9b413..299534f54 100644
--- a/fsl/data/bitmap.py
+++ b/fsl/data/bitmap.py
@@ -167,4 +167,6 @@ class Bitmap(object):
 
         data = np.array(data, order='F', copy=False)
 
-        return fslimage.Image(data, name=self.name)
+        return fslimage.Image(data,
+                              name=self.name,
+                              dataSource=self.dataSource)
diff --git a/fsl/data/image.py b/fsl/data/image.py
index 417a0445c..1bf901c28 100644
--- a/fsl/data/image.py
+++ b/fsl/data/image.py
@@ -809,6 +809,7 @@ class Image(Nifti):
         """
 
         nibImage = None
+        saved    = False
 
         if indexed is not False:
             warnings.warn('The indexed argument is deprecated '
@@ -841,10 +842,10 @@ class Image(Nifti):
 
         # The image parameter may be the name of an image file
         if isinstance(image, six.string_types):
-
             image      = op.abspath(addExt(image))
             nibImage   = nib.load(image, **kwargs)
             dataSource = image
+            saved      = True
 
         # Or a numpy array - we wrap it in a nibabel image,
         # with an identity transformation (each voxel maps
@@ -906,7 +907,7 @@ class Image(Nifti):
         self.__dataSource   = dataSource
         self.__threaded     = threaded
         self.__nibImage     = nibImage
-        self.__saveState    = dataSource is not None
+        self.__saveState    = saved
         self.__imageWrapper = imagewrapper.ImageWrapper(self.nibImage,
                                                         self.name,
                                                         loadData=loadData,
-- 
GitLab