Skip to content

FIX: Read BIDS config.json under grabbids or layout #2679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions nipype/interfaces/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@

have_pybids = True
try:
from bids import grabbids as gb
import bids
except ImportError:
have_pybids = False

if have_pybids:
try:
from bids import layout as bidslayout
except ImportError:
from bids import grabbids as bidslayout

try:
import pyxnat
except:
Expand Down Expand Up @@ -2810,7 +2816,7 @@ def __init__(self, infields=None, **kwargs):

# If infields is empty, use all BIDS entities
if infields is None and have_pybids:
bids_config = join(dirname(gb.__file__), 'config', 'bids.json')
bids_config = join(dirname(bidslayout.__file__), 'config', 'bids.json')
bids_config = json.load(open(bids_config, 'r'))
infields = [i['name'] for i in bids_config['entities']]

Expand All @@ -2835,7 +2841,7 @@ def _list_outputs(self):
exclude = None
if self.inputs.strict:
exclude = ['derivatives/', 'code/', 'sourcedata/']
layout = gb.BIDSLayout(self.inputs.base_dir, exclude=exclude)
layout = bidslayout.BIDSLayout(self.inputs.base_dir, exclude=exclude)

# If infield is not given nm input value, silently ignore
filters = {}
Expand Down
1 change: 0 additions & 1 deletion nipype/interfaces/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
have_pybids = True
try:
import bids
from bids import grabbids as gb
filepath = os.path.realpath(os.path.dirname(bids.__file__))
datadir = os.path.realpath(os.path.join(filepath, 'tests/data/'))
except ImportError:
Expand Down