From f5f631e25c5d5fea025a44bcead9a6c775adffbc Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Tue, 4 Feb 2020 12:18:20 +0000
Subject: [PATCH] BF: only load bids metadata if image is in bids dir, *and*
 has a bids filename.

---
 fsl/data/image.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fsl/data/image.py b/fsl/data/image.py
index b65f28105..2060aad04 100644
--- a/fsl/data/image.py
+++ b/fsl/data/image.py
@@ -1540,7 +1540,8 @@ def loadMetadata(image):
     basename = op.basename(removeExt(filename))
     dirname  = op.dirname(filename)
 
-    if fslbids.inBIDSDir(image.dataSource):
+    if fslbids.isBIDSFile(image.dataSource) and \
+       fslbids.inBIDSDir( image.dataSource):
         return fslbids.loadMetadata(image.dataSource)
 
     jsonfile = op.join(dirname, '{}.json'.format(basename))
-- 
GitLab