Skip to content

--derivatives and --session-label and bids filters conflicts #3581

@bpinsard

Description

@bpinsard

What happened?

I am trying to replicate what we were doing with the 20LTS for the specific usecase of neuromod but the 25.xx

  • run smriprep on the anat dataset (T1w, T2w)
  • run fmriprep on a fMRI only dataset, each session separately to distribute more easily on a HPC.

When running fmriprep with bids filters and --derivatives to input smriprep results and also trying to use --session-label all end up crashing at different stages.

fmriprep w ./workdir --participant-label 01 --session-label 001 --
derivatives sourcedata/smriprep --fs-subjects-dir sourcedata/smriprep/sourcedata/*freesurfer* --bids-filter-file code/fmriprep_study-cneuromod.emotion-videos_sub-01_ses-001_bids_filters.json --output-layout bids --ignore slicetiming --use-syn-sdc warn --me-output-echos --output-spaces MNI152NLin2009cAsym T1w:res-iso2mm --cifti-output 91k --notrack --write-graph --skip_bids_validation --omp-nthreads 8 --nprocs 12 --mem_mb 45056 --fs-license-file code/freesurfer.license  --track-carbon --stop-on-first-crash sourcedata/cneuromod.emotion-videos ./ participant

gives

          File "/app/.pixi/envs/fmriprep/lib/python3.12/site-packages/fmriprep/interfaces/bids.py", line 148, in _creat
e_multi_source_file
            p = Path(filename_to_list(in_files)[0])
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
        IndexError: list index out of range

because it passes the session-label intended for fMRI selection to the precomputed anat derivatives collection here

session_id=session_id,

which will not collect anything as smriprep output does not have sessions (~averages all), unless maybe when using the new sessionwise option.
Maybe the simplest solution would be to only pass session_id when --subject-anatomical-reference sessionwise ?

Not using --session-label and relying on --bids-filters to select the session for func/fmap results in another error triggered here .
https://github.com/nipreps/niworkflows/blob/2591b8a5fc90a0f4809ac3288d6fdce5f9aaa227/niworkflows/utils/bids.py#L279-L281
as session_id is already a list of all sessions passed from fmriprep config.execution.processing_groups, never Query.OPTIONAL even if --session-label is not specified.

Obviously, this is again a super-edgy case, and as it is not covered by tests it broke during the large fit/apply refactor. From the code it seems that there are not really any full tests of the precomputed derivatives input, maybe I could work on that.

What command did you use?

fmriprep w ./workdir --participant-label 01 --session-label 001 --
derivatives sourcedata/smriprep --fs-subjects-dir sourcedata/smriprep/sourcedata/*freesurfer* --bids-filter-file code/fmriprep_study-cneuromod.emotion-videos_sub-01_ses-001_bids_filters.json --output-layout bids --ignore slicetiming --use-syn-sdc warn --me-output-echos --output-spaces MNI152NLin2009cAsym T1w:res-iso2mm --cifti-output 91k --notrack --write-graph --skip_bids_validation --omp-nthreads 8 --nprocs 12 --mem_mb 45056 --fs-license-file code/freesurfer.license  --track-carbon --stop-on-first-crash sourcedata/cneuromod.emotion-videos ./ participant

What version of fMRIPrep are you running?

25.2.3

How are you running fMRIPrep?

Singularity

Is your data BIDS valid?

Yes

Are you reusing any previously computed results?

Anatomical derivatives, FreeSurfer

Please copy and paste any relevant log output.

Additional information / screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions