fMRIPrep 25.2.3 cannot find T1w when using --session-label for sessions without anat

Summary of what happened:

Hi everyone,

I’m processing a longitudinal/multi-session dataset with fMRIPrep 25.2.3.

Subject sub-02 has a single anatomical scan acquired in ses-01, while functional runs were acquired across multiple sessions (ses-01 to ses-05).

My BIDS structure is:

sub-02/
├── ses-01/
│   ├── anat/
│   │   ├── sub-02_ses-01_T1w.nii.gz
│   │   └── sub-02_ses-01_T1w.json
│   ├── func/
│   └── fmap/
├── ses-02/
│   ├── func/
│   └── fmap/
├── ses-03/
│   ├── func/
│   └── fmap/
├── ses-04/
│   ├── func/
│   └── fmap/
└── ses-05/
    ├── func/
    └── fmap/

I would like to preprocess only sessions 03–05 using the anatomical scan from session 01. The dataset previously processed successfully for sessions 01 and 02 using the same T1w image. Here’s the command I used:

fmriprep-docker $BIDS_dir \
  $fMRIprep_output_dir \
  -w $fMRIprep_working_dir \
  --fs-license-file '/usr/local/freesurfer/7.4.1/.license' \
  --participant-label 02 \
  --session-label 03 04 05 \
  --output-spaces anat MNI152NLin2009cAsym \
  --n_cpus 20

However, fMRIPrep fails with:

FileNotFoundError: No "t1w" images found for sub-02

My questions are:

  1. Is it expected that --session-label 03 04 05 prevents fMRIPrep from using a T1w acquired in ses-01?

  2. Should fMRIPrep automatically reuse a T1w from another session when processing later sessions?

  3. Is the recommended workflow to always include ses-01 in the preprocessing command, e.g.:

--session-label 01 03 04 05

even if I only need outputs from sessions 03–05?

  1. If I have already processed ses-01 previously, is there a way to preprocess only new sessions while reusing the existing anatomical processing results, without rerunning ses-01?

Any guidance would be appreciated.

Thanks!

Version:

25.2.3

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

Docker


Hi @Yan_Huang,

If you only have one t1w you want to apply everywhere, can you try putting the anatomical image above the session level? E.g. sub-02/anat/sub-02_T1w.nii.gz|.json.

Best,
Steven

Hi @Steven ,

Thank you for the suggestion.

I tried moving the anatomical image to the subject level:

sub-02/
├── anat/
│   ├── sub-02_T1w.nii.gz
│   └── sub-02_T1w.json
├── ses-01/
│   ├── func/
│   └── fmap/
├── ses-02/
│   ├── func/
│   └── fmap/
├── ses-03/
│   ├── func/
│   └── fmap/
├── ses-04/
│   ├── func/
│   └── fmap/
└── ses-05/
    ├── func/
    └── fmap/

And fMRIPrep still produced the same error:

260604-04:16:14,874 nipype.workflow ERROR:
	 could not run node: fmriprep_25_2_wf.sub_02_ses_03-04-05_wf.bidssrc
260604-04:16:15,108 nipype.workflow CRITICAL:
	 fMRIPrep failed: Traceback (most recent call last):
  File "/app/.pixi/envs/fmriprep/lib/python3.12/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.pixi/envs/fmriprep/lib/python3.12/site-packages/nipype/pipeline/engine/nodes.py", line 525, in run
    result = self._run_interface(execute=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.pixi/envs/fmriprep/lib/python3.12/site-packages/nipype/pipeline/engine/nodes.py", line 643, in _run_interface
    return self._run_command(execute)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.pixi/envs/fmriprep/lib/python3.12/site-packages/nipype/pipeline/engine/nodes.py", line 769, in _run_command
    raise NodeExecutionError(msg)
nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node bidssrc.

Traceback:
	Traceback (most recent call last):
	  File "/app/.pixi/envs/fmriprep/lib/python3.12/site-packages/nipype/interfaces/base/core.py", line 401, in run
	    runtime = self._run_interface(runtime)
	              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "/app/.pixi/envs/fmriprep/lib/python3.12/site-packages/niworkflows/interfaces/bids.py", line 297, in _run_interface
	    raise FileNotFoundError(msg)
	FileNotFoundError: No "t1w" images found for sub-02


fMRIPrep: Please report errors to https://github.com/nipreps/fmriprep/issues

I wonder whether specifying --session-label 03 04 05 could be causing this issue.

Maybe putting the T1w image in a newly created ses-anat/ and using –session-label anat 03 04 05 could work? It is just a guess from my part.

Thanks for your suggestion @jsein.

The way you mentioned worked. I have a quick follow-up question: if I have already processed some sessions, like with –session-label anat 03 04 05, and need to run new sessions with –session-label anat 06, will this affect the preprocessed T1w image?

I would say no (but I am not a fmriprep developper). fmriprep will reuse the already run freesurfer output, and also, should be using all the anat preprocessed files already computed if you point to the same working directory (-w ) during you second execution of fmriprep.

Hi @jsein. I processed a new session using –session-label anat 06 with the same working directory. The freesurfer output was reused, but the preprocessed T1w was processed again and overwritten. I wonder if it will cause problems for the previous sessions.

Hi @Yan_Huang , my guess is that the re-preprocessed T1w should very similar to the originally preprocessed T1w, since in it using the same input image and the same freesurfer derivatives. The difference must be coming from the normalisation of the T1w image in the template space with ANTs which may be giving slightly different result on two identical execution.
Food for thoughts: I have never played with those parameters but I also guess that --skull-strip-fixed-seed and --random-seedmay be useful for better repeatability in your case.

Thanks for the advice @jsein. I checked the T1w outputs generated from two separate fMRIPrep runs using --skull-strip-fixed-seed, --random-seed, and --omp-nthreads. After comparing them in AFNI, the results appear to be virtually identical across the two runs. The same goes for the normalization results.

1 Like