From a6b40f987ae61c5e755d5bb04d28a0f3ff88f02f Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Fri, 12 Nov 2021 11:13:09 +0000 Subject: [PATCH] RF: Make sure that input images don't get associated with temp files --- fsl/wrappers/wrapperutils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fsl/wrappers/wrapperutils.py b/fsl/wrappers/wrapperutils.py index aab71b90c..8a5fa0eb4 100644 --- a/fsl/wrappers/wrapperutils.py +++ b/fsl/wrappers/wrapperutils.py @@ -1050,6 +1050,12 @@ def fileOrImage(*args, **kwargs): hd, infile = tempfile.mkstemp(fslimage.defaultExt(), dir=workdir) os.close(hd) + + # Create a copy of the input image and + # save that, so the original doesn't + # get associated with the temp file + val = nib.nifti1.Nifti1Image( + np.asanyarray(val.dataobj), None, val.header) val.to_filename(infile) return infile -- GitLab