From b50751a203d7915046e0d37162dc6513299604f2 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Wed, 1 Aug 2018 20:55:56 +0100
Subject: [PATCH] RF: Windows compatibility

---
 fsl/utils/imcp.py            | 1 +
 fsl/utils/path.py            | 2 +-
 fsl/utils/run.py             | 3 +++
 fsl/wrappers/wrapperutils.py | 2 +-
 4 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/fsl/utils/imcp.py b/fsl/utils/imcp.py
index 047f1f2f2..8950e074d 100644
--- a/fsl/utils/imcp.py
+++ b/fsl/utils/imcp.py
@@ -137,6 +137,7 @@ def imcp(src,
 
         img = nib.load(src)
         nib.save(img, dest)
+        img = None
 
         if move:
             # if input is an image pair, we
diff --git a/fsl/utils/path.py b/fsl/utils/path.py
index fc8efeadb..4190865a8 100644
--- a/fsl/utils/path.py
+++ b/fsl/utils/path.py
@@ -65,7 +65,7 @@ def shallowest(path, suffixes):
     path = path.strip()
 
     # We've reached the root of the file system
-    if path == op.sep or path == '':
+    if path == op.sep or path == '' or op.splitdrive(path)[1] == '':
         return None
 
     path   = path.rstrip(op.sep)
diff --git a/fsl/utils/run.py b/fsl/utils/run.py
index 4c45f6aa8..a5b9df816 100644
--- a/fsl/utils/run.py
+++ b/fsl/utils/run.py
@@ -6,6 +6,9 @@
 #
 """This module provides some functions for running shell commands.
 
+.. note:: The functions in this module are only known to work in Unix-like
+          environments.
+
 .. autosummary::
    :nosignatures:
 
diff --git a/fsl/wrappers/wrapperutils.py b/fsl/wrappers/wrapperutils.py
index 2ef47df62..21829c13d 100644
--- a/fsl/wrappers/wrapperutils.py
+++ b/fsl/wrappers/wrapperutils.py
@@ -91,7 +91,6 @@ import              os
 import              re
 import              sys
 import              glob
-import              shutil
 import              random
 import              string
 import              fnmatch
@@ -864,6 +863,7 @@ class _FileOrThing(object):
                 fval = self.__load(fullpath)
                 if fval is not None:
                     prefixed = self.__removeExt(prefixed)
+                    prefPat  = prefPat.replace('\\', '\\\\')
                     prefixed = re.sub('^' + prefPat, prefName, prefixed)
                     result[prefixed] = fval
                     break
-- 
GitLab