Fmriprep bids-filter: implement "or" operator?

Hi all,
I’d like to filter my input data to fmriprep but can’t find any documentation on how the filtering exactly works. I have three func images, of which I’d like to use only two, i.e. skip the part-phase data in the example below:

$ tree func
func
|-- sub-100_task-rest_dir-AP_run-1_part-mag_bold.json
|-- sub-100_task-rest_dir-AP_run-1_part-mag_bold.nii.gz
|-- sub-100_task-rest_dir-AP_run-1_part-phase_bold.json
|-- sub-100_task-rest_dir-AP_run-1_part-phase_bold.nii.gz
|-- sub-100_task-rest_dir-AP_run-1_rec-NORDIC_bold.json
`-- sub-100_task-rest_dir-AP_run-1_rec-NORDIC_bold.nii.gz

I’ve seen examples of --bids-filter-file, but it seems to me the filter terms are AND operated, and I’d like to use an OR operator. I know that you can use lists for that, but I’m unsure how that applies between entities. Is the filter file below the way or how can I build my filter?

{
  "fmap": {"datatype": "fmap"},
  "bold": [{"datatype": "func", "part": "mag", "suffix": "bold"}, {"datatype": "func", "reconstruction": "NORDIC", "suffix": "bold"}],
  "sbref": {"datatype": "func", "suffix": "sbref"},
  "flair": {"datatype": "anat", "suffix": "FLAIR"},
  "t2w": {"datatype": "anat", "suffix": "T2w"},
  "t1w": {"datatype": "anat", "suffix": "T1w"},
  "roi": {"datatype": "anat", "suffix": "roi"}
}

Generally, lists are OR. What about:

{
  "bold": {"datatype": "func", "part": ["mag", null], "suffix": "bold"},
}
1 Like

That looks good, and I’ll try it. In fact, isn’t this filter something that would be good always and should be a default (given that fmriprep doesn’t deal with phase data)?

It should… PRs welcome. :slight_smile:

Yes, but my concern is that people may still want the spatial transformations from the mag data to be applied to the phase data. That would involve a more elaborate PR

Well, it’s not happening now, so at least it would be an upgrade from crashing.

Mhh, I used the filter you suggested but the report says only 1 functional series was found?

Summary

Subject ID: 100
Structural images: 1 T1-weighted (+ 1 T2-weighted)
Functional series: 1
    Task: rest (1 run)
Standard output spaces: MNI152NLin2009cAsym
Non-standard output spaces:
FreeSurfer reconstruction: Not run

I know both series had a task label rest and a run index 1, but they still differed in the other entities. From the output it seems fmriprep only found the part-mag images and did not find the NORDIC files, but if I look at the fmriprep.toml file I see:

[execution.bids_filters.bold]
datatype = "func"
part = [ "mag", "None",]
suffix = "bold"

I know TOML doesn’t support a null datatype, is this the cause of the problem?

Possibly. We could use false, but that would need to come along with interpreting it correctly in this context.