--bids-filter-file configuration file specification with multiple bold tasks

Summary of what happened:

I am using --bids-filter-file with fmriprep. I have some participants that have multiple bold runs for one task in func (because they task was started, stopped, restarted), as well as two T1w images (raw and prenormed as generated by the scanner) in my anat folder. Rather than manually removing the files I dont want, I saw --bids-filter-file can be used. I do not get a reported error with my .json file, but two of the bold runs (the task runs) are not preprocessed (i.e., fmriprep only processed the resting state bold and not the tasks bold, despite it finding all three in the terminal log). Am I specifying the other func files incorrectly in the .json file for --bids-filter-file?

Command used (and if a helper script was used, a link to the helper script or the command generated):

fMRIPrep command: /app/.pixi/envs/fmriprep/bin/fmriprep /data /out participant --participant-label P001 --nthreads 24 --omp-nthreads 8 --bids-filter-file /tmp/bids_filter.json --output-spaces MNI152NLin6Asym:res-02

And here is the contents of the .json file for --bids-filter-file:

{
  "fmap": {
    "datatype": "fmap"
  },
  "bold": {
    "datatype": "func", 
    "task": "present",
    "run": "02",
    "suffix": "bold"
  },
  "bold": {
    "datatype": "func", 
    "task": "absent",
    "suffix": "bold"
  },
  "bold": {
    "datatype": "func", 
    "task": "rest",
    "suffix": "bold"
  },
  "t1w": {
    "datatype": "anat", 
    "acquisition": null, 
    "suffix": "T1w"}
}

Version:

fMRIPrep version: 25.2.5

Environment (Docker, Singularity / Apptainer, custom installation):

fmriprep-docker

Data formatted according to a validatable standard? Please provide the output of the validator:

The validator does not have any errors related to func but to dwi (which I am currently not working on). The folder structure/contents are:

sub-P001
    func
        sub-P001_task-absent_bold.json
        sub-P001_task-absent_bold.nii.gz
        sub-P001_task-present_run-01_bold.json
        sub-P001_task-present_run-01_bold.nii.gz
        sub-P001_task-present_run-02_bold.json
        sub-P001_task-present_run-02_bold.nii.gz
        sub-P001_task-rest_bold.json
        sub-P001_task-rest_bold.nii.gz

Relevant log outputs (up to 20 lines):

Before fmriprep starts the summary recognizes the tasks (see below), but they do not appear again in the rest of the terminal output.

[34me[4mSummary:e[24me[39m e [34me[4mAvailable Tasks:e[24me[39m  [34me[4mAvailable Modalities:e[39me[24m 
        1063 Files, 53.38GB        absent                  MRI                   
        48 - Subjects              present                                       
        1 - Session                rest      

Screenshots / relevant information:


Dictionaries must have unique keys, so you can’t have multiple “bold” entries. My guess is that only the last “bold” entry is being kept when the JSON file is loaded into memory. You can use lists for individual subfields in the different fields, like the following:

{
  "bold": {
    "task": ["present", "absent", "rest"],
    "run": [null, "02"]
  },
  "t1w": {
    "acquisition": null
  }
}

The drawback is that the query will find anything that matches any of the elements of the lists- you can’t specify particular combinations (e.g., run-02 of task-present, but run-01 of task-absent). What I put above might work for you (task may be “present”, “absent”, or “rest”; run may be missing or “02”) since it should skip task-present run-01 runs.

Also, you don’t need to include all of the fields that already exist in fMRIPrep’s filter. fMRIPrep will automatically combine your filter with its own.