Skip to content

Commit 52cf9e4

Browse files
committed
Check if pybids is installed when importing
1 parent 8ed1c44 commit 52cf9e4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

nipype/interfaces/bids.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222
Str,
2323
Undefined)
2424

25-
from bids.grabbids import BIDSLayout
25+
try:
26+
from bids.grabbids import BIDSLayout
27+
except ImportError:
28+
have_pybids = False
29+
else:
30+
have_pybids = True
2631

2732

2833
class BIDSDataGrabberInputSpec(DynamicTraitedSpec):
@@ -117,6 +122,9 @@ def __init__(self, infields=None, outfields=None, **kwargs):
117122
self.inputs.trait_set(trait_change_notify=False, **undefined_traits)
118123

119124
def _run_interface(self, runtime):
125+
if not have_pybids:
126+
raise ImportError("The BIDSEventsGrabber interface requires pybids."
127+
" Please make sure it is installed.")
120128
return runtime
121129

122130
def _list_outputs(self):

0 commit comments

Comments
 (0)