Issue with BIDSDataGrabber in NiPyPe 1.6.1

Hi all,
I ran into an issue when trying to update a pipeline with the BidsDatagrabber interface. The dataset is correctly formatted as a BIDS dataset according to the bids-validator. I can also get the files via the pybids layout command, i.e. layout = BIDSLayout(folder). However, when I try to get the files via the BIDSDataGrabber, I first get the warning:

The 'extension' entity currently excludes the leading dot ('.'). As of version 0.14.0, it will include the leading dot. To suppress this warning and include the leading dot, use `bids.config.set_option('extension_initial_dot', True)* 

and then it crashes:

ValueError                                Traceback (most recent call last)
<ipython-input-1-2fecf98ad7d3> in <module>
      6 bg.inputs.base_dir = 'bids/'
      7 bg.inputs.subject = '101'
----> 8 bg.run()

/opt/anaconda3/lib/python3.8/site-packages/nipype/interfaces/base/core.py in run(self, cwd, ignore_exception, **inputs)
    428             runtime = self._run_interface(runtime)
    429             runtime = self._post_run_hook(runtime)
--> 430             outputs = self.aggregate_outputs(runtime)
    431         except Exception as e:
    432             import traceback

/opt/anaconda3/lib/python3.8/site-packages/nipype/interfaces/base/core.py in aggregate_outputs(self, runtime, needed_outputs)
    504         """Collate expected outputs and apply output traits validation."""
    505         outputs = self._outputs()  # Generate an empty output spec object
--> 506         predicted_outputs = self._list_outputs()  # Predictions from _list_outputs
    507         if not predicted_outputs:
    508             return outputs

/opt/anaconda3/lib/python3.8/site-packages/nipype/interfaces/io.py in _list_outputs(self)
   2984             args = query.copy()
   2985             args.update(filters)
-> 2986             filelist = layout.get(return_type="file", **args)
   2987             if len(filelist) == 0:
   2988                 msg = "Output key: %s returned no files" % key

/opt/anaconda3/lib/python3.8/site-packages/bids/layout/layout.py in get(self, return_type, target, scope, regex_search, absolute_paths, invalid_filters, **filters)
    629                     if suggestions:
    630                         msg += "Did you mean {}? ".format(suggestions)
--> 631                     raise ValueError(msg + "If you're sure you want to impose "
    632                                      "this constraint, set "
    633                                      "invalid_filters='allow'.")

ValueError: 'extensions' is not a recognized entity. Did you mean ['extension']? If you're sure you want to impose this constraint, set invalid_filters='allow'.

Iā€™m running nipype v1.6.1 and pybids v0.13.1 under Python 3.8.8.

Any help would be massively appreciated!

Hi,
Sorry for the late reply.

Looks like BIDSDataGrabber for nipype needs to be updated. A change was recently made to pybids so that extensions for was dropped in favor of extension.

In the meantime you could try to downgrade pybids to v0.8.

Best,
Alejandro

One more thing you can do in the meantime, you can set the parameter output_query manualy.

By default it is set to:

            self.inputs.output_query = {
                "bold": {
                    "datatype": "func",
                    "suffix": "bold",
                    "extensions": ["nii", ".nii.gz"],
                },
                "T1w": {
                    "datatype": "anat",
                    "suffix": "T1w",
                    "extensions": ["nii", ".nii.gz"],
                },
            }

The issue is that extensions is now deprecated.

You can manually set output_query to:

            {
                "bold": {
                    "datatype": "func",
                    "suffix": "bold",
                    "extension": ["nii", ".nii.gz"],
                },
                "T1w": {
                    "datatype": "anat",
                    "suffix": "T1w",
                    "extension": ["nii", ".nii.gz"],
                },
            }

and that should return bold and T1w images without issue.

Also, you can modify that output query to return whatever it is that is of interest to you from the BIDS Dataset, depending on your needs.

1 Like

Brilliant, thank you very much for your help. :pray:

No problem

Related PR on nipype: https://github.com/nipy/nipype/pull/3380