From 343ec8643e9deb145b13c9849c6610fdba980658 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Fri, 12 Nov 2021 11:10:05 +0000
Subject: [PATCH] RF: Check that mapped nifti file exists, save to new temp
 file if not.

---
 fsl/wrappers/wrapperutils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fsl/wrappers/wrapperutils.py b/fsl/wrappers/wrapperutils.py
index 260841d4b..aab71b90c 100644
--- a/fsl/wrappers/wrapperutils.py
+++ b/fsl/wrappers/wrapperutils.py
@@ -1046,7 +1046,7 @@ def fileOrImage(*args, **kwargs):
 
             # in-memory image - we have
             # to save it out to a file
-            if infile is None:
+            if infile is None or not op.exists(infile):
                 hd, infile = tempfile.mkstemp(fslimage.defaultExt(),
                                               dir=workdir)
                 os.close(hd)
-- 
GitLab