TEST: Ensure that Paths and lists of Paths can be passed to BIDSLayout
@@ -3,7 +3,8 @@ BIDSLayout class."""
import os
import re
-from os.path import (join, abspath, basename)
+from os.path import join, abspath, basename
+from pathlib import Path
import numpy as np
import pytest
@@ -514,6 +515,21 @@ def test_deriv_indexing():
assert not layout.get(scope='nonexistent')
+def test_path_arguments():
+ data_dir = join(get_test_data_path(), 'ds005')
+ deriv_dir = join(data_dir, 'derivatives', 'events')
+
+ layout = BIDSLayout(Path(data_dir), derivatives=Path(deriv_dir))
+ assert layout.get(scope='derivatives')
+ assert layout.get(scope='events')
+ assert not layout.get(scope='nonexistent')
+
+ layout = BIDSLayout(Path(data_dir), derivatives=[Path(deriv_dir)])
+ assert layout.get(scope='derivatives')
+ assert layout.get(scope='events')
+ assert not layout.get(scope='nonexistent')
+
+
def test_layout_in_scope(layout_ds005, layout_ds005_derivs):
assert layout_ds005._in_scope(['all'])
assert layout_ds005._in_scope('raw')
