From 513c49f157aa3a8c082085faaa26596d2e9e4d97 Mon Sep 17 00:00:00 2001 From: Adina Wagner Date: Wed, 31 Oct 2018 12:47:28 -0400 Subject: [PATCH 1/3] DOC: minor typo --- bids/layout/layout.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bids/layout/layout.py b/bids/layout/layout.py index 3b0e2cd10..4ce5e4e7f 100644 --- a/bids/layout/layout.py +++ b/bids/layout/layout.py @@ -69,7 +69,7 @@ class BIDSLayout(Layout): was left empty (in which case the root defaults to the file system root). derivatives (bool, str, list): Specificies whether and/or which - derivatives to to index. If True, all pipelines found in the + derivatives to index. If True, all pipelines found in the derivatives/ subdirectory will be indexed. If a str or list, gives the paths to one or more derivatives directories to index. If False or None, the derivatives/ directory is ignored during indexing, and From 4b34e184e59972d094a0e45622e184d0a10fb68b Mon Sep 17 00:00:00 2001 From: Adina Wagner Date: Wed, 31 Oct 2018 12:50:19 -0400 Subject: [PATCH 2/3] ENH: exclude common irrelevant non-BIDS-defined data sources --- bids/layout/layout.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bids/layout/layout.py b/bids/layout/layout.py index 4ce5e4e7f..55854fc18 100644 --- a/bids/layout/layout.py +++ b/bids/layout/layout.py @@ -114,7 +114,10 @@ def __init__(self, root, validate=True, index_associated=True, "dataset_description.json." % k) # Determine which subdirectories to exclude from indexing - excludes = {"code", "stimuli", "sourcedata", "models", "derivatives"} + # A set is extended with non-BIDS-defined common suspects + # which are not expected to carry any data of interest + excludes = {"code", "stimuli", "sourcedata", "models", "derivatives", + ".git", ".datalad", ".cache", ".workdir", "workdir"} if include is not None: include = listify(include) if "derivatives" in include: From 89e41efb558bcea1db4f09965b284bcdd3d50745 Mon Sep 17 00:00:00 2001 From: Adina Wagner Date: Wed, 31 Oct 2018 12:55:02 -0400 Subject: [PATCH 3/3] ENH: extract only path from object and fix potential named tuple problem --- bids/layout/layout.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bids/layout/layout.py b/bids/layout/layout.py index 55854fc18..15d5f5301 100644 --- a/bids/layout/layout.py +++ b/bids/layout/layout.py @@ -566,18 +566,24 @@ def index_file(self, f, overwrite=False): an entry already exists. """ if isinstance(f, six.string_types): - f = self.layout.get_file(f) + filename = self.layout.get_file(f).path + elif isinstance(f, tuple): + # See http://github.com/grabbles/grabbit/pull/84 + # .path is not available within File named tuple + filename = f.filename + else: + filename = f - if f.path in self.file_index and not overwrite: + if filename in self.file_index and not overwrite: return - md = self._get_metadata(f.path) + md = self._get_metadata(filename) for md_key, md_val in md.items(): if md_key not in self.key_index: self.key_index[md_key] = {} - self.key_index[md_key][f.path] = md_val - self.file_index[f.path][md_key] = md_val + self.key_index[md_key][filename] = md_val + self.file_index[filename][md_key] = md_val def _get_metadata(self, path, **kwargs): potential_jsons = self.layout._get_nearest_helper(path, '.json',