Fairly straightforward question here, but as a novice I could use some clarification: When extracting metadata with Pybids, what does the number in brackets do?
f = layout.get(task=‘nback’, run=1, extensions=‘nii.gz’)[0].filename
In subsequent examples written by Chris to conduct first level analyses on fmriprep data, I get an error and this number changes to 5:
source_epi = layout.get(type=“bold”, task=“fingerfootlips”, session=“test”, extensions=“nii.gz”)[5]
But when I index ‘layout’ it shows up as: Subjects: 0 | Sessions: 0 | Runs: 0, even though there are subjects, sessions, runs in that folder. Consequently, ‘file’ comes up empty. Datadir contains folders for 2 subjects, HTML outputs, dataset_description.json, and a logs folder, so I think it’s the correct directory to work with pybids.
When I change ‘layout’ to a few levels up (B:\InProcess\3T\NABM\fMRI\fmriprep-1.3.2\out, or B:\InProcess\3T\NABM\fMRI\fmriprep-1.3.2), I get an error about ‘dataset_description.json’ missing.
@atersakyan, solution that worked when I tested this is following:
create somewhere your root BIDS directory, e.g. B:\InProcess\3T\NABM\fMRI\MyStudy
in this root BIDS directory create minimal dataset_descripton.json file (following specification) and B:\InProcess\3T\NABM\fMRI\MyStudy\derivatives directory
copy entire fmriprep directory to B:\InProcess\3T\NABM\fMRI\MyStudy\derivatives\
I believe that main argument of BIDSLayout object is path to root BIDS directory and not derived one. Specification says:
Args:
root (str): The root directory of the BIDS dataset.
dataset_description.json for derived BIDS structure has slightly different mandatory fields than for unprocessed, original data. I am not sure if there is another solution, that allows to treat fmriprep directory as valid root directory of the BIDS dataset.
I know this is a bit of an old thread, but just want to add another option.
You can leave the structure as is and just add “validate=False” to the BIDSlayout.
So, instead of what you originally wrote, just use: