BIDS inheritance and suffix-wide JSON files

Hey all,

I’m trying to understand how BIDS inheritance works and what I’m allowed to to when creating BIDS dataset. For this purpose, I played around with the example BIDS datasets and the BIDS Validator. I’m now wondering if BIDS accepts “suffix-wide” JSON files:

  1. Let’s say I have metadata that are common to all acquisitions of a given modality, e.g. T1w. Can I add a T1w.json at the root of my dataset with e.g. manufacturer and institution information?
  2. I wanted to test the previous point with the BIDS Validator. Taking dataset ds000246 as an example, the BIDS Validator seems to accept a root-level T1w.json file, but not a meg.json or even a task-noise_run-01_meg.json file. What’s going on here? I thought at least task-noise_run-01_meg.json would be valid according to the specification?


hey @sdiebolt

I think this is a “known” bug in the validator that seems to not “support” inheritance as well as you would expect.

A quick check tells me there are similar issues for other suffixes.

We are in a bit of the transition phase on the validator where we are trying to start using the BIDS schema to do validation and then stop using the “legacy” validator (the one you probably used). So it explains why some of those bugs are not getting fixed as quickly as you would expect: rather spend time on the new validator than “perfecting” a whole bunch of regular expressions that get so complex that changing them may introduce new bugs.

One sanity check you can do is to check if some other tools that should be able to “understand” this type of inheritance can actually do it.

Mostly I am thinking of pybids for python and bids matlab for matlab / octave.

If you are not sure how to check this, let me know and I can send some code snippets.

1 Like

Hey @Remi-Gau,

I wasn’t aware of these issues, I should have looked at the bids validator repository. Thanks for pointing me to the right direction! I’ll use pybids as a backup validator from now on.

Actually, pybids might have the same problem. Here’s what I tried:

Using the ds001 example BIDS dataset, I can check metadata from any BOLD NIfTI file using:

>>> layout = BIDSLayout("bids-examples/ds001/")
>>> layout.get(subject="01", suffix="bold")[0].get_associations()
[<BIDSJSONFile filename='/home/sdiebolt/Documents/Work/bids-examples/ds001/task-balloonanalogrisktask_bold.json'>]
>>> layout.get(subject="01", suffix="bold")[0].get_metadata()
{'RepetitionTime': 2.0, 'TaskName': 'balloon analog risk task'}

But then if I replace the root-level task-balloonanalogrisktask_bold.json file by e.g. bold.json and re-instantiate the BIDSLayout, the metadata file isn’t detected by the layout, i.e.

>>> layout.get(extension="json")
[<BIDSJSONFile filename='/home/sdiebolt/Documents/Work/bids-examples/ds001/dataset_description.json'>, <BIDSJSONFile filename='/home/sdiebolt/Documents/Work/bids-examples/ds001/participants.json'>]

Note that task-balloonanalogrisktask_run-01_bold.json gets detected however.

Am I doing something wrong? Should I open an issue on pybids?

After looking at pybids’ documentation more thoroughly, this behavior might be due to the fact that it is validating datasets with the same validator as the one used by the web version of BIDS Validator. Using validate = False when instantiating the layout leads to bold.json being detected and correctly associated!