From 2306f558c5d925be2daff44c43023f13600b6b88 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Fri, 20 Aug 2021 16:04:30 +0100 Subject: [PATCH] RF: Expand wildcard patterns if they are passed to imglob, instead of being expanded by the shell. --- fsl/scripts/imglob.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fsl/scripts/imglob.py b/fsl/scripts/imglob.py index 1e756dee6..9aafce906 100644 --- a/fsl/scripts/imglob.py +++ b/fsl/scripts/imglob.py @@ -59,6 +59,19 @@ def imglob(paths, output=None): imgfiles = [] + # Expand any wildcard paths if provided. + # Depending on the way that imglob is + # invoked, this may not get done by the + # calling shell. + expanded = [] + for path in paths: + if any(c in path for c in '*?[]'): + expanded.extend(glob.glob(path)) + else: + expanded.append(path) + + paths = expanded + # Build a list of all image files (both # hdr and img and otherwise) that match for path in paths: -- GitLab