I try to use nipype BIDSDataGrabber to iterate through subject’s files.
When I try to use it I get an error.
The code I try to run is:
from nipype.interfaces.io import BIDSDataGrabber
bg_all = pe.Node(BIDSDataGrabber(), name=‘bids-grabber’)
bg_all.inputs.base_dir = data_dir
bg_all.inputs.output_query = {‘bolds’: dict(type=‘bold’)}
bg_all.iterables = (‘subject’, layout.get_subjects()[:2])
bg_all.run()
The error I receive is:
190806-09:49:16,733 nipype.workflow INFO:
[Node] Setting-up “bids-grabber” in “/tmp/tmp0eqr4eua/bids-grabber”.
190806-09:49:16,740 nipype.workflow INFO:
[Node] Running “bids-grabber” (“nipype.interfaces.io.BIDSDataGrabber”)
190806-09:49:16,747 nipype.workflow WARNING:
[Node] Error on “bids-grabber” (/tmp/tmp0eqr4eua/bids-grabber)Traceback (most recent call last):
File “”, line 1, in
bg_all.run()File “/home/or/anaconda3/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py”, line 472, in run
result = self._run_interface(execute=True)File “/home/or/anaconda3/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py”, line 563, in _run_interface
return self._run_command(execute)File “/home/or/anaconda3/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py”, line 643, in _run_command
result = self._interface.run(cwd=outdir)File “/home/or/anaconda3/lib/python3.6/site-packages/nipype/interfaces/base/core.py”, line 377, in run
outputs = self.aggregate_outputs(runtime)File “/home/or/anaconda3/lib/python3.6/site-packages/nipype/interfaces/base/core.py”, line 455, in aggregate_outputs
predicted_outputs = self._list_outputs()File “/home/or/anaconda3/lib/python3.6/site-packages/nipype/interfaces/io.py”, line 2831, in _list_outputs
from bids import BIDSLayoutImportError: cannot import name ‘BIDSLayout’
If I use a different pybids import there is no issue at all.
Code:
from bids.grabbids import BIDSLayout
layout = BIDSLayout(data_dir)
Any idea what is happening?