How to query multi-echo files using pybids?

I have a BIDS-conform data set that contains MEMPRAGE sMRI data. I tried to query the data set for only the multi-echo files (that is, 'please give me all files that contain ‘echo-xx’) but couldn’t figure out how to do this using layout.get(). Here’s an example for one subject:

sub-A00000909_ses-20110101_acq-mprage_run-01_echo-01_T1w.json
sub-A00000909_ses-20110101_acq-mprage_run-01_echo-01_T1w.nii.gz
sub-A00000909_ses-20110101_acq-mprage_run-01_echo-02_T1w.json
sub-A00000909_ses-20110101_acq-mprage_run-01_echo-02_T1w.nii.gz
sub-A00000909_ses-20110101_acq-mprage_run-01_echo-03_T1w.json
sub-A00000909_ses-20110101_acq-mprage_run-01_echo-03_T1w.nii.gz
sub-A00000909_ses-20110101_acq-mprage_run-01_echo-04_T1w.json
sub-A00000909_ses-20110101_acq-mprage_run-01_echo-04_T1w.nii.gz
sub-A00000909_ses-20110101_acq-mprage_run-01_echo-05_T1w.json
sub-A00000909_ses-20110101_acq-mprage_run-01_echo-05_T1w.nii.gz
sub-A00000909_ses-20110101_acq-mprage_run-02_T1w.json
sub-A00000909_ses-20110101_acq-mprage_run-02_T1w.nii.gz
sub-A00000909_ses-20110101_acq-mprage_run-03_echo-01_T1w.json
sub-A00000909_ses-20110101_acq-mprage_run-03_echo-01_T1w.nii.gz
sub-A00000909_ses-20110101_acq-mprage_run-03_echo-02_T1w.json
sub-A00000909_ses-20110101_acq-mprage_run-03_echo-02_T1w.nii.gz
sub-A00000909_ses-20110101_acq-mprage_run-03_echo-03_T1w.json
sub-A00000909_ses-20110101_acq-mprage_run-03_echo-03_T1w.nii.gz
sub-A00000909_ses-20110101_acq-mprage_run-03_echo-04_T1w.json
sub-A00000909_ses-20110101_acq-mprage_run-03_echo-04_T1w.nii.gz
sub-A00000909_ses-20110101_acq-mprage_run-03_echo-05_T1w.json
sub-A00000909_ses-20110101_acq-mprage_run-03_echo-05_T1w.nii.gz
sub-A00000909_ses-20110101_acq-mprage_run-04_T1w.json
sub-A00000909_ses-20110101_acq-mprage_run-04_T1w.nii.gz

Can anybody tell me how to do this?

Greetings,

Johannes

1 Like

Perhaps try something like this:

from bids import BIDSLayout

layout = BIDSLayout('.')
# Get available echoes if you don't know them ahead of time
available_echoes = layout.get_echoes(suffix='T1w')
# Grab T1w scans with these echoes
layout.get(echo=available_echoes, suffix='T1w')

Does that do what you want?

Unfortunately not…layout.get_echoes(suffix='T1w') returns an empty list.

I think I see the problem. That code worked fine for me with version 0.12.2, but I was using multi-echo fMRI data. I think that the issue is that the pybids configuration files do not support multi-echo structural data yet. Currently, I don’t think multi-echo T1w scans are even BIDS compliant, and I’m afraid pybids might not be capable of indexing them.

It might be worth opening an issue in the pybids repository and in the BIDS specification repository requesting support for multi-echo T1w scans. I don’t see any mention of multi-echo T1w or MEMPRAGE in the only relevant BEP, BEP001, so this may merit an independent change to the specification.

1 Like

On the pybids side: There was an older issue to include a BEP001 config in pybids, but I don’t know that it was ever followed-up on. It would likely involve adding a new BEP001 config here.

1 Like

Alright, I will raise an issue both in the pybids and BIDS-standard specification repository then, thanks for your replies!