Layout.get list index out of range

Hello,

I am trying to run through Chris’ nipype 1st level tutorial post fmriprep (and in my case, smoothing using susan).

It seems no matter what combination of filtering arguments I’m using with layout.get, I get a “list index out of range” error.

I’m able to use BIDSlayout and and see the correct number of subjects and runs, but unable to filter.

The line in question:
layout.get(suffix=‘susan’, sub= ‘01’, task=‘pain’, run=‘01’, extensions=‘nii.gz’)[0].filename

The file I would be looking for is:
sub-01_task-pain_run-01_space-MNI152NLin2009cAsym_desc-preproc_bold_susan.nii.gz

Not sure what I’m missing, any help appreciated :slight_smile:

Hi @azg,

I believe this is due to the bids derivatives naming scheme (and therefore pybids) being a moving target (but slowly converging!) and has probably changed since Chris wrote the tutorial.

Namely, the output should be named something like:
sub-01_task-pain_run-01_space-MNI152NLin2009cAsym_desc-susan_bold.nii.gz

(the double suffixes _bold_susan are not allowed in more recent versions of pybids, resulting in pybids not finding any files as your error suggests)

To make sure this answer works for you, what version of pybids are you using?

the following code should give you the answer.

import bids
bids.__version__

Best,
James

Thanks for the quick response! I went ahead and edited the name of the output to what you suggested but it still seems to be giving me an index error.

I’m using pybids version 0.6.5

Not sure how much this matters, since it seems layout is accessing the folder just fine, but the data directory is set to:

`Desktop/fmri_RacePain/derivatives/fmriprep/’

Best,
Az

I forgot to mention the request would change to (if you were using pybids>=0.7.0:

layout.get(suffix='bold', desc='susan', sub= ‘01’, task=‘pain’, run=‘01’, extensions=‘nii.gz’)

but I see you are using an older version of pybids, so I do not think I can provide a good answer on how to get 0.6.5 to work, the usage of pybids has gone through multiple changes and I cannot remember which changes occurred when.

if you wish to upgrade your pybids version and see how to interact with layout objects, you can check out their binder link.

Sorry I cannot be more helpful for this specific issue, but someone else may be able to provide more specific debugging steps you can take.

James